/* ============================================================
   SOS Mi Gente: mg-app.css (global baseline + shared components)
   Palette: dataviz reference instance (light mode).
   Typography floor: nothing below 11px, body ≥ 14px.
   ============================================================ */

:root {
    color-scheme: light;
    /* surfaces & ink */
    --page:        #f9f9f7;
    --surface:     #fcfcfb;
    --ink:         #0b0b0b;
    --ink-2:       #52514e;
    --muted:       #898781;
    --hairline:    #e1e0d9;
    --ring:        rgba(11,11,11,0.10);
    /* brand / action */
    --primary:     #2a78d6;
    --primary-dn:  #256abf;
    --primary-soft:#e7f0fb;
    /* status (fixed, never reused as series) */
    --st-good:     #0ca30c;
    --st-good-txt: #006300;
    --st-warning:  #fab219;
    --st-serious:  #ec835a;
    --st-critical: #d03b3b;
    /* progress bar segments */
    --seg-done:    #0ca30c;
    --seg-way:     #fab219;
    --seg-open:    #e1e0d9;
    /* misc */
    --radius: 12px;
    --shadow: 0 1px 2px rgba(11,11,11,.05), 0 4px 14px rgba(11,11,11,.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dn); text-decoration: none; }
a:hover { text-decoration: underline; }

small, .text-small, caption, .hint, label { font-size: 12px; }

.wrapper { min-height: 100vh; display: flex; flex-direction: column; }
.main-content {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 18px 16px 90px;
    flex: 1;
}

