/* =========================================================
   Channel Manager — styles
   Change colours here (the :root block) to restyle the site.
   ========================================================= */
:root,
[data-theme="dark"] {
  --bg: #0A100E;
  --side: #0D1513;
  --panel: #111A17;
  --raised: #16211D;
  --hover: #1A2722;
  --line: #1E2B26;
  --line-2: #2A3B34;
  --text: #E8F0EC;
  --muted: #8FA39A;
  --faint: #5F7069;
  --accent: #F2B533;
  --accent-2: #FFCB5C;
  --accent-ink: #2A1E00;
  --accent-soft: rgba(242, 181, 51, .13);
  --accent-line: rgba(242, 181, 51, .45);
  --warn: #E8A93B;
  --warn-soft: rgba(232, 169, 59, .12);
  --danger: #EF5B6B;
  --danger-soft: rgba(239, 91, 107, .12);
  --info: #7EA6F2;
  --info-soft: rgba(126, 166, 242, .12);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --radius: 14px;
  --side-w: 248px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #F3F6F4;
  --side: #FFFFFF;
  --panel: #FFFFFF;
  --raised: #F4F7F5;
  --hover: #EDF2EF;
  --line: #E1E8E4;
  --line-2: #CFDAD4;
  --text: #13201B;
  --muted: #5C6F67;
  --faint: #8A9A93;
  --accent: #B07F0C;
  --accent-2: #946A08;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(176, 127, 12, .1);
  --accent-line: rgba(176, 127, 12, .45);
  --warn: #B7791F;
  --warn-soft: rgba(183, 121, 31, .1);
  --danger: #D4364A;
  --danger-soft: rgba(212, 54, 74, .09);
  --info: #3B6FD8;
  --info-soft: rgba(59, 111, 216, .09);
  --shadow: 0 18px 50px rgba(19, 32, 27, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }

svg.i { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
  background: var(--side); border-right: 1px solid var(--line);
  padding: 22px 14px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 8px; min-width: 0; }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-mark svg.i { width: 28px; height: 28px; stroke-width: 0; fill: currentColor; }
.brand-name { font-size: 19px; line-height: 1; font-weight: 800; letter-spacing: -.3px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 6px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  height: 42px; padding: 0 12px; background: none; border: 0; border-radius: 10px;
  cursor: pointer; color: var(--muted); font-weight: 500; font-size: 15px; text-align: left;
  transition: background .15s, color .15s;
}
.nav button:hover { background: var(--hover); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; font-weight: 600; min-width: 24px; height: 20px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--raised); color: var(--muted); border: 1px solid var(--line); }
.nav-count:empty { display: none; }
.nav-count.alert { background: var(--danger-soft); color: var(--danger); border-color: rgba(239, 91, 107, .35); }
.nav-count.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(232, 169, 59, .35); }

.side-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-link {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px;
  background: none; border: 0; color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer; text-align: left; width: 100%;
}
.side-link:hover { background: var(--hover); color: var(--text); }
.side-user { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); cursor: pointer; text-align: left; width: 100%; }
.side-user:hover { border-color: var(--line-2); }
.side-user .avatar { width: 34px; height: 34px; border-radius: 10px; }
.side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-user-text b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-text small { color: var(--muted); font-size: 12px; }

