/* ============================================================================
   The Wall — Dashboard design system: "Editorial Desk"
   Light, warm-neutral. Shared by every Phase 8 dashboard screen.
   ========================================================================== */

:root {
  /* --- surfaces & structure --- */
  --paper:      #FBFBF9;   /* page surface */
  --paper-2:    #ffffff;   /* raised cards / sidebar */
  --ink:        #1a2b4a;   /* primary structure + headings + body-strong */
  --slate:      #5a6b82;   /* secondary text / chrome */
  --hairline:   #e8e6df;   /* borders / dividers */
  --hairline-2: #f0eee7;   /* faint fills / hover */

  /* --- signal / status --- */
  --amber:      #E8A33D;   /* RESERVED: single primary action per screen */
  --amber-deep: #cf8a24;   /* amber hover/border */
  --sage:       #5b8a72;   /* success */
  --sage-soft:  #e7f0ea;
  --clay:       #c47a52;   /* warning */
  --clay-soft:  #f5eae1;

  /* --- region identity tints (accents only, never text) --- */
  --mu:  #c44d3f;  /* Mauritius — coral */
  --sa:  #e85d2f;  /* South Africa — sunset orange */
  --uae: #d4af6a;  /* UAE — champagne gold */

  /* --- type --- */
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;

  /* --- scale / geometry --- */
  --sidebar-w: 240px;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-1: 0 1px 2px rgba(26,43,74,.06), 0 1px 3px rgba(26,43,74,.05);
  --shadow-2: 0 4px 16px rgba(26,43,74,.10);
  --focus: 0 0 0 3px rgba(232,163,61,.45);
}

* { box-sizing: border-box; }

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* tabular figures wherever numbers line up */
.tnum, table, .stat, .metric { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

a { color: var(--ink); }

/* ---- typography scale ---- */
h1, h2, h3 { font-family: var(--serif); color: var(--ink); margin: 0; font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
.eyebrow { font-family: var(--sans); font-size: .72rem; font-weight: 600; letter-spacing: .09em;
           text-transform: uppercase; color: var(--slate); }
.muted { color: var(--slate); }
.small { font-size: .85rem; }

/* ============================================================================
   APP LAYOUT — fixed sidebar + slim topbar + work area
   ========================================================================== */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

/* ---- SIDEBAR ---- */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  background: var(--paper-2);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  padding: 20px 14px;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 4px 8px 18px; }
.brand-mark { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.brand-sub { font-family: var(--sans); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--slate); }

/* region switcher */
.region-switch { display: flex; flex-direction: column; gap: 3px; margin-bottom: 20px; }
.region-switch .eyebrow { padding: 0 8px 6px; }
.region-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--slate);
  border-left: 3px solid transparent;
  font-size: .92rem; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.region-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: var(--_tint, var(--slate)); }
.region-item:hover { background: var(--hairline-2); color: var(--ink); }
.region-item.is-active {
  background: var(--hairline-2); color: var(--ink); font-weight: 600;
  border-left-color: var(--_tint, var(--ink));
}
.region-item.is-static { cursor: default; }
.region-item.is-active.is-static:hover { background: var(--hairline-2); }

/* nav */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-heading { padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--slate); font-weight: 500; font-size: .95rem;
  border-left: 3px solid transparent;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--hairline-2); color: var(--ink); }
