/* ===========================================================
   ArcTracer — design system
   Identity: Libyan limestone & earth. Cyrene's weathered stone,
   terracotta of fired clay, the deep teal of the Mediterranean.
   Display: Amiri (serif, gravitas). Body: IBM Plex Sans Arabic.
   =========================================================== */

:root {
    --sand:       #F3EEE3;   /* page background — limestone dust */
    --sand-deep:  #E7DECB;
    --ink:        #2A2420;   /* near-black warm */
    --ink-soft:   #5C534A;
    --terra:      #B4502E;   /* fired-clay accent */
    --terra-deep: #8C3A1F;
    --teal:       #1F4E5F;   /* Mediterranean, used for structure */
    --gold:       #C08A2D;   /* medium confidence */
    --green:      #2E7D46;   /* high confidence / verified */
    --line:       #D6CcB8;
    --white:      #FBF9F4;
    --shadow:     0 1px 2px rgba(42,36,32,.06), 0 6px 20px rgba(42,36,32,.07);
    --radius:     4px;       /* restrained, near-architectural */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--sand);
    color: var(--ink);
    font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

h1, h2, h3, .display {
    font-family: "Amiri", Georgia, serif;
    font-weight: 700;
    line-height: 1.25;
    color: var(--ink);
}

a { color: var(--terra-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 500;
}
.topbar__inner {
    max-width: 1180px; margin: 0 auto; padding: 0 20px;
    height: 64px; display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--teal); }
.brand:hover { text-decoration: none; }
.brand__text strong { display: block; font-family: "Amiri", serif; font-size: 20px; color: var(--ink); letter-spacing: .3px; }
.brand__text small { display: block; font-size: 11px; color: var(--ink-soft); margin-top: -2px; }
.topnav { display: flex; align-items: center; gap: 6px; }
.topnav__link {
    color: var(--ink-soft); padding: 8px 14px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500;
}
.topnav__link:hover { background: var(--sand); text-decoration: none; color: var(--ink); }
.topnav__link.is-active { color: var(--terra-deep); background: var(--sand); }
.topnav__logout { margin-inline-start: 6px; }

/* ---------- Page shell ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 32px 20px 64px; }

.foot {
    border-top: 1px solid var(--line); background: var(--white);
    padding: 20px; text-align: center;
}
.foot p { margin: 0; font-size: 12.5px; color: var(--ink-soft); max-width: 720px; margin: 0 auto; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; border: 1px solid transparent; }
.flash--ok  { background: #EAF3EC; border-color: #BFD8C5; color: #205633; }
.flash--err { background: #F8EAE6; border-color: #E2BDB1; color: #7A2E1A; }
.flash--err div + div { margin-top: 4px; }

/* ---------- Page header ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.pagehead__title { font-size: 30px; margin: 0; }
.pagehead__sub { color: var(--ink-soft); font-size: 14px; margin: 6px 0 0; }
.eyebrow {
    font-family: "IBM Plex Sans Arabic", sans-serif; font-size: 12px; font-weight: 600;
    letter-spacing: 1px; color: var(--terra); text-transform: none; margin-bottom: 8px;
    display: inline-flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: ""; width: 18px; height: 1px; background: var(--terra); display: inline-block; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
    font-family: inherit; font-size: 14px; font-weight: 600; padding: 10px 18px;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--terra); color: #fff; }
.btn--primary:hover { background: var(--terra-deep); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--sand); }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--danger { background: transparent; border-color: #D9B4A9; color: var(--terra-deep); }
.btn--danger:hover { background: #F8EAE6; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid--surveys { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card__body { padding: 18px; }
.card__title { font-size: 18px; margin: 0 0 4px; }
.card__meta { font-size: 12.5px; color: var(--ink-soft); }
.card__foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: #FCFAF5; }

/* status pill */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
    background: var(--sand-deep); color: var(--ink);
}
.pill__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field textarea, .field select {
    font-family: inherit; font-size: 14px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--white);
    color: var(--ink);
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: 2px solid var(--terra); outline-offset: 0; border-color: var(--terra);
}
.field__hint { font-size: 12px; color: var(--ink-soft); }

.panel {
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.panel + .panel { margin-top: 18px; }

/* ---------- Map ---------- */
#map, #map-mini { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
#map { height: 420px; }
#map-mini { height: 360px; }
.leaflet-container { font-family: inherit; }

/* preset chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
    border: 1px solid var(--line); background: var(--white); border-radius: 999px;
    padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--ink);
    font-family: inherit;
}
.chip:hover { border-color: var(--terra); color: var(--terra-deep); }

/* ---------- Results layout ---------- */
.results { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.candlist { max-height: 620px; overflow-y: auto; }
.cand {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px;
    border-bottom: 1px solid var(--line);
}
.cand:last-child { border-bottom: none; }
.cand__conf {
    flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: 14px;
    color: #fff; font-family: "Amiri", serif;
}
.cand__body { flex: 1; min-width: 0; }
.cand__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cand__ref { font-weight: 700; font-size: 14px; }
.cand__kind { font-size: 12px; color: var(--ink-soft); }
.cand__reasons { margin: 6px 0 0; padding: 0; list-style: none; }
.cand__reasons li { font-size: 12.5px; color: var(--ink-soft); padding-inline-start: 14px; position: relative; }
.cand__reasons li::before { content: "—"; position: absolute; inset-inline-start: 0; color: var(--terra); }

/* progress */
.progress {
    height: 8px; background: var(--sand-deep); border-radius: 999px; overflow: hidden; margin: 10px 0;
}
.progress__bar { height: 100%; background: var(--terra); width: 0; transition: width .6s ease; }

/* stat strip */
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 4px 0 20px; }
.stat { }
.stat__n { font-family: "Amiri", serif; font-size: 28px; font-weight: 700; color: var(--teal); line-height: 1; }
.stat__l { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* empty */
.empty { text-align: center; padding: 64px 20px; color: var(--ink-soft); }
.empty h2 { font-size: 22px; color: var(--ink); margin-bottom: 8px; }

/* disclaimer banner */
.notice {
    background: #FAF3E7; border: 1px solid #E6D5Ae; border-inline-start: 4px solid var(--gold);
    border-radius: var(--radius); padding: 14px 16px; font-size: 13px; color: #6B5414;
    margin-bottom: 24px;
}

/* auth */
.authwrap { min-height: 70vh; display: grid; place-items: center; }
.authcard { width: 100%; max-width: 400px; }
.authcard .panel { padding: 32px; }
.authcard h1 { font-size: 26px; text-align: center; margin: 0 0 4px; }
.authcard .sub { text-align: center; color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }

@media (max-width: 860px) {
    .form-grid, .results { grid-template-columns: 1fr; }
    .pagehead { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
