:root {
  --bg: #0d0e10;
  --surface: #141518;
  --surface-2: #1a1b1f;
  --hover: #1f2025;
  --border: #25262c;
  --border-strong: #33343b;
  --text: #ececee;
  --muted: #8d8e98;
  --faint: #5d5e68;
  --accent: #c4f36b;
  --accent-ink: #141a07;
  --accent-soft: rgb(196 243 107 / 0.12);
  --danger: #f2706b;
  --danger-soft: rgb(242 112 107 / 0.12);
  --warn: #f0b84a;
  --warn-soft: rgb(240 184 74 / 0.12);
  --info: #8fb4ff;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px rgb(0 0 0 / 0.35);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: "Geist Variable", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono Variable", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f4;
    --surface: #ffffff;
    --surface-2: #f1f1ef;
    --hover: #ececea;
    --border: #e3e3df;
    --border-strong: #d2d2cd;
    --text: #17181a;
    --muted: #63646c;
    --faint: #9a9ba2;
    --accent: #4f7a0c;
    --accent-ink: #ffffff;
    --accent-soft: rgb(79 122 12 / 0.1);
    --danger: #c23a34;
    --danger-soft: rgb(194 58 52 / 0.09);
    --warn: #a36a00;
    --warn-soft: rgb(163 106 0 / 0.1);
    --info: #2d5fd1;
    --shadow: 0 1px 2px rgb(23 24 26 / 0.04), 0 12px 32px rgb(23 24 26 / 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
[hidden] { display: none !important; }
a { color: inherit; }
code, .mono, .num { font-family: var(--mono); font-feature-settings: "tnum"; }
code { font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out), transform 120ms var(--ease-out), opacity 150ms;
}
.btn i { font-size: 15px; }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-icon { width: 30px; padding: 0; height: 30px; }
.btn-block { width: 100%; height: 40px; }
.btn.loading { pointer-events: none; opacity: 0.7; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; display: grid; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; margin-top: 10px; }
.login-card p { margin: -8px 0 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px; border-right: 1px solid var(--border); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; letter-spacing: -0.02em; padding: 0 6px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 16px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.nav a i { font-size: 18px; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav a.active i { color: var(--accent); }
.nav em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }

.engine {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  transition: border-color 200ms var(--ease-out), transform 120ms var(--ease-out);
}
.engine:active { transform: scale(0.98); }
.engine-led { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.engine[aria-pressed="true"] .engine-led { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.engine.quiet .engine-led { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.engine-text { display: grid; line-height: 1.25; min-width: 0; }
.engine-text strong { font-size: 13px; font-weight: 600; }
.engine-text small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch { margin-left: auto; width: 30px; height: 18px; border-radius: 99px; background: var(--border-strong); position: relative; flex: none; transition: background-color 200ms var(--ease-out); }
.switch span { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform 220ms var(--ease-out); }
[aria-pressed="true"] > .switch { background: var(--accent); }
[aria-pressed="true"] > .switch span { transform: translateX(12px); background: var(--accent-ink); }

.main { min-width: 0; }
.dry-banner { display: flex; align-items: center; gap: 8px; padding: 9px 32px; background: var(--warn-soft); color: var(--warn); font-size: 13px; border-bottom: 1px solid var(--border); }
.view { padding: 28px 32px 64px; max-width: 1320px; }
.view-enter { animation: view-in 260ms var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.panel-head h2 { font-size: 14px; }
.panel-body { padding: 14px 16px 16px; }

.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); margin-bottom: 16px; }
.kpi { padding: 16px 18px; border-left: 1px solid var(--border); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi label { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.kpi .v { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; }
.kpi .v small { font-size: 14px; color: var(--faint); margin-left: 2px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi-hero .v { font-size: 34px; color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.stack { display: grid; gap: 16px; align-content: start; }

/* chart */
.chart { display: grid; grid-template-columns: repeat(24, 1fr); align-items: end; gap: 4px; height: 150px; padding-top: 8px; }
.bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; cursor: default; }
.bar span { display: block; border-radius: 3px 3px 1px 1px; min-height: 0; transform-origin: bottom; animation: grow 500ms var(--ease-out) both; animation-delay: calc(var(--i) * 14ms); }
.bar .ok { background: var(--accent); opacity: 0.85; }
.bar .err { background: var(--danger); opacity: 0.8; }
.bar .none { height: 2px; background: var(--border-strong); animation: none; }
.bar:hover .ok { opacity: 1; }
@keyframes grow { from { transform: scaleY(0); } }
.chart-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; font-family: var(--mono); margin-top: 8px; }
.tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(3px);
  background: var(--text); color: var(--bg); font-size: 11.5px; padding: 4px 7px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 120ms, transform 160ms var(--ease-out); font-family: var(--mono); z-index: 2;
}
.bar:hover .tip { opacity: 1; transform: translateX(-50%) translateY(0); }

/* lists */
.rows { display: grid; }
.row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.row-min { min-width: 0; }
.ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 16px; flex: none; }
.ico.ok { background: var(--accent-soft); color: var(--accent); }
.ico.err { background: var(--danger-soft); color: var(--danger); }
.ico.warn { background: var(--warn-soft); color: var(--warn); }

.feed { max-height: 420px; overflow: auto; }
.feed .row { animation: feed-in 320ms var(--ease-out); }
@keyframes feed-in { from { opacity: 0; transform: translateY(-4px); } }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 120ms; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 13px; }
td .t { font-weight: 500; }
td .s { color: var(--muted); font-size: 12.5px; }
.cell-actions { display: flex; gap: 4px; justify-content: flex-end; }
.ellipsis { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.err { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: rgb(143 180 255 / 0.12); color: var(--info); }
.pill i { font-size: 13px; }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }

/* toggle */
.toggle { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background-color 200ms var(--ease-out); flex: none; margin: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform 220ms var(--ease-out); }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(14px); background: var(--accent-ink); }

/* forms */
.field { display: grid; gap: 6px; align-content: start; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field small { color: var(--faint); font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=tel], input[type=time], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; transition: border-color 150ms, box-shadow 150ms;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; min-height: 0; }
.form-error:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.settings-group { display: grid; grid-template-columns: 240px 1fr; gap: 32px; padding: 22px 0; border-top: 1px solid var(--border); }
.settings-group:first-of-type { border-top: 0; padding-top: 4px; }
.settings-group h3 { font-size: 14px; }
.settings-group p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 52px; }
.input-suffix em { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--faint); font-size: 12px; pointer-events: none; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--border); }
.segmented button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; transition: background-color 150ms, color 150ms; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); }

