:root {
  /* Theme: black & white by default. --brand / --brand-ink / --brand-soft are set from the agency's brand colour (Settings > Agency & branding). */
  --brand: #111111; --brand-ink: #ffffff; --brand-soft: #efefef; --brand-text: #111111;
  --bg: #ffffff; --panel: #ffffff; --ink: #111111; --muted: #5c5c5c; --line: #e4e4e4;
  --bad: #b42318; --bad-soft: #fee4e2; --warn: #b54708; --warn-soft: #fef0c7; --info: #175cd3; --info-soft: #e0eaff;
  --ok: #067647; --ok-soft: #dcfae6; --ph: #fde7f3; --wk: #f2f4f7; --un: #fbeaea;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--brand-text); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: var(--brand); color: var(--brand-ink); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { font-size: 34px; line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
.auth-hero p { opacity: .85; max-width: 420px; line-height: 1.5; }
.auth-hero ul { padding: 0; list-style: none; display: grid; gap: 10px; opacity: .95; }
.auth-hero li::before { content: "✓"; margin-right: 10px; font-weight: 700; }
.auth-card { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card form { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.auth-card h2 { margin: 0; font-size: 22px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: var(--brand-ink); font-weight: 800; }
.auth-hero .logo-mark { background: rgba(255,255,255,.18); }
@media (max-width: 820px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { padding: 28px 16px; } .auth-hero ul { display: none; } }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.shell.with-ai { grid-template-columns: 220px 1fr 360px; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .logo { padding: 4px 8px 16px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.nav a:hover { background: var(--wk); }
.nav a.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.side .me { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; font-size: 13px; color: var(--muted); }
.main { padding: 22px 26px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin-top: 4px; }
.mobile-nav { display: none; }
@media (max-width: 1180px) { .shell.with-ai { grid-template-columns: 220px 1fr; } .ai { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 100vw); z-index: 30; box-shadow: -8px 0 30px rgba(0,0,0,.15); } .ai.closed { display: none; } }
@media (max-width: 760px) {
  .shell, .shell.with-ai { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .mobile-nav a { white-space: nowrap; padding: 6px 10px; border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--wk); }
  .mobile-nav a.active { background: var(--brand); color: var(--brand-ink); }
  .main { padding: 16px; }
}

/* ---------- components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--ink); }
input, select, textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 80px; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--wk); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; padding: 10px; }
.error { color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; }
.muted { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--wk); color: var(--muted); }
.pill.violation, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warning { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.ok, .pill.published, .pill.active, .pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.draft, .pill.pending, .pill.scheduled { background: var(--warn-soft); color: var(--warn); }
.pill.blocked, .pill.rejected, .pill.failed { background: var(--bad-soft); color: var(--bad); }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.scroll-x { overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; }
.kpi .l { color: var(--muted); font-size: 12px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- roster grid */
.roster { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.roster th, .roster td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; min-width: 34px; height: 38px; padding: 0; }
.roster th.name, .roster td.name { position: sticky; left: 0; background: var(--panel); text-align: left; padding: 0 10px; min-width: 150px; z-index: 1; font-weight: 600; }
.roster thead th { background: var(--panel); font-weight: 600; line-height: 1.2; padding: 4px 0; }
.roster .dow { color: var(--muted); font-weight: 500; font-size: 10px; }
.roster .wk { background: var(--wk); }
.roster .ph { background: var(--ph); }
.roster td.cell { cursor: default; }
.roster.editable td.cell { cursor: pointer; }
.roster.editable td.cell:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
.shift-chip { display: inline-grid; place-items: center; width: 26px; height: 24px; border-radius: 6px; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.shift-chip.manual { box-shadow: inset 0 0 0 2px #fbbf24; }
.shift-chip.bad { background: var(--bad); }
.un-mark { display: inline-grid; place-items: center; width: 26px; height: 24px; border-radius: 6px; background: repeating-linear-gradient(45deg, var(--un), var(--un) 4px, transparent 4px, transparent 8px); color: var(--bad); font-weight: 700; font-size: 10px; }
.roster td.count { font-weight: 600; color: var(--muted); }
.roster td.count.short { color: var(--bad); background: var(--bad-soft); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; align-items: center; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.flags { display: grid; gap: 6px; max-height: 420px; overflow: auto; }
.flag { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: var(--wk); }
.flag .rule { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---------- availability calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .hd { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; }
.cal .day { min-height: 74px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--panel); font-size: 11px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.cal .day:hover { border-color: var(--brand); }
.cal .day.out { opacity: .35; }
.cal .day.ph { background: var(--ph); }
.cal .day .n { font-weight: 700; font-size: 12px; }
.cal .tag { border-radius: 4px; padding: 1px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .tag.unavailable { background: var(--bad-soft); color: var(--bad); }
.cal .tag.available, .cal .tag.preferred { background: var(--ok-soft); color: var(--ok); }
.cal .tag.shift { background: var(--brand-soft); color: var(--brand-text); }
.cal .tag.phn { color: #9d174d; }

/* ---------- assistant panel */
.ai { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.ai header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.ai header b { display: flex; align-items: center; gap: 8px; }
.ai .spark { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 12px; }
.ai .log { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 11px; border-radius: 10px; line-height: 1.45; white-space: pre-wrap; max-width: 92%; }
.msg.bot { background: var(--wk); align-self: flex-start; }
.msg.me { background: var(--brand); color: var(--brand-ink); align-self: flex-end; }
.rulecard { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 6px; background: var(--panel); }
.rulecard .src { color: var(--muted); font-size: 12px; font-style: italic; }
.ai footer { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 8px; }
.ai footer textarea { min-height: 70px; }
.drop { border: 1.5px dashed var(--line); border-radius: 8px; padding: 10px; text-align: center; color: var(--muted); font-size: 12px; cursor: pointer; }
.drop.over { border-color: var(--brand); color: var(--brand-text); }
.fab { position: fixed; right: 18px; bottom: 18px; z-index: 25; border-radius: 999px; padding: 12px 16px; box-shadow: 0 8px 20px rgba(0,0,0,.18); display: none; }
@media (max-width: 1180px) { .fab { display: inline-flex; gap: 8px; } }

/* ---------- modal / toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: min(680px, 100%); max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--wk); padding: 8px 10px; border-radius: 8px; word-break: break-all; user-select: all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand-text); border-color: var(--brand); font-weight: 600; }
.shell > div { min-width: 0; }
.topbar select { width: auto; }
.pill { white-space: nowrap; }
.roster td.cell, .roster thead th { min-width: 32px; }
[hidden] { display: none !important; }
.grid2 > .card, .grid3 > .card { min-width: 0; overflow-x: auto; }
@media (max-width: 760px) { .main { overflow-x: hidden; } }
.roster td.na { background: repeating-linear-gradient(135deg, transparent, transparent 5px, var(--wk) 5px, var(--wk) 7px); }

.client-pick{margin:6px 0 14px;padding:10px;border:1px solid var(--line);border-radius:10px}
.client-pick select{width:100%}
