/* ================================================================
 * cfworker — Warp-terminal-esque modern macOS dashboard
 * ============================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Surfaces — warm-tinted dark (not pure black) */
  --bg:           #0F1116;
  --bg-1:         #151820;
  --bg-2:         #1C1F29;
  --bg-3:         #242835;
  --bg-4:         #2E3241;
  --bg-elevated:  rgba(28, 31, 41, 0.72);     /* translucent for frosted panels */
  --bg-glass:     rgba(21, 24, 32, 0.76);

  /* Borders — hairline, soft */
  --border:       rgba(255, 255, 255, 0.06);
  --border-2:     rgba(255, 255, 255, 0.10);
  --border-3:     rgba(255, 255, 255, 0.16);

  /* Text — warm white, not stark */
  --text:         #F2F3F5;
  --text-2:       #B2B7C2;
  --text-3:       #7C818E;
  --text-4:       #555962;

  /* Primary accent — soft purple (Warp / Raycast style) */
  --accent:       #B68CFB;
  --accent-hover: #C9A4FF;
  --accent-deep:  #8E5CE8;
  --accent-soft:  rgba(182, 140, 251, 0.12);
  --accent-line:  rgba(182, 140, 251, 0.28);
  --accent-grad:  linear-gradient(135deg, #B68CFB 0%, #F99FC9 100%);

  /* Secondary accent — coral pink */
  --pink:         #F99FC9;
  --pink-soft:    rgba(249, 159, 201, 0.14);

  /* States */
  --success:      #66E8A4;
  --success-soft: rgba(102, 232, 164, 0.12);
  --warning:      #FFD166;
  --warning-soft: rgba(255, 209, 102, 0.12);
  --danger:       #FF7A7A;
  --danger-soft:  rgba(255, 122, 122, 0.12);
  --info:         #7AB8FF;
  --info-soft:    rgba(122, 184, 255, 0.12);

  /* Legacy compat shims */
  --phos:         var(--accent);
  --phos-bright:  var(--accent-hover);
  --phos-dim:     var(--accent-deep);
  --phos-glow:    rgba(182, 140, 251, 0.28);
  --phos-wash:    var(--accent-soft);
  --amber:        var(--warning);
  --red:          var(--danger);
  --cyan:         var(--info);
  --fg:           var(--text);
  --fg-2:         var(--text-2);
  --fg-3:         var(--text-3);
  --fg-4:         var(--text-4);

  /* Fonts */
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Radii — roundness everywhere */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Shadows — soft, layered */
  --shadow-xs:    0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm:    0 2px 4px -1px rgba(0, 0, 0, 0.25), 0 1px 2px -1px rgba(0, 0, 0, 0.2);
  --shadow-md:    0 8px 16px -4px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  --shadow-lg:    0 24px 48px -12px rgba(0, 0, 0, 0.55), 0 6px 12px -6px rgba(0, 0, 0, 0.35);
  --shadow-xl:    0 40px 80px -16px rgba(0, 0, 0, 0.65), 0 10px 20px -8px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 0 0 1px var(--accent-line), 0 12px 40px -8px rgba(182, 140, 251, 0.3);

  /* Transitions */
  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out:  cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "cv11" 1, "ss01" 1, "ss03" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.002em;
}

body {
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg);
  /* Aurora gradient backdrop */
  background-image:
    radial-gradient(ellipse 70% 50% at 10% 0%,   rgba(182, 140, 251, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(249, 159, 201, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%,  rgba(122, 184, 255, 0.04) 0%, transparent 60%);
}

::selection { background: var(--accent); color: var(--bg); }

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }

button { font: inherit; cursor: pointer; border: none; background: transparent; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--font-mono); }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }

/* ================================================================
 * APP SHELL
 * ============================================================== */

.shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "side  top"
    "side  main";
  height: 100vh;
  padding: 12px;
  gap: 12px;
  background-color: transparent;
}

