:root {
  --bg: #0a0c12;
  --bg-2: #11141c;
  --panel: #161a24;
  --panel-2: #1d2230;
  --border: #242a3a;
  --border-soft: #1c2230;
  --text: #ecf0f7;
  --text-2: #b8bfd0;
  --muted: #7c849a;
  --muted-2: #4b5365;

  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-glow: rgba(139,92,246,.20);

  --amber: #f59e0b;
  --amber-2: #fbbf24;
  --amber-glow: rgba(245,158,11,.20);

  --ok: #10b981;
  --ok-2: #34d399;
  --warn: #f59e0b;
  --danger: #f43f5e;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 20px 60px -20px rgba(0,0,0,.6);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(1000px 700px at 85% -200px, rgba(139,92,246,.10), transparent 60%),
    radial-gradient(800px 600px at -100px 110%, rgba(16,185,129,.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, "SF Pro Display", system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1 {
  font-size: 28px; margin: 0 0 4px;
  font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.2;
}
h2 {
  font-size: 16px; margin: 36px 0 14px;
  font-weight: 600; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-2);
}
h2 i { width: 18px; height: 18px; color: var(--muted); }
h3 { font-size: 15px; margin: 0 0 2px; font-weight: 600; letter-spacing: -0.005em; }

p { margin: 0 0 8px; }

/* lucide icon defaults */
[data-lucide] {
  width: 16px; height: 16px;
  stroke-width: 2;
  flex-shrink: 0;
  vertical-align: -3px;
}
.inline-icon { width: 14px; height: 14px; vertical-align: -2px; opacity: .8; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.big-icon { width: 32px; height: 32px; stroke-width: 1.5; }

.muted    { color: var(--muted); }
.small    { font-size: 12.5px; }
.mono     { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.center   { text-align: center; }
.ok       { color: var(--ok-2); }
.danger   { color: var(--danger); }
.pad-2    { padding: 28px !important; }

/* ─── nav ─── */
.topnav {
  display: flex; align-items: center; gap: 32px;
  padding: 12px 28px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(11,13,18,.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 30;
}
.topnav .brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.topnav .brand i {
  width: 18px; height: 18px;
  color: var(--accent-2);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.brand-logo {
  width: 38px; height: 38px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}
.brand-logo.large {
  width: 56px; height: 56px;
  border-radius: 10px;
}
@media (max-width: 720px) {
  .brand-logo { width: 34px; height: 34px; }
}
.topnav .brand:hover { color: var(--text); }

.topnav .links {
  display: flex; gap: 2px; flex: 1;
}
.topnav .links a {
  color: var(--muted);
  padding: 7px 12px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  display: flex; align-items: center; gap: 7px;
  transition: all var(--transition);
}
.topnav .links a i { width: 14px; height: 14px; }
.topnav .links a:hover {
  background: var(--panel);
  color: var(--text);
}

.topnav-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--panel); color: var(--text); }

/* status pill */
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: var(--panel-2);
  border: 1px solid var(--border);
  letter-spacing: -0.005em;
  transition: all var(--transition);
}
.status-pill .status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted-2);
}
.status-pill.idle    { color: var(--muted); }
.status-pill.idle    .status-dot { background: var(--muted-2); }
.status-pill.running {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  border-color: transparent;
  box-shadow: 0 0 20px var(--accent-glow);
}
.status-pill.running .status-dot {
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255,255,255,.6);
  animation: pulse 1.5s infinite;
}
.status-pill.paused  { color: #1a1a1a; background: var(--warn); border-color: transparent; }
.status-pill.paused  .status-dot { background: rgba(0,0,0,.4); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,.6); }
  70%  { box-shadow: 0 0 0 6px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ─── layout ─── */
.container { max-width: 1180px; margin: 32px auto 80px; padding: 0 28px; }

.hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 28px;
}
.hero p { margin: 0; }
.hero .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ─── range selector ─── */
.range-bar {
  display: flex; align-items: center;
  margin: 0 0 18px;
  position: relative;
}
.range-group {
  display: inline-flex; gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 4px;
}
.range-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: -0.005em;
  display: inline-flex; align-items: center; gap: 5px;
}
.range-btn i { width: 13px; height: 13px; }
.range-btn:hover { color: var(--text); background: var(--panel-2); }
.range-btn.active {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
  box-shadow: 0 2px 8px -2px var(--accent-glow);
}