/* dialog */
.overlay { position: fixed; inset: 0; background: rgb(5 6 8 / 0.6); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade 180ms var(--ease-out); }
@media (prefers-color-scheme: light) { .overlay { background: rgb(23 24 26 / 0.28); } }
.dialog {
  width: 100%; max-width: 480px; max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  animation: pop 220ms var(--ease-out); transform-origin: center;
}
.dialog.wide { max-width: 760px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.dialog-head h2 { font-size: 16px; }
.dialog-body { padding: 16px 20px; display: grid; gap: 16px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.overlay.closing { animation: fade-out 140ms var(--ease-out) forwards; }
.overlay.closing .dialog { animation: pop-out 140ms var(--ease-out) forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(4px); } }
@keyframes pop-out { to { opacity: 0; transform: scale(0.97); } }

.drawer-overlay { place-items: stretch end; padding: 0; }
.drawer { width: min(560px, 100vw); height: 100dvh; max-height: none; border-radius: 0; border-width: 0 0 0 1px; animation: slide 260ms var(--ease-out); }
.drawer-overlay.closing .drawer { animation: slide-out 180ms var(--ease-out) forwards; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes slide-out { to { transform: translateX(24px); opacity: 0; } }

.steps { display: flex; gap: 6px; }
.steps span { height: 3px; flex: 1; border-radius: 3px; background: var(--border-strong); transition: background-color 250ms var(--ease-out); }
.steps span.on { background: var(--accent); }

/* ads */
.ads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.ad { display: flex; flex-direction: column; overflow: hidden; transition: border-color 150ms; }
.ad:hover { border-color: var(--border-strong); }
.ad.off { opacity: 0.55; }
.ad-preview { padding: 16px; background: var(--surface-2); flex: 1; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; overflow: hidden; max-width: 100%; }
.bubble img, .bubble video { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.bubble .txt { padding: 9px 12px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; max-height: 180px; overflow: hidden; }
.ad-meta { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); }
.ad-meta .t { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drop { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: border-color 150ms, background-color 150ms; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; }
.variants { display: grid; gap: 8px; }

/* empty / skeleton */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 48px 20px; color: var(--muted); }
.empty i { font-size: 30px; color: var(--faint); }
.empty h3 { color: var(--text); font-size: 15px; }
.empty p { margin: 0; max-width: 46ch; }
.skel { background: linear-gradient(90deg, var(--surface-2) 0%, var(--hover) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 60; width: min(360px, calc(100vw - 40px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 13px;
  animation: toast-in 260ms var(--ease-out);
}
.toast i { font-size: 17px; margin-top: 1px; }
.toast.ok i { color: var(--accent); }
.toast.err i { color: var(--danger); }
.toast.out { animation: toast-out 180ms var(--ease-out) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.callout i { font-size: 17px; color: var(--info); margin-top: 1px; }
.callout.warn i { color: var(--warn); }
.callout.err { background: var(--danger-soft); color: var(--danger); }
.callout.err i { color: var(--danger); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar select { width: auto; min-width: 150px; height: 32px; padding: 4px 10px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.kv div { background: var(--surface); padding: 10px 12px; }
.kv label { display: block; color: var(--muted); font-size: 12px; }
.kv strong { font-family: var(--mono); font-weight: 500; font-size: 15px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 20px; margin-top: 12px; }
.tabs button { border: 0; background: none; padding: 9px 10px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 150ms, border-color 150ms; }
.tabs button.on { color: var(--text); border-color: var(--accent); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(4) { border-left: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid var(--border); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { scrollbar-width: none; min-width: 0; position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar .brand span:last-child { display: none; }
  .nav { display: flex; }
  .nav a span, .nav em { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; }
  .engine-text { display: none; }
  #logout { display: none; }
  .view { padding: 20px 16px 48px; }
  .dry-banner { padding: 9px 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi { border-left: 0 !important; border-top: 1px solid var(--border); }
  .kpi:first-child { grid-column: 1 / -1; border-top: 0; }
  .form-grid, .settings-group { grid-template-columns: 1fr; gap: 12px; }
  .kv { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* keep chart tooltips inside the panel at both edges */
.bar:nth-child(-n+4) .tip { left: 0; transform: translateY(3px); }
.bar:nth-child(-n+4):hover .tip { transform: translateY(0); }
.bar:nth-last-child(-n+4) .tip { left: auto; right: 0; transform: translateY(3px); }
.bar:nth-last-child(-n+4):hover .tip { transform: translateY(0); }

/* joiner */
.joiner-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.acc-list { display: grid; gap: 2px; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; background: var(--bg); }
.acc-pick { padding: 6px 8px; border-radius: 6px; transition: background-color 120ms; }
.acc-pick:hover { background: var(--surface-2); }
.acc-pick input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.jobs { display: grid; gap: 0; }
.job { display: grid; gap: 10px; padding: 14px 0; border-top: 1px solid var(--border); }
.job:first-child { border-top: 0; padding-top: 4px; }
.job-top { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.job .t { font-weight: 500; }
.job .s { color: var(--muted); font-size: 12.5px; }
.progress { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 400ms var(--ease-out); }
.progress.active span { background-image: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.35), transparent); background-size: 60px 100%; background-repeat: no-repeat; animation: sweep 1.4s linear infinite; background-color: var(--accent); }
@keyframes sweep { from { background-position: -60px 0; } to { background-position: calc(100% + 60px) 0; } }
@media (max-width: 1100px) { .joiner-grid { grid-template-columns: 1fr; } }

/* avatars + selection */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-weight: 600; flex: none; object-fit: cover; border: 1px solid var(--border); letter-spacing: 0.02em; }
.acc-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sel-cell { width: 36px; padding-right: 0 !important; }
.cb { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; cursor: pointer; vertical-align: middle; }
tbody tr.selected { background: var(--accent-soft); }
.bulkbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  opacity: 0; transform: translateY(-4px); pointer-events: none; height: 0; padding-block: 0; margin-bottom: 0; overflow: hidden;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.bulkbar.on { opacity: 1; transform: none; pointer-events: auto; height: auto; padding-block: 8px; margin-bottom: 12px; }
.bulkbar > span { font-size: 13px; color: var(--muted); margin-right: 4px; }
.bulkbar strong { color: var(--text); font-family: var(--mono); }
.nav em.badge.on { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 6px; font-weight: 600; line-height: 18px; }

/* inbox */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: calc(100dvh - 210px); min-height: 460px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.inbox-tools { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.inbox-tools select { height: 32px; padding: 4px 8px; flex: 1; min-width: 0; }
.inbox-tools .segmented button { padding: 4px 9px; font-size: 12.5px; }
.dlist { overflow-y: auto; flex: 1; padding: 6px; }
.dlg {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; transition: background-color 120ms;
}
.dlg:hover { background: var(--surface-2); }
.dlg.on { background: var(--hover); }
.dlg .row-min { display: grid; gap: 1px; flex: 1; }
.dlg-top { display: flex; justify-content: space-between; gap: 8px; }
.dlg .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg .time { color: var(--faint); font-size: 11.5px; font-family: var(--mono); white-space: nowrap; }
.dlg .s { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg .via { color: var(--faint); font-size: 11.5px; }
.dlg.unread .t { font-weight: 650; }
.dlg.unread .s { color: var(--text); }
.dlg .count { align-self: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font: 600 11.5px/20px var(--mono); text-align: center; }
.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread > .empty { margin: auto; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.thread-head .t { font-weight: 600; }
.thread-head .s { color: var(--muted); font-size: 12.5px; }
.thread-head .back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.msg { max-width: min(560px, 78%); padding: 8px 11px 6px; border-radius: 14px; display: grid; gap: 2px; animation: feed-in 220ms var(--ease-out); }
.msg.in { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--accent-soft); border: 1px solid rgb(196 243 107 / 0.18); border-bottom-right-radius: 4px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg .media { display: inline-flex; gap: 5px; align-items: center; color: var(--muted); font-size: 12.5px; }
.msg time { font-size: 10.5px; color: var(--faint); justify-self: end; font-family: var(--mono); }
.day-sep { align-self: center; margin: 10px 0 4px; }
.day-sep span { font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 2px 10px; border-radius: 99px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); }
.composer textarea { min-height: 38px; max-height: 160px; resize: none; padding: 8px 11px; }
.composer .btn { height: 38px; width: 38px; }

/* analytics */
.grid-2.even { grid-template-columns: 1fr 1fr; }
.delta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.delta.up { color: var(--accent); }
.delta.down { color: var(--danger); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.ok { background: var(--accent); }
.sw.err { background: var(--danger); }
.share { height: 4px; border-radius: 4px; margin-top: 6px; max-width: 260px; }
.share span { display: block; height: 100%; border-radius: 4px; background: var(--accent); min-width: 2px; }
.share.err span { background: var(--danger); }
.heatmap { display: grid; grid-template-columns: 36px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.hm-label { font-size: 11.5px; color: var(--muted); }
.hm-hour { font-size: 10.5px; color: var(--faint); font-family: var(--mono); padding-top: 4px; }
.hm-cell { position: relative; aspect-ratio: 1.6; border-radius: 4px; background: var(--surface-2); }
.hm-cell::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--accent); opacity: var(--a); }
.hm-cell:hover { outline: 2px solid var(--text); outline-offset: 1px; z-index: 2; }
.hm-cell:hover .tip { opacity: 1; transform: translateX(-50%) translateY(0); }
.hm-cell.edge .tip { left: auto; right: 0; transform: translateY(3px); }
.hm-cell.edge:hover .tip { transform: translateY(0); }
.hm-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; }
.hm-scale { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); font-size: 11.5px; }
.hm-scale i { width: 14px; height: 10px; border-radius: 3px; background: var(--surface-2); position: relative; overflow: hidden; }
.hm-scale i::after { content: ""; position: absolute; inset: 0; background: var(--accent); opacity: var(--a); }
.notify-status { margin-top: 12px; }

@media (max-width: 1100px) { .grid-2.even { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .inbox { grid-template-columns: 1fr; height: calc(100dvh - 190px); }
  .inbox.has-sel .inbox-list { display: none; }
  .inbox:not(.has-sel) .thread { display: none; }
  .thread-head .back { display: inline-flex; }
  .heatmap { grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 2px; }
  .hm-hour { font-size: 8.5px; }
}
