/* =====================================================================
   RDMP · Roadmap de Proyectos TI
   Estética corporativa: rojo / amarillo sobre neutros limpios.
   ===================================================================== */
:root {
    --red: #D01012;
    --red-600: #B00D0F;
    --red-50: #FDECEC;
    --yellow: #FFCF00;
    --yellow-50: #FFF8D6;
    --blue: #006DB7;
    --green: #00A650;
    --ink: #16181D;
    --ink-2: #3A3F4B;
    --muted: #6B7280;
    --line: #E5E7EB;
    --line-2: #F0F1F3;
    --bg: #F5F6F8;
    --card: #FFFFFF;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --sidebar: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
    border: 1px solid transparent; background: var(--card); color: var(--ink);
    font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid rgba(0, 109, 183, .35); outline-offset: 1px; }
.btn--primary { background: var(--red); color: #fff; }
.btn--primary:hover { background: var(--red-600); }
.btn--ghost { border-color: var(--line); }
.btn--ghost:hover { background: var(--line-2); }
.btn--danger-ghost { color: var(--red); border-color: #F3C4C5; }
.btn--danger-ghost:hover { background: var(--red-50); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }
.icon-btn {
    border: 0; background: transparent; width: 34px; height: 34px; border-radius: 8px;
    cursor: pointer; font-size: 16px; color: var(--muted);
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

/* ---------- Formularios ---------- */
.form label, .auth-card label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
input, select, textarea {
    font: 400 14px var(--font); color: var(--ink);
    border: 1px solid #D5D8DE; border-radius: var(--radius-sm);
    padding: 8px 10px; background: #fff; min-height: 38px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 109, 183, .15); }
input[type=range] { padding: 0; border: 0; box-shadow: none; accent-color: var(--red); min-height: 0; }
.is-invalid { border-color: var(--red) !important; background: #FFFAFA; }
.err { color: var(--red); font-weight: 500; min-height: 0; }
.err:empty { display: none; }
.hint { color: var(--muted); font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 16px; display: grid; gap: 12px; }
legend { font-weight: 700; padding: 0 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row .num { width: 76px; flex: none; }

/* ---------- Alertas ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13.5px; }
.alert--error { background: var(--red-50); color: #8A0B0C; border: 1px solid #F6C7C8; }
.alert--ok { background: #E7F7EE; color: #075E33; border: 1px solid #BFE8D1; }
.alert--info { background: #E8F2FA; color: #0A4A78; border: 1px solid #C4DDF0; }

/* ---------- Login / instalador ---------- */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
    background:
        linear-gradient(180deg, var(--red) 0 6px, transparent 6px),
        radial-gradient(circle at 12% 18%, rgba(255, 207, 0, .18), transparent 40%),
        var(--bg);
}
.auth-card {
    background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
    padding: 28px; width: 100%; max-width: 380px; display: grid; gap: 14px;
}
.auth-card--wide { max-width: 560px; }
.auth-card h1 { font-size: 20px; }
.auth-card p { margin: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-brand .logo { width: 44px; height: 44px; }
.auth-brand strong { display: block; font-size: 20px; letter-spacing: .5px; }
.auth-brand span { color: var(--muted); font-size: 13px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.checklist .ok { color: #067A3E; }
.checklist .bad { color: var(--red); font-weight: 600; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar); flex: none; background: var(--ink); color: #C9CDD6;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    border-top: 4px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 20px; color: #fff; }
.brand strong { display: block; font-size: 17px; letter-spacing: .6px; }
.brand small { display: block; color: #9AA1AE; font-size: 12px; }
.nav { display: grid; gap: 2px; padding: 0 10px; }
.nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
    color: #C9CDD6; font-weight: 500; position: relative;
}
.nav svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.is-active { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.is-active::before {
    content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--yellow);
}
.nav a.is-active svg { fill: var(--yellow); opacity: 1; }
.sidebar__foot { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: 10px; }
.sidebar__foot .btn--ghost { color: #C9CDD6; border-color: rgba(255, 255, 255, .15); background: transparent; }
.sidebar__foot .btn--ghost:hover { background: rgba(255, 255, 255, .06); }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user b { color: #fff; font-weight: 600; display: block; }
.user small { color: #9AA1AE; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 20px 28px 14px; background: var(--bg);
}
.topbar h1 { font-size: 22px; font-weight: 800; letter-spacing: -.2px; }
.topbar p { margin: 2px 0 0; font-size: 13px; }
.view { padding: 6px 28px 32px; min-width: 0; }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card__head h3 { font-size: 15px; font-weight: 700; }
.empty { color: var(--muted); padding: 14px 0; text-align: center; font-size: 13px; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 16px; border: 0; text-align: left; cursor: pointer; font: inherit; color: inherit;
    border-top: 4px solid var(--kpi, var(--ink)); transition: transform .12s, box-shadow .12s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 24, 40, .12); }
.kpi span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi strong { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }

.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line-2); }
.stack i { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; margin-top: 14px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend b { margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li {
    display: flex; align-items: center; gap: 12px; padding: 10px 4px;
    border-bottom: 1px solid var(--line-2); cursor: pointer;
}
.mini-list li:last-child { border-bottom: 0; }
.mini-list li:hover { background: #FAFAFB; }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars { display: grid; gap: 10px; }
.bars .row { display: grid; grid-template-columns: 140px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; }
.bars .row span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars .track { height: 10px; background: var(--line-2); border-radius: 5px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--blue); border-radius: 5px; }
.bars b { text-align: right; }

/* ---------- Chips / badges ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 20px;
    background: color-mix(in srgb, var(--c) 13%, #fff); color: color-mix(in srgb, var(--c) 80%, #000);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.prio { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.prio i { display: inline-flex; gap: 2px; }
.prio i b { width: 4px; height: 11px; border-radius: 1px; background: #D5D8DE; }
.prio--critica { color: var(--red); } .prio--critica i b { background: var(--red); }
.prio--alta { color: #C2410C; } .prio--alta i b:nth-child(-n+3) { background: #EA7317; }
.prio--media { color: #946800; } .prio--media i b:nth-child(-n+2) { background: #E0A800; }
.prio--baja { color: var(--muted); } .prio--baja i b:nth-child(1) { background: #9CA3AF; }
.badge-late {
    display: inline-flex; align-items: center; gap: 4px; background: var(--red); color: #fff;
    font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; letter-spacing: .2px; white-space: nowrap;
}
.badge-soon { background: var(--yellow); color: #4A3B00; }
.date-late { color: var(--red); font-weight: 600; }
.avatar {
    width: 26px; height: 26px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff; background: var(--av, #6B7280);
}
.progress { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.progress .track { flex: 1; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.progress .fill { height: 100%; background: var(--green); border-radius: 3px; }
.progress span { font-size: 12px; font-weight: 600; width: 34px; text-align: right; color: var(--ink-2); }

/* ---------- Barra de filtros ---------- */
.filters {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px;
    background: var(--card); padding: 10px 12px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters input, .filters select { width: auto; min-width: 140px; height: 36px; min-height: 36px; padding: 6px 10px; }
.filters .search { flex: 1 1 220px; min-width: 180px; padding-left: 32px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 10px center no-repeat; }
.filters .date-range { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.filters .date-range input { min-width: 0; width: 140px; }
.filters .check { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.filters .check input { width: 16px; min-width: 0; padding: 0; min-height: 0; height: 16px; accent-color: var(--red); }
.filters .count { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 0 12px; height: 34px; font: 600 13px var(--font); cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.is-active { background: var(--ink); color: #fff; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(262px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kcol { background: #ECEEF1; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); min-height: 180px; }
.kcol__head {
    display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; font-weight: 700; font-size: 13.5px;
    border-top: 4px solid var(--c); border-radius: var(--radius) var(--radius) 0 0;
}
.kcol__head .n { margin-left: auto; background: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--muted); }
.kcol__body { padding: 4px 10px 12px; overflow-y: auto; display: grid; gap: 10px; align-content: start; flex: 1; min-height: 80px; border-radius: 0 0 var(--radius) var(--radius); transition: background .15s; }
.kcol.is-over .kcol__body { background: color-mix(in srgb, var(--c) 12%, transparent); outline: 2px dashed var(--c); outline-offset: -4px; }
.kcard {
    background: #fff; border-radius: 10px; padding: 12px; box-shadow: var(--shadow); cursor: grab;
    border-left: 4px solid transparent; display: grid; gap: 9px; user-select: none;
}
.kcard:hover { box-shadow: 0 4px 12px rgba(16, 24, 40, .12); }
.kcard.is-late { border-left-color: var(--red); }
.kcard.is-dragging { opacity: .45; }
.kcard .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kcard h4 { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.3; word-break: break-word; }
.kcard .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.kcard .who { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink-2); }
.kcard .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard .blk { font-size: 12px; color: #8A0B0C; background: var(--red-50); border-radius: 6px; padding: 5px 8px; }

/* ---------- Roadmap ---------- */
.filters select#rm-group { min-width: 190px; }
.gantt { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.gantt__scroll { overflow-x: auto; }
.gantt__inner { min-width: 980px; position: relative; }
.g-rowx { display: grid; grid-template-columns: 270px 1fr; }
.g-cell-left { position: sticky; left: 0; z-index: 5; background: #fff; border-right: 1px solid var(--line); }
.g-head { height: 58px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-end; padding: 0 14px 9px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.g-timehead { height: 58px; border-bottom: 1px solid var(--line); position: relative; }
.g-month { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line); padding: 7px 8px 0; font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-transform: capitalize; }
.g-month small { font-weight: 500; color: var(--muted); }
.g-load { position: absolute; bottom: 6px; left: 0; right: 0; height: 18px; }
.g-load i { position: absolute; bottom: 0; height: 100%; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 11px; font-weight: 700; color: #0A4A78; }
.g-load i b { position: absolute; inset: 1px 4px; border-radius: 4px; background: var(--blue); z-index: -1; }
.g-load i { isolation: isolate; }
.g-body { position: relative; }
.g-overlay { position: absolute; top: 0; bottom: 0; left: 270px; right: 0; pointer-events: none; }
.g-lines { position: absolute; inset: 0; }
.g-lines i { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #EEF0F2; }
.g-lines i.q { border-left: 1px solid var(--line); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--red); z-index: 4; }
.g-today::before { content: "Hoy"; position: absolute; top: 0; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 0 0 4px 4px; }
.g-group { height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 14px; font-weight: 700; font-size: 12.5px; background: #F4F5F7; border-bottom: 1px solid var(--line); }
.g-grouprow .g-cell-left { background: #F4F5F7; }
.g-row { height: 46px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; cursor: pointer; }
.g-row:hover { background: #FAFAFB; }
.g-row .t { min-width: 0; flex: 1; }
.g-row .t b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-row .t small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { height: 46px; border-bottom: 1px solid var(--line-2); position: relative; }
.g-bar {
    position: absolute; top: 10px; height: 26px; border-radius: 6px; background: var(--c);
    min-width: 6px; cursor: pointer; overflow: hidden; display: flex; align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15); z-index: 1;
}
.g-bar:hover { filter: brightness(1.08); box-shadow: 0 3px 10px rgba(0, 0, 0, .2); }
.g-bar .pf { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, .22); }
.g-bar span { position: relative; color: #fff; font-size: 12px; font-weight: 600; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-bar.is-open { border-top-right-radius: 0; border-bottom-right-radius: 0; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.g-bar.is-closed { opacity: .72; }
.g-late {
    position: absolute; top: 14px; height: 18px; border-radius: 0 4px 4px 0;
    background: repeating-linear-gradient(135deg, rgba(208, 16, 18, .55) 0 5px, rgba(208, 16, 18, .15) 5px 10px);
}
.g-outside { position: absolute; top: 14px; font-size: 11px; color: var(--muted); font-weight: 600; }
.g-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.g-legend div { display: flex; align-items: center; gap: 6px; }
.g-legend .hatch { width: 18px; height: 10px; border-radius: 2px; background: repeating-linear-gradient(135deg, rgba(208, 16, 18, .6) 0 3px, rgba(208, 16, 18, .15) 3px 6px); }
.unplanned { margin-top: 18px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { border: 1px dashed #C5CAD3; background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; font-family: inherit; }
.tag:hover { border-color: var(--blue); }

/* ---------- Tabla ---------- */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 1080px; }
.grid th, .grid td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.grid th {
    font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
    background: #FAFAFB; position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap;
}
.grid th:hover { color: var(--ink); }
.grid th.sorted::after { content: " ▲"; font-size: 9px; color: var(--red); }
.grid th.sorted.desc::after { content: " ▼"; }
.grid th.nosort { cursor: default; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: #FAFBFC; }
.grid tr.is-late td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.grid .pname b { display: block; font-weight: 600; max-width: 280px; }
.grid .badge-late { margin-top: 3px; }
.grid td.pname { min-width: 210px; }
.grid .pname small { color: var(--muted); display: block; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid .code { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.grid td.nowrap { white-space: nowrap; }
.grid .actions { white-space: nowrap; text-align: right; }

/* ---------- Modal ---------- */
.modal {
    border: 0; border-radius: 16px; padding: 0; width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 40px); box-shadow: var(--shadow-lg); color: var(--ink);
}
.modal::backdrop { background: rgba(22, 24, 29, .5); backdrop-filter: blur(2px); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 22px 12px; border-top: 5px solid var(--red); }
.modal__head h2 { font-size: 19px; font-weight: 800; }
.modal__head .code { font-size: 12px; font-weight: 700; color: var(--muted); }
.modal__body { padding: 8px 22px 16px; overflow-y: auto; }
.modal__foot { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: #FAFAFB; }
.tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 8px 12px; font: 600 13.5px var(--font); color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.is-active { color: var(--ink); border-bottom-color: var(--yellow); }
.history { list-style: none; margin: 0; padding: 4px 0; display: grid; gap: 0; }
.history li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; font-size: 13px; }
.history li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--blue); }
.history li.create::before { border-color: var(--green); }
.history li.delete::before { border-color: var(--red); }
.history time { color: var(--muted); font-size: 12px; display: block; }
.history del { color: var(--muted); }
.history ins { text-decoration: none; font-weight: 600; }

/* ---------- Toast / tooltip ---------- */
.toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100;
    background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow-lg);
    font-weight: 500; max-width: calc(100vw - 32px);
}
.toast.is-error { background: #8A0B0C; }
.tooltip {
    position: fixed; z-index: 90; pointer-events: none; background: var(--ink); color: #fff;
    border-radius: 8px; padding: 10px 12px; font-size: 12.5px; max-width: 300px; box-shadow: var(--shadow-lg);
}
.tooltip b { display: block; font-size: 13px; margin-bottom: 4px; }
.tooltip div { color: #C9CDD6; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 12; }
}
@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: sticky; flex-direction: row; align-items: center; z-index: 20; }
    .brand { padding: 10px 14px; }
    .brand small { display: none; }
    .nav { display: flex; padding: 0; overflow-x: auto; flex: 1; }
    .nav a { padding: 10px; }
    .nav a span { display: none; }
    .nav a.is-active::before { left: 8px; right: 8px; top: auto; bottom: -2px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
    .sidebar__foot { margin: 0; border: 0; padding: 8px 12px; }
    .sidebar__foot .user { display: none; }
    .topbar { padding: 16px 16px 10px; }
    .view { padding: 4px 16px 24px; }
    .grid-form, .grid-2 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
}
@media (max-width: 560px) {
    .topbar { flex-direction: column; align-items: stretch; }
    .filters input, .filters select { flex: 1 1 140px; }
    .filters .date-range { flex-wrap: wrap; }
    .brand span { display: none; }
    .sidebar__foot .btn { padding: 0 8px; font-size: 12px; }
}