/* custom date popover */
.custom-popover {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 320px;
  opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: all var(--transition);
  z-index: 50;
}
.custom-popover.open {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.custom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.custom-row .field { margin: 0; }
.custom-row input[type=date] {
  width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.custom-row input[type=date]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.custom-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ─── avatars ─── */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
  display: block;
}
.avatar.medium { width: 56px; height: 56px; }
.avatar.large { width: 80px; height: 80px; }
.avatar.medium.fallback { font-size: 22px; }
.avatar.fallback {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--accent-2);
  font-size: 16px;
  background: linear-gradient(135deg, rgba(139,92,246,.20), rgba(139,92,246,.05));
  border-color: rgba(139,92,246,.3);
  letter-spacing: 0;
}
.avatar.large.fallback { font-size: 32px; }

.account-identity {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.account-identity h3 { margin-bottom: 0; }

.table-identity {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}

.identity-row {
  display: flex; gap: 24px; align-items: flex-start;
}
.avatar-block {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0;
}
.avatar-block .btn { cursor: pointer; }
.identity-fields { flex: 1; min-width: 0; }

/* ─── cards ─── */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent), var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color var(--transition), transform var(--transition);
}
.card.no-pad { padding: 0; overflow: hidden; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 8px;
}
.card.stat {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px;
}
.card.stat .stat-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  color: var(--muted);
}
.card.stat .stat-icon i { width: 18px; height: 18px; }
.card.stat .stat-icon.purple {
  background: linear-gradient(135deg, rgba(139,92,246,.18), rgba(139,92,246,.04));
  border-color: rgba(139,92,246,.3);
  color: var(--accent-2);
}
.card.stat .stat-icon.amber {
  background: linear-gradient(135deg, rgba(245,158,11,.18), rgba(245,158,11,.04));
  border-color: rgba(245,158,11,.3);
  color: var(--amber-2);
}
.card.stat .stat-icon.red {
  background: linear-gradient(135deg, rgba(244,63,94,.18), rgba(244,63,94,.04));
  border-color: rgba(244,63,94,.3);
  color: var(--danger);
}
.card.stat .big { font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.card.stat .lbl { color: var(--muted); font-size: 12.5px; margin-top: 6px; font-weight: 500; }

/* ─── accounts grid ─── */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.account { display: flex; flex-direction: column; }
.account:hover {
  border-color: var(--border);
  transform: translateY(-1px);
}
.account-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.account-actions { display: flex; gap: 6px; }

.pill-group { margin: 16px 0 12px; }
.pill-label {
  font-size: 11.5px; color: var(--muted);
  margin-top: 10px; margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
}
.pill-label:first-child { margin-top: 0; }
.pill-label i { width: 12px; height: 12px; }

.schedule-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pill i { width: 11px; height: 11px; opacity: .7; }
.pill.time {
  color: var(--accent-2);
  border-color: rgba(139,92,246,.3);
  background: rgba(139,92,246,.06);
}
.pill.time.story {
  color: var(--amber-2);
  border-color: rgba(245,158,11,.3);
  background: rgba(245,158,11,.06);
}

.account-meta {
  display: grid; gap: 6px;
  font-size: 12.5px;
  padding: 14px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}
.account-meta > div {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted);
}
.account-meta b { color: var(--text-2); font-weight: 500; }
.account-meta span { font-variant-numeric: tabular-nums; }

.last-run {
  font-size: 13px; padding: 12px 0;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-2);
}
.last-run.muted { color: var(--muted); }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}
.dot.ok     { background: var(--ok); box-shadow: 0 0 12px rgba(16,185,129,.6); }
.dot.danger { background: var(--danger); box-shadow: 0 0 12px rgba(244,63,94,.6); }
.dot.muted  { background: var(--muted-2); }

.account .link {
  font-size: 13px; color: var(--accent-2);
  margin-top: auto; padding-top: 6px;
  display: inline-flex; align-items: center; gap: 4px;
}
.account .link i { width: 14px; height: 14px; transition: transform var(--transition); }
.account .link:hover i { transform: translateX(2px); }

.account.add {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--muted);
  min-height: 220px;
  transition: all var(--transition);
}
.account.add:hover {
  border-color: var(--accent);
  color: var(--accent-2);
  background: rgba(139,92,246,.04);
  transform: translateY(-1px);
}
.account.add i { color: currentColor; }

