/* ==========================================================================
   Arabic posting progress — brutalist light theme
   ========================================================================== */

:root {
    /* surfaces — neutral greys, no warm cast */
    --plane: #e7e9ec;
    --surface: #ffffff;
    --surface-sunken: #f3f4f6;
    --hatch: #dfe2e6;
    --row-hover: #e8eef7;

    /* ink */
    --ink: #101214;
    --ink-2: #4b5058;
    --ink-muted: #7b818a;

    /* chrome */
    --line: #101214;
    --grid: #dfe1e5;
    --baseline: #c2c6cc;

    /* validated categorical slots — blue / violet / aqua / orange */
    --fb: #2a78d6;
    --ig: #4a3aa7;
    --tt: #1baf7a;
    --yt: #eb6834;

    /* status */
    --good: #0ca30c;
    --good-ink: #006300;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;

    /* sequential blue ramp (heatmap) */
    --seq-100: #cde2fb;
    --seq-200: #9ec5f4;
    --seq-300: #6da7ec;
    --seq-400: #3987e5;
    --seq-500: #256abf;
    --seq-600: #184f95;

    --border-w: 3px;
    --shadow: 6px 6px 0 0 var(--line);
    --shadow-sm: 4px 4px 0 0 var(--line);
    --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: var(--plane);
    background-image: radial-gradient(rgba(16, 18, 20, 0.10) 1px, transparent 1px);
    background-size: 22px 22px;
    color: var(--ink);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--ink);
    color: #fff;
}

.shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

/* --- header ------------------------------------------------------------- */

.masthead {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.masthead h1 {
    margin: 0;
    font-size: clamp(28px, 4.4vw, 52px);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -0.03em;
    line-height: 0.95;
}

.masthead .sub {
    margin: 8px 0 0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--ink-2);
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.badge.dark {
    background: var(--ink);
    color: #fff;
}

.badge.warn {
    background: var(--warning);
}

/* --- filter bar --------------------------------------------------------- */

.filters {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 26px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field label {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ink-2);
}

.field input[type="date"] {
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    padding: 8px 10px;
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    color: var(--ink);
    min-width: 168px;
}

.field input[type="date"]:focus-visible {
    outline: 3px solid var(--fb);
    outline-offset: 2px;
}

.presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

button {
    font-family: var(--font);
    cursor: pointer;
}

.preset {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    color: var(--ink);
    padding: 8px 11px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.preset:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-sm);
}

.preset:active {
    transform: translate(1px, 1px);
    box-shadow: none;
}

.preset[aria-pressed="true"] {
    background: var(--ink);
    color: #fff;
}

.spacer {
    flex: 1 1 20px;
}

.btn-primary {
    border: var(--border-w) solid var(--line);
    background: var(--warning);
    color: var(--ink);
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-primary:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 0 var(--line);
}

.btn-primary:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 0 var(--line);
}

.btn-ghost {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    color: var(--ink);
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-decoration: none;
    display: inline-block;
}

.btn-ghost:hover {
    background: var(--ink);
    color: #fff;
}

/* --- notice ------------------------------------------------------------- */

.notice {
    border: var(--border-w) solid var(--line);
    border-left-width: 10px;
    border-left-color: var(--warning);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 10px 14px;
    margin-bottom: 22px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-2);
    display: none;
}

.notice.show {
    display: block;
}

.notice strong {
    color: var(--ink);
}

/* --- section titles ----------------------------------------------------- */

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 34px 0 16px;
}

.section-title h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.section-title .rule {
    flex: 1;
    height: 3px;
    background: var(--line);
}

/* --- KPI tiles ---------------------------------------------------------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
}

.tile {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tile:hover {
    transform: translate(-3px, -3px);
    box-shadow: 9px 9px 0 0 var(--line);
}

.tile.hero {
    background: var(--ink);
    color: #fff;
}

.tile.hero .tile-label,
.tile.hero .tile-note {
    color: rgba(255, 255, 255, 0.72);
}

.tile-head {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: var(--border-w) solid currentColor;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.swatch {
    width: 14px;
    height: 14px;
    border: 2px solid var(--line);
    flex: none;
}

.tile.hero .swatch {
    border-color: #fff;
}

.tile-label {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-2);
}

.tile-value {
    font-size: 40px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.03em;
}

.tile-value .of {
    font-size: 15px;
    font-weight: 800;
    color: var(--ink-2);
    letter-spacing: 0;
}

.tile.hero .tile-value .of {
    color: rgba(255, 255, 255, 0.72);
}

.meter {
    height: 16px;
    border: 2px solid currentColor;
    margin-top: 12px;
    background: var(--surface-sunken);
    position: relative;
    overflow: hidden;
}

.tile.hero .meter {
    background: #2b3038;
}

.meter-fill {
    height: 100%;
    width: 0;
    transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Where 100% sits when the bar runs past it. */
