:root {
    --primary: #0b4d8c;
    --primary-dark: #073b6d;
    --accent: #f59e0b;
    --success: #16a34a;
    --danger: #dc2626;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --card: #ffffff;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.link-muted { color: var(--text-muted); font-size: 13px; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; width: 100%; }
.main { flex: 1; padding: 24px 0 48px; }
.footer { padding: 20px 0; text-align: center; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border); background: #fff; }

.topbar { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.topbar-inner { display: flex; align-items: center; gap: 24px; max-width: 1100px; margin: 0 auto; padding: 0 20px; min-height: 56px; }
.brand { color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand span { color: rgba(255,255,255,.65); font-weight: 400; font-size: 12px; margin-left: 4px; }
.nav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.nav a { color: rgba(255,255,255,.85); padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar-user span { color: rgba(255,255,255,.9); }
.topbar-user .link-muted { color: rgba(255,255,255,.7); }
.topbar-user .link-muted:hover { color: #fff; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.page-sub { color: var(--text-muted); font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card-body { padding: 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-value.money { color: var(--primary); }

.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .3px; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11,77,140,.12);
}
.form-help { font-size: 12px; color: var(--text-muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 8px; border: none; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: filter .15s, transform .05s; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn-accent { background: var(--accent); color: #1a1a1a; }
.btn-accent:hover { filter: brightness(.95); text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }

.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.table th { background: #f1f5f9; font-weight: 600; color: var(--text); text-transform: uppercase; font-size: 11px; letter-spacing: .3px; }
.table tr:last-child td { border-bottom: none; }
.table td.money { text-align: right; font-variant-numeric: tabular-nums; }
.table th.money { text-align: right; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge-borrador { background: #f1f5f9; color: #475569; }
.badge-aceptada { background: #dbeafe; color: #1e40af; }
.badge-contrato_generado { background: #dcfce7; color: #166534; }
.badge-rechazada { background: #fee2e2; color: #991b1b; }

.hero-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 24px 0; }
.hero-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text); transition: transform .15s, box-shadow .15s; }
.hero-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.08); text-decoration: none; }
.hero-card .h { font-weight: 700; font-size: 16px; }
.hero-card .s { color: var(--text-muted); font-size: 13px; }

.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #0b4d8c 0%, #1e293b 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 12px; padding: 32px; box-shadow: 0 20px 40px rgba(15,23,42,.15); }
.auth-title { margin: 0 0 4px; font-size: 22px; }
.auth-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

.print-only { display: none; }

@media print {
    .topbar, .footer, .actions, .no-print { display: none !important; }
    .print-only { display: block; }
    body { background: #fff; }
    .card { box-shadow: none; border: none; }
    .container { max-width: 100%; padding: 0; }
    .main { padding: 0; }
}

@media (max-width: 720px) {
    .topbar-inner { flex-direction: column; align-items: stretch; padding: 12px 20px; gap: 8px; min-height: 0; }
    .nav { justify-content: center; margin-left: 0; }
    .topbar-user { justify-content: space-between; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.15); }
    .page-head h1 { font-size: 18px; }
}