/* ================================================================
 * SIDEBAR — translucent, floating
 * ============================================================== */

.side {
  grid-area: side;
  grid-row: 1 / 3;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.side-brand {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.side-brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.03em;
  box-shadow: 0 2px 8px rgba(182, 140, 251, 0.25);
  flex-shrink: 0;
}
.side-brand-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.side-brand-name small {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
  margin-top: 2px;
}

.side-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.side-group { margin-bottom: 18px; }
.side-group-title {
  padding: 0 10px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s var(--ease-out);
  cursor: pointer;
  margin-bottom: 1px;
}
.side-link:hover { background: var(--bg-3); color: var(--text); }
.side-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.side-link .ico {
  width: 20px; height: 20px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.side-link .ico svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.side-link.active .ico {
  background: var(--accent);
  color: #fff;
}
.side-link .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 2px 7px;
  border-radius: var(--r-full);
  min-width: 22px;
  text-align: center;
  font-weight: 500;
}
.side-link.active .count {
  background: var(--accent);
  color: #fff;
}

.side-foot {
  border-top: 1px solid var(--border);
  padding: 10px;
}
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease-out);
}
.side-user:hover { background: var(--bg-3); }
.side-user-avatar {
  width: 30px; height: 30px;
  border-radius: var(--r-full);
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.side-user-info { flex: 1; min-width: 0; }
.side-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-user-role { font-size: 11px; color: var(--text-3); text-transform: capitalize; }
.side-user-logout {
  color: var(--text-3);
  padding: 6px;
  border-radius: var(--r-sm);
}
.side-user-logout:hover { color: var(--danger); background: var(--danger-soft); }
.side-user-logout svg {
  width: 14px; height: 14px;
  stroke: currentColor; stroke-width: 1.8; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ================================================================
 * TOP BAR — floating, frosted
 * ============================================================== */

.topbar {
  grid-area: top;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  box-shadow: var(--shadow-md);
}
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.crumb .here { color: var(--text); font-weight: 600; }
.crumb .sep { color: var(--text-4); }

.search-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-3);
  width: 320px;
  transition: all 0.15s var(--ease-out);
}
.search-btn:hover {
  border-color: var(--border-2);
  color: var(--text-2);
  background: var(--bg-4);
}
.search-btn svg {
  width: 14px; height: 14px;
  stroke: currentColor; stroke-width: 1.8; fill: none;
  flex-shrink: 0;
}
.search-btn-text { flex: 1; text-align: left; }
.search-btn kbd {
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-3);
  box-shadow: var(--shadow-xs);
}

/* ================================================================
 * MAIN
 * ============================================================== */

.main {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 36px 40px;
  box-shadow: var(--shadow-md);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
}
.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 4px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-2);
  font-weight: 400;
  max-width: 680px;
  line-height: 1.55;
}
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ================================================================
 * STAT CARDS — soft, rounded, floating
 * ============================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  transition: all 0.18s var(--ease-out);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.stat:hover::before { opacity: 1; }
.stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.stat-value .suffix { font-size: 13px; color: var(--text-3); font-weight: 500; }
.stat-delta {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--r-full);
  font-weight: 600;
}
.stat-delta.pos { color: var(--success); background: var(--success-soft); }
.stat-delta.neu { color: var(--text-3); background: var(--bg-3); }
.stat-meta { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.stat-bar {
  height: 6px;
  background: var(--bg-1);
  border-radius: var(--r-full);
  margin-top: 12px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: var(--accent-grad);
  border-radius: var(--r-full);
  transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 8px rgba(182, 140, 251, 0.4);
}

/* ================================================================
 * TOOLBAR & FILTERS
 * ============================================================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filters {
  display: flex;
  gap: 3px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
}
.chip {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-2);
  border-radius: var(--r-sm);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  transition: all 0.12s var(--ease-out);
}
.chip:hover { color: var(--text); background: var(--bg-3); }
.chip-on {
  background: var(--bg-4);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.chip-count {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  padding: 1px 6px;
  background: var(--bg-1);
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
}
.chip-on .chip-count { background: var(--bg-2); color: var(--text-2); }
.chip-acc-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.toolbar-count { margin-left: auto; font-size: 12px; color: var(--text-3); }

/* ================================================================
 * BUTTONS — rounded, soft
 * ============================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text);
  transition: all 0.15s var(--ease-out);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.btn:hover {
  background: var(--bg-3);
  border-color: var(--border-3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg {
  width: 14px; height: 14px;
  stroke: currentColor; stroke-width: 1.8; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(182, 140, 251, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(182, 140, 251, 0.4);
  filter: brightness(1.06);
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); border-color: transparent; box-shadow: none; transform: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; background: transparent; border-color: transparent; box-shadow: none; }
.btn-icon:hover { background: var(--bg-3); transform: none; }

/* ================================================================
 * TABLE — rounded, soft rows
 * ============================================================== */

.table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.thead {
  display: grid;
  grid-template-columns: 44px minmax(200px, 1.4fr) 160px minmax(240px, 2fr) 110px 80px;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#worker-list { list-style: none; }
#worker-list .row {
  display: grid;
  grid-template-columns: 44px minmax(200px, 1.4fr) 160px minmax(240px, 2fr) 110px 80px;
  gap: 16px;
  padding: 14px 20px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s var(--ease-out);
  cursor: pointer;
}
#worker-list .row:last-child { border-bottom: 0; }
#worker-list .row:hover { background: var(--bg-1); }
#worker-list .row.selected { background: var(--accent-soft); }
#worker-list .row.highlighted { animation: rowPulse 2s ease-out; }
@keyframes rowPulse {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* Toggle switch — rounded, soft */
.active-toggle {
  position: relative;
  width: 34px; height: 20px;
  display: inline-block;
  cursor: pointer;
}
.active-input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 2; }
.toggle-slide {
  display: block;
  width: 34px; height: 20px;
  background: var(--bg-4);
  border-radius: var(--r-full);
  position: relative;
  transition: background 0.18s var(--ease-out);
}
.toggle-slide::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--text-2);
  border-radius: 50%;
  transition: all 0.2s var(--ease-out);
  box-shadow: var(--shadow-xs);
}
.active-input:checked + .toggle-slide {
  background: var(--accent-grad);
  box-shadow: 0 0 12px rgba(182, 140, 251, 0.3);
}
.active-input:checked + .toggle-slide::after {
  background: #fff;
  transform: translateX(14px);
}
.active-input:disabled + .toggle-slide { opacity: 0.5; cursor: wait; }

.domain-col { display: flex; align-items: center; gap: 10px; min-width: 0; }
.domain-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.copy-btn {
  opacity: 0;
  padding: 5px;
  color: var(--text-3);
  border-radius: var(--r-sm);
  transition: all 0.12s var(--ease-out);
}
#worker-list .row:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); background: var(--accent-soft); }
.copy-btn svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.8; fill: none; }

.tag-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 10px;
  background: var(--bg-3);
  border-radius: var(--r-full);
  width: fit-content;
  max-width: 100%;
}
.acc-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; flex-shrink: 0; }

.redirect-col { min-width: 0; }
.redirect-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  transition: all 0.12s var(--ease-out);
}
.redirect-input:hover { border-color: var(--border-2); color: var(--text); background: var(--bg-3); }
.redirect-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-1);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tag-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-full);
  width: fit-content;
}
.tag-state::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.tag-state.is-active { color: var(--success); background: var(--success-soft); }
.tag-state.is-inactive { color: var(--text-3); background: var(--bg-3); }
.tag-state.is-inactive::before { box-shadow: none; }
.tag-script { display: none; }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s var(--ease-out);
}
#worker-list .row:hover .row-actions { opacity: 1; }
.save-btn, .remove-btn {
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  transition: all 0.12s var(--ease-out);
}
.save-btn { color: var(--accent); }
.save-btn:hover:not(:disabled) { background: var(--accent-soft); }
.save-btn:disabled { opacity: 0; pointer-events: none; }
.remove-btn { color: var(--text-3); }
.remove-btn:hover { background: var(--danger-soft); color: var(--danger); }
.row-rail { display: none; }