.meter-mark {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 3px;
    background: var(--ink);
}

.tile.hero .meter-mark {
    background: #fff;
}

.tile-foot {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.tile-pct {
    font-size: 18px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.tile-note {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.delta.up {
    color: var(--good-ink);
}

.delta.down {
    color: var(--critical);
}

.tile.hero .delta.up {
    color: #6ee06e;
}

.tile.hero .delta.down {
    color: #ff9a9a;
}

/* --- chart cards -------------------------------------------------------- */

.grid {
    display: grid;
    gap: 18px;
}

/* Fixed column counts, not auto-fit — `span-2` has to mean "full width", and
   auto-fit silently adds a third track on wide screens. */
.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1180px) {
    .grid.three,
    .grid.four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.card {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.card.span-2 {
    grid-column: span 2;
}

.card-head {
    border-bottom: var(--border-w) solid var(--line);
    padding-bottom: 9px;
    margin-bottom: 14px;
}

.card-head h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.card-head p {
    margin: 5px 0 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.chart-box {
    position: relative;
    flex: 1;
    min-height: 260px;
}

.chart-box.tall {
    min-height: 340px;
}

/* Radar & donut keep a square plot, so height is what sizes them. */
.chart-box.square {
    min-height: 420px;
}

.chart-box.short {
    min-height: 170px;
}

/* --- small multiples ---------------------------------------------------- */

.mini {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 12px;
    min-width: 0;
}

.mini-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.mini-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.mini-stat {
    font-size: 12px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.mini-box {
    position: relative;
    height: 130px;
}

/* --- heatmap ------------------------------------------------------------ */

.heat-wrap {
    overflow-x: auto;
    padding-bottom: 6px;
}

.heat {
    border-collapse: separate;
    border-spacing: 2px;
    font-variant-numeric: tabular-nums;
    /* Auto layout + width:100% spreads slack across cells on short ranges while
       still letting min-width force a horizontal scroll on long ones. */
    width: 100%;
}

.heat th.row-head {
    width: 150px;
}

.heat th {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-2);
    padding: 4px 6px;
    white-space: nowrap;
}

.heat th.row-head {
    text-align: right;
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
}

.heat th.col-head {
    text-align: center;
}

.heat td {
    min-width: 34px;
    height: 36px;
    text-align: center;
    border: 2px solid var(--line);
    font-size: 11px;
    font-weight: 900;
    cursor: default;
}

.hatch {
    background: repeating-linear-gradient(
        45deg,
        var(--surface-sunken),
        var(--surface-sunken) 4px,
        var(--hatch) 4px,
        var(--hatch) 8px
    );
    color: var(--ink-muted);
}

.heat-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-2);
    flex-wrap: wrap;
}

.heat-legend .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.heat-legend .box {
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
}

/* --- table -------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    min-width: 900px;
}

table.data th,
table.data td {
    border: 2px solid var(--line);
    padding: 7px 9px;
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
}

table.data thead th {
    background: var(--ink);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: sticky;
    top: 0;
}

table.data th.left,
table.data td.left {
    text-align: left;
}

table.data tbody tr:nth-child(even) {
    background: var(--surface-sunken);
}

table.data tbody tr:hover {
    background: var(--row-hover);
}

table.data td.metric {
    font-weight: 800;
}

table.data td.hit {
    color: var(--good-ink);
}

table.data td.miss {
    color: var(--critical);
}

table.data tfoot td {
    background: var(--ink);
    color: #fff;
    font-weight: 900;
}

.pill {
    display: inline-block;
    border: 2px solid var(--line);
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pill.ok {
    background: #d6f5d6;
}

.pill.mid {
    background: #fdf0cc;
}

.pill.bad {
    background: #fadada;
}

.pill.partial {
    background: var(--surface-sunken);
    color: var(--ink-2);
}

/* --- top performing content --------------------------------------------- */

.top-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.top-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 2px solid var(--grid);
}

.top-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.top-rank {
    flex: none;
    width: 26px;
    height: 26px;
    border: 2px solid var(--line);
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    display: grid;
    place-items: center;
    font-variant-numeric: tabular-nums;
}

.top-row:nth-child(1) .top-rank {
    background: var(--warning);
    color: var(--ink);
}

.top-row:nth-child(2) .top-rank,
.top-row:nth-child(3) .top-rank {
    background: var(--surface-sunken);
    color: var(--ink);
}

.top-main {
    flex: 1;
    min-width: 0;
}

.top-title {
    display: block;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    color: var(--ink);
    text-decoration: none;
    /* Arabic captions are long — two lines, then ellipsis. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

a.top-title:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
}

.top-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin-top: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.top-tag {
    border: 2px solid var(--line);
    background: var(--surface-sunken);
    padding: 0 5px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.top-bar {
    height: 8px;
    border: 2px solid var(--line);
    background: var(--surface-sunken);
    margin-top: 7px;
    overflow: hidden;
}

.top-bar span {
    display: block;
    height: 100%;
}

.top-views {
    flex: none;
    text-align: right;
    font-size: 17px;
    font-weight: 900;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    min-width: 62px;
}

.top-views em {
    display: block;
    font-style: normal;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--ink-2);
    text-transform: uppercase;
}

.top-empty {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-2);
}

/* .swatch sizes itself as a flex item elsewhere; inside an h3 it needs a box. */
.card-head h3 .swatch {
    display: inline-block;
    vertical-align: -2px;
    margin-right: 5px;
}

/* --- legend ------------------------------------------------------------- */

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 2px solid var(--grid);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-2);
}

.legend-item .box {
    width: 13px;
    height: 13px;
    border: 2px solid var(--line);
}

.legend-item .dash {
    width: 18px;
    height: 0;
    border-top: 3px dashed var(--ink);
}

/* --- loading / empty ---------------------------------------------------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(231, 233, 236, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.overlay.show {
    display: flex;
}

.overlay-box {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 18px 26px;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.empty {
    border: var(--border-w) dashed var(--baseline);
    background: var(--surface);
    padding: 40px;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-2);
}

/* --- login -------------------------------------------------------------- */

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    box-shadow: 10px 10px 0 0 var(--line);
    padding: 28px;
}