/* ---------------- topbar + nav ---------------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-name {
    font-weight: 700; font-size: 20px; letter-spacing: .2px; color: var(--ink);
}
.brand-name .dot { color: var(--primary); }
.brand-emergency {
    font-size: 12px; color: var(--ink-2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 40vw;
}
.topbar-spacer { flex: 1; }
.topbar-user { font-size: 13px; color: var(--ink-2); max-width: 32vw;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-toggle {
    border: 1px solid var(--hairline); background: var(--surface);
    border-radius: 10px; font-size: 18px; line-height: 1;
    padding: 8px 11px; cursor: pointer; color: var(--ink);
}

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 264px; background: var(--surface);
    border-right: 1px solid var(--hairline);
    transform: translateX(-100%);
    transition: transform .18s ease;
    padding: 18px 14px;
    display: flex; flex-direction: column; gap: 4px;
}
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
.sidebar .side-brand { font-weight: 700; font-size: 22px; margin: 4px 8px 14px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 12px; border-radius: 10px;
    color: var(--ink); font-size: 15px;
}
.sidebar nav a:hover { background: var(--primary-soft); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary-dn); font-weight: 600; }
.sidebar .side-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }
.nav-scrim {
    position: fixed; inset: 0; z-index: 55; background: rgba(11,11,11,.28);
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.nav-scrim.show { opacity: 1; pointer-events: auto; }

/* ---------------- buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-size: 15px; font-weight: 600;
    padding: 12px 18px; min-height: 44px;
    cursor: pointer; transition: filter .12s ease, background .12s ease;
    text-decoration: none !important;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dn); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--hairline); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-danger-outline { background: var(--surface); color: var(--st-critical); border-color: var(--hairline); }
.btn-danger-outline:hover { background: #fbeaea; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; min-height: 36px; font-size: 13px; border-radius: 8px; }

/* ---------------- cards ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--ring);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}
.card + .card { margin-top: 12px; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--primary); }

.cards-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px)  { .cards-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1020px) { .cards-grid { grid-template-columns: 1fr 1fr 1fr; } }

/* ---------------- chips ---------------- */
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    border-radius: 999px; padding: 3px 10px;
    font-size: 12px; font-weight: 600; line-height: 1.5;
    background: var(--page); color: var(--ink-2);
    border: 1px solid var(--hairline);
}
.chip-cat { background: var(--primary-soft); border-color: transparent; color: #1c5cab; }
.chip-critica { background: var(--st-critical); border-color: transparent; color: #fff; }
.chip-alta    { background: #fdecdf; border-color: transparent; color: #b34a22; }
.chip-media   { background: #fdf3d7; border-color: transparent; color: #8a6103; }
.chip-baja    { background: var(--page); color: var(--ink-2); }
.chip-status-abierta    { background: var(--primary-soft); border-color: transparent; color: #1c5cab; }
.chip-status-cubierta   { background: #fdf3d7; border-color: transparent; color: #8a6103; }
.chip-status-completada { background: #e2f4e2; border-color: transparent; color: var(--st-good-txt); }
.chip-status-cancelada  { background: var(--page); color: var(--muted); }
.chip-status-activa     { background: #fdf3d7; border-color: transparent; color: #8a6103; }
.chip-status-entregada  { background: #e2f4e2; border-color: transparent; color: var(--st-good-txt); }
.chip-status-vencida    { background: #fbeaea; border-color: transparent; color: var(--st-critical); }
.chip-status-liberada   { background: var(--page); color: var(--ink-2); }
.chip-status-propuesta  { background: var(--primary-soft); border-color: transparent; color: #1c5cab; }
.chip-status-rechazada  { background: var(--page); color: var(--muted); }

/* ---------------- progress (delivered | committed | open) ---------------- */
.progress {
    display: flex; gap: 2px; /* 2px surface gap between fills (mark spec) */
    height: 10px; border-radius: 6px; overflow: hidden;
    background: transparent; margin: 10px 0 6px;
}
.progress .seg { height: 100%; border-radius: 3px; min-width: 0; }
.progress .seg-done { background: var(--seg-done); }
.progress .seg-way  { background: var(--seg-way); }
.progress .seg-open { background: var(--seg-open); }
.progress-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12px; color: var(--ink-2); }
.progress-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.progress-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------------- need card bits ---------------- */
.need-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.need-time { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.need-title { font-size: 17px; font-weight: 600; margin: 8px 0 2px; color: var(--ink); }
.need-zone { font-size: 13px; color: var(--ink-2); }
.need-remaining { font-size: 14px; margin-top: 4px; }
.need-remaining b { font-size: 15px; }
.need-groups { font-size: 12px; color: var(--ink-2); }
.need-cta { margin-top: 12px; }

/* ---------------- tabs / filters ---------------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin-bottom: 12px; }
.tab {
    border: 1px solid var(--hairline); background: var(--surface);
    border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 14px;
    font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters select, .filters input[type="search"], .filters input[type="text"] {
    font: inherit; font-size: 14px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--hairline);
    border-radius: 10px; padding: 10px 12px; min-height: 42px;
}
.filters input[type="search"] { flex: 1; min-width: 150px; }

/* ---------------- forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.form-control {
    width: 100%; font: inherit; font-size: 15px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--hairline);
    border-radius: 10px; padding: 12px 12px; min-height: 46px;
}
.form-control:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
textarea.form-control { min-height: 96px; resize: vertical; }
.field-error { color: var(--st-critical); font-size: 12px; margin-top: 4px; display: none; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segmented button {
    font: inherit; font-size: 13px; font-weight: 600; padding: 10px 4px;
    border-radius: 10px; border: 1px solid var(--hairline);
    background: var(--surface); color: var(--ink-2); cursor: pointer; min-height: 42px;
}
.segmented button.sel-critica { background: var(--st-critical); border-color: transparent; color: #fff; }
.segmented button.sel-alta    { background: var(--st-serious);  border-color: transparent; color: #fff; }
.segmented button.sel-media   { background: var(--st-warning);  border-color: transparent; color: #3d2c00; }
.segmented button.sel-baja    { background: var(--ink-2);       border-color: transparent; color: #fff; }

.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper button {
    width: 46px; font-size: 20px; font-weight: 600; border-radius: 10px;
    border: 1px solid var(--hairline); background: var(--surface); cursor: pointer; color: var(--ink);
}
.stepper input { text-align: center; font-weight: 600; }

/* ---------------- panel (dashboard) ---------------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(5, 1fr); } }
.tile {
    background: var(--surface); border: 1px solid var(--ring);
    border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.tile .t-label { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.tile .t-value { font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1.15; margin-top: 2px; }
.tile .t-sub { font-size: 12px; color: var(--muted); }
.tile.accent .t-value { color: var(--primary-dn); }

.section-h { font-size: 16px; font-weight: 700; margin: 22px 0 10px; }

/* horizontal bar rows — single-hue magnitude, thin marks, rounded data ends */
.hbar-row { display: grid; grid-template-columns: minmax(120px, 38%) 1fr 44px; gap: 10px; align-items: center; padding: 7px 0; }
.hbar-label { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 14px; border-radius: 4px; background: transparent; position: relative; }
.hbar-fill { height: 100%; border-radius: 4px; background: var(--primary); min-width: 2px; }
.hbar-val { font-size: 13px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }

/* activity feed */
.feed-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.feed-item:last-child { border-bottom: none; }
.feed-ico { font-size: 16px; line-height: 1.4; }
.feed-txt { font-size: 14px; color: var(--ink); }
.feed-txt .who { font-weight: 600; }
.feed-meta { font-size: 12px; color: var(--muted); }

/* ---------------- claims list ---------------- */
.claim-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.claim-row:last-child { border-bottom: none; }
.claim-main { flex: 1; min-width: 0; }
.claim-name { font-weight: 600; font-size: 14px; }
.claim-sub { font-size: 12px; color: var(--ink-2); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 600; }
.countdown.danger { color: var(--st-critical); }

/* ---------------- notifications ---------------- */
#toast-root { position: fixed; left: 12px; right: 12px; bottom: 16px; z-index: 100;
    display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    max-width: 560px; width: 100%;
    background: var(--ink); color: #fff;
    border-radius: 12px; padding: 12px 16px; font-size: 14px;
    box-shadow: var(--shadow); opacity: 0; transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--st-critical); }
.toast.ok  { background: var(--st-good-txt); }

/* ---------------- misc ---------------- */
.empty {
    text-align: center; color: var(--ink-2); padding: 44px 16px;
    border: 1px dashed var(--hairline); border-radius: var(--radius); background: var(--surface);
}
.empty .big { font-size: 34px; }
.page-title { font-size: 21px; font-weight: 700; margin: 4px 0 14px; }
.subtle { color: var(--ink-2); font-size: 13px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
.spinner {
    width: 26px; height: 26px; margin: 30px auto; border-radius: 50%;
    border: 3px solid var(--hairline); border-top-color: var(--primary);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-more { display: flex; justify-content: center; margin-top: 16px; }

.auth-box { max-width: 420px; margin: 26px auto; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; font-size: 13px; color: var(--ink-2); }
.timeline li .tl-ico { flex: none; }
.timeline li b { color: var(--ink); }

.notice {
    background: var(--primary-soft); border-radius: 10px; padding: 10px 12px;
    font-size: 13px; color: #1c5cab;
}
.notice.warn { background: #fdf3d7; color: #8a6103; }

/* ---------------- article picker ---------------- */
.ap-results {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 40;
    background: var(--surface); border: 1px solid var(--hairline);
    border-radius: 10px; box-shadow: var(--shadow);
    max-height: 260px; overflow-y: auto; display: none; margin-top: 4px;
}
.ap-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    text-align: left; font: inherit; font-size: 14px; color: var(--ink);
    background: none; border: none; border-bottom: 1px solid var(--hairline);
    padding: 11px 12px; cursor: pointer;
}
.ap-item:last-child { border-bottom: none; }
.ap-item:hover { background: var(--primary-soft); }
.ap-item .ap-unit { margin-left: auto; font-size: 12px; color: var(--muted); }
.ap-new { color: var(--primary-dn); font-weight: 600; }

/* ---------------- publish lines ---------------- */
.line-card { border: 1px solid var(--hairline); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--page); }
.line-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.line-title { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.line-remove { margin-left: auto; background: none; border: none; color: var(--st-critical); font-size: 16px; cursor: pointer; padding: 4px 8px; }

/* ---------------- coordination console ---------------- */
.match-box { border-top: 1px dashed var(--hairline); margin-top: 10px; padding-top: 10px; }
.match-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.match-row:last-child { border-bottom: none; }
.match-main { flex: 1; min-width: 200px; }
.match-name { font-weight: 600; font-size: 14px; }
.match-sub { font-size: 12px; color: var(--ink-2); }
.match-act { display: flex; align-items: center; gap: 6px; }
.match-act input[type="number"] { width: 74px; }
.match-act select { min-height: 36px; padding: 6px 8px; font-size: 13px; border: 1px solid var(--hairline); border-radius: 8px; background: var(--surface); }
.qty-mini { font: inherit; font-size: 14px; border: 1px solid var(--hairline); border-radius: 8px; padding: 7px 8px; min-height: 36px; }
