/* ==========================================================================
   Five Star Tap — design tokens
   Squared geometry, hairline rules, generous type. Light and dark are both
   first-class: every color is a token, and dark redefines only the tokens.
   ========================================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --bg:        #f5f5f7;
  --surface:   #ffffff;
  --surface-2: #fafafa;
  --raised:    #ffffff;
  --scrim:     rgba(255, 255, 255, 0.72);

  --text:      #1d1d1f;
  --text-2:    #4a4a4f;
  --muted:     #86868b;
  --faint:     #a1a1a6;

  --line:      #e2e2e5;
  --line-2:    #d2d2d7;

  --accent:      #0071e3;
  --accent-hi:   #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.10);

  --ok:      #1d8a4e;
  --warn:    #b25000;
  --danger:  #d13438;
  --ok-soft:     rgba(29, 138, 78, 0.10);
  --warn-soft:   rgba(178, 80, 0, 0.10);
  --danger-soft: rgba(209, 52, 56, 0.10);

  --r:    4px;
  --r-lg: 6px;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.05);
  --sh-2: 0 4px 16px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.05);
  --sh-3: 0 16px 48px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.07);

  --header-h: 56px;
  --rail-w: 360px;

  /* Layer scale. Leaflet positions its own panes from 400 to 700 and they
     must stay below our chrome, so everything here clears 800. .body owns a
     stacking context (below) which keeps Leaflet's numbers from leaking into
     the root and competing with these. */
  --z-map-tools: 500;
  --z-rail:      900;
  --z-drawer:    950;
  --z-header:   1000;
  --z-overlay:  1100;
  --z-toast:    1200;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #000000;
    --surface:   #141416;
    --surface-2: #1b1b1e;
    --raised:    #1c1c1f;
    --scrim:     rgba(20, 20, 22, 0.76);
    --text:      #f5f5f7;
    --text-2:    #d0d0d4;
    --muted:     #8e8e93;
    --faint:     #6a6a70;
    --line:      #2a2a2e;
    --line-2:    #38383d;
    --accent:      #0a84ff;
    --accent-hi:   #3b9bff;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --ok:      #30d158;
    --warn:    #ff9f0a;
    --danger:  #ff453a;
    --ok-soft:     rgba(48, 209, 88, 0.15);
    --warn-soft:   rgba(255, 159, 10, 0.15);
    --danger-soft: rgba(255, 69, 58, 0.15);
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sh-2: 0 4px 16px rgba(0, 0, 0, 0.5);
    --sh-3: 0 16px 48px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

[data-theme="dark"] {
  --bg:        #000000;
  --surface:   #141416;
  --surface-2: #1b1b1e;
  --raised:    #1c1c1f;
  --scrim:     rgba(20, 20, 22, 0.76);
  --text:      #f5f5f7;
  --text-2:    #d0d0d4;
  --muted:     #8e8e93;
  --faint:     #6a6a70;
  --line:      #2a2a2e;
  --line-2:    #38383d;
  --accent:      #0a84ff;
  --accent-hi:   #3b9bff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --ok:      #30d158;
  --warn:    #ff9f0a;
  --danger:  #ff453a;
  --ok-soft:     rgba(48, 209, 88, 0.15);
  --warn-soft:   rgba(255, 159, 10, 0.15);
  --danger-soft: rgba(255, 69, 58, 0.15);
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 4px 16px rgba(0, 0, 0, 0.5);
  --sh-3: 0 16px 48px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.021em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 8px;
  border: 3px solid transparent; background-clip: content-box;
}
.scroll::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Controls
   ========================================================================== */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-line: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px;
  font: inherit; font-size: 13px; font-weight: 500; letter-spacing: -0.01em;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-line); border-radius: var(--r);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              transform .1s var(--ease), opacity .15s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: scale(0.978); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn-primary {
  --btn-bg: var(--accent); --btn-fg: #fff; --btn-line: var(--accent);
  font-weight: 550;
}
.btn-primary:hover { --btn-bg: var(--accent-hi); --btn-line: var(--accent-hi); }

