/* ASNaji Watches — Posting Monitor design system (Arabic RTL) */
:root {
    --navy: #0b1c2c;
    --navy-mid: #122536;
    --charcoal: #1a2332;
    --gold: #c4a574;
    --gold-soft: #d8c3a1;
    --gold-dim: rgba(196, 165, 116, 0.18);
    --cream: #f6f3ee;
    --cream-deep: #ebe6de;
    --surface: #ffffff;
    --surface-2: #faf8f5;
    --ink: #121820;
    --muted: #5c6570;
    --line: #e2ddd4;
    --line-strong: #cdc6ba;
    --success: #1f6b4a;
    --success-bg: #e8f3ee;
    --warn: #8f6a1f;
    --warn-bg: #f7efd9;
    --danger: #8f2d2d;
    --danger-bg: #f8eaea;
    --info: #2a4a6b;
    --info-bg: #e8eef5;
    --shadow-sm: 0 1px 2px rgba(11, 28, 44, 0.05);
    --shadow-md: 0 8px 24px rgba(11, 28, 44, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
    --focus: 0 0 0 3px rgba(196, 165, 116, 0.45);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--cream);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-mid); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--gold); }

img { max-width: 100%; display: block; }

:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ——— App shell ——— */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
    background: linear-gradient(180deg, var(--navy) 0%, var(--charcoal) 100%);
    color: #f5f1ea;
    border-bottom: 1px solid rgba(196, 165, 116, 0.35);
    position: sticky;
    top: 0;
    z-index: 40;
}

.app-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand:hover { color: inherit; }

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid var(--gold);
    box-shadow: inset 0 0 0 4px rgba(196, 165, 116, 0.15), 0 0 0 1px rgba(255,255,255,0.04);
    position: relative;
    flex-shrink: 0;
    background:
        radial-gradient(circle at center, transparent 38%, rgba(196,165,116,0.35) 39%, transparent 42%),
        radial-gradient(circle at center, var(--gold) 0 3px, transparent 4px);
}

.brand-mark::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 1px solid rgba(196, 165, 116, 0.45);
}

.brand-text { min-width: 0; }
.brand-text strong {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.brand-text span {
    display: block;
    font-size: 0.78rem;
    color: rgba(245, 241, 234, 0.72);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.35rem 1.25rem 2.5rem;
}

.app-footer {
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.8rem;
    padding: 0.85rem 1.25rem;
    text-align: center;
}

/* ——— Primitives ——— */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
}

.panel--flush { padding: 0; overflow: hidden; }

