:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --line: #e4e7e6;
  --line-2: #d4d9d7;
  --text: #17201d;
  --muted: #64706b;
  --primary: #0f6e56;
  --primary-2: #0b5945;
  --primary-soft: #e6f3ee;
  --accent: #b7791f;
  --danger: #c2362b;
  --danger-soft: #fdecea;
  --warn: #a16207;
  --warn-soft: #fef6e1;
  --info: #1d5fa8;
  --info-soft: #e8f0fb;
  --ok-soft: #e6f3ee;
  --side: #10231d;
  --side-2: #183129;
  --side-text: #c8d6d0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 35, 29, .06), 0 4px 14px rgba(16, 35, 29, .05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.sp { height: 8px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #1aa37a, #0f6e56); display: grid; place-items: center; font-size: 13px; font-weight: 800; color: #fff; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: #8fa89f; letter-spacing: .02em; }
.nav { padding: 4px 10px 16px; display: flex; flex-direction: column; gap: 1px; }
.nav .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #7d958c; padding: 14px 10px 6px; font-weight: 650; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.on { background: #1d3b32; color: #fff; box-shadow: inset 3px 0 0 #2fc08f; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.side-foot { margin-top: auto; padding: 12px 14px; border-top: 1px solid #20392f; font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .burger { display: none; }
.top .emp { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top .emp b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--primary-2); border-color: #c6e4d8; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: #f1dfaa; }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: #f5c9c4; }
.content { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-h p { margin: 4px 0 0; color: var(--muted); }
.banner { background: #fff7e6; border: 1px solid #f2d79b; color: #7a5200; padding: 8px 24px; font-size: 13px; display: flex; gap: 10px; align-items: center; }

/* ---------- Components ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card > .bd { padding: 18px; }
.card > .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

.kpi { padding: 16px 18px; }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--text); font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--panel-2); border-color: #bfc6c3; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: #efc3be; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn svg { width: 16px; height: 16px; }
.btn.big { height: 44px; font-size: 15px; padding: 0 20px; }

label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #34403b; min-width: 0; }
label.f .req { color: var(--danger); }
label.f .help { font-weight: 400; color: var(--muted); font-size: 11.5px; }
input, select, textarea { font: 14px var(--font); color: var(--text); background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; height: 36px; width: 100%; min-width: 0; outline: none; transition: border-color .12s, box-shadow .12s; }
textarea { padding: 8px 10px; height: auto; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 110, 86, .14); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); padding: 0; }
input[type=color] { padding: 2px; width: 46px; }
input.mono, textarea.mono { font-family: var(--mono); font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13.5px; cursor: pointer; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.form-grid > * { grid-column: span 12; }
.c2 { grid-column: span 2 !important; } .c3 { grid-column: span 3 !important; } .c4 { grid-column: span 4 !important; } .c5 { grid-column: span 5 !important; }
.c6 { grid-column: span 6 !important; } .c8 { grid-column: span 8 !important; } .c9 { grid-column: span 9 !important; }
.invalid { border-color: var(--danger) !important; }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; font: 600 13px var(--font); color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--primary-2); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--primary-2); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }

table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: #f6faf8; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; opacity: .5; display: block; margin: 0 auto 8px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { background: var(--ok-soft); color: var(--primary-2); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-mute { background: #eef0ef; color: #5c6863; }
.tipo { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-weight: 800; font-size: 12px; background: var(--primary-soft); color: var(--primary-2); }
.tipo.E { background: #fdf0e6; color: #a4520f; } .tipo.P { background: var(--info-soft); color: var(--info); } .tipo.T { background: #f1edfb; color: #6142b6; }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid; font-size: 13.5px; }
.alert.warn { background: var(--warn-soft); border-color: #f1dfaa; color: #6b4b05; }
.alert.danger { background: var(--danger-soft); border-color: #f5c9c4; color: #8c241b; }
.alert.info { background: var(--info-soft); border-color: #c8daf3; color: #17467c; }
.alert.ok { background: var(--ok-soft); border-color: #c6e4d8; color: #0b4a3a; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* Modal / drawer */
.ov { position: fixed; inset: 0; background: rgba(12, 22, 18, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.lg { max-width: 860px; }
.modal .hd { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal .bd { padding: 18px 20px; overflow-y: auto; }
.modal .ft { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.ov.drawer { justify-content: flex-end; padding: 0; align-items: stretch; }
.ov.drawer .modal { max-width: 620px; height: 100vh; max-height: 100vh; border-radius: 0; animation: slide .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: #142520; color: #eaf3ef; padding: 11px 14px; border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; animation: fade .15s; }
.toast.err { background: #5b1a14; }
.toast.ok { background: #0d4b3b; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.sum { position: sticky; top: 76px; }
.sum .line { display: flex; justify-content: space-between; padding: 5px 0; font-variant-numeric: tabular-nums; }
.sum .tot { font-size: 22px; font-weight: 750; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; color: var(--primary-2); }

.section { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.section > .sh { padding: 12px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.section > .sh h3 { flex: 1; }
.section > .sb { padding: 16px; }
.num-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-2); display: grid; place-items: center; font-size: 12px; font-weight: 750; flex: none; }

.lines { display: flex; flex-direction: column; gap: 10px; }
.lin { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: var(--panel-2); position: relative; }
.lin .del { position: absolute; top: 8px; right: 8px; }
.lin-grid { display: grid; gap: 10px; grid-template-columns: 120px 90px 90px 1fr 130px; }
.lin-grid2 { display: grid; gap: 10px; grid-template-columns: 110px 140px 150px 150px 1fr; margin-top: 10px; align-items: end; }
.lin .imp { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; align-self: center; }

.pac-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; transition: border-color .15s, box-shadow .15s; }
.pac-card.activo { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 110, 86, .12); }
.pac-card .ph { padding: 16px; display: flex; gap: 12px; align-items: center; }
.pac-card .logo { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.pac-card .pb { padding: 0 16px 16px; }

.designer { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.designer .ctrl { max-height: calc(100vh - 150px); overflow-y: auto; position: sticky; top: 76px; }
.preview-frame { width: 100%; height: calc(100vh - 160px); min-height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.colrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.colrow input[type=text] { height: 30px; }

.keybox { font-family: var(--mono); background: #10231d; color: #b9f3dc; padding: 12px 14px; border-radius: 8px; word-break: break-all; font-size: 13px; }
pre.code { background: #10231d; color: #d7e9e2; padding: 14px; border-radius: 9px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; margin: 0; }

.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(1200px 600px at -10% -10%, #1b8f6a 0%, transparent 60%), linear-gradient(160deg, #0f2a22, #10231d 60%, #0b1a15); color: #d9ebe4; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 34px; color: #fff; max-width: 460px; line-height: 1.15; letter-spacing: -.02em; }
.login-art ul { padding: 0; list-style: none; display: grid; gap: 10px; margin: 28px 0 0; }
.login-art li { display: flex; gap: 10px; align-items: center; }
.login-art li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2fc08f; }
.login-form { display: grid; place-items: center; padding: 32px 20px; background: #fff; }
.login-form .box { width: 100%; max-width: 380px; }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bars div { flex: 1; background: linear-gradient(180deg, #2fa57f, #0f6e56); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover { opacity: .8; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: 1fr; }
  .sum { position: static; }
  .designer { grid-template-columns: 1fr; }
  .designer .ctrl { position: static; max-height: none; }
  .lin-grid { grid-template-columns: 1fr 1fr 1fr; }
  .lin-grid > .desc { grid-column: 1 / -1; }
  .lin-grid2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 150; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .top { padding: 0 14px; }
  .top .burger { display: inline-flex; }
  .content { padding: 16px 16px 60px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid > [class^="c"], .form-grid > [class*=" c"] { grid-column: span 12 !important; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  table.t.resp thead { display: none; }
  table.t.resp, table.t.resp tbody, table.t.resp tr, table.t.resp td { display: block; width: 100%; }
  table.t.resp tr { border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.t.resp td { border: 0; padding: 4px 10px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.t.resp td::before { content: attr(data-l); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
  table.t.resp td.num { text-align: right; }
  .modal .ft .btn { flex: 1; }
  .page-h .row { width: 100%; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .kpi .val { font-size: 20px; }
  .lin-grid, .lin-grid2 { grid-template-columns: 1fr 1fr; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 7px 8px; }
}
@media print { .side, .top { display: none; } }