/* ─── buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 14px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn:hover { border-color: var(--muted-2); background: var(--border-soft); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 18px -4px var(--accent-glow);
}
.btn.primary:hover { filter: brightness(1.1); box-shadow: 0 6px 22px -4px var(--accent-glow); }
.btn.amber {
  background: linear-gradient(135deg, var(--amber), #d97706);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 18px -4px var(--amber-glow);
}
.btn.amber:hover { filter: brightness(1.08); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1a1a1a; }
.btn.warn:hover { filter: brightness(1.05); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.small i { width: 14px; height: 14px; }
.btn.big { padding: 11px 22px; font-size: 14px; }
.btn.icon-only { padding: 7px; }
.btn.icon-only i { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.5; cursor: wait; }

/* ─── tables ─── */
table.runs, table.accounts-table {
  width: 100%; border-collapse: collapse;
}
table th, table td {
  padding: 12px 18px; text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
table th {
  background: var(--bg-2);
  font-weight: 600; color: var(--muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: rgba(139,92,246,.025); }
table .actions-cell {
  display: flex; gap: 6px; justify-content: flex-end;
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: -0.005em;
}
.badge i { width: 12px; height: 12px; }
.badge.ok     { background: rgba(16,185,129,.13);  color: var(--ok-2); }
.badge.danger { background: rgba(244,63,94,.13); color: var(--danger); }
.badge.muted  { background: var(--panel-2); color: var(--muted); }

/* ─── form sections ─── */
.card.section { margin-bottom: 16px; }
.section-title {
  margin: 0 0 18px;
  font-size: 14px; font-weight: 600;
  color: var(--text); letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px;
}
.section-title i {
  width: 16px; height: 16px;
  color: var(--accent-2);
}

/* ─── forms ─── */
.edit-form { display: flex; flex-direction: column; gap: 0; }
.edit-form .field { margin-bottom: 14px; }
.edit-form .field:last-child { margin-bottom: 0; }
.edit-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; color: var(--text-2); }
.edit-form input[type=text], .edit-form input[type=number],
.edit-form input[type=time], .edit-form input[type=password],
.edit-form textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px; font-size: 13.5px;
  font-family: inherit;
  transition: all var(--transition);
}
.edit-form input:focus, .edit-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.edit-form input[disabled], .edit-form input[readonly] {
  opacity: .55; cursor: not-allowed;
}
.edit-form textarea {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  line-height: 1.6; font-size: 13px;
  resize: vertical;
}
.edit-form .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.edit-form code {
  background: var(--panel-2);
  padding: 1px 6px; border-radius: 4px;
  font-size: 12px;
}

/* ─── time list ─── */
.time-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.time-row {
  display: flex; gap: 8px; align-items: center;
}
.time-row input[type=time] { flex: 0 0 160px; font-variant-numeric: tabular-nums; }

/* ─── sticky save ─── */
.sticky-save {
  position: sticky; bottom: 0;
  background: linear-gradient(180deg, transparent, var(--bg) 60%);
  padding: 20px 0 0; margin-top: 4px;
  display: flex; justify-content: flex-end;
  z-index: 5;
}