.btn-ghost { --btn-bg: transparent; --btn-line: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  color: var(--text-2); background: transparent;
  border: 1px solid transparent; border-radius: var(--r);
  cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.field { display: block; margin-bottom: 14px; }
.field > .label {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.045em; text-transform: uppercase;
  color: var(--muted);
}
.field .hint { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.45; }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="url"], textarea, select {
  width: 100%; padding: 8px 11px;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8.2 2.3 4.5l.9-.9L6 6.4l2.8-2.8.9.9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 12px;
  padding-right: 30px; cursor: pointer;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

/* ==========================================================================
   Chrome
   ========================================================================== */

.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

.header {
  display: flex; align-items: center; gap: 16px;
  height: var(--header-h); flex: 0 0 var(--header-h);
  padding: 0 16px;
  background: var(--scrim);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  /* Positioned so the z-index is unconditional rather than relying on
     flex-item behaviour, and high enough that the account menu hanging below
     the header is not painted over by the map. */
  position: relative;
  z-index: var(--z-header);
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .mark {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  background: var(--text); color: var(--bg);
  border-radius: 3px;
}
.brand .mark svg { width: 15px; height: 15px; }
.brand .name { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.brand .name span { color: var(--muted); font-weight: 400; }

.header .spacer { flex: 1; }

.searchbox { position: relative; flex: 0 1 300px; }
.searchbox svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--faint); pointer-events: none;
}
.searchbox input { height: 32px; padding: 0 11px 0 30px; font-size: 13px; }

.avatar {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex: none;
  font-size: 11px; font-weight: 650; letter-spacing: 0.02em; color: #fff;
  background: var(--accent); border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 230px; padding: 5px;
  background: var(--raised); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-3);
  z-index: 200;
}
.menu[hidden] { display: none !important; }
.menu-head { padding: 9px 11px 10px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.menu-head .n { font-size: 13px; font-weight: 600; }
.menu-head .e { font-size: 12px; color: var(--muted); word-break: break-all; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 11px; font: inherit; font-size: 13px; text-align: left;
  color: var(--text); background: none; border: 0; border-radius: 3px; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.menu-sep { height: 1px; margin: 5px 0; background: var(--line); }

.body {
  display: flex; flex: 1; min-height: 0;
  /* position alone is not enough: without an explicit z-index this element
     forms no stacking context, and Leaflet's pane z-indexes (400-700) then
     compete directly with the header. */
  position: relative;
  z-index: 0;
}

/* ==========================================================================
   Rail
   ========================================================================== */

.rail {
  display: flex; flex-direction: column;
  width: var(--rail-w); flex: 0 0 var(--rail-w); min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line);
  z-index: var(--z-rail);
}

.rail-top { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-bottom: 13px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stat { padding: 8px 9px; background: var(--surface); }
.stat .v { font-size: 17px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 10px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 25px; padding: 0 9px;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 3px;
  cursor: pointer; user-select: none;
  transition: background .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease);
}
.chip:hover { border-color: var(--faint); }
.chip[aria-pressed="true"] { color: var(--text); background: var(--surface-2); border-color: var(--text); }
.chip .dot { width: 7px; height: 7px; border-radius: 1px; flex: none; }
.chip .n { color: var(--faint); font-variant-numeric: tabular-nums; }

.rail-list { flex: 1; min-height: 0; }

.loc {
  display: block; width: 100%; padding: 11px 16px 12px;
  text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  cursor: pointer; font: inherit; color: var(--text);
  transition: background .12s var(--ease);
  position: relative;
}
.loc::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--rep, transparent);
}
.loc:hover { background: var(--surface-2); }
.loc[aria-current="true"] { background: var(--accent-soft); }
.loc .r1 { display: flex; align-items: baseline; gap: 8px; }
.loc .nm {
  font-size: 13.5px; font-weight: 550; letter-spacing: -0.012em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.loc .ad {
  margin-top: 2px; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.loc .r2 { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.loc .rep { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.loc .rep .dot { width: 7px; height: 7px; border-radius: 1px; }

.pill {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  border-radius: 2px; white-space: nowrap;
}
.pill-prospect  { color: var(--muted); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.pill-visited   { color: var(--warn);  background: var(--warn-soft); }
.pill-installed { color: var(--ok);    background: var(--ok-soft); }
.pill-declined  { color: var(--danger);background: var(--danger-soft); }

.empty { padding: 44px 28px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; margin-bottom: 12px; color: var(--line-2); }
.empty .t { font-size: 13.5px; font-weight: 550; color: var(--text-2); margin-bottom: 4px; }
.empty .d { font-size: 12.5px; line-height: 1.5; }

/* ==========================================================================
   Map
   ========================================================================== */

.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }

.map-tools {
  position: absolute; top: 14px; right: 14px; z-index: var(--z-map-tools);
  display: flex; flex-direction: column; gap: 6px;
}
.map-tools .icon-btn {
  width: 34px; height: 34px;
  background: var(--scrim);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line-2); box-shadow: var(--sh-1);
}
.map-tools .icon-btn:hover { background: var(--surface); }
.map-tools .icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.map-hint {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  z-index: var(--z-map-tools); display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 14px; max-width: min(560px, calc(100% - 28px));
  font-size: 13px; color: var(--text);
  background: var(--scrim);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--sh-2);
}
.map-hint[hidden] { display: none !important; }

/* Leaflet pin: a squared marker with a stem, tinted by the rep's color. */
.pin { position: relative; }
.pin i {
  display: block; width: 20px; height: 20px;
  background: var(--rep, var(--accent));
  border: 2px solid #fff; border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform .16s var(--ease);
}
.pin::after {
  content: ''; position: absolute; left: 50%; top: 19px;
  width: 2px; height: 7px; margin-left: -1px;
  background: var(--rep, var(--accent)); opacity: .55;
}
.pin.is-active i { transform: scale(1.35); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }
.pin.st-declined i { opacity: .42; }
.pin.st-installed i::before {
  content: ''; position: absolute; inset: 4px;
  background: #fff; border-radius: 1px;
}
.leaflet-marker-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.me-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15), 0 2px 8px rgba(0, 0, 0, .3);
}
.me-dot::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%;
  background: var(--accent); opacity: .18;
  animation: ping 2.4s var(--ease) infinite;
}
@keyframes ping {
  0%   { transform: scale(.55); opacity: .30; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .me-dot::after { animation: none; opacity: .18; }
  * { scroll-behavior: auto !important; }
}

.leaflet-container { font: inherit !important; background: var(--bg) !important; }
.leaflet-control-attribution {
  font-size: 10px !important; color: var(--faint) !important;
  background: var(--scrim) !important; border-radius: 2px 0 0 0 !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar { border: 1px solid var(--line-2) !important; border-radius: var(--r) !important;
  box-shadow: var(--sh-1) !important; overflow: hidden; }
.leaflet-bar a {
  background: var(--scrim) !important; color: var(--text) !important;
  border-bottom-color: var(--line) !important;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.leaflet-bar a:hover { background: var(--surface) !important; }
/* Dark map tiles: dim + invert-free tinting keeps labels readable. */
[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.86) contrast(1.06); }

/* ==========================================================================
   Detail drawer
   ========================================================================== */

.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100%;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--sh-3); z-index: var(--z-drawer);
  transform: translateX(100%); transition: transform .34s var(--ease);
}
.drawer.open { transform: none; }
.drawer[hidden] { display: none !important; }

