:root {
    --primary: #1a365d;
    --primary-light: #2b6cb0;
    --accent: #38b2ac;
    --danger: #e53e3e;
    --success: #38a169;
    --bg: #f7fafc;
    --card: #ffffff;
    --text: #2d3748;
    --muted: #718096;
    --border: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px; }

/* ========== MENÚ HORIZONTAL PC ========== */
.site-header {
    background: var(--primary);
    color: #fff;
    margin-bottom: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    height: 52px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
}
.site-brand {
    color: #fff !important;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none !important;
    margin-right: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
.site-menu {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}
.site-header-end {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}
.mh-user {
    font-size: 0.85rem;
    color: rgba(255,255,255,.7);
    white-space: nowrap;
}
.mh-link {
    display: inline-block;
    color: rgba(255,255,255,.92) !important;
    text-decoration: none !important;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 7px 11px;
    border-radius: 6px;
    white-space: nowrap;
    border: none;
    background: transparent;
    cursor: pointer;
}
.mh-link:hover,
.mh-link.on {
    background: rgba(255,255,255,.14);
    color: #fff !important;
}
.mh-out {
    background: rgba(0,0,0,.2);
    border: 1px solid rgba(255,255,255,.2);
}
.mh-item {
    position: relative;
    display: inline-block;
}
.mh-btn {
    display: inline-block;
    color: rgba(255,255,255,.92);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 7px 11px;
    border-radius: 6px;
    white-space: nowrap;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}
.mh-item:hover > .mh-btn,
.mh-item.on > .mh-btn {
    background: rgba(255,255,255,.14);
    color: #fff;
}
.mh-sub {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    padding: 6px 0;
    z-index: 200;
    border: 1px solid var(--border);
}
.mh-item:hover > .mh-sub {
    display: block;
}
.mh-sub a {
    display: block;
    padding: 9px 14px;
    color: var(--text) !important;
    text-decoration: none !important;
    font-size: 0.9rem;
    white-space: nowrap;
}
.mh-sub a:hover,
.mh-sub a.on {
    background: #ebf4ff;
    color: var(--primary-light) !important;
}

/* Compatibilidad clases viejas .header (por si alguna página aún las usa) */
.header {
    background: var(--primary);
    color: white;
    padding: 12px 0;
    margin-bottom: 24px;
}
.header .container { display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 1.2rem; }
.header nav a { color: rgba(255,255,255,.9); margin-left: 14px; }

/* Cards */
.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}
.card h2 { font-size: 1.25rem; margin-bottom: 16px; color: var(--primary); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary-light); color: white; }
.btn-primary:hover { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #2f855a; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border .15s;
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(43,108,176,.15); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #edf2f7; font-weight: 600; color: var(--primary); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover { background: #f7fafc; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: #c6f6d5; color: #22543d; }
.badge-warning { background: #feebc8; color: #744210; }
.badge-danger { background: #fed7d7; color: #742a2a; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    text-align: center;
}
.stat-card .number { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

#items-table input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
#items-table td { vertical-align: middle; }

@media print {
    body * { visibility: hidden; }
    .factura-print, .factura-print *,
    .presupuesto-print, .presupuesto-print * { visibility: visible; }
    .factura-print, .presupuesto-print { position: absolute; left: 0; top: 0; width: 100%; }
    .no-print { display: none !important; }
    .site-header { display: none !important; }
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.alert-success { background: #c6f6d5; color: #22543d; border: 1px solid #9ae6b4; }
.alert-error { background: #fed7d7; color: #742a2a; border: 1px solid #feb2b2; }
.alert-info { background: #bee3f8; color: #2a4365; border: 1px solid #90cdf4; }

.footer {
    text-align: center;
    padding: 30px 0;
    color: var(--muted);
    font-size: 0.85rem;
}