/* ─── login ─── */
.login-card {
  max-width: 380px; margin: 100px auto;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.login-brand i { width: 24px; height: 24px; color: var(--accent-2); filter: drop-shadow(0 0 12px var(--accent-glow)); }
.login-card p { margin-top: 0; color: var(--muted); }
.login-card form { display: flex; gap: 8px; margin-top: 22px; }
.login-card input {
  flex: 1;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit; font-size: 14px;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-card button {
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  border: none; color: #fff;
  border-radius: 8px;
  padding: 10px 18px; cursor: pointer;
  font-weight: 600; font-family: inherit;
}

/* ─── flash ─── */
.flash {
  padding: 12px 18px; margin: 16px 28px 0;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  display: flex; align-items: center; gap: 10px;
}
.flash i { width: 16px; height: 16px; flex-shrink: 0; }
.flash-success {
  background: rgba(16,185,129,.08);
  color: var(--ok-2);
  border-color: rgba(16,185,129,.25);
}
.flash-error {
  background: rgba(244,63,94,.08);
  color: var(--danger);
  border-color: rgba(244,63,94,.25);
}

/* ─── calendar ─── */
.cal-nav {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: 11px; padding: 4px 4px 4px 8px;
}
.cal-month {
  padding: 0 8px;
  font-weight: 600; font-size: 14px;
  letter-spacing: -0.01em;
  min-width: 140px; text-align: center;
}
.cal-grid { background: var(--panel); }
.cal-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-soft);
}
.cal-header > div {
  padding: 10px 12px;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
}
.cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
}
.cal-day {
  min-height: 110px;
  padding: 8px 10px;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.empty { background: var(--bg-2); }
.cal-day.past { opacity: .55; }
.cal-day.today {
  background: rgba(139,92,246,.04);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.cal-day.today .cal-day-num { color: var(--accent-2); font-weight: 700; }
.cal-day-num {
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
}
.cal-runs { display: flex; flex-wrap: wrap; gap: 4px; }
.cal-pill {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
}
.cal-pill.ok     { background: rgba(16,185,129,.15); color: var(--ok-2); }
.cal-pill.danger { background: rgba(244,63,94,.15); color: var(--danger); }
.cal-schedule {
  display: flex; flex-direction: column; gap: 3px;
  margin-top: 2px;
}
.cal-event {
  font-size: 11px; font-weight: 500;
  padding: 2px 6px; border-radius: 4px;
  display: inline-flex; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums;
}
.cal-event i { width: 10px; height: 10px; }
.cal-event.post  { background: rgba(139,92,246,.10); color: var(--accent-2); }
.cal-event.story { background: rgba(245,158,11,.10); color: var(--amber-2); }

/* ─── thumbnails (recent runs) ─── */
.thumb-mini {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  display: block;
}
.thumb-mini.placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-2);
}
.thumb-mini.placeholder i { width: 18px; height: 18px; }