#worker-empty {
  padding: 64px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
#list-count { color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 500; }

/* ================================================================
 * DRAWER — right slide-in, rounded, frosted
 * ============================================================== */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 12px;
}
.drawer::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(15, 17, 22, 0.6);
  backdrop-filter: blur(4px);
}
.drawer-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  overflow-y: auto;
  animation: drawerIn 0.25s var(--ease-out);
  box-shadow: var(--shadow-xl);
}
@keyframes drawerIn {
  from { transform: translateX(20px) scale(0.98); opacity: 0; }
  to   { transform: translateX(0) scale(1);       opacity: 1; }
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(30px);
  z-index: 1;
}
.drawer-head h2 { font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.drawer-body { padding: 22px 24px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
input[type="text"], input[type="password"] {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s var(--ease-out);
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-1);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="text"]::placeholder, input[type="password"]::placeholder { color: var(--text-4); }
textarea {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  width: 100%;
  resize: vertical;
  transition: all 0.15s var(--ease-out);
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-1);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-2);
}
.field-check input {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-3);
  border-radius: var(--r-xs);
  background: var(--bg-2);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s var(--ease-out);
}
.field-check input:checked {
  background: var(--accent-grad);
  border-color: transparent;
}
.field-check input:checked::after {
  content: '';
  position: absolute;
  top: 2px; left: 5px;
  width: 5px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.add-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto auto;
  gap: 12px;
  align-items: end;
}

.status { font-size: 12px; color: var(--text-3); padding: 8px 0; min-height: 1em; }
.status.ok { color: var(--success); }
.status.err { color: var(--danger); }
.status.warn { color: var(--warning); }

