/* Traveldragons dashboard, styled to match the Travel Dragons backoffice.
   One set of components is reused on every page:
   - status pills (.status-pill + st-* state)
   - toolbars (.records-toolbar with .search-field, .filter-field, .btn)
   - tables (.table-wrap > .data-table, optional .table-footer)
   - buttons (.btn with .btn-primary / .btn-ghost / .btn-danger-ghost, .btn-sm)
   - panels (.page-card, .detail-card, .kpi-card, .attention-card) */

:root {
  /* color */
  --ground: #f4f5f0;
  --bg: #ffffff;
  --panel: #f9faf7;
  --panel-2: #edf2ee;
  --panel-3: #dfe8df;
  --sage-2: #edf2ec;
  --sage: #dfe8df;
  --border: #e6ebe7;
  --line: #d7ded8;
  --border-solid: #d7ded8;
  --border-hover: #bdc8c0;
  --input-border: #bdc8c0;
  --text: #17201d;
  --text-dim: #66736e;
  --text-faint: #7f8c86;
  --head-text: #44534e;
  --ink: #123e35;
  --ink-deep: #07342c;
  --ink-soft: #315d53;
  --ink-hover: #195347;
  --amber: #d84b35;
  --amber-dark: #bd3b28;
  --amber-soft: rgba(216,75,53,0.10);
  --control-h: 46px;
  --focus-ring: 0 0 0 3px rgba(49,93,83,0.13);

  /* status palette: one pair (text / background) per state */
  --st-running-text: #315d53;  --st-running-bg: #e4eeea;
  --st-success-text: #236446;  --st-success-bg: #e8f3ea;
  --st-failed-text: #a62e22;   --st-failed-bg: #f8e4e0;
  --st-waiting-text: #8a5a12;  --st-waiting-bg: #fbf1dc;
  --st-none-text: #7f8c86;     --st-none-bg: #dfe8df;

  /* type: DM Sans for body text, Manrope for headings and brand */
  --sans: 'DM Sans', -apple-system, 'Segoe UI', sans-serif;
  --display: 'Manrope', 'DM Sans', sans-serif;
  --mono: 'JetBrains Mono', Consolas, 'Liberation Mono', monospace;

  /* spacing (rem based) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;

  /* radius: panels 14px, controls 9px, inputs 8px */
  --radius: 14px;
  --radius-control: 9px;
  --radius-sm: 8px;

  /* elevation */
  --shadow-md: 0 12px 35px rgba(15,48,40,0.08), 0 2px 8px rgba(15,48,40,0.04);
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
::selection { background: #b8d2c6; color: #092f28; }
:focus-visible { outline: 3px solid rgba(216,75,53,0.34); outline-offset: 3px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #9aaba4; border: 3px solid var(--ground); border-radius: 99px; }
::-webkit-scrollbar-track { background: var(--ground); }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

h1, h2, h3 { font-family: var(--display); letter-spacing: -0.03em; margin-top: 0; }
h1 { font-size: clamp(2rem, 3.2vw, 3rem); line-height: 1.05; margin-bottom: 0.55rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.35rem; }
p { margin-top: 0; color: var(--text-dim); line-height: 1.55; }

.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mt-section { margin-top: var(--sp-5); }

/* ---------- shell: fixed ink sidebar, workspace beside it ---------- */
.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  height: 100vh;
  background: var(--ink-deep);
  color: #ffffff;
  padding: 1.8rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  z-index: 20;
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.72rem; padding: 0 0.65rem; margin-bottom: 2.3rem; }
.sidebar-brand svg { width: 29px; height: 29px; flex: none; }
.sidebar-brand svg circle[r="6.5"], .sidebar-brand svg line { stroke: #c2e0d2; }
.sidebar-brand svg circle[r="2"] { fill: #c2e0d2; }
.sidebar-title { font-family: var(--display); font-size: 1.22rem; font-weight: 700; letter-spacing: -0.03em; color: #ffffff; line-height: 1.2; }
.sidebar-sub { font-size: 0.78rem; color: #a9c8bb; }

.sidebar-nav { display: grid; gap: 0.35rem; }
.sidebar-nav-system { margin-top: var(--sp-6); }
.nav-group-label { padding: 0 0.88rem 0.4rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #a9c8bb; }
.nav-item {
  display: flex; align-items: center; gap: 0.9rem;
  background: none; border: none; color: #d9e8e1;
  padding: 0.84rem 0.88rem; border-radius: var(--radius-control);
  font-size: 1rem; font-weight: 600; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover, .nav-item.active { background: var(--ink-hover); color: #ffffff; }
.nav-item svg { width: 22px; height: 22px; flex: none; }
.nav-item svg * { stroke: currentColor; }

.sidebar-stats {
  display: flex; flex-direction: column; gap: 0.2rem;
  margin-top: auto; padding: 1rem 0.65rem 0.6rem;
  border-top: 1px solid rgba(225,241,234,0.18);
}
.stat-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0; }
.stat-icon {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 6px; color: #b8d2c6; background: rgba(255,255,255,0.08);
}
.stat-label { flex: 1; font-size: 0.85rem; color: #b8d2c6; font-weight: 500; }
.stat-value { font-size: 0.95rem; font-weight: 700; color: #eef7f2; font-variant-numeric: tabular-nums; }
.stat-row.good .stat-icon { color: #8fd6ae; background: rgba(143,214,174,0.12); }
.stat-row.good .stat-value { color: #8fd6ae; }
.stat-row.warn .stat-icon { color: #f0c46b; background: rgba(240,196,107,0.12); }
.stat-row.warn .stat-value { color: #f0c46b; }
.stat-row.bad .stat-icon { color: #f3a494; background: rgba(243,164,148,0.12); }
.stat-row.bad .stat-value { color: #f3a494; }

.sidebar-footer { display: flex; flex-direction: column; gap: 0.9rem; padding: 1.2rem 0.65rem 0.2rem; border-top: 1px solid rgba(225,241,234,0.23); margin-top: 0.6rem; }
.server-status { display: flex; align-items: center; gap: 0.6rem; font-size: 0.82rem; color: #b8d2c6; }
.server-dot { width: 7px; height: 7px; border-radius: 50%; background: #7f8c86; flex: none; }
.server-dot.up { background: #8fd6ae; box-shadow: 0 0 0 3px rgba(143,214,174,0.18); }
.server-dot.down { background: #f3a494; box-shadow: 0 0 0 3px rgba(243,164,148,0.18); }

.how-it-works { font-size: 0.8rem; color: #b8d2c6; }
.how-it-works strong { display: block; color: #eef7f2; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.4rem; }
.how-it-works ol { margin: 0; padding-left: 1.1rem; line-height: 1.8; }

/* ---------- workspace + topbar ---------- */
.main { margin-left: 250px; min-height: 100vh; }
.topbar {
  height: 84px;
  padding: 0 clamp(1.2rem, 3.4vw, 3.2rem);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  background: rgba(244,245,240,0.94);
  position: sticky; top: 0; z-index: 12;
  backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 2rem; margin: 0; line-height: 1.1; }
.view-sub { margin: 0.2rem 0 0; font-size: 0.95rem; color: var(--text-dim); }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); flex: none; }
.btn-refresh {
  width: var(--control-h); height: var(--control-h); border-radius: var(--radius-control); border: 1px solid #bdc8c0;
  background: var(--bg); color: var(--ink); display: flex; align-items: center; justify-content: center;
  transition: transform 0.4s ease, border-color 0.15s, color 0.15s;
}
.btn-refresh svg { width: 18px; height: 18px; }
.btn-refresh:hover { color: var(--amber); border-color: var(--border-hover); }
.btn-refresh.spin svg { animation: spin 0.6s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

.proxy-field { display: flex; align-items: center; gap: var(--sp-2); margin: 0; }
.proxy-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
/* Dropdowns: one look everywhere (top bar, toolbars, forms). The field, border, height,
   font and chevron are the same; only the wrapper differs for the labelled filters. */
.proxy-select, .select-wide {
  appearance: none; -webkit-appearance: none;
  height: var(--control-h); padding: 0 2.2rem 0 0.85rem; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--input-border); background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2366736e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.85rem center / 12px 8px;
  color: var(--text); font-size: 0.95rem; font-weight: 600;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.proxy-select { max-width: 200px; }
.select-wide { width: 100%; max-width: none; }
.proxy-select:hover, .select-wide:hover { border-color: var(--border-hover); }
.proxy-select:focus, .select-wide:focus { outline: 0; border-color: var(--ink-soft); box-shadow: var(--focus-ring); }
/* accent whenever a proxy is picked, so it's obvious the next run won't be direct */
.proxy-select.active { border-color: var(--amber); color: var(--amber); }
select option { color: var(--text); background: #ffffff; font-weight: 400; }

.view-panel { padding: var(--sp-4) clamp(1.2rem, 3.4vw, 3.2rem) 4rem; max-width: 1600px; }

/* ---------- status pills: the only status treatment in the app ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  padding: 0.38rem 0.56rem; border-radius: 6px;
  font-size: 0.78rem; font-weight: 700; line-height: 1.2;
  color: var(--st-none-text); background: var(--st-none-bg);
}
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.status-pill.st-running { color: var(--st-running-text); background: var(--st-running-bg); }
.status-pill.st-success { color: var(--st-success-text); background: var(--st-success-bg); }
.status-pill.st-failed  { color: var(--st-failed-text);  background: var(--st-failed-bg); }
.status-pill.st-waiting { color: var(--st-waiting-text); background: var(--st-waiting-bg); }
.status-pill.st-none    { color: var(--st-none-text);    background: var(--st-none-bg); }

/* ---------- buttons: one scale for the whole app ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  min-height: 46px; padding: 0.75rem 1.15rem; border: none; border-radius: var(--radius-control);
  font-family: var(--sans); font-size: 0.95rem; font-weight: 700; line-height: 1.2; white-space: nowrap;
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn svg { width: 13px; height: 13px; flex: none; }
.btn-primary { background: var(--amber); color: #ffffff; box-shadow: 0 7px 18px rgba(186,55,36,0.18); }
.btn-primary:hover:not(:disabled) { background: var(--amber-dark); }
.btn-primary:disabled { background: var(--panel-3); color: var(--text-faint); box-shadow: none; }

.btn-spinner {
  display: inline-block; width: 11px; height: 11px; vertical-align: -1.5px;
  border: 2px solid rgba(127,140,134,0.3); border-top-color: var(--text-faint);
  border-radius: 50%; animation: btn-spinner-rotate 0.7s linear infinite;
}
@keyframes btn-spinner-rotate { to { transform: rotate(360deg); } }
.btn-ghost { background: var(--sage-2); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--border-hover); background: var(--sage); }
.btn-danger-ghost { background: var(--bg); border: 1px solid #e3bcb5; color: var(--st-failed-text); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--st-failed-bg); border-color: #d19a90; }
.btn-sm { min-height: 34px; padding: 0.4rem 0.8rem; font-size: 0.85rem; border-radius: 7px; }
.btn-sm svg { width: 11px; height: 11px; }

.back-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: none; border: none; color: var(--ink); font-size: 0.95rem; font-weight: 700;
  padding: 0.45rem 0; margin-bottom: var(--sp-4);
}
.back-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.back-link svg { width: 12px; height: 12px; }

/* ---------- toolbars: search, filters and actions share one row style ---------- */
.records-toolbar { display: flex; align-items: center; gap: 0.75rem; flex-wrap: nowrap; margin-bottom: var(--sp-4); }
.search-field, .filter-field {
  display: flex; align-items: center; gap: 0.5rem; height: var(--control-h);
  background: var(--bg); border: 1px solid var(--input-border); border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 0.95rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.search-field { flex: 1 1 0; min-width: 140px; max-width: 410px; padding: 0 var(--sp-4); background: #f9faf7; color: var(--text-faint); }
.search-wide { max-width: none; }
.search-field input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: 0.95rem; }
.search-field input::placeholder { color: #7b8983; }
.search-field svg, .filter-field svg { width: 15px; height: 15px; flex: none; }
.filter-field { padding: 0 2.2rem 0 0.85rem; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2366736e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.85rem center / 12px 8px; cursor: pointer; white-space: nowrap; gap: 0.5rem; }
.filter-field:hover { border-color: var(--border-hover); }
.filter-field select {
  appearance: none; -webkit-appearance: none; border: none; background: transparent; outline: none;
  font-size: 0.95rem; font-weight: 600; color: var(--text); cursor: pointer; padding: 0;
  height: 100%;
}
.search-field:focus-within, .filter-field:focus-within { border-color: var(--ink-soft); box-shadow: var(--focus-ring); }
.filter-k { color: var(--text-dim); }
.btn-auto { flex: none; }

.custom-range { display: flex; align-items: center; gap: var(--sp-3); margin: 0 0 var(--sp-4); font-size: 0.9rem; color: var(--text-dim); }
.custom-range label { display: flex; align-items: center; gap: var(--sp-2); }
.custom-range input[type="date"] {
  height: 40px; padding: 0 var(--sp-3); font-size: 0.9rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--input-border); border-radius: var(--radius-sm);
}

/* filter chips, one style for every chip row */
.chip-bar { min-height: 36px; margin: var(--sp-5) 0 var(--sp-4); }
.chip-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 0.5rem; height: 36px; padding: 0 0.9rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px; color: var(--text-dim);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--border-hover); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.chip-count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-3); color: var(--text-dim); font-size: 0.82rem; font-weight: 700;
}
.chip.active .chip-count { background: rgba(255,255,255,0.18); color: #ffffff; }

/* ---------- panels ---------- */
.page-card, .detail-card, .kpi-card, .attention-card, .table-wrap {
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.page-card { padding: 1.8rem 2.2rem; }
.page-card.narrow { max-width: 560px; }
/* data-entry forms: wide card, fields in columns, automation picker and save button share the top row */
.form-card { max-width: 1040px; }
.form-top { display: flex; align-items: flex-end; gap: var(--sp-3); padding-bottom: var(--sp-5); margin-bottom: var(--sp-5); border-bottom: 1px solid var(--line); }
.form-automation { flex: 1; max-width: 420px; }
.form-actions { justify-content: flex-end; margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.form-actions .btn-primary { min-width: 220px; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-2); }
.page-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); flex: none; }
.page-actions.bordered { border-top: 1px solid var(--line); padding-top: var(--sp-4); margin-top: var(--sp-5); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: var(--sp-6) 0 var(--sp-3); }
.section-head h2 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.hint-text { font-size: 0.92rem; color: var(--text-dim); line-height: 1.55; margin: 0 0 var(--sp-4); }
.empty-note { font-size: 0.9rem; color: var(--text-faint); margin: 0; }
.req-mark { color: var(--amber); }

/* empty states */
.empty-state {
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 4.2rem 1.5rem; text-align: center; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
}
.empty-glyph { width: 46px; height: 46px; margin-bottom: 0.5rem; color: var(--ink-soft); }
.empty-state h2 { font-size: 1.25rem; color: var(--text); margin: 0 0 0.35rem; }
.empty-state p { max-width: 380px; font-size: 0.95rem; margin: 0 0 1.25rem; }

/* ---------- tables: one pattern on every page ---------- */
.table-wrap { overflow: hidden; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
  height: 46px; vertical-align: middle;
  text-align: left; background: var(--panel-2); color: var(--head-text);
  font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.055em;
  padding: 0.85rem 1.15rem;
}
.data-table td { padding: 1.05rem 1.15rem; border-top: 1px solid var(--line); vertical-align: middle; color: var(--text); }
.data-table tbody tr:first-child td { border-top: 0; }
.data-table tbody tr.clickable { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr.clickable:hover { background: #fafcf9; }
.data-table .cell-name { font-weight: 700; color: var(--text); }
.data-table .cell-dim { color: var(--text-dim); }
.data-table .cell-faint { color: var(--text-faint); font-family: var(--mono); font-size: 0.82rem; }
.data-table .cell-mono { font-family: var(--mono); font-size: 0.84rem; color: var(--text-dim); }
.data-table .cell-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }
.data-table td.col-check { width: 44px; padding-right: 0; }
.data-table td.col-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.data-table td.col-menu { width: 44px; padding-right: 1.15rem; color: var(--text-faint); }
.data-table tbody tr:hover td.col-menu { color: var(--text); }
.data-table td.col-menu svg { display: block; margin-left: auto; width: 18px; height: 18px; }
/* footer under a table: same height and alignment on every page */
.table-footer { min-height: 60px; padding: 0 1.15rem; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); font-size: 0.9rem; color: var(--text-dim); border-top: 1px solid var(--line); }
.pager-gap { min-width: 24px; text-align: center; color: var(--text-faint); }
.list-summary { font-size: 0.9rem; color: var(--text-dim); }
.rec-pager { display: flex; align-items: center; gap: 0.5rem; }
.rec-pager button {
  min-width: 36px; height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px;
  background: none; color: var(--text-dim); font-size: 0.92rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.rec-pager button:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.rec-pager button:disabled { opacity: 0.35; cursor: default; }
.rec-pager button.active { color: #ffffff; background: var(--ink); border-color: var(--ink); }
.rec-pager #recPages { display: flex; gap: 0.5rem; }
.row-action {
  background: var(--bg); border: 1px solid #b9c7bf; border-radius: 7px; padding: 0.5rem 0.72rem;
  color: var(--ink); font-weight: 700; font-size: 0.88rem;
}

/* ---------- overview: attention + KPI cards ---------- */
.attention-toolbar { display: flex; justify-content: flex-end; margin-bottom: var(--sp-2); }
.attention-list { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-6); }
.attention-card {
  display: flex; align-items: center; gap: var(--sp-4);
  border-left: 4px solid var(--line); padding: 1.1rem 1.3rem;
}
.attention-card.sev-failed { border-left-color: var(--st-failed-text); }
.attention-card.sev-waiting { border-left-color: var(--ink-soft); }
.attention-icon {
  width: 40px; height: 40px; border-radius: var(--radius-control); flex: none;
  display: flex; align-items: center; justify-content: center; background: var(--sage-2); color: var(--ink);
}
.attention-card.sev-failed .attention-icon { background: var(--st-failed-bg); color: var(--st-failed-text); }
.attention-card.sev-waiting .attention-icon { background: var(--st-running-bg); color: var(--ink-soft); }
.attention-body { flex: 1; min-width: 0; }
.attention-title { font-weight: 700; font-size: 1rem; }
.attention-sub { color: var(--text-dim); font-size: 0.9rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attention-actions { display: flex; gap: var(--sp-2); flex: none; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-5); margin-bottom: 2rem; }
.kpi-card { padding: 1.3rem 1.4rem; }
.kpi-value { font-family: var(--display); font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--text); }
.kpi-label { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.25rem; }
.kpi-card.kpi-running .kpi-value { color: var(--ink-soft); }
.kpi-card.kpi-failed .kpi-value { color: var(--st-failed-text); }

/* ---------- key/value lists (connections, settings) ---------- */
.kv-list { display: flex; flex-direction: column; }
.kv-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: 1rem 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: none; }
.kv-k { font-size: 0.95rem; color: var(--text-dim); }
.kv-v { font-size: 0.95rem; font-weight: 700; font-family: var(--mono); color: var(--text); }

.admin-mailbox-row.kv-row { padding-bottom: 0.4rem; }
.admin-mailbox-ws { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-faint); margin-top: 0.1rem; }
.admin-mailbox-messages { padding: 0 0 1rem; border-bottom: 1px solid var(--line); }
.admin-mailbox-messages:last-child { border-bottom: none; }
.admin-mailbox-msg { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.55rem 0.75rem; background: var(--panel); border-radius: var(--radius-sm); margin-bottom: 0.4rem; }
.admin-mailbox-msg.clickable { cursor: pointer; }
.admin-mailbox-msg.clickable:hover { background: var(--panel-2); }
.admin-mailbox-msg-subject { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.admin-mailbox-msg-meta { font-size: 0.78rem; color: var(--text-dim); font-family: var(--mono); }
.admin-mailbox-clip { font-size: 0.8rem; }
.admin-mailbox-msg-body { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.admin-mailbox-msg-text { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 0.82rem; color: var(--text); margin: 0; max-height: 320px; overflow-y: auto; }
.admin-mailbox-attachments { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.6rem; }
.admin-mailbox-attachment-link { font-size: 0.82rem; color: var(--amber); text-decoration: none; }
.admin-mailbox-attachment-link:hover { text-decoration: underline; }
.kv-sub { font-size: 0.85rem; color: var(--text-faint); margin-top: 2px; }

/* ---------- detail pages (record + automation): same header and facts ---------- */
/* keep the Proxy control in place on every page; hide it only visually so the header never shifts */
.on-automation-detail .topbar-actions .proxy-field { visibility: hidden; }
.detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.detail-facts, .meta-row { display: flex; gap: 2.2rem; }
.fact, .meta-row > div { display: flex; flex-direction: column; gap: 2px; }
.fact-k, .meta-k { font-size: 0.85rem; color: var(--text-dim); }
.fact-v, .meta-v { font-size: 1rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.detail-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.detail-actions .proxy-field { margin-right: var(--sp-2); }
.detail-card { padding: 0 2.2rem 2rem; }
.tabs { display: flex; gap: 2rem; border-bottom: 1px solid var(--line); margin: 0 -2.2rem 1.8rem; padding: 0 2.2rem; }
.tab {
  background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -1px;
  padding: 1.1rem 0 0.95rem; font-size: 0.98rem; font-weight: 600; color: var(--text-dim);
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--ink); border-bottom-color: var(--amber); }
.tab:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 2px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* steps list */
.step-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.step-list li { border-bottom: 1px solid var(--line); background: var(--bg); transition: background 0.1s; }
.step-list li:last-child { border-bottom: none; }
.step-list li:hover, .step-list li.editing { background: #fafcf9; }
.step-row-top { display: flex; gap: var(--sp-3); align-items: center; padding: 0.9rem 1.15rem; }
.step-idx {
  font-family: var(--mono); font-size: 0.8rem; color: var(--text-faint);
  width: 26px; height: 26px; border-radius: 6px; background: var(--sage-2);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.step-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.step-line { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }
.verb { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); background: var(--panel-2); border-radius: 6px; padding: 2px 8px; flex: none; }
.verb-click { color: var(--st-running-text); background: var(--st-running-bg); }
.verb-input { color: var(--ink); background: var(--sage-2); }
.verb-navigate { color: var(--st-success-text); background: var(--st-success-bg); }
.step-txt { font-size: 0.95rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.step-sel { font-family: var(--mono); font-size: 0.8rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-tag { font-size: 0.78rem; font-weight: 600; color: var(--text-dim); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; flex: none; }
.step-tag-warn { color: var(--st-waiting-text); border-color: #e7cf9c; background: var(--st-waiting-bg); }
.step-actions { display: flex; gap: var(--sp-1); opacity: 0; transition: opacity 0.1s; flex: none; }
.step-list li:hover .step-actions, .step-list li.editing .step-actions, .step-actions:focus-within { opacity: 1; }
.step-action-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; border-radius: 7px; color: var(--text-dim);
}
.step-action-btn:hover { color: var(--text); border-color: var(--line); background: var(--bg); }
.step-action-btn.danger:hover { color: var(--st-failed-text); border-color: #e3bcb5; }
.step-action-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.step-edit-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3); padding: 0 1.15rem 1.15rem 3.4rem; }
.step-edit-field { display: flex; flex-direction: column; gap: var(--sp-1); }
.step-edit-field label, .run-data-field label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.step-edit-field input, .run-data-field input {
  min-height: 48px; padding: 0.72rem 0.85rem; font-size: 0.95rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--input-border); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.step-edit-field input:focus, .run-data-field input:focus { outline: 0; border-color: var(--ink-soft); box-shadow: var(--focus-ring); }
.step-edit-actions { grid-column: 1 / -1; display: flex; gap: var(--sp-2); }
.step-edit-actions button { min-height: 40px; padding: 0 1rem; border-radius: var(--radius-control); font-size: 0.92rem; font-weight: 700; border: 1px solid var(--line); }
.step-edit-save { background: var(--amber); color: #ffffff; border-color: var(--amber) !important; }
.step-edit-cancel { background: var(--sage-2); color: var(--ink); }

/* run data */
.run-data-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-4) var(--sp-5); }
.run-data-field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.run-data-field label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-data-empty { color: var(--text-dim); font-size: 0.95rem; }

/* script */
.code-block {
  font-family: var(--mono); font-size: 0.85rem; line-height: 1.6; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem; margin: 0; overflow: auto; max-height: 560px; white-space: pre;
}

/* live run + stepper */
.live-run { margin-bottom: var(--sp-5); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.live-run-head { display: flex; justify-content: space-between; padding: 0.65rem 1rem; background: var(--panel); font-size: 0.88rem; color: var(--text-dim); border-bottom: 1px solid var(--line); }
.live-run-status { font-weight: 700; color: var(--ink-soft); }
.live-run-error { padding: 0.65rem 1rem; font-size: 0.85rem; color: var(--st-failed-text); background: var(--st-failed-bg); border-bottom: 1px solid var(--line); font-family: var(--mono); word-break: break-word; }

.run-stepper { display: flex; flex-direction: column; }
.run-step { border-bottom: 1px solid var(--line); }
.run-step:last-child { border-bottom: none; }
.run-step > summary {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem; cursor: pointer;
  font-size: 0.95rem; color: var(--text-dim); user-select: none;
}
.run-step > summary::-webkit-details-marker { display: none; }
.run-step > summary::marker { content: ''; }
.run-step-chevron {
  width: 6px; height: 6px; flex: none; margin-right: 1px;
  border-right: 1.3px solid var(--text-faint); border-bottom: 1.3px solid var(--text-faint);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.run-step[open] .run-step-chevron { transform: rotate(45deg); }
.run-step-icon {
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line); color: var(--text-faint);
}
.run-step-idx { font-family: var(--mono); font-size: 0.8rem; color: var(--text-faint); flex: none; width: 14px; text-align: right; }
.run-step-label { font-family: var(--mono); font-size: 0.85rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-step-retry { margin-left: auto; font-size: 0.8rem; color: var(--st-waiting-text); flex: none; }
.run-step.is-running .run-step-icon { border-color: var(--ink-soft); }
.run-step.is-running .run-step-label { color: var(--text); font-weight: 700; }
.run-step.is-done .run-step-icon { border-color: var(--st-success-text); color: var(--st-success-text); background: var(--st-success-bg); }
.run-step.is-warning .run-step-icon { border-color: var(--st-waiting-text); color: var(--st-waiting-text); background: var(--st-waiting-bg); }
.run-step.is-failed .run-step-icon { border-color: var(--st-failed-text); color: var(--st-failed-text); background: var(--st-failed-bg); }
.run-step.is-failed .run-step-label { color: var(--st-failed-text); font-weight: 700; }
.run-step-spinner { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); animation: run-step-pulse 1.1s ease-in-out infinite; }
@keyframes run-step-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}
.run-step-error { margin: 0 1rem 0.7rem 2.6rem; padding: 0.6rem 0.75rem; border-radius: 7px; background: var(--st-failed-bg); color: var(--st-failed-text); font-size: 0.85rem; font-family: var(--mono); }
.run-step-detail {
  margin: 0 1rem 0.7rem 2.6rem; padding: 0.6rem 0.75rem; border-radius: 7px;
  background: var(--panel); color: var(--text-dim); font-family: var(--mono); font-size: 0.8rem;
  line-height: 1.6; max-height: 160px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  border: 1px solid var(--line);
}
.raw-log { border-top: 1px solid var(--line); }
.raw-log summary { padding: 0.6rem 1rem; font-size: 0.85rem; color: var(--text-faint); cursor: pointer; user-select: none; }
.raw-log summary::-webkit-details-marker { display: none; }
.raw-log summary::marker { content: ''; }
.raw-log[open] summary { border-bottom: 1px solid var(--line); }
.terminal {
  background: var(--panel); margin: 0; padding: 0.8rem 1rem; font-family: var(--mono); font-size: 0.8rem; line-height: 1.7;
  color: var(--st-success-text); max-height: 220px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.run-screenshot { width: 100%; display: block; border-top: 1px solid var(--line); }

.past-runs { display: flex; flex-direction: column; gap: var(--sp-3); }
.past-run { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.8rem 1rem; font-size: 0.9rem; }
.past-run.clickable { cursor: pointer; transition: background 0.1s, border-color 0.1s; }
.past-run.clickable:hover { background: var(--panel-2); border-color: var(--border-hover); }
.past-run-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-1); }
.past-run-when { color: var(--text-faint); font-family: var(--mono); font-size: 0.82rem; }
.past-run-meta { color: var(--text-dim); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1100px) {
  .records-toolbar { flex-wrap: wrap; }
  .search-field { flex: 1 1 280px; }
}
@media (max-width: 980px) {
  .sidebar { position: static; width: auto; height: auto; }
  .main { margin-left: 0; }
  .topbar { height: auto; padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
  .step-edit-form { padding-left: 1.15rem; }
}
@media (max-width: 980px) {
  .data-table th { padding: 0.75rem 0.7rem; }
  .data-table td { padding: 0.85rem 0.7rem; }
}
@media (max-width: 680px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-actions { width: 100%; }
  .view-panel { padding: 1rem 1rem 3rem; }
  .page-card { padding: 1.25rem; }
  .detail-card { padding: 0 1.25rem 1.25rem; }
  .tabs { margin: 0 -1.25rem 1.25rem; padding: 0 1.25rem; gap: 1.2rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .search-field { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- new record: field hints ---------- */
.run-data-field .field-hint { font-size: 12px; color: var(--text-faint); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- auto-run toggle, parallel-runs input ---------- */
.switch-field { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none; }
.switch-field input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch { position: relative; width: 32px; height: 18px; border-radius: 999px; background: var(--border-hover); transition: background 0.15s; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #ffffff; box-shadow: var(--shadow-xs); transition: transform 0.15s; }
.switch-field input:checked + .switch { background: var(--amber); }
.switch-field input:checked + .switch::after { transform: translateX(14px); }
.switch-field input:focus-visible + .switch { outline: 2px solid var(--amber); outline-offset: 2px; }
.num-input { width: 72px; font: inherit; font-size: 13px; padding: var(--sp-1) var(--sp-2); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.num-input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }

/* ---------- connections: add a proxy ---------- */
.proxy-add { flex-wrap: wrap; gap: var(--sp-2); }
.proxy-add-input { flex: 1; min-width: 240px; font: inherit; font-family: var(--mono); font-size: 12px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.proxy-add-input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.proxy-add-msg { font-size: 12px; color: var(--text-dim); }
.proxy-add-msg.ok { color: var(--green); }
.proxy-add-msg.err { color: var(--red); }

/* ---------- run steps: page screenshots ---------- */
.run-page-shot-link { display: block; margin: var(--sp-2) var(--sp-3) var(--sp-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.run-page-shot { display: block; width: 100%; height: auto; max-height: 420px; object-fit: contain; object-position: top; }

/* ---------- roles: hide admin-only parts from non-admin users ---------- */
.role-user .admin-only { display: none !important; }

/* ---------- saved passwords: masked, icons inside the field itself ---------- */
.secret-field { position: relative; }
.secret-field input { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: var(--sp-2) 4.3rem var(--sp-2) var(--sp-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.secret-field input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.secret-field-icons { position: absolute; right: 0.3rem; top: 50%; transform: translateY(-50%); display: flex; }
.field-icon-btn {
  display: flex; align-items: center; justify-content: center; width: 1.8rem; height: 1.8rem;
  border: none; border-radius: var(--radius-sm); background: none; color: var(--text-dim); cursor: pointer; padding: 0;
}
.field-icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* A plain button + absolutely-positioned list, not a native <select> -- no second,
   browser-drawn popup stacked on top of the input's own dropdown affordance. */
.email-field-wrap { position: relative; }
.email-field-wrap input { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: var(--sp-2) 2.1rem var(--sp-2) var(--sp-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.email-field-wrap input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.email-dropdown-btn { position: absolute; right: 0.25rem; top: 50%; transform: translateY(-50%); width: 1.7rem; height: 1.7rem; }
.email-dropdown-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 0.3rem); z-index: 20;
  background: var(--bg); border: 1px solid var(--border-solid); border-radius: var(--radius-sm);
  max-height: 180px; overflow-y: auto;
}
.email-dropdown-item { padding: 0.5rem var(--sp-3); font-size: 13px; color: var(--text); cursor: pointer; }
.email-dropdown-item:hover { background: var(--panel-2); }
.email-dropdown-empty { padding: 0.5rem var(--sp-3); font-size: 13px; color: var(--text-faint); }
.secret-dots { font-family: var(--mono); font-size: 13px; color: var(--text-dim); letter-spacing: 1px; }

/* ---------- book-appointment calendar-day / appointment-time: one unified control ---------- */
/* The mode trigger (Desired/Earliest/Random, Desired/Range/Any) and its matching input live
   inside ONE bordered box so the field reads as a single control, not a small pill floating
   above an unrelated input. When the active mode needs no extra input, that input is simply
   `.hidden` (display:none), which removes it from the flex layout entirely — the trigger's
   own flex:1 then fills the whole box automatically, no extra JS state needed. */
.combo-field {
  position: relative; display: flex; align-items: stretch; width: 100%; min-height: 48px;
  border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.combo-field:focus-within { border-color: var(--ink-soft); box-shadow: var(--focus-ring); }
.combo-field-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  flex: 1 1 0; min-width: 0; padding: 0 0.9rem; border: none;
  border-radius: calc(var(--radius-sm) - 1px) 0 0 calc(var(--radius-sm) - 1px);
  background: var(--panel-2);
  color: var(--text); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.combo-field-trigger:hover { background: var(--panel-3); }
/* When the mode needs no extra input, the trigger alone fills the box -- round all 4
   corners instead of just the left two (its background would otherwise square off
   past the box's own rounded right corners now that overflow isn't clipped it). */
.combo-field:not(:has(> .combo-field-input:not(.hidden)), :has(> .combo-field-range:not(.hidden))) .combo-field-trigger {
  border-radius: calc(var(--radius-sm) - 1px) !important;
}
.combo-field-trigger svg { flex: none; color: var(--text-faint); }
.combo-field > .combo-field-input {
  flex: 1 1 0; min-width: 0; width: 100%; box-sizing: border-box; border: none;
  border-left: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 0.85rem; padding: 0 0.85rem; min-height: auto;
}
.combo-field > .combo-field-input:focus { outline: none; box-shadow: none; }
.combo-field-range {
  display: flex; align-items: center; gap: 0.4rem; flex: 1 1 0; min-width: 0;
  border-left: 1px solid var(--line); padding: 0 0.65rem;
}
.combo-field .combo-field-range input {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 0.85rem; padding: 0; min-height: auto;
}
.combo-field .combo-field-range input:focus { outline: none; box-shadow: none; }
.combo-field-sep { flex: none; font-size: 0.78rem; color: var(--text-faint); }
.combo-field > .combo-field-input, .combo-field .combo-field-range input {
  accent-color: var(--amber); color-scheme: light;
}
.combo-field .mode-dropdown-list {
  position: absolute; left: 0; top: calc(100% + 0.3rem); z-index: 20; min-width: 100%;
  width: max-content; background: var(--bg); border: 1px solid var(--border-solid);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm, 0 4px 14px rgba(0,0,0,0.08));
}
.mode-dropdown-item { padding: 0.5rem var(--sp-3); font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap; }
.mode-dropdown-item:hover { background: var(--panel-2); }
.mode-dropdown-item.active { color: var(--amber); font-weight: 600; }

/* ---------- sign-in page ---------- */
body.login-page { min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center; background: var(--panel); }
.login-card { width: 100%; max-width: 360px; background: var(--bg); border: 1px solid var(--border-solid); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: var(--sp-8) var(--sp-6); }
.login-card h1 { font-size: 22px; margin: 0 0 var(--sp-1); }
.login-sub { margin: 0 0 var(--sp-6); color: var(--text-dim); font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: var(--sp-2); }
.login-card label { font-size: 12px; color: var(--text-dim); font-weight: 500; margin-top: var(--sp-2); }
.login-card input { font: inherit; font-size: 14px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.login-card input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.login-error { color: var(--red); font-size: 13px; margin: var(--sp-2) 0 0; }
.login-submit { margin-top: var(--sp-4); }

/* ---------- sign out ---------- */
/* Sits on the sidebar's dark background, so it takes the sidebar's own palette
   (same family as .nav-item) instead of the light-panel button colors. */
.logout-btn { margin: var(--sp-3) var(--sp-4) 0; font: inherit; font-size: 12px; padding: var(--sp-1) var(--sp-3); border: 1px solid rgba(217,232,225,0.25); border-radius: var(--radius-sm); background: transparent; color: #d9e8e1; cursor: pointer; }
.logout-btn:hover { color: #ffffff; background: var(--ink-hover); border-color: rgba(217,232,225,0.4); }

/* ---------- workspaces & team ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3); align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: 12px; color: var(--text-dim); font-weight: 500; }
.form-grid input { font: inherit; font-size: 13px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.secret-once { margin-top: var(--sp-4); padding: var(--sp-4); border: 1px solid rgba(217,119,6,0.35); background: var(--warn-soft); border-radius: var(--radius); font-size: 13px; }
.secret-once-row { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); }
.secret-once-row span { width: 80px; color: var(--text-dim); }
.secret-once code { font-family: var(--mono); font-size: 13px; background: var(--bg); padding: var(--sp-1) var(--sp-2); border-radius: var(--radius-sm); }
/* employees don't manage the team; the Team menu is for owners */
.role-employee .team-only { display: none !important; }

/* ---------- change password dialog ---------- */
.pw-dialog { background: var(--panel, #fff); color: var(--text); border: 1px solid var(--border-solid); border-radius: var(--radius); padding: var(--sp-4); width: min(360px, 92vw); }
.pw-dialog::backdrop { background: rgba(0,0,0,0.4); }
.pw-dialog h3 { margin: 0 0 var(--sp-3); font-size: 15px; }
.pw-dialog label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: 12px; color: var(--text-dim); margin-bottom: var(--sp-3); }
.pw-dialog input { font: inherit; font-size: 13px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.pw-error { color: #b91c1c; font-size: 12px; margin: 0 0 var(--sp-3); }
.pw-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); }
