/* ===================================================================
   Bishop Auckland Constituency Explorer
   Shared styling is carried over from capstrategy (Claude design-system
   tokens, Design/claude-tokens.css); explorer-specific rules follow.
   =================================================================== */
/* --- Design tokens (copied from Design/claude-tokens.css) --- */
:root {
  --om-bg-app: #faf9f5;
  --om-bg-panel: #f8f7f3;
  --om-bg-surface: #ffffff;
  --om-bg-elevated: #ffffff;
  --om-bg-active: #e8e6dc;
  --om-bg-selected: #e3dacc;
  --om-bg-muted: #f0eee6;

  --om-border-subtle: #0f0c0814;
  --om-border-card: #0f0c081f;
  --om-border-default: #0f0c081a;
  --om-border-strong: #0f0c0838;
  --om-border-focus: #0f0c085c;

  --om-text-primary: #0f0c08eb;
  --om-text-prose: #0f0c08cc;
  --om-text-secondary: #0f0c08a3;
  --om-text-tertiary: #0f0c0899;
  --om-text-disabled: #0f0c0852;
  --om-text-inverse: #faf9f5;
  --om-text-link: #6a9bcc;

  --om-accent-primary: #d97757;
  --om-accent-primary-hover: #c46a4d;
  --om-accent-primary-active: #b05e43;
  --om-accent-secondary: #6a9bcc;
  --om-accent-success: #558a42;
  --om-accent-sage: #788c5d;
  --om-accent-warning: #c9a82d;
  --om-accent-error: #a63244;

  /* Insertions and deletions in a markup diff (Consolidate only). The success
     accent is 4.1:1 on a card — fine on a pill, under the line for a paragraph
     — so the ink is darkened to 5.9:1. Colour is never the only signal here:
     red/green is the worst pair for colour vision deficiency, so a deletion is
     struck through and an insertion underlined as well. */
  --om-diff-ins: #3f6b30;
  --om-diff-del: var(--om-accent-error);

  /* A member's own text in a markup question. A darkened --om-accent-secondary:
     the accent itself is 2.8:1 on a card, fine for a pill and unreadable as a
     paragraph. Blue because it is the one accent not already carrying a meaning
     — red is Delete, terracotta the primary action, yellow the stale warning. */
  --om-mk-mine: #3d6f9e;

  /* Amber as text: the warning accent is 2:1 on a card, so wording that has
     to be read (a choice grid round still to finish) uses a darkened ink. */
  --om-warn-ink: #7a6210;

  --om-shadow-xs: 0 1px 2px #1414130a;
  --om-shadow-sm: 0 1px 3px #1414130f;
  --om-shadow-md: 0 4px 6px #1414130f;
  --om-shadow-diffuse: 0 4px 20px #1414130a;
  --om-shadow-lg: 0 10px 15px #14141314;
  --om-shadow-card: 0 18px 44px #1414131a, 0 3px 10px #1414130d;
  --om-shadow-modal: 0 24px 48px #0f0c0829, 0 8px 16px #0f0c0814;

  --om-font-sans: "Anthropic Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
                  Roboto, "Helvetica Neue", Arial, sans-serif;
  --om-font-serif: "Anthropic Serif", ui-serif, Georgia, "Times New Roman", serif;
  --om-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                  "Liberation Mono", "Courier New", monospace;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
}

:root[data-theme="dark"] {
  --om-bg-app: #1c1b19;
  --om-bg-panel: #222220;
  --om-bg-surface: #2a2927;
  --om-bg-elevated: #2a2927;
  --om-bg-active: #35332c;
  --om-bg-selected: #3c392f;
  --om-bg-muted: #2e2c26;

  --om-border-subtle: #faf9f51a;
  --om-border-card: #faf9f524;
  --om-border-default: #faf9f51f;
  --om-border-strong: #faf9f53d;
  --om-border-focus: #faf9f566;

  --om-text-primary: #faf9f5eb;
  --om-text-prose: #faf9f5cc;
  --om-text-secondary: #faf9f5a3;
  --om-text-tertiary: #faf9f599;
  --om-text-disabled: #faf9f552;
  --om-text-inverse: #1c1b19;
  --om-text-link: #7eaeda;

  --om-accent-primary: #e08968;
  --om-accent-primary-hover: #e89b7e;
  --om-accent-primary-active: #efad94;
  --om-accent-secondary: #7eaeda;
  --om-accent-success: #6fa859;
  --om-accent-sage: #8fae6a;
  --om-accent-warning: #dabe4a;
  --om-accent-error: #dc8290;

  /* All comfortable on a dark card (5.2–6.2:1), so no darkened variants. */
  --om-diff-ins: var(--om-accent-success);
  --om-diff-del: var(--om-accent-error);
  --om-mk-mine: var(--om-accent-secondary);
  --om-warn-ink: var(--om-accent-warning);

  --om-shadow-xs: 0 1px 2px #0000003d;
  --om-shadow-sm: 0 1px 3px #00000047;
  --om-shadow-md: 0 4px 6px #00000047;
  --om-shadow-diffuse: 0 4px 20px #0000003d;
  --om-shadow-lg: 0 10px 15px #00000052;
  --om-shadow-card: 0 18px 44px #0006, 0 3px 10px #0000003d;
  --om-shadow-modal: 0 24px 48px #0000007a, 0 8px 16px #00000052;
}