.drawer-head { padding: 16px 16px 14px; border-bottom: 1px solid var(--line); }
.drawer-head .top { display: flex; align-items: flex-start; gap: 10px; }
.drawer-title {
  flex: 1; font-size: 19px; font-weight: 600; letter-spacing: -0.026em; line-height: 1.25;
  padding: 2px 4px; margin: -2px -4px;
  border: 1px solid transparent; border-radius: 3px; cursor: text;
}
.drawer-title:hover { border-color: var(--line-2); }
.drawer-title:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); cursor: text; }
.drawer-sub { margin-top: 5px; font-size: 13px; color: var(--muted); line-height: 1.45; }

.drawer-body { flex: 1; min-height: 0; }

.sect { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.sect-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 11px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.045em; text-transform: uppercase;
  color: var(--muted);
}

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.status-opt {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px; font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--text-2); background: var(--surface); text-align: left;
  border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.status-opt:hover { border-color: var(--faint); }
.status-opt[aria-pressed="true"] { color: var(--text); border-color: var(--text); background: var(--surface-2); }
.status-opt .dot { width: 8px; height: 8px; border-radius: 1px; flex: none; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text-2); word-break: break-word; }

.locked {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--faint);
}
.locked svg { width: 12px; height: 12px; }

/* Notes: read-only cards that flip to an editor in place. */
.note {
  padding: 11px 12px; margin-bottom: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .14s var(--ease);
}
.note:hover { border-color: var(--line-2); }
.note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.note-title { flex: 1; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.note-body { font-size: 13px; line-height: 1.55; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.note-meta { margin-top: 8px; font-size: 11.5px; color: var(--faint); }
.note-actions { display: flex; gap: 5px; }
.note .note-actions { opacity: 0; transition: opacity .14s var(--ease); }
.note:hover .note-actions, .note:focus-within .note-actions { opacity: 1; }
.note-edit input { margin-bottom: 7px; }
.note-edit .row { display: flex; gap: 6px; margin-top: 8px; }

/* ==========================================================================
   Modal
   ========================================================================== */

.overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  display: grid; place-items: center; padding: 20px;
  background: rgba(0, 0, 0, 0.38);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fade .18s var(--ease);
}
.overlay[hidden] { display: none !important; }
@keyframes fade { from { opacity: 0; } }

.modal {
  width: 100%; max-width: 460px; max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-3);
  animation: rise .26s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 13px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { flex: 1; font-size: 16px; letter-spacing: -0.022em; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px; border-top: 1px solid var(--line);
}
.modal-foot .spacer { flex: 1; }

.tabs { display: flex; gap: 2px; padding: 3px; margin-bottom: 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.tab {
  flex: 1; padding: 6px 10px; font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--muted); background: none; border: 0; border-radius: 2px; cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.tab[aria-selected="true"] { color: var(--text); background: var(--surface); box-shadow: var(--sh-1); }

.preview {
  padding: 12px 13px; margin-top: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
}
.preview .nm { font-size: 14px; font-weight: 600; letter-spacing: -0.015em; }
.preview .ad { margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.preview .co { margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--faint); }

.msg { padding: 9px 11px; font-size: 12.5px; line-height: 1.45; border-radius: var(--r); }
.msg[hidden] { display: none !important; }
.msg-error { color: var(--danger); background: var(--danger-soft); }
.msg-ok    { color: var(--ok); background: var(--ok-soft); }
.msg-warn  { color: var(--warn); background: var(--warn-soft); }

.spin {
  width: 14px; height: 14px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-host {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: 7px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 9px 15px; font-size: 13px; color: #fff;
  background: rgba(28, 28, 30, .94);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-radius: var(--r); box-shadow: var(--sh-3);
  animation: rise .22s var(--ease);
}
.toast.err { background: var(--danger); }

/* ==========================================================================
   Sign in
   ========================================================================== */

.auth { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100dvh; }

.auth-art {
  position: relative; overflow: hidden;
  padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  color: #f5f5f7; background: #08080a;
}
.auth-art::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 12% 8%, rgba(0, 113, 227, .30), transparent 58%),
    radial-gradient(90% 80% at 88% 96%, rgba(94, 92, 230, .26), transparent 55%),
    linear-gradient(160deg, #0b0b0f 0%, #08080a 100%);
}
.auth-art::after {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(90% 70% at 40% 40%, #000 30%, transparent 100%);
  mask-image: radial-gradient(90% 70% at 40% 40%, #000 30%, transparent 100%);
}
.auth-art > * { position: relative; z-index: 1; }
.auth-art .brand { color: #f5f5f7; }
.auth-art .brand .mark { background: #f5f5f7; color: #08080a; }
.auth-art h1 {
  max-width: 13ch; margin-bottom: 18px;
  font-size: clamp(34px, 3.6vw, 52px); font-weight: 600;
  letter-spacing: -0.035em; line-height: 1.05;
}
.auth-art .lede { max-width: 40ch; font-size: 16px; line-height: 1.55; color: rgba(245, 245, 247, .7); }
.auth-marks { display: flex; gap: 28px; font-size: 12.5px; color: rgba(245, 245, 247, .55); }
.auth-marks div strong {
  display: block; font-size: 21px; font-weight: 600; letter-spacing: -0.03em;
  color: #f5f5f7; margin-bottom: 1px;
}

.auth-pane { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 330px; }
.auth-card h2 { font-size: 26px; letter-spacing: -0.03em; margin-bottom: 6px; }
.auth-card .sub { margin-bottom: 26px; font-size: 14px; color: var(--muted); }
.auth-card .field input { height: 38px; }
.auth-foot { margin-top: 22px; font-size: 12px; color: var(--faint); line-height: 1.5; }

@media (max-width: 880px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}

/* ==========================================================================
   Team (admin)
   ========================================================================== */

.page { max-width: 900px; margin: 0 auto; padding: 34px 24px 80px; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 30px; letter-spacing: -0.033em; margin-bottom: 6px; }
.page-head p { font-size: 14.5px; color: var(--muted); max-width: 62ch; line-height: 1.5; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.panel-head h2 { flex: 1; font-size: 14px; letter-spacing: -0.015em; }

.urow { display: flex; align-items: center; gap: 13px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.urow:last-child { border-bottom: 0; }
.urow .who { flex: 1; min-width: 0; }
.urow .who .n { font-size: 13.5px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.urow .who .e { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.urow .acts { display: flex; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; height: 17px; padding: 0 6px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 2px;
}
.tag-admin { color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.tag-off { color: var(--danger); background: var(--danger-soft); box-shadow: none; }

.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  position: relative; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--line-2); border-radius: 3px; cursor: pointer;
  transition: transform .12s var(--ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch::after {
  content: ''; position: absolute; inset: 3px; border-radius: 2px; background: var(--c);
}

@media (max-width: 1000px) {
  :root { --rail-w: 300px; }
}
@media (max-width: 820px) {
  .rail { position: absolute; inset: 0 auto 0 0; box-shadow: var(--sh-3); transform: translateX(-100%);
    transition: transform .3s var(--ease); }
  .rail.open { transform: none; }
  .drawer { width: 100%; }
  .searchbox { flex: 1 1 auto; }
  .header .hide-sm { display: none; }
}