.panel__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.panel__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.panel__subtitle {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.muted { color: var(--muted); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge--gold {
    background: var(--gold-dim);
    color: #7a5d2e;
    border-color: rgba(196, 165, 116, 0.35);
}

.badge--ok { background: var(--success-bg); color: var(--success); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--neutral { background: var(--cream-deep); color: var(--muted); }

.btn,
button.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.95rem;
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
    background: var(--navy);
    color: #f7f4ef;
}

.btn:hover { background: var(--navy-mid); color: #fff; }
.btn:active { transform: translateY(1px); }

.btn--gold {
    background: linear-gradient(180deg, #d4b896 0%, var(--gold) 100%);
    color: var(--navy);
}
.btn--gold:hover { filter: brightness(1.03); color: var(--navy); }

.btn--ghost {
    background: transparent;
    border-color: rgba(245, 241, 234, 0.28);
    color: #f5f1ea;
}
.btn--ghost:hover { background: rgba(255,255,255,0.06); color: #fff; }

.btn--secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}
.btn--secondary:hover { background: var(--cream); color: var(--ink); }

.btn--sm { padding: 0.4rem 0.7rem; font-size: 0.82rem; }

.btn[disabled],
.btn.is-loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

.field { margin-bottom: 0.95rem; }
.field label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.field-hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }

.input,
select.input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: var(--focus);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .input { padding-left: 2.75rem; }

.input-toggle {
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
}
.input-toggle:hover { color: var(--navy); background: var(--cream); }

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.alert {
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: 0.92rem;
}
.alert--error { background: var(--danger-bg); border-color: #e2b6b6; color: var(--danger); }
.alert--ok { background: var(--success-bg); border-color: #b7d7c8; color: var(--success); }
.alert--info { background: var(--info-bg); border-color: #c5d4e4; color: var(--info); }
.alert--warn { background: var(--warn-bg); border-color: #e2d4a8; color: var(--warn); }

.coverage-banner {
    border-width: 1px 1px 1px 4px;
    border-inline-start-color: var(--gold);
    box-shadow: var(--shadow-sm);
}

.stats--compact .stat__value { font-size: 1.2rem; }

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.pager__status {
    font-size: 0.85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.pager__disabled {
    font-size: 0.82rem;
    color: var(--muted);
    opacity: 0.65;
    padding: 0.4rem 0.7rem;
}

.pager--numbered { gap: 0.55rem; }
.pager__pages {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.pager__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.45rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.pager__page:hover { background: var(--cream); color: var(--navy); }
.pager__page--current {
    background: var(--navy);
    border-color: var(--navy);
    color: #f7f4ef;
}
.pager__ellipsis span {
    display: inline-flex;
    min-width: 1.5rem;
    justify-content: center;
    color: var(--muted);
}

.monitor-list-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.15rem 0.35rem;
}
.monitor-range {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--navy);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.monitor-pager {
    padding: 1rem 1.15rem 1.15rem;
    border-top: 1px solid var(--line);
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

table.data th,
table.data td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    font-size: 0.9rem;
    vertical-align: top;
}

table.data th {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: rgba(196, 165, 116, 0.06); }
table.data a.row-link {
    font-weight: 600;
    color: var(--navy);
    text-decoration: none;
}
table.data a.row-link:hover { color: #7a5d2e; text-decoration: underline; }

.meta-table th {
    width: 32%;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
}

/* ——— Stats ——— */
.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow-sm);
    animation: rise .45s ease both;
}

.stat:nth-child(2) { animation-delay: .05s; }
.stat:nth-child(3) { animation-delay: .1s; }
.stat:nth-child(4) { animation-delay: .15s; }
.stat:nth-child(5) { animation-delay: .2s; }
.stat:nth-child(6) { animation-delay: .25s; }

.stat__label {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}
.stat__value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.stat__note {
    margin-top: 0.3rem;
    font-size: 0.72rem;
    color: var(--muted);
}

.stat--accent {
    border-color: rgba(196, 165, 116, 0.55);
    background: linear-gradient(180deg, #fffdf9 0%, var(--surface) 100%);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: end;
    margin-bottom: 1rem;
}

.toolbar .field { margin: 0; flex: 1 1 160px; }
.toolbar .field--grow { flex: 2 1 240px; }
.toolbar .actions { display: flex; gap: 0.45rem; align-items: end; }

.pill-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

.status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
}

.status-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    background: var(--surface-2);
}
.status-card__k {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}
.status-card__v { font-weight: 600; font-size: 0.95rem; }

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.1rem;
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0.25rem 0 0.85rem;
}
.legend span::before {
    content: "";
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.legend .l-erp::before { background: var(--info); }
.legend .l-provider::before { background: var(--gold); }
.legend .l-zatca::before { background: var(--success); }

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ——— Login ——— */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: var(--cream);
}

.login-brand {
    position: relative;
    background:
        radial-gradient(ellipse 80% 60% at 70% 20%, rgba(196,165,116,0.18), transparent 55%),
        linear-gradient(165deg, #08131f 0%, var(--navy) 45%, var(--charcoal) 100%);
    color: #f5f1ea;
    padding: 2.5rem clamp(1.5rem, 4vw, 3.5rem);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    animation: fadein .5s ease;
}

.login-brand__ornament {
    position: absolute;
    width: min(420px, 70vw);
    height: min(420px, 70vw);
    border-radius: 50%;
    border: 1px solid rgba(196, 165, 116, 0.28);
    top: 50%;
    left: 55%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.login-brand__ornament::before,
.login-brand__ornament::after {
    content: "";
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    border: 1px solid rgba(196, 165, 116, 0.18);
}
.login-brand__ornament::after { inset: 34%; border-color: rgba(196, 165, 116, 0.35); }
.login-brand__ornament .tick {
    position: absolute;
    width: 2px;
    height: 12px;
    background: rgba(196, 165, 116, 0.55);
    left: 50%;
    top: 6%;
    transform: translateX(-50%);
}

.login-brand__content { position: relative; z-index: 1; max-width: 34rem; }

.login-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--gold-soft);
    border: 1px solid rgba(196, 165, 116, 0.35);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    margin-bottom: 1.4rem;
    background: rgba(196, 165, 116, 0.08);
}

.login-brand h1 {
    margin: 0 0 0.85rem;
    font-size: clamp(1.55rem, 2.6vw, 2.15rem);
    font-weight: 700;
    line-height: 1.35;
}

.login-brand p.lead {
    margin: 0;
    color: rgba(245, 241, 234, 0.78);
    font-size: 1rem;
    max-width: 32ch;
}

.login-brand__foot {
    position: relative;
    z-index: 1;
    font-size: 0.82rem;
    color: rgba(245, 241, 234, 0.6);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 1rem;
    margin-top: 2rem;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    animation: rise .5s ease .05s both;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 1.6rem 1.5rem 1.4rem;
}

.login-card h2 {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
}

.login-card .readonly-note {
    display: inline-flex;
    margin: 0.85rem 0 1.1rem;
}

/* ——— Phase E.1 presentation helpers ——— */
.evidence-meta__lead { margin: 0 0 0.45rem; }
.evidence-meta__note { margin: 0 0 0.75rem; font-size: 0.86rem; }
.evidence-meta__times {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem 0.85rem;
    margin: 0;
}
.evidence-meta__times > div {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(42, 74, 107, 0.12);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
}
.evidence-meta__times dt {
    margin: 0 0 0.2rem;
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
}
.evidence-meta__times dd {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--navy);
    font-variant-numeric: tabular-nums;
}

.toolbar--evidence,
.toolbar--audit {
    gap: 0.7rem 0.75rem;
    padding: 1rem 1.1rem;
}
.toolbar .field label {
    display: block;
    margin-bottom: 0.28rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 600;
}
.input--date {
    min-width: 10.5rem;
    font-variant-numeric: tabular-nums;
}
.actions--sticky {
    flex: 0 0 auto;
    margin-inline-start: auto;
    padding-bottom: 0.05rem;
}

.table-wrap--evidence,
.table-wrap--audit {
    max-width: 100%;
}
.data--evidence,
.data--audit {
    min-width: 980px;
}
.data--evidence .col-pk,
.data--audit .col-pk { min-width: 11.5rem; }
.data--evidence .col-date,
.data--audit .col-date { min-width: 6.5rem; white-space: nowrap; }
.data--evidence .col-store,
.data--audit .col-store { min-width: 4.25rem; }
.data--evidence .col-staging,
.data--audit .col-staging { min-width: 8.5rem; }
.data--evidence .col-provider { min-width: 5.5rem; }
.data--evidence .col-uuid { min-width: 14rem; max-width: 18rem; }
.data--evidence .col-class,
.data--audit .col-class { min-width: 10rem; }
.data--evidence .col-evidence { min-width: 12rem; max-width: 16rem; }
.data--audit .col-note { min-width: 12rem; max-width: 18rem; }

.mono-id,
.mono-clip,
.uuid-chip {
    font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: isolate;
}
.mono-id { white-space: nowrap; }
.mono-clip {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
}
.uuid-chip {
    display: inline-block;
    max-width: 100%;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    background: var(--cream-deep);
    border: 1px solid var(--line);
    font-size: 0.72rem;
    line-height: 1.35;
    word-break: break-all;
    white-space: normal;
}
.evidence-subtype { margin-top: 0.25rem; font-size: 0.72rem; }
.evidence-status { font-size: 0.8rem; font-weight: 600; color: var(--navy-mid); line-height: 1.35; }
.evidence-provenance { margin-top: 0.2rem; font-size: 0.72rem; word-break: break-word; }
.gate-footer { margin-top: 1rem; }

@media (max-width: 960px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .status-grid { grid-template-columns: 1fr; }
    .login-page { grid-template-columns: 1fr; }
    .login-brand {
        min-height: auto;
        padding: 1.75rem 1.35rem 1.5rem;
    }
    .login-brand__ornament { opacity: 0.35; width: 260px; height: 260px; top: 20%; left: 80%; }
    .login-brand p.lead { max-width: none; }
    .evidence-meta__times { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .actions--sticky { margin-inline-start: 0; width: 100%; }
}

@media (max-width: 640px) {
    .stats { grid-template-columns: 1fr 1fr; }
    .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .app-header__inner { flex-direction: column; align-items: stretch; }
    .header-meta { justify-content: space-between; }
    .brand-text span { white-space: normal; }
    table.data th,
    table.data td { font-size: 0.82rem; padding: 0.55rem 0.6rem; }
    .evidence-meta__times { grid-template-columns: 1fr; }
    .data--evidence,
    .data--audit { min-width: 860px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