/* --- Reset / base --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--om-font-sans);
  background: var(--om-bg-app);
  color: var(--om-text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--om-text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; color: var(--om-text-prose); }
small { color: var(--om-text-secondary); }


/* --- Top bar --- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--om-bg-surface);
  border-bottom: 1px solid var(--om-border-default);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brand .logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--om-accent-primary);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .95rem;
}
.topbar .spacer { flex: 1; }
.userchip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--om-border-default); background: var(--om-bg-panel);
  color: inherit; text-decoration: none; cursor: pointer;
  transition: background .12s, border-color .12s;
}
a.userchip:hover { background: var(--om-bg-active); border-color: var(--om-border-strong); text-decoration: none; }
.userchip .avatar {
  width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  background: var(--om-accent-secondary); color: #fff; font-size: .75rem; font-weight: 700;
}
.userchip .meta { display: flex; flex-direction: column; line-height: 1.1; }
.userchip .meta b { font-size: .8rem; }
.userchip .meta span { font-size: .68rem; color: var(--om-text-secondary); }
.icon-btn {
  border: 1px solid var(--om-border-default); background: var(--om-bg-panel);
  color: var(--om-text-secondary); width: 34px; height: 34px; border-radius: 8px;
  cursor: pointer; font-size: 1rem; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--om-bg-active); color: var(--om-text-primary); }


/* --- App layout (sidebar + main) --- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 84px); }
.sidebar {
  background: var(--om-bg-panel); border-right: 1px solid var(--om-border-default);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}
.sidebar .group-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--om-text-tertiary); margin: 14px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--om-text-prose); font-size: .9rem; cursor: pointer;
}
.nav-item:hover { background: var(--om-bg-active); text-decoration: none; color: var(--om-text-primary); }
.nav-item.active { background: var(--om-bg-selected); color: var(--om-text-primary); font-weight: 600; }
.nav-item .ic { width: 18px; text-align: center; opacity: .8; }
.sidebar .spacer { flex: 1; }
.sidebar-version {
  display: flex; flex-direction: column; gap: 1px;
  margin: 10px 8px 2px; padding-top: 10px;
  border-top: 1px solid var(--om-border-default);
  font-size: .68rem; line-height: 1.4; color: var(--om-text-tertiary);
  font-variant-numeric: tabular-nums;
}

.main { padding: 24px 32px 60px; max-width: 1100px; }
.page-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-header .titles { flex: 1; }
.page-header .crumbs { font-size: .8rem; color: var(--om-text-secondary); margin-bottom: 4px; }
.page-header .crumbs a { color: var(--om-text-secondary); }
.page-header h1 { margin-bottom: 2px; }
.page-header .sub { color: var(--om-text-secondary); font-size: .9rem; }
.header-actions { display: flex; gap: 8px; align-items: center; }


/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: inherit; font-size: .88rem; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--om-border-default); background: var(--om-bg-surface);
  color: var(--om-text-primary); transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--om-bg-active); }
.btn-primary { background: var(--om-accent-primary); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--om-accent-primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--om-text-secondary); }
.btn-ghost:hover { background: var(--om-bg-active); color: var(--om-text-primary); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* --- Cards --- */
.card {
  background: var(--om-bg-surface); border: 1px solid var(--om-border-card);
  border-radius: var(--radius); box-shadow: var(--om-shadow-xs); margin-bottom: 18px;
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--om-border-subtle);
  display: flex; align-items: center; gap: 12px;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-header .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.project-card { cursor: pointer; transition: box-shadow .15s, transform .05s; }
