:root {
  --navy: #0b2a4a; --navy-2: #133c66; --gold: #c9962b; --gold-soft: #f6ecd6;
  --bg: #f4f6f9; --panel: #ffffff; --line: #dfe4ec; --text: #1c2533; --muted: #5d6b80;
  --red: #c0392b; --red-soft: #fbe9e7; --amber: #b7791f; --amber-soft: #fdf3dc; --green: #2f855a; --green-soft: #e3f4ea;
  --blue-soft: #e7eef8; --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--navy-2); }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 17px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #d6e0ee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand b { display: block; color: #fff; font-family: Georgia, serif; font-size: 17px; letter-spacing: .2px; }
.brand span { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.nav { padding: 10px 8px; flex: 1; overflow: auto; }
.nav a { display: flex; align-items: center; gap: 10px; color: #d6e0ee; text-decoration: none; padding: 9px 12px; border-radius: 6px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.on { background: rgba(201,150,43,.18); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.who { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.who b { color: #fff; display: block; }
.who .role { color: var(--gold); font-size: 12px; }
.who button { margin-top: 8px; background: none; border: 1px solid rgba(255,255,255,.25); color: #d6e0ee; padding: 4px 10px; border-radius: 5px; cursor: pointer; }
.main { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 28px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.content { padding: 22px 28px 60px; max-width: 1280px; }
.btn.menu-btn { display: none; }

/* Components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .n { font-size: 28px; font-weight: 700; color: var(--navy); }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.alert .n { color: var(--red); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: #b9c3d3; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { color: var(--red); border-color: #efc2bc; }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.toolbar input[type=search] { min-width: 240px; flex: 1; max-width: 380px; }

table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfd; position: sticky; top: 0; }
.t td { padding: 9px 10px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: #f7f9fc; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--navy-2); white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.gray { background: #eef0f3; color: #556; }
.sem { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.sem::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #ccd; }
.sem.Alta::before { background: var(--red); } .sem.Media::before { background: #e0a526; } .sem.Baja::before { background: var(--green); }

.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid #eef1f5; }
.alerts li:last-child { border: 0; }
.alerts .when { font-size: 13px; color: var(--muted); }

/* Forms */
.form .section { font-weight: 700; color: var(--navy); border-bottom: 2px solid var(--gold-soft); padding: 18px 0 6px; margin-bottom: 12px; grid-column: 1 / -1; }
.form .section:first-child { padding-top: 0; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label { font-weight: 600; font-size: 13px; }
.field .req { color: var(--red); }
.field .hint { font-size: 12px; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=date], .field input[type=time], .field input[type=number], .field input[type=password], .field select, .field textarea {
  padding: 8px 10px; border: 1px solid #cfd6e1; border-radius: 6px; background: #fff; width: 100%; }
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #9db8dc; border-color: #6d93c7; }
.opts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.opts label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
.field.ro .val { padding: 6px 0; white-space: pre-wrap; }
.field.hide { display: none; }
.picker { display: flex; gap: 8px; align-items: center; }
.picker .sel { flex: 1; padding: 8px 10px; border: 1px solid #cfd6e1; border-radius: 6px; background: #fafbfd; min-height: 36px; }
.check-line { display: flex; gap: 8px; align-items: flex-start; font-weight: 400 !important; }
.check-line input { margin-top: 3px; }
.formbar { display: flex; gap: 10px; justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--line); margin-top: 18px; position: sticky; bottom: 0; background: var(--panel); padding-bottom: 4px; }
.sensitive { background: #fff8f6; border-left: 3px solid #efc2bc; padding-left: 10px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }
.tabs .cnt { background: #eef0f3; border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }

.head-case { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 18px; margin-top: 12px; }
.facts div span { display: block; font-size: 12px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid #eef1f5; display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; }
.timeline li:last-child { border: 0; }
.timeline .d { color: var(--muted); font-size: 13px; }
.done { text-decoration: line-through; color: var(--muted); }
.notice { padding: 10px 14px; border-radius: 6px; background: var(--blue-soft); color: var(--navy-2); margin-bottom: 14px; }
.notice.warn { background: var(--amber-soft); color: #7a5212; }

.bars .row { display: grid; grid-template-columns: minmax(120px, 38%) 1fr 40px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.bars .bar { height: 10px; background: #eef1f5; border-radius: 5px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--navy-2); border-radius: 5px; }
.bars .n { text-align: right; font-weight: 600; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0%, #0d3358 60%, #174a7c 100%); padding: 16px; }
.login .box { background: #fff; width: 100%; max-width: 400px; border-radius: 12px; padding: 32px 30px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login .logo { font-family: Georgia, serif; color: var(--navy); font-size: 22px; font-weight: 700; }
.login .logo small { display: block; color: var(--gold); font-family: system-ui, sans-serif; font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 600; margin-bottom: 4px; }
.login form { display: grid; gap: 14px; margin-top: 22px; }
.login .err { color: var(--red); font-size: 13px; min-height: 18px; }
.login .foot { margin-top: 18px; font-size: 12px; color: var(--muted); }

/* Modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(11,25,45,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header button { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal .body { padding: 18px 20px; }
.modal .formbar { position: static; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; }
#toast div { background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 6px; margin-top: 8px; box-shadow: var(--shadow); }
#toast div.err { background: var(--red); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .fgrid { grid-template-columns: 1fr; }
  .alerts li { grid-template-columns: 1fr; gap: 2px; }
  .timeline li { grid-template-columns: 1fr; gap: 4px; }
  .toolbar input[type=search], .toolbar select { min-width: 0; flex: 1 1 100%; max-width: none; }
}
@media print { .side, .top .actions, .formbar, .tabs { display: none !important; } .shell { display: block; } }