.nav-item.is-active { background: #eef1f6; color: var(--ink); font-weight: 600; border-left-color: var(--ink); }
.nav-item svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .8; }
.nav-count { flex: 0 0 auto; background: var(--clay); color: #fff; font-size: .68rem; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; }
.sidebar-foot { margin-top: auto; padding: 14px 8px 2px; color: var(--slate); font-size: .78rem; }

/* ---- TOPBAR ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 26px;
  background: rgba(251,251,249,.9); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar-title h1 { font-size: 1.35rem; }
.topbar-region { font-family: var(--sans); font-size: .82rem; color: var(--slate); display: inline-flex; align-items: center; gap: 7px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.who { text-align: right; line-height: 1.25; }
.who .name { font-weight: 600; font-size: .9rem; color: var(--ink); }
.who .role { font-size: .72rem; color: var(--slate); text-transform: uppercase; letter-spacing: .06em; }
.topbar-link { font-size: .85rem; color: var(--slate); text-decoration: none; }
.topbar-link:hover { color: var(--ink); text-decoration: underline; }

.sidebar-toggle { display: none; }

/* ---- MAIN ---- */
.main { min-width: 0; display: flex; flex-direction: column; }
.work { padding: 28px 26px 64px; max-width: 1080px; width: 100%; }

/* ============================================================================
   PRIMITIVES — buttons, badges, cards, tables, forms
   ========================================================================== */

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: .9rem; font-weight: 600; line-height: 1;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
/* PRIMARY = amber fill, ink text. One per screen. */
.btn-primary { background: var(--amber); color: var(--ink); border-color: var(--amber-deep); }
.btn-primary:hover { background: var(--amber-deep); }
/* SECONDARY = outline */
.btn-secondary { background: var(--paper-2); color: var(--ink); border-color: var(--hairline); }
.btn-secondary:hover { border-color: var(--slate); background: var(--hairline-2); }
/* AMBER-OUTLINE = the always-present global action (publish-to-live) — accent, not fill */
.btn-accent { background: transparent; color: var(--ink); border-color: var(--amber); }
.btn-accent:hover { background: #fdf5e8; border-color: var(--amber-deep); }
.btn-ghost { background: transparent; color: var(--slate); border-color: transparent; }
.btn-ghost:hover { color: var(--ink); background: var(--hairline-2); }
.btn-sm { padding: 7px 12px; font-size: .82rem; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600;
         padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; }
.badge-success { background: var(--sage-soft); color: #2f6b4f; border-color: #cfe3d6; }
.badge-warning { background: var(--clay-soft); color: #8a4b2a; border-color: #ecd6c6; }
.badge-muted   { background: var(--hairline-2); color: var(--slate); border-color: var(--hairline); }

/* cards */
.card { background: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-pad { padding: 20px 22px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

/* launcher tiles (home) */
.tile { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; text-decoration: none;
        background: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--radius);
        box-shadow: var(--shadow-1); transition: box-shadow .14s ease, transform .06s ease, border-color .14s ease; }
.tile:hover { box-shadow: var(--shadow-2); border-color: #dcd9cf; }
.tile-title { font-family: var(--serif); font-size: 1.15rem; color: var(--ink); }
.tile-desc { font-size: .85rem; color: var(--slate); }
.tile-accent { width: 30px; height: 3px; border-radius: 2px; background: var(--_tint, var(--ink)); margin-bottom: 2px; }

/* tables (shared for later prompts) */
.table { width: 100%; border-collapse: collapse; background: var(--paper-2);
         border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase;
            color: var(--slate); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--hairline); background: var(--hairline-2); }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--hairline); font-size: .9rem; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s ease; }
.table tbody tr:hover { background: #fbf9f3; }

/* forms (shared for later prompts) */
.field { display: block; margin-bottom: 16px; }
.field > .label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.input, .select, .textarea {
  box-sizing: border-box;
  width: 100%; font-family: var(--sans); font-size: .92rem; line-height: 1.4; color: var(--ink);
  background-color: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  padding: 10px 12px; vertical-align: middle;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--amber); outline: none; box-shadow: var(--focus); }

/* Selects line up with inputs/buttons: strip native chrome and draw ONE caret so
   height, padding, and box model match adjacent controls in every flex row. */
.select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23596880' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px 7px;
}
.select::-ms-expand { display: none; }
/* Compact variant (Sort / Hero / filters): tighter box, same caret room. */
.select-sm, .input-sm {
  box-sizing: border-box; font-size: .86rem; line-height: 1.3; padding: 8px 10px;
}
.select-sm { padding-right: 30px; background-position: right 10px center; }

/* section intro + placeholder */
.section-intro { margin-bottom: 22px; }
.section-intro h1 { font-size: 1.75rem; margin-bottom: 4px; }
.placeholder-note {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 24px; border: 1px dashed #d8d5cb; border-radius: var(--radius);
  background: #fbfaf6; color: var(--slate);
}
.placeholder-note .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); flex: 0 0 auto; }