.project-card:hover { box-shadow: var(--om-shadow-md); }
.project-card .type-tag {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--om-accent-primary);
}


/* --- Status pills --- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--om-border-default); background: var(--om-bg-muted);
  color: var(--om-text-secondary);
}
.pill .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.pill.draft { color: var(--om-text-tertiary); }
.pill.open { color: var(--om-accent-secondary); border-color: color-mix(in srgb, var(--om-accent-secondary) 40%, transparent); }
.pill.consolidation { color: var(--om-accent-warning); border-color: color-mix(in srgb, var(--om-accent-warning) 40%, transparent); }
.pill.locked { color: var(--om-accent-success); border-color: color-mix(in srgb, var(--om-accent-success) 40%, transparent); }
.pill.role { color: var(--om-accent-sage); }


/* --- Tables --- */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--om-border-subtle); }
.table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--om-text-tertiary); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--om-bg-panel); }
/* Phase description in the project phases table: cap at 2 lines (full text on hover). */
.phase-desc {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; max-width: 46ch;
}


/* --- Forms --- */
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field .hint { font-size: .8rem; color: var(--om-text-secondary); margin: 0 0 8px; }
.field .req { color: var(--om-accent-error); }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; font-family: inherit; font-size: .92rem; color: var(--om-text-primary);
  background: var(--om-bg-surface); border: 1px solid var(--om-border-default);
  border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 96px; resize: vertical; }

/* --- Utilities --- */
.row { display: flex; gap: 12px; align-items: center; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--om-text-secondary); }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.notice { background: var(--om-bg-muted); border: 1px solid var(--om-border-default); border-left: 3px solid var(--om-accent-secondary);
  border-radius: 8px; padding: 10px 14px; font-size: .85rem; color: var(--om-text-prose); margin-bottom: 16px; }
.locked-note { border-left-color: var(--om-accent-success); }
/* Stale/out-of-date AI summary warning. */
.notice-stale {
  border-left-color: var(--om-accent-warning);
  background: color-mix(in srgb, var(--om-accent-warning) 10%, var(--om-bg-muted));
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--om-border-default); }
  .sidebar .group-label, .sidebar .spacer { display: none; }
  .main { padding: 18px; }
}


