:root {
  --bg: #0a0c11; --surface: #11141b; --surface-2: #161a23; --border: #222836; --border-2: #2c3343;
  --text: #e7e9ef; --muted: #8a93a6; --faint: #5d6578;
  --accent: #8b6cff; --accent-2: #6d4dff; --accent-soft: rgba(139,108,255,.14);
  --ok: #2fbf71; --ok-soft: rgba(47,191,113,.14); --warn: #f0a63a; --warn-soft: rgba(240,166,58,.14);
  --bad: #f05252; --bad-soft: rgba(240,82,82,.14); --info: #4aa8ff; --info-soft: rgba(74,168,255,.14);
  --radius: 12px; --radius-sm: 8px; --shadow: 0 8px 30px rgba(0,0,0,.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); background: var(--surface); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #3ec7ff); display: grid; place-items: center; font-size: 15px; color: #fff; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav .count { margin-left: auto; font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; color: var(--muted); }
.sidebar .foot { margin-top: auto; font-size: 11px; color: var(--faint); padding: 10px; border-top: 1px solid var(--border); }
.sidebar .foot .safe { color: var(--ok); }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: rgba(10,12,17,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 24px 28px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.banner { padding: 10px 28px; font-size: 13px; font-weight: 600; text-align: center; }
.banner.demo { background: repeating-linear-gradient(45deg, #3a2a05, #3a2a05 12px, #2c2004 12px, #2c2004 24px); color: #ffd27a; border-bottom: 1px solid #5a4210; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.cols-2 { grid-template-columns: 1.4fr 1fr; } .cols-3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.flat { padding: 0; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { color: var(--faint); font-size: 12px; }
.kpi.accent { background: linear-gradient(160deg, rgba(139,108,255,.18), var(--surface) 60%); border-color: #3b3266; }

.goal { display: flex; align-items: center; gap: 18px; }
.ring { --p: 0; width: 96px; height: 96px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); display: grid; place-items: center; flex: none; }
.ring::after { content: attr(data-label); width: 74px; height: 74px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 18px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bars .bar { flex: 1; background: var(--accent-soft); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bars .bar > span { position: absolute; bottom: 0; left: 0; right: 0; background: var(--accent); border-radius: 4px 4px 0 0; }
.bars-x { display: flex; gap: 6px; font-size: 10px; color: var(--faint); margin-top: 6px; } .bars-x span { flex: 1; text-align: center; }
.hbar { display: grid; grid-template-columns: 140px 1fr 44px; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; }
.hbar .track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 99px; }
.hbar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.input, select.input, textarea.input { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; outline: none; min-width: 0; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.search { flex: 1; min-width: 200px; }
textarea.input { width: 100%; min-height: 80px; resize: vertical; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-2); background: var(--surface-2); padding: 8px 13px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; } .btn.primary:hover { background: var(--accent); }
.btn.danger { background: var(--bad-soft); border-color: #5c2a2a; color: #ffb4b4; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--text); }
tbody tr { cursor: pointer; } tbody tr:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge.A { background: var(--ok-soft); color: #6fe3a3; border-color: #1f5a3b; }
.badge.B { background: var(--info-soft); color: #8fc9ff; border-color: #1e4566; }
.badge.C { background: var(--warn-soft); color: #ffc878; border-color: #5c4318; }
.badge.descartado, .badge.neutral { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge.ok { background: var(--ok-soft); color: #6fe3a3; } .badge.warn { background: var(--warn-soft); color: #ffc878; }
.badge.bad { background: var(--bad-soft); color: #ff9b9b; } .badge.info { background: var(--info-soft); color: #8fc9ff; }
.badge.accent { background: var(--accent-soft); color: #c3b4ff; }
.state { font-size: 12px; color: var(--muted); } .state::before { content: "●"; margin-right: 5px; color: var(--accent); }
.state.final::before { color: var(--faint); } .state.blocked::before { color: var(--bad); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .mono { font-family: var(--mono); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 13px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
.col-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; }
.col-head .n { color: var(--muted); }
.col.final { opacity: .75; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px; }
.kcard .t { font-weight: 600; margin-bottom: 4px; cursor: pointer; } .kcard .t:hover { color: var(--accent); }
.kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.kcard select { margin-top: 8px; width: 100%; font-size: 12px; padding: 5px 8px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs button.active { color: var(--text); border-color: var(--accent); }

.md { line-height: 1.6; overflow-wrap: anywhere; } .md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; text-transform: none; letter-spacing: 0; color: var(--text); }
.md h1 { font-size: 18px; } .md h2 { font-size: 15px; } .md h3 { font-size: 14px; }
.md table { margin: 10px 0; font-size: 12.5px; display: block; overflow-x: auto; } .md th, .md td { padding: 6px 10px; border: 1px solid var(--border); position: static; }
.md tbody tr { cursor: default; } .md code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; } .md blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 0 8px 8px 0; }
.md ul { padding-left: 20px; }
.message { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 13.5px; line-height: 1.6; }

.notice { border: 1px solid; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; }
.notice.safe { border-color: #1f5a3b; background: var(--ok-soft); color: #9de8bf; }
.notice.warn { border-color: #5c4318; background: var(--warn-soft); color: #ffd79e; }
.notice.bad { border-color: #5c2a2a; background: var(--bad-soft); color: #ffbcbc; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; width: min(520px, 100%); padding: 22px; box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 6px; } .modal p { color: var(--muted); margin: 0 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.modal .input { width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text) !important; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--surface-2); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow); font-size: 13px; white-space: pre-wrap; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); }

.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); height: 90px; }
@keyframes sk { to { background-position: -200% 0; } }

.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--border); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .when { color: var(--faint); font-size: 12px; }

@media (max-width: 1100px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .banner { padding: 8px 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .value { font-size: 22px; }
  .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; }
  .hbar { grid-template-columns: 96px 1fr 36px; }
  th, td { padding: 9px 10px; }
  .hide-sm { display: none; }
  .kanban { grid-auto-columns: 82%; }
}