.divider { height: 1px; background: var(--hairline); border: 0; margin: 26px 0; }

/* ============================================================================
   AUTH (login) — same theme, centered
   ========================================================================== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
             background: radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, var(--paper) 60%); }
.auth-card { width: 100%; max-width: 380px; background: var(--paper-2); border: 1px solid var(--hairline);
             border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 30px 30px 26px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .mark { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; color: var(--ink); }
.auth-brand .sub { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--slate); margin-top: 2px; }
.auth-flash { background: #fbeceb; border: 1px solid #e6b9b4; color: #8a2f28; border-radius: var(--radius-sm);
              padding: 10px 12px; font-size: .85rem; margin-bottom: 16px; }

/* ============================================================================
   FOCUS + MOTION + RESPONSIVE
   ========================================================================== */
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 3px; }
.btn:focus-visible, .region-item:focus-visible, .nav-item:focus-visible { outline: none; box-shadow: var(--focus); }

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

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; width: 82vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow-2);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(26,43,74,.28); z-index: 30; }
  .sidebar-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    border: 1px solid var(--hairline); background: var(--paper-2); cursor: pointer;
  }
  .sidebar-toggle svg { width: 20px; height: 20px; color: var(--ink); }
  .work { padding: 20px 16px 56px; }
  .topbar { padding: 12px 16px; }
}

/* ============================================================================
   SHARED CONFIRM / EDIT MODAL (consolidated — Phase 8 modal-sweep fix)
   Every dashboard modal uses class="cf-modal" + the `hidden` attribute. The
   [hidden] rule below hides it; NEVER put an inline `display` on a .cf-modal
   element (an inline display overrides `hidden` and the modal gets stuck open,
   which was the Ads/Sources bug). Pages may override .cf-box max-width only.
   ========================================================================== */
.cf-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.cf-modal[hidden] { display: none; }
.cf-backdrop { position: absolute; inset: 0; background: rgba(26, 43, 74, .34); }
.cf-box {
  position: relative; width: 100%; max-width: 460px;
  background: var(--paper-2); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 22px 24px;
}

/* --- Shared list toolbar (search + sort) + pager (Published / Review) --------
   Server-side controls: they submit via GET so state lives in the URL. */
.list-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin-bottom: 18px;
}
.list-toolbar .lt-search { flex: 1 1 260px; display: flex; gap: 8px; align-items: flex-end; }
.list-toolbar .lt-search .input { flex: 1; }
.list-toolbar .lt-field { display: flex; flex-direction: column; gap: 5px; }
.list-toolbar .lt-field .muted { font-size: .78rem; }
.list-toolbar .input { padding: 8px 10px; font-size: .88rem; }
.lt-clear { align-self: center; font-size: .82rem; color: var(--slate); }

.pager {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 6px; margin: 22px 0 4px;
}
.pager .pager-status { color: var(--slate); font-size: .85rem; margin: 0 10px; }
.pager a, .pager span.pager-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--hairline); color: var(--ink); text-decoration: none;
  font-size: .86rem; background: var(--paper-2);
}
.pager a:hover { border-color: var(--slate); }
.pager a:focus-visible { outline: none; box-shadow: var(--focus); }
.pager .pager-num.is-current { background: var(--ink); color: var(--paper-2); border-color: var(--ink); font-weight: 600; }
.pager .pager-gap { border: 0; background: transparent; min-width: 18px; color: var(--slate); }
.pager .is-disabled { opacity: .4; pointer-events: none; }