.login-head h1 {
    margin: 0;
    font-size: 38px;
    font-weight: 900;
    line-height: 0.92;
    text-transform: uppercase;
    letter-spacing: -0.03em;
}

.login-head .sub {
    margin: 10px 0 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ink-2);
}

.login-swatches {
    display: flex;
    gap: 5px;
    margin: 18px 0 22px;
    padding-bottom: 22px;
    border-bottom: var(--border-w) solid var(--line);
}

.login-swatches span {
    flex: 1;
    height: 12px;
    border: 2px solid var(--line);
}

.login-error {
    border: var(--border-w) solid var(--line);
    border-left-width: 10px;
    border-left-color: var(--critical);
    background: var(--surface-sunken);
    margin: 0 0 18px;
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 800;
}

.login-field {
    margin-bottom: 16px;
}

.login-field input {
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
    padding: 11px 12px;
    width: 100%;
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    color: var(--ink);
}

.login-field input::placeholder {
    color: var(--ink-muted);
    font-weight: 600;
}

.login-field input:focus-visible {
    outline: 3px solid var(--fb);
    outline-offset: 2px;
}

.login-submit {
    width: 100%;
    margin-top: 6px;
    padding: 13px;
    font-size: 13px;
}

/* --- session bar -------------------------------------------------------- */

.session {
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-user {
    border: var(--border-w) solid var(--line);
    background: var(--ink);
    color: #fff;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: var(--shadow-sm);
}

.session-out {
    border: var(--border-w) solid var(--line);
    background: var(--surface);
    color: var(--ink);
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.session-out:hover {
    background: var(--critical);
    color: #fff;
}

/* --- responsive --------------------------------------------------------- */

@media (max-width: 820px) {
    .card.span-2 {
        grid-column: span 1;
    }

    .grid.two,
    .grid.three,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .field input[type="date"] {
        min-width: 0;
        width: 100%;
    }
}

@media print {
    body {
        background: #fff;
    }

    .filters,
    .overlay {
        display: none !important;
    }

    .card,
    .tile {
        box-shadow: none;
        break-inside: avoid;
    }
}
