:root {
  --navy: #323792;
  --navy-dark: #262a73;
  --blue: #115aa9;
  --green: #239561;
  --bg: #f4f6fa;
  --card: #fff;
  --border: #e2e5ec;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #c62828;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
h1 { font-size: 22px; margin: 0; color: var(--navy); }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--navy); }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, var(--navy), var(--blue) 70%, var(--green)); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card img { height: 96px; margin: 0 auto 10px; display: block; }
.login-card h1 { text-align: center; font-size: 20px; }
.login-card p { text-align: center; color: var(--muted); margin: 4px 0 22px; font-size: 13px; }

/* Form */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #e3eefa; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border-radius: 7px; border: none; background: linear-gradient(135deg, var(--green), var(--blue)); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.btn.light { background: #fff; color: var(--navy); border: 1px solid var(--border); }
.btn.light:hover { border-color: var(--blue); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.msg { font-size: 13px; margin-top: 10px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* Layout */
.layout { display: flex; height: 100vh; }
.sidebar { width: 228px; flex-shrink: 0; background: var(--navy); color: #fff; display: flex; flex-direction: column; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sb-brand .logo { background: #fff; border-radius: 9px; padding: 4px; display: flex; }
.sb-brand img { height: 30px; }
.sb-brand b { display: block; font-size: 15px; letter-spacing: .04em; }
.sb-brand small { color: rgba(255,255,255,.65); font-size: 11px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-group { margin: 12px 0 4px; padding: 0 16px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.5); }
.sidebar nav a { display: block; padding: 9px 16px 9px 20px; color: rgba(255,255,255,.78); border-left: 3px solid transparent; font-size: 14px; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.12); border-left-color: #4ade80; color: #fff; font-weight: 600; }
.sb-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.sb-user b { display: block; }
.sb-user small { color: rgba(255,255,255,.6); }
.sb-user .links { margin-top: 8px; display: flex; gap: 12px; }
.sb-user .links a { color: rgba(255,255,255,.8); font-size: 12px; cursor: pointer; }
.main { flex: 1; overflow-y: auto; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cards & KPIs */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 22px; font-weight: 800; color: var(--navy); margin-top: 4px; }
.kpi .note { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.danger .value { color: var(--danger); }
.kpi.ok .value { color: var(--ok); }
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.cols > .card { margin-bottom: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 9px 10px; border-bottom: 1px solid var(--border); background: #fafbfd; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #eef0f4; vertical-align: top; }
tbody tr:hover td { background: #f7f9fd; }
tr.click { cursor: pointer; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); background: #fafbfd; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.red { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

/* Pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f4; color: #4b5563; white-space: nowrap; }
.pill.ok { background: #dcfce7; color: var(--ok); }
.pill.warn { background: #fef3c7; color: var(--warn); }
.pill.danger { background: #fee2e2; color: var(--danger); }
.pill.blue { background: #e3eefa; color: var(--blue); }

/* Filters */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; min-width: 260px; }
.filters label { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; cursor: pointer; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--green); }
.tabs a:hover { text-decoration: none; color: var(--navy); }

/* Charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar .b { width: 100%; max-width: 38px; background: linear-gradient(180deg, var(--blue), var(--navy)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.current .b { background: linear-gradient(180deg, #34d399, var(--green)); }
.bar span { font-size: 11px; color: var(--muted); margin-top: 5px; white-space: nowrap; }
.tramos { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #eef0f4; margin: 8px 0 10px; }
.tramos div { height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid #eef0f4; }
.timeline li:last-child { border-bottom: none; }
.timeline .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 480px; padding: 22px; max-height: 90vh; overflow-y: auto; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.banner.info { background: #eef6ff; border-color: #bfdbfe; color: #1e3a8a; }
.banner { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 13px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .nav-group { display: none; }
  .main { overflow: visible; padding: 16px; }
  .cols, .grid2 { grid-template-columns: 1fr; }
  html, body { height: auto; }
}