.scrim { display: none; }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.mainbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mainbar-title { min-width: 0; flex: 1; }
.mainbar h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.3px; line-height: 1.2; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; margin-top: 2px; }
.status strong { font-weight: 600; color: var(--text); white-space: nowrap; }
.status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); flex: 0 0 auto; }
.status.err .status-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status.busy .status-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.mainbar-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px; color: var(--text);
}
.icon-btn:hover { border-color: var(--line-2); }
.menu-btn { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; cursor: pointer; text-decoration: none;
  font-weight: 600; font-size: 14px; white-space: nowrap; border: 1px solid var(--line-2);
  background: var(--raised); color: var(--text); transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-line { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.btn-line:hover { border-color: var(--accent); }
.btn-solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-solid:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-warn { background: var(--warn-soft); border-color: rgba(232, 169, 59, .45); color: var(--warn); }
.btn-danger { background: var(--danger-soft); border-color: rgba(239, 91, 107, .45); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; gap: 5px; }
.btn-sm svg.i { width: 15px; height: 15px; }
.btn-block { width: 100%; height: 44px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- page layouts ---------- */
.page { padding: 24px 28px 64px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.cols { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-wide { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush .panel-head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; flex-wrap: wrap; }
.panel-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 16px; font-weight: 700; flex: 1; min-width: 0; }
.panel-title svg.i { width: 19px; height: 19px; color: var(--muted); }
.panel-title .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--raised); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.panel-title .count:empty { display: none; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.kpi span { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi span svg.i { width: 16px; height: 16px; }
.kpi b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi em { display: block; font-style: normal; color: var(--faint); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.accent b { color: var(--accent); }
.kpi.long b { font-size: 22px; padding-top: 4px; }
.kpi.neg b { color: var(--danger); }
.kpis.inner .kpi { background: var(--raised); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 7px; }
.field small { display: block; color: var(--muted); margin-top: 5px; font-size: 12px; }
input, select {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 10px;
  background: var(--raised); border: 1px solid var(--line-2); color: var(--text); font-size: 15px; outline: none;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.copy-row .btn { height: 42px; }
.form-error { color: var(--danger); margin: -4px 0 14px; }

/* filter bar above tables */
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.filters .search { position: relative; flex: 1 1 240px; }
.filters .search svg.i { position: absolute; left: 13px; top: 12px; color: var(--faint); }
.filters .search input { padding-left: 40px; }
.filters select { width: auto; flex: 0 1 170px; }
.filters .btn { height: 42px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
.panel:not(.flush) .table-wrap { border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); padding: 11px 14px; background: var(--raised); border-bottom: 1px solid var(--line); white-space: nowrap;
}
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th { position: relative; }
th .arrow { position: absolute; margin-left: 3px; opacity: 0; }
th.num .arrow { margin-left: 0; transform: translateX(calc(-100% - 3px)); } /* number columns: arrow sits to the left so it never sticks out */ /* takes no space, so headings line up with the numbers */
th[data-sort]:hover .arrow { opacity: .4; }
th.sorted { color: var(--text); }
th.sorted .arrow { opacity: 1; color: var(--accent); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
tbody tr[data-pick] { cursor: pointer; }
tbody tr.selected td { background: var(--accent-soft); }
tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td .t { font-weight: 600; white-space: nowrap; }
td .s { color: var(--muted); font-size: 12px; white-space: nowrap; }
td a.t { text-decoration: none; }
td a.t:hover { color: var(--accent); }
td.wrap .s, td.wrap .t { white-space: normal; }
.acts { display: flex; gap: 6px; justify-content: flex-end; }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
tfoot td { background: var(--raised); font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }

.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }

.empty { color: var(--muted); padding: 28px 12px; text-align: center; }
.empty svg.i { width: 30px; height: 30px; margin: 0 auto 8px; color: var(--faint); }

/* ---------- preview / notes ---------- */
.preview { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.preview + .preview { margin-top: 12px; }
.preview h4 { margin: 0 0 4px; font-size: 17px; }
.preview .meta { color: var(--muted); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin-top: 14px; }
.facts div span { display: block; color: var(--muted); font-size: 12px; }
.facts div b { font-weight: 600; font-size: 14px; }

.note { border: 1px solid var(--line); background: var(--raised); border-radius: 10px; padding: 12px 14px; color: var(--muted); line-height: 1.55; margin: 0 0 16px; font-size: 14px; }
.note b { color: var(--text); font-weight: 600; }
.note.warn { background: var(--warn-soft); border-color: rgba(232, 169, 59, .4); color: var(--warn); }
.note.ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.note ol { margin: 6px 0 0; padding-left: 20px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.b-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(232, 169, 59, .35); }
.b-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(239, 91, 107, .35); }
.b-info { background: var(--info-soft); color: var(--info); border-color: rgba(126, 166, 242, .35); }
.b-3f { background: rgba(179, 146, 240, .14); color: #B392F0; border-color: rgba(179, 146, 240, .4); }
.b-mute { background: transparent; color: var(--muted); border-color: var(--line-2); }
.owner { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; }
.owner::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c, var(--faint)); }

.owner-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--raised); margin: 0 0 14px; }
.owner-bar i { display: block; height: 100%; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; }
.list-item .s { color: var(--muted); font-size: 13px; }

/* ---------- sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.brand-lg { padding: 0; }
.brand-lg .brand-mark svg.i { width: 40px; height: 40px; }
.brand-lg .brand-name { font-size: 32px; }
.login-sub { color: var(--muted); margin: 8px 0 24px; font-size: 16px; }
.login-help { color: var(--faint); font-size: 13px; margin: 16px 0 0; text-align: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--panel); border: 1px solid var(--accent-line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; max-width: 92vw;
  transition: opacity .2s, transform .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(239, 91, 107, .5); }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); padding: 80px 0; }


/* columns shown only on desktop (lg) or only on phones (sm) */
.sm-only { display: none; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.task { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.task .badge { flex: 0 0 auto; height: 20px; padding: 0 7px; font-size: 11px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .grid-2, .grid-wide { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: min(280px, 84vw);
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .5); }
  .menu-btn { display: grid; }
  .mainbar { padding: 12px 16px; gap: 12px; }
  .mainbar h1 { font-size: 20px; }
  .page { padding: 16px 16px 48px; gap: 16px; }
  .panel { padding: 16px; }
  .panel.flush .panel-head { padding: 14px 16px; }
  .filters { padding: 12px 16px; }
  .filters select { flex: 1 1 140px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi b { font-size: 22px; }
  .split { grid-template-columns: 1fr; }
  .lg-only { display: none; }
  .sm-only { display: table-cell; }
  table.fit-sm { min-width: 0 !important; }
  table.fit-sm th, table.fit-sm td { padding-left: 10px; padding-right: 10px; }
  table.fit-sm th { font-size: 11px; letter-spacing: 0; }
  table.fit-sm .btn-lbl { display: none; }
  table.fit-sm .acts { gap: 4px; }
  table.fit-sm tfoot td.sm-only { display: table-cell; }
  table.fit-sm .btn-sm { width: 34px; height: 34px; padding: 0; }
  table.fit-sm td .t, table.fit-sm td .s { white-space: normal; word-break: break-word; }
}
@media (max-width: 520px) {
  .hide-xs { display: none; }
  .mainbar-actions .btn { width: 42px; padding: 0; }
  .status span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01s !important; }
}
tbody tr.empty-row:hover td { background: none; }