/* --- Choropleth steps: one blue hue, light -> dark (validated sequential ramp) --- */
:root { --ch-1: #b7d3f6; --ch-2: #6da7ec; --ch-3: #3987e5; --ch-4: #1c5cab; --ch-5: #0d366b; --ch-none: #e6e4dc; --ch-line: #ffffff; }
:root[data-theme="dark"] { --ch-none: #3a3934; --ch-line: #1c1b19; }

/* --- Explorer page --- */
.topbar .brand, .topbar .brand:hover { color: var(--om-text-primary); text-decoration: none; }
.layout.explorer { grid-template-columns: 250px minmax(0, 1fr) 360px; height: calc(100vh - 55px); min-height: 0; }
.layout.explorer .sidebar { overflow: auto; }
.layer-btn {
  display: block; width: 100%; text-align: left; font: inherit; font-size: .88rem;
  padding: 7px 10px; border-radius: 8px; border: 0; background: none; color: var(--om-text-prose); cursor: pointer;
}
.layer-btn:hover { background: var(--om-bg-active); color: var(--om-text-primary); }
.layer-btn[aria-pressed="true"] { background: var(--om-bg-selected); color: var(--om-text-primary); font-weight: 600; }
.layer-btn:disabled { cursor: default; color: var(--om-text-disabled); background: none; }
.layer-btn small { display: block; font-size: .7rem; color: var(--om-text-tertiary); }
.search { display: flex; gap: 6px; }
.search input { width: 210px; padding: 7px 10px; }
.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--om-bg-app); }
.legend {
  position: absolute; left: 12px; bottom: 30px; z-index: 500; max-width: 270px;
  background: var(--om-bg-surface); border: 1px solid var(--om-border-card); border-radius: var(--radius-sm);
  box-shadow: var(--om-shadow-sm); padding: 10px 12px; font-size: .78rem;
}
.legend b { display: block; margin-bottom: 6px; }
.legend .lrow { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-variant-numeric: tabular-nums; }
.legend .sw { width: 18px; height: 12px; border-radius: 3px; border: 1px solid var(--om-border-default); opacity: .5; }
.caveat {
  position: absolute; right: 10px; bottom: 22px; z-index: 500; margin: 0; font-size: .72rem;
  background: var(--om-bg-surface); color: var(--om-text-secondary); padding: 3px 8px; border-radius: 6px;
}
.panel { overflow: auto; padding: 14px; border-left: 1px solid var(--om-border-default); background: var(--om-bg-panel); }
.panel .card { margin-bottom: 12px; }
.panel h2 { font-size: 1rem; }
.metric { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--om-border-subtle); font-size: .88rem; }
.metric:last-of-type { border-bottom: 0; }
.metric .v { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.metric .sub { grid-column: 1 / -1; color: var(--om-text-secondary); font-size: .76rem; }
.metric.active { background: var(--om-bg-active); margin: 0 -8px; padding: 8px; border-radius: 6px; }
.topic { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--om-accent-primary); font-weight: 700; margin: 12px 0 2px; }
.comps { display: flex; gap: 16px; flex-wrap: wrap; margin: 4px 0 10px; }
.comps div { font-size: .76rem; color: var(--om-text-secondary); }
.comps b { display: block; font-size: 1.05rem; color: var(--om-text-primary); font-variant-numeric: tabular-nums; }
.tablewrap { max-height: 320px; overflow: auto; }
.table.compact th, .table.compact td { padding: 5px 6px; font-size: .78rem; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr { cursor: pointer; }
.table tbody tr.sel { background: var(--om-bg-selected); }
.notice-stale ul { margin: 6px 0 0; padding-left: 18px; }
.leaflet-container { font-family: var(--om-font-sans); }
.leaflet-tooltip { font-size: .78rem; }

@media (max-width: 1000px) {
  .layout.explorer { grid-template-columns: 1fr; height: auto; }
  .layout.explorer .sidebar { flex-direction: row; overflow-x: auto; }
  .layout.explorer .sidebar .group-label, .layer-btn:disabled, .layer-btn small, .sidebar-version { display: none; }
  .layer-btn { white-space: nowrap; width: auto; }
  .mapwrap { height: 60vh; }
  .panel { border-left: 0; }
  .topbar { flex-wrap: wrap; }
  .search { width: 100%; order: 3; }
  .search input { flex: 1; width: auto; }
  .layout.explorer .nav-item { white-space: nowrap; }
  .legend { bottom: 22px; font-size: .7rem; padding: 6px 8px; }
  .legend .note { display: none; }
  .caveat { right: auto; left: 0; bottom: auto; top: 100%; background: none; padding: 4px 16px; }
  .mapwrap { margin-bottom: 34px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Admin (from Strategic Direction) --- */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--om-border-default); border-radius: 8px; cursor: pointer; font-size: .9rem;
}
.choice:hover { background: var(--om-bg-panel); }
.choice input { accent-color: var(--om-accent-primary); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 500px at 70% -10%, color-mix(in srgb, var(--om-accent-primary) 12%, transparent), transparent),
  var(--om-bg-app); }
.auth-card { width: 100%; max-width: 400px; background: var(--om-bg-surface); border: 1px solid var(--om-border-card);
  border-radius: var(--radius-lg); box-shadow: var(--om-shadow-card); padding: 28px; }
.auth-card .brand { justify-content: center; font-size: 1.15rem; margin-bottom: 4px; }
.auth-card .tagline { text-align: center; color: var(--om-text-secondary); font-size: .88rem; margin-bottom: 22px; }
.ai-disclaimer { font-size: .75rem; color: var(--om-text-tertiary); margin-top: 10px; }
.notice-error { border-left-color: var(--om-accent-error); }
.importlog { margin: 0; padding: 12px 16px; max-height: 320px; overflow: auto; font-size: .78rem; line-height: 1.45;
  background: var(--om-bg-muted); border-top: 1px solid var(--om-border-subtle); white-space: pre-wrap; word-break: break-word; }
.table td form { margin: 0; }
.table td .btn { white-space: nowrap; }
.card-body > form > .hint { font-size: .85rem; color: var(--om-text-secondary); margin: 0 0 16px; }
@media (max-width: 760px) { .table td small { word-break: break-word; } .main { min-width: 0; } }
