:root {
  --bg: #f4f6fa; --panel: #ffffff; --ink: #161b29; --muted: #626c82; --line: #e3e7ef; --brand: #3757d6; --brand-ink: #ffffff;
  --ok: #0f7b55; --warn: #a85a08; --bad: #c2362b; --side: #111726; --side-ink: #a9b3c7; --side-on: #ffffff;
  --soft: color-mix(in srgb, var(--brand) 9%, var(--panel)); --hover: color-mix(in srgb, var(--ink) 4%, var(--panel));
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04); --pop: 0 18px 48px rgba(10, 16, 30, .28);
  color-scheme: light;
}
/* Dark: when the device asks for it (unless the person chose light), or when the person chose dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) { --bg: #0c111b; --panel: #151b29; --ink: #e6eaf3; --muted: #8f9bb3; --line: #232c41; --brand: #7089ff; --brand-ink: #0a0f1d;
    --ok: #3ccf9b; --warn: #f0a24b; --bad: #ff7a70; --side: #080c15; --side-ink: #8f9bb3; --shadow: none; --pop: 0 18px 48px rgba(0, 0, 0, .6); color-scheme: dark; }
}
:root[data-theme=dark] { --bg: #0c111b; --panel: #151b29; --ink: #e6eaf3; --muted: #8f9bb3; --line: #232c41; --brand: #7089ff; --brand-ink: #0a0f1d;
  --ok: #3ccf9b; --warn: #f0a24b; --bad: #ff7a70; --side: #080c15; --side-ink: #8f9bb3; --shadow: none; --pop: 0 18px 48px rgba(0, 0, 0, .6); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }
.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- shell and sidebar ---- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 14px 10px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.brand { color: var(--side-on); font-weight: 700; font-size: 16px; padding: 4px 10px 12px; letter-spacing: -.01em; }
.brand small { display: block; font-weight: 400; color: var(--side-ink); font-size: 12px; letter-spacing: 0; }
.navscroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px 8px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.navgroup { display: flex; flex-direction: column; gap: 1px; margin-bottom: 10px; }
.navhead { display: flex; align-items: center; width: 100%; background: none; border: 0; cursor: pointer; text-align: left; padding: 6px 10px 4px; color: var(--side-ink); opacity: .75; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; border-radius: 6px; }
.navhead:hover { opacity: 1; }
.navhead .grow { flex: 1; }
.navhead .ico { width: 12px; height: 12px; transition: transform .15s; }
.navgroup.folded .navhead .ico { transform: rotate(-90deg); }
.navgroup.folded { margin-bottom: 2px; }
.side a { color: var(--side-ink); padding: 7px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.side a .grow { flex: 1; min-width: 0; }
.side a:hover { background: rgba(255, 255, 255, .07); color: var(--side-on); text-decoration: none; }
.side a.on { background: var(--brand); color: var(--brand-ink); }
.side :focus-visible { outline-color: #fff; }
.navfoot { border-top: 1px solid rgba(255, 255, 255, .09); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.side .who { padding: 4px 10px; font-size: 12px; }
.side .who label { color: var(--side-ink); }
.side .who select { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: var(--side-on); padding: 5px 8px; }
.side .who select option { color: #111; }
.linkish { background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--side-ink); font-size: 12px; text-transform: capitalize; }
.linkish:hover { color: var(--side-on); text-decoration: underline; }
.mobilebar, .scrim { display: none; }
.main { padding: 24px 32px 48px; min-width: 0; max-width: 1480px; width: 100%; transition: opacity .12s; position: relative; }
.main.busy { opacity: .55; pointer-events: none; }
.main.busy::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 30; background: linear-gradient(90deg, transparent, var(--brand), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: slide 1s linear infinite; }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; min-height: 36px; }
.top .grow { flex: 1; }

.skeleton { display: flex; flex-direction: column; gap: 14px; }
.sk { border-radius: var(--radius); background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 50%, var(--panel)) 37%, var(--line) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.sk-title { height: 28px; width: 220px; border-radius: 8px; } .sk-card { height: 170px; } .sk-card.short { height: 110px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .sk, .main.busy::before, .modal, .toast { animation: none !important; } .main { transition: none; } }

/* ---- surfaces ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.stat { transition: border-color .12s, transform .12s; }
a.stat:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-1px); }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td, tr.click:focus-visible td { background: var(--hover); }
tr.click:focus-visible { outline: none; }
.tablecard { padding: 0; overflow-x: auto; }
.tablecard th { background: color-mix(in srgb, var(--bg) 60%, var(--panel)); position: sticky; top: 0; }
.tablefoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); background: var(--hover); text-decoration: none; }
a.btn { color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); border-color: color-mix(in srgb, var(--brand) 88%, #000); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--panel)); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.solid:hover { background: color-mix(in srgb, var(--bad) 88%, #000); }
.btn.small { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand-ink); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.danger.solid.busy::after { border-color: #fff; border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); box-shadow: none; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:disabled, textarea:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.search { max-width: 320px; }

.chip { display: inline-block; background: var(--soft); color: var(--brand); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 500; margin: 1px 3px 1px 0; }
.chip button { background: none; border: 0; cursor: pointer; padding: 0 0 0 4px; color: inherit; }
.badge { display: inline-block; white-space: nowrap; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 500; background: color-mix(in srgb, var(--muted) 13%, transparent); color: var(--muted); }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.dot { background: var(--brand); color: var(--brand-ink); border-radius: 999px; font-size: 11px; font-weight: 600; padding: 0 7px; }
.side a.on .dot { background: var(--brand-ink); color: var(--brand); }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar.big { width: 52px; height: 52px; font-size: 18px; }
.who-row { display: flex; align-items: center; gap: 10px; }
.who-row > b { white-space: nowrap; }

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.col { background: color-mix(in srgb, var(--bg) 70%, var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); min-width: 248px; width: 248px; padding: 10px; flex: none; }
.col.over { outline: 2px dashed var(--brand); }
.col h3 { margin: 0 0 2px; font-size: 13px; display: flex; justify-content: space-between; }
.col .sum { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.opp { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s; }
.opp:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.opp.won { border-left: 3px solid var(--ok); } .opp.lost, .opp.abandoned { border-left: 3px solid var(--bad); opacity: .75; }
.opp .t { font-weight: 600; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 500; transition: background .12s, border-color .12s; }
.tab:hover { text-decoration: none; background: var(--hover); border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.tab.on, .tab.on:hover { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.inbox { display: grid; grid-template-columns: 330px 1fr; gap: 14px; height: calc(100vh - 116px); }
.convs { overflow-y: auto; padding: 0; }
.conv { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: block; color: inherit; }
.conv:hover { background: var(--hover); text-decoration: none; }
.conv.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--brand); }
.conv .prev { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; padding: 0; min-height: 0; }
.thread .head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 70%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: color-mix(in srgb, var(--muted) 12%, var(--panel)); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.out { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-radius: 14px 14px 4px 14px; }
.bubble .meta { font-size: 11px; opacity: .75; margin-top: 2px; }
.compose { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { min-height: 40px; height: 40px; }

.day { font-weight: 600; margin: 14px 0 6px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot { border: 1px solid var(--brand); color: var(--brand); background: none; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.slot:hover { background: var(--brand); color: var(--brand-ink); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; font-size: 12px; max-height: 320px; margin: 8px 0 0; }
.node { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--panel); }
.arrow { text-align: center; color: var(--muted); line-height: 1.2; }
.flow { display: flex; flex-direction: column; gap: 4px; max-width: 520px; margin-top: 10px; }

/* ---- dialogs and messages ---- */
.overlay { position: fixed; inset: 0; background: rgba(8, 12, 22, .55); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; overflow-y: auto; z-index: 20; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px 22px; width: 100%; max-width: 480px; border: 1px solid var(--line); box-shadow: var(--pop); animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal.wide { max-width: 660px; }
.modal-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { font-size: 17px; margin: 0; flex: 1; line-height: 1.3; }
.modal .x { background: none; border: 0; cursor: pointer; font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; margin: -2px -6px 0 0; border-radius: 6px; }
.modal .x:hover { color: var(--ink); background: var(--hover); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 380px; box-shadow: var(--pop); cursor: pointer; animation: pop .16s ease-out; border-left: 4px solid var(--ok); }
.toast.err { background: var(--bad); color: #fff; border-left-color: rgba(255, 255, 255, .5); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }

.login { max-width: 440px; margin: 12vh auto; padding: 0 16px; }
.login .card { padding: 28px; box-shadow: var(--pop); }
.login h1 { margin-bottom: 6px; }
.login .btn.primary { width: 100%; padding: 9px; margin-top: 4px; }
.err-text { color: var(--bad); margin-top: 8px; }

/* ---- phones and narrow windows: the sidebar becomes a drawer ---- */
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
  .mobilebar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 6; background: var(--side); color: var(--side-on); padding: 8px 12px; }
  .mobilebar b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobilebar .menu { background: none; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
  .mobilebar .menu .ico { width: 20px; height: 20px; }
  .mobilebar .dot:hover { text-decoration: none; }
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: min(280px, 86vw); height: auto; z-index: 15; transform: translateX(-102%); transition: transform .18s ease; }
  .shell.navopen .side { transform: none; box-shadow: var(--pop); }
  .shell.navopen .scrim { display: block; position: fixed; inset: 0; background: rgba(8, 12, 22, .5); z-index: 14; }
  .side a { padding: 9px 10px; }
  .main { padding: 16px 14px 40px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 10px 12px; }
  .stat .n { font-size: 20px; }
  .grid.two { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .convs { max-height: 240px; }
  .thread { min-height: 420px; }
  .bubble { max-width: 88%; }
  .tablecard td:first-child, .tablecard th:first-child { min-width: 150px; }
  .tablecard td { white-space: nowrap; }
  .tablecard td:first-child { white-space: normal; }
  .modal { max-width: calc(100vw - 24px); padding: 16px; }
  .overlay { padding: 4vh 12px; }
  #toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  .top h1 { font-size: 19px; }
}

.week { display: grid; grid-template-columns: 54px repeat(7, minmax(110px, 1fr)); min-width: 860px; }
.wk-corner, .wk-head { position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: center; z-index: 2; color: var(--muted); font-size: 12px; }
.wk-head b { display: block; font-size: 18px; color: var(--ink); }
.wk-head.today b { color: var(--brand); }
.wk-axis { position: relative; border-right: 1px solid var(--line); }
.wk-hour { position: absolute; right: 6px; transform: translateY(-7px); font-size: 11px; color: var(--muted); }
.wk-axis .wk-hour:first-child { transform: none; }
.wk-col { position: relative; border-left: 1px solid var(--line); cursor: cell; background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 47px, var(--line) 47px, var(--line) 48px); }
.wk-avail { position: absolute; left: 0; right: 0; background: var(--soft); opacity: .75; pointer-events: auto; }
.wk-block { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(45deg, var(--line), var(--line) 6px, transparent 6px, transparent 12px); font-size: 11px; color: var(--muted); padding: 2px 6px; overflow: hidden; cursor: pointer; z-index: 1; }
.wk-appt { position: absolute; border: 0; border-left: 3px solid var(--warn); background: var(--panel); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); border-radius: 6px; padding: 3px 6px; text-align: left; font-size: 12px; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; z-index: 1; }
.wk-appt.confirmed { border-left-color: var(--ok); }
.wk-appt.cancelled { opacity: .5; }
.wk-appt span { color: var(--muted); }
.wk-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 1; pointer-events: none; }
.step { margin-bottom: 12px; }
.step-n { background: var(--brand); color: var(--brand-ink); width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.step-links { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; align-items: flex-start; }
textarea.rawjson { min-height: 420px; font: 12px/1.5 ui-monospace, Menlo, monospace; }

.bar { height: 10px; border-radius: 999px; background: var(--soft); overflow: hidden; margin: 12px 0 6px; }
.bar > div { height: 100%; background: var(--brand); transition: width .15s; }
.bar.small { height: 6px; margin: 0; }

.gwrap { padding: 0 2px 10px; }
.gsearch { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .07); color: var(--side-on); }
.gsearch::placeholder { color: var(--side-ink); opacity: .8; }
.gsearch:focus { outline: 2px solid var(--brand); outline-offset: 0; background: rgba(255, 255, 255, .12); }
.gresults { position: fixed; z-index: 60; width: 380px; max-width: calc(100vw - 16px); max-height: 65vh; overflow-y: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); padding: 6px; }
.gresults[hidden] { display: none; }
.ghead { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 8px 4px; }
.gitem { padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.gitem.on { background: var(--soft); }
.gtitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gempty { padding: 14px 10px; color: var(--muted); }
[hidden] { display: none !important; }
.tplpick { width: auto; max-width: 190px; padding: 4px 8px; font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.metric { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); min-width: 0; }
.mval { font-size: 22px; }
.delta { font-size: 12px; font-weight: 600; color: var(--muted); }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.spark { display: block; margin-top: 6px; max-width: 100%; }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--brand); opacity: .12; stroke: none; }
.spark-flat { stroke: var(--line); stroke-width: 1.5; }
.platform { font-weight: 600; margin: 4px 0 6px; }
.topitems { min-width: 220px; max-width: 320px; flex: 1; }
.dot-status { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot-status.ok { background: var(--ok); } .dot-status.bad { background: var(--bad); } .dot-status.warn { background: var(--warn); } .dot-status.run { background: var(--brand); }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 720px; }
.mhead { padding: 8px 6px; text-align: center; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.mcell { min-height: 112px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mcell:hover { background: var(--soft); }
.mcell.off { background: var(--bg); color: var(--muted); }
.mcell.over { outline: 2px solid var(--brand); outline-offset: -2px; background: var(--soft); }
.mnum { font-size: 12px; font-weight: 600; padding: 1px 4px; align-self: flex-start; border-radius: 10px; }
.mcell.today .mnum { background: var(--brand); color: var(--brand-ink); }
.mchip { border: 0; border-left: 3px solid var(--warn); background: var(--panel); color: var(--ink); text-align: left; font-size: 12px; padding: 2px 5px; border-radius: 4px; cursor: grab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.mchip.confirmed { border-left-color: var(--ok); }
.mmore { font-size: 11px; color: var(--muted); padding: 0 4px; }
.mblock { border: 0; background: repeating-linear-gradient(45deg, var(--line), var(--line) 5px, transparent 5px, transparent 10px); color: var(--muted); font-size: 11px; padding: 1px 5px; border-radius: 4px; text-align: left; cursor: pointer; margin-top: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-appt[draggable=true] { cursor: grab; }

.lib { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; align-items: start; }
.libfolders { padding: 8px; position: sticky; top: 14px; }
.libfolder { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.libfolder:hover { background: var(--soft); }
.libfolder.on { background: var(--brand); color: var(--brand-ink); }
.libfolder.on .muted { color: inherit; opacity: .8; }
.libroot.dropping .lib { outline: 2px dashed var(--brand); outline-offset: 6px; border-radius: var(--radius); }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.fcard { display: flex; flex-direction: column; gap: 3px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; cursor: pointer; box-shadow: var(--shadow); min-width: 0; }
.fcard:hover { border-color: var(--brand); }
.fthumb { height: 118px; border-radius: 7px; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 4px; }
.fthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftype { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 6px; background: var(--soft); color: var(--brand); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.ftype.big { min-width: 64px; height: 44px; font-size: 15px; }
.fpreview { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 90px; }
.fpreview img { max-width: 100%; max-height: 360px; border-radius: 4px; }
.fpreview textarea { background: var(--panel); }
.ftext { font: 13px/1.5 ui-monospace, Menlo, monospace; min-height: 220px; }
@media (max-width: 800px) { .lib { grid-template-columns: 1fr; } .libfolders { position: static; display: flex; gap: 4px; overflow-x: auto; } .libfolder { width: auto; flex: none; white-space: nowrap; } .libfolders .btn { width: auto !important; flex: none; margin-top: 0 !important; } }