/* ─── calendar filters ─── */
.cal-filters {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.cal-filter-group { display: flex; align-items: center; gap: 8px; }
.cal-filter-label {
  font-size: 12.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.cal-select {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.cal-select:focus { outline:none; border-color: var(--accent); }
.cal-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
}
.cal-toggle input { accent-color: var(--accent); }
.cal-toggle input:not(:checked) + .pill { opacity: 0.4; }

/* ─── modal ─── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
  z-index: 100;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%; max-width: 440px;
  box-shadow: var(--shadow);
  transform: scale(.96);
  transition: transform var(--transition);
}
.modal-backdrop.open .modal { transform: scale(1); }
.modal input[type=text] {
  width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-size: 14px;
  font-family: inherit;
}
.modal input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }

/* ─── tooltips ─── */
[data-tooltip] { position: relative; }
[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 100;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  background: var(--panel-2);
  color: var(--text);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  letter-spacing: -0.005em;
}
[data-tooltip]::before {
  content: "";
  bottom: calc(100% + 3px);
  border: 5px solid transparent;
  border-top-color: var(--border);
  width: 0; height: 0;
  padding: 0;
}
[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── mobile hamburger + helpers ─── */
.mobile-only { display: none; }
.desktop-only { display: inline-flex; }
.nav-toggle {
  display: none !important;
  background: var(--panel-2);
  border: 1px solid var(--border);
  width: 38px; height: 38px;
  border-radius: 9px;
  color: var(--text);
  cursor: pointer;
  align-items: center; justify-content: center;
  font-family: inherit;
  flex-shrink: 0;
  padding: 0;
}
.nav-toggle i { width: 20px; height: 20px; }
.nav-toggle:hover { background: var(--border-soft); }
.nav-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  z-index: 25;
  opacity: 0;
  transition: opacity 0.2s;
}

/* ─── mobile ─── */
@media (max-width: 720px) {
  .mobile-only { display: flex; }
  .desktop-only { display: none !important; }
  .nav-toggle { display: inline-flex !important; }

  /* nav becomes hamburger drawer */
  .topnav {
    position: relative;
    padding: 14px 14px;
    padding-top: calc(14px + env(safe-area-inset-top));
    gap: 8px;
    min-height: 58px;
    align-items: center;
    background: var(--bg-2);
  }
  .topnav .brand {
    font-size: 15px;
    flex-shrink: 0;
  }
  .topnav .brand i { width: 16px; height: 16px; }
  .topnav-right {
    margin-left: auto;
    gap: 8px;
  }
  .topnav .links {
    position: fixed;
    top: calc(58px + env(safe-area-inset-top)); left: 0; right: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 2px;
    transform: translateY(-120%);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 28;
    box-shadow: var(--shadow);
  }
  .topnav .links a {
    padding: 12px 16px;
    font-size: 15px;
    border-radius: 8px;
  }
  .topnav .links a i { width: 16px; height: 16px; }

  body.nav-open .topnav .links { transform: translateY(0); }
  body.nav-open .nav-overlay {
    display: block;
    opacity: 1;
  }

  /* status pill smaller on mobile */
  .status-pill {
    padding: 4px 10px 4px 8px;
    font-size: 11.5px;
  }
  .status-pill .status-text {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* layout */
  .container { padding: 0 14px; margin-top: 18px; margin-bottom: 60px; }
  .hero { flex-direction: column; align-items: stretch; gap: 14px; }
  .hero h1 { font-size: 24px; }
  .hero .actions { display: flex; flex-wrap: wrap; }
  .hero .actions .btn { flex: 1; justify-content: center; }
  h2 { font-size: 15px; margin-top: 24px; }
  .grid-2 { grid-template-columns: 1fr !important; }

  /* stat cards: 2x2 grid */
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card.stat { padding: 14px; gap: 12px; }
  .card.stat .stat-icon { width: 36px; height: 36px; }
  .card.stat .stat-icon i { width: 16px; height: 16px; }
  .card.stat .big { font-size: 20px; }
  .card.stat .lbl { font-size: 11.5px; margin-top: 3px; }

  /* range bar wraps + scrolls if needed */
  .range-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .range-group { flex-shrink: 0; }
  .range-btn { padding: 6px 10px; font-size: 12.5px; }
  .custom-popover {
    position: fixed;
    left: 14px; right: 14px;
    top: auto; bottom: 20px;
    min-width: 0;
  }
  .custom-row { grid-template-columns: 1fr 1fr; }

  /* account cards */
  .account-grid { grid-template-columns: 1fr; }
  .account .account-head { flex-wrap: wrap; }
  .account-actions { display: flex; gap: 8px; }
  .account-actions .btn.small { padding: 8px 12px; }
  .account-actions .btn.small i { width: 16px; height: 16px; }
  .account.add { min-height: 120px; }

  .avatar.medium { width: 48px; height: 48px; }
  .avatar.medium.fallback { font-size: 18px; }

  /* tables: horizontal scroll */
  .card.no-pad { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.runs, table.accounts-table { min-width: 580px; }
  table th, table td { padding: 10px 12px; font-size: 12.5px; }
  .thumb-mini { width: 40px; height: 40px; }

  /* form */
  .edit-form .card.section { padding: 16px; }
  .identity-row { flex-direction: column; align-items: center; gap: 16px; }
  .identity-row .identity-fields { width: 100%; }
  .sticky-save .btn { width: 100%; justify-content: center; }

  /* time picker rows */
  .time-row { gap: 6px; }
  .time-row input[type=time] { flex: 1; }

  /* calendar — compact */
  .cal-header > div { padding: 8px 4px; font-size: 10.5px; }
  .cal-day { min-height: 76px; padding: 4px 5px; }
  .cal-day-num { font-size: 11px; }
  .cal-event {
    font-size: 9.5px; padding: 1px 4px;
    overflow: hidden; white-space: nowrap;
  }
  .cal-event i { width: 8px; height: 8px; }
  .cal-pill { font-size: 9.5px; padding: 1px 4px; }
  .cal-filters { gap: 10px; }
  .cal-select { font-size: 13px; padding: 8px 10px; }

  /* tooltips off on mobile (hover doesn't exist) */
  [data-tooltip]:hover::before,
  [data-tooltip]:hover::after { display: none; }

  /* modal full-width */
  .modal { width: calc(100% - 28px); padding: 20px; }

  /* flash full-width */
  .flash { margin: 14px 14px 0; }

  /* hide thumbnail column on very small screens? — keep it for now, table scrolls */
}

/* ─── extra small screens (under 380px) ─── */
@media (max-width: 380px) {
  .cards { grid-template-columns: 1fr; }
  .card.stat .big { font-size: 22px; }
  .topnav .brand span { display: none; }   /* show only lightning bolt on tiny screens */
}