.bulk-summary { font-size: 12px; margin-bottom: 10px; display: flex; gap: 14px; flex-wrap: wrap; }
.bulk-summary .ok { color: var(--success); }
.bulk-summary .warn { color: var(--warning); }
.bulk-summary .err { color: var(--danger); }
.bulk-list { list-style: none; border-top: 1px solid var(--border); max-height: 45vh; overflow-y: auto; }
.bulk-list li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.bdot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-4); }
.bdot.ok { background: var(--success); box-shadow: 0 0 6px rgba(102, 232, 164, 0.5); }
.bdot.warn { background: var(--warning); }
.bdot.err { background: var(--danger); }
.bdot.pending { background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.bdom { font-family: var(--font-mono); color: var(--text); }
.bmsg { color: var(--text-3); font-size: 11px; }

/* ================================================================
 * COMMAND PALETTE
 * ============================================================== */

.cmd-overlay {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(15, 17, 22, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}
.cmd {
  width: 92%; max-width: 600px;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--accent-line);
  overflow: hidden;
  animation: cmdIn 0.2s var(--ease-out);
}
@keyframes cmdIn {
  from { transform: translateY(-10px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.cmd-input-wrap svg { width: 16px; height: 16px; stroke: var(--text-3); stroke-width: 1.8; fill: none; }
#cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
#cmd-input::placeholder { color: var(--text-3); }
.cmd-results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.cmd-group-label {
  padding: 10px 14px 6px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.1s var(--ease-out);
  border-radius: var(--r-sm);
  margin: 1px 0;
  opacity: 0;
  transform: translateY(-4px);
  animation: cmdItemIn 260ms var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 18ms);
}
@keyframes cmdItemIn {
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .cmd-item { animation: none; opacity: 1; transform: none; }
}
.cmd-item:hover { background: var(--bg-3); }
.cmd-item.sel {
  background: var(--accent-grad);
  color: #fff;
}
.cmd-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.cmd-item.sel .cmd-dot { background: #fff; }
.cmd-name { flex: 1; font-weight: 500; }
.cmd-name mark {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 2px;
  animation: markPop 320ms var(--ease-out);
}
@keyframes markPop {
  0% { background: transparent; transform: scale(1); }
  30% { background: var(--accent); color: #fff; transform: scale(1.08); }
  100% { background: var(--accent-soft); color: var(--accent); transform: scale(1); }
}
.cmd-item.sel .cmd-name mark { background: rgba(255,255,255,0.25); color: #fff; }
.cmd-meta { color: var(--text-3); font-size: 11px; }
.cmd-item.sel .cmd-meta { color: rgba(255,255,255,0.8); }
.cmd-empty {
  padding: 24px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
  animation: cmdEmptyIn 260ms var(--ease-out);
}
@keyframes cmdEmptyIn {
  0% { opacity: 0; transform: translateY(-2px); }
  30% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* Live result-count pill */
.cmd-count {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line, transparent);
  white-space: nowrap;
}
.cmd-count.is-empty {
  background: transparent;
  color: var(--text-3);
  border-color: var(--border);
}
.cmd-count.bump {
  animation: cmdCountBump 280ms var(--ease-out);
}
@keyframes cmdCountBump {
  0% { transform: scale(0.85); opacity: 0.3; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Icon + input pulse while typing */
.cmd.is-searching .cmd-icon { stroke: var(--accent); }
.cmd.is-searching .cmd-input-wrap {
  border-bottom-color: var(--accent-line, var(--accent));
  box-shadow: inset 0 -1px 0 0 var(--accent);
}
.cmd.pulse .cmd-icon { animation: cmdIconPulse 420ms var(--ease-out); }
@keyframes cmdIconPulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
  40% { transform: scale(1.15); filter: drop-shadow(0 0 6px var(--accent)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
}
.cmd-input-wrap { transition: border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out); }

/* ================================================================
 * TOAST
 * ============================================================== */

.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 14px 18px;
  font-size: 13px;
  max-width: 420px;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s var(--ease-out);
  border-left: 3px solid var(--accent);
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ================================================================
 * SCROLLBAR
 * ============================================================== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: var(--r-full); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); background-clip: padding-box; border: 2px solid transparent; }

/* ================================================================
 * LOGIN PAGE
 * ============================================================== */

.login-body { height: auto; overflow: auto; background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-slab {
  width: 100%;
  max-width: 420px;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 28px;
}
.login-brand-mark {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 12px rgba(182, 140, 251, 0.3);
}
.login-brand-name { font-weight: 600; font-size: 16px; }
.login-brand-name small { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; margin-top: 2px; }

.login-h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-sub { font-size: 14px; color: var(--text-2); margin-bottom: 24px; line-height: 1.55; }
.login-form .field { margin-bottom: 14px; }
.login-form input { width: 100%; }
.login-form button { width: 100%; padding: 11px 14px; font-weight: 600; }

/* ================================================================
 * RESPONSIVE
 * ============================================================== */

@media (max-width: 900px) {
  .shell { grid-template-columns: 64px 1fr; padding: 8px; gap: 8px; }
  .side-brand-name, .side-group-title, .side-link span, .side-link .count,
  .side-user-info, .side-user-chev { display: none; }
  .side-link { justify-content: center; padding: 10px 0; }
  .side-brand { padding: 14px 0; justify-content: center; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  /* Keep the Account column visible on narrow viewports; hide redirect + actions */
  .thead, #worker-list .row {
    grid-template-columns: 44px minmax(0, 1.4fr) 140px 100px;
  }
  .thead .col-redirect, .thead .col-actions,
  #worker-list .redirect-col, #worker-list .row-actions { display: none; }
  .main { padding: 20px 18px 40px; }
  .search-btn { width: 200px; }
}

/* ================================================================
 * USER MENU (dropdown from sidebar user card) + PASSWORD DRAWER
 * ============================================================== */

.side-foot { position: relative; }
.side-user { position: relative; cursor: pointer; }
.side-user-chev {
  color: var(--text-3);
  transition: transform 0.15s var(--ease-out), color 0.15s;
  flex-shrink: 0;
}
.side-user:hover .side-user-chev { color: var(--text-2); }
.side-user.open .side-user-chev { transform: rotate(180deg); color: var(--accent); }
.side-user-chev svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.user-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 10px;
  right: 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 100;
  animation: menuIn 0.16s var(--ease-out);
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.1s var(--ease-out), color 0.1s;
  text-align: left;
}
.user-menu-item:hover { background: var(--bg-3); }
.user-menu-item svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  color: var(--text-3);
}
.user-menu-item:hover svg { color: var(--accent); }
.user-menu-danger { color: var(--danger); }
.user-menu-danger:hover { background: var(--danger-soft); }
.user-menu-danger:hover svg { color: var(--danger); }
.user-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 2px;
}

/* Field sub-text (hint below inputs) */
.field-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Password strength hint */
.pw-strength {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}
.pw-strength .bar {
  flex: 1;
  height: 3px;
  border-radius: var(--r-full);
  background: var(--bg-3);
  transition: background 0.2s var(--ease-out);
}
.pw-strength.s1 .bar:nth-child(1) { background: var(--danger); }
.pw-strength.s2 .bar:nth-child(-n+2) { background: var(--warning); }
.pw-strength.s3 .bar:nth-child(-n+3) { background: var(--accent); }
.pw-strength.s4 .bar { background: var(--success); }

/* ================================================================
 * OWNER COLUMN (dashboard, admin-only)
 * ============================================================== */

/* Hidden by default for non-admin users */
.col-owner, .tag-owner { display: none; }

/* When admin, reveal and re-lay-out the grid */
body.is-admin .col-owner,
body.is-admin .tag-owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
body.is-admin .thead,
body.is-admin #worker-list .row {
  grid-template-columns: 44px minmax(180px, 1.2fr) 130px 140px minmax(200px, 1.6fr) 110px 80px;
}

.tag-owner .owner-avatar {
  width: 18px; height: 18px;
  border-radius: var(--r-full);
  background: var(--accent-grad);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.tag-owner .owner-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Narrow viewport for admin: keep owner + account visible, drop redirect/actions */
@media (max-width: 900px) {
  body.is-admin .thead,
  body.is-admin #worker-list .row {
    grid-template-columns: 44px minmax(0, 1fr) 100px 120px 100px;
  }
  body.is-admin .col-redirect,
  body.is-admin .col-actions,
  body.is-admin #worker-list .redirect-col,
  body.is-admin #worker-list .row-actions { display: none; }
}

/* Hide the "Admin" sidebar group entirely for non-admin users */
body:not(.is-admin) .side-group-admin-only { display: none; }

.side-user-script {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Cloak-router drawer */
.cloak-path { border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 12px; margin-bottom: 12px; }
.cloak-path-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cloak-path-head input { flex: 1; }
.cloak-rule { display: grid; grid-template-columns: 60px 1fr auto; gap: 8px; margin-bottom: 6px; align-items: center; }
.cloak-rule input { width: 100%; box-sizing: border-box; }
.cloak-sources { display: flex; gap: 12px; font-size: 12px; margin: 4px 0 10px 0; }
.cloak-sources label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.cloak-row-x { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 16px; }
.cloak-row-x:hover { color: var(--danger); }
#cloak-form .status { font-size: 12px; color: var(--text-3); min-height: 1em; margin: 8px 0; }
#cloak-form .status.err { color: var(--danger); }
#cloak-form .status.ok  { color: var(--success); }
