/* Èsmeralda backend – look and feel of the TalkyPage customer portal (talkypage packages/ui tokens, apps/app shell):
   sidebar of places, pill tabs, cards in a grid, one floating save bar, toasts, keys. Accent: Station X pink. */
:root {
  --font-ui: "Public Sans", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Michroma", var(--font-ui);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --radius-control: 10px; --radius-panel: 16px; --radius-tile: 22px; --radius-pill: 999px;
  --ease: cubic-bezier(0.2, 0, 0, 1); --spring: cubic-bezier(.34, 1.5, .64, 1);
  --color-bg: #f6f6f7; --color-surface: #ffffff; --color-sunken: #f0f1f3;
  --color-text: #14161a; --color-muted: #56585b; --color-faint: #787b7e;
  --color-border: #d1d5d8; --color-border-soft: #e5e8ec; --color-control: #a3a7ab;
  --accent: #e0398f; --accent-ink: #b0216b; --accent-tint: #fde8f2; --gold: #c8973c;
  --action: #4b6dbc; --action-ink: #34508f; --action-tint: #e6f0ff;
  --pos: #207d3f; --pos-tint: #e3f6e6; --neg: #ad4d49; --neg-tint: #ffe9e6; --warn: #9c5e00; --warn-tint: #feeddb;
  --shadow-card: inset 0 1px 0 rgb(255 255 255 / .6), 0 1px 2px rgb(28 25 54 / .05), 0 18px 40px -30px rgb(28 25 54 / .35);
  --gloss: linear-gradient(180deg, rgb(255 255 255 / .55), rgb(255 255 255 / 0) 60%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #15171b; --color-surface: #1d2025; --color-sunken: #101216; --color-text: #f2f4f7; --color-muted: #a1a5aa;
    --color-faint: #7e8389; --color-border: #3b3f45; --color-border-soft: #2a2e34; --color-control: #5a5f66;
    --accent-tint: #3a1a2c; --action-tint: #18233c; --pos-tint: #15301f; --neg-tint: #3a1b1a; --warn-tint: #3a2a12;
    --shadow-card: 0 1px 2px rgb(0 0 0 / .3), 0 18px 40px -30px rgb(0 0 0 / .8); --gloss: none; color-scheme: dark;
  }
}
@font-face { font-family: "Michroma"; src: url("/admin/assets/Michroma-Regular.ttf"); font-display: swap; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/24px var(--font-ui); background: var(--color-bg); color: var(--color-text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #3a1230 0%, #12080f 55%, #07040a 100%); }
.login-card { width: min(420px, 100%); padding: 40px 36px 32px; border-radius: 22px; background: rgb(255 255 255 / .04);
  border: 1px solid rgb(255 255 255 / .1); box-shadow: 0 30px 80px -30px #ff3fa480, inset 0 1px 0 rgb(255 255 255 / .08);
  color: #fff; backdrop-filter: blur(10px); animation: pop .35s var(--spring); }
.login-card .kicker { font: 12px/1 var(--font-display); letter-spacing: .38em; color: #f1cf86; text-transform: uppercase; }
.login-card h1 { margin: 14px 0 6px; font: 30px/1.1 var(--font-display); letter-spacing: .12em; text-transform: uppercase;
  text-shadow: 0 0 18px rgb(255 79 174 / .8); }
.login-card p { margin: 0 0 26px; color: rgb(255 255 255 / .65); font-size: 15px; }
.login-card input { width: 100%; height: 52px; padding: 0 18px; border-radius: 12px; border: 1px solid rgb(255 255 255 / .18);
  background: rgb(0 0 0 / .35); color: #fff; font-size: 17px; transition: border-color .12s, box-shadow .12s; }
.login-card input:focus { outline: none; border-color: #ff4fae; box-shadow: 0 0 0 3px rgb(255 79 174 / .25); }
.login-card button { width: 100%; height: 52px; margin-top: 14px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700;
  font-size: 16px; color: #1a0612; background: linear-gradient(180deg, #ff74bd, #e0398f); box-shadow: 0 10px 30px -10px #ff3fa4;
  transition: transform .12s var(--spring), filter .12s; }
.login-card button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.login-card button:active { transform: translateY(1px) scale(.98); }
.login-msg { min-height: 22px; margin-top: 12px; font-size: 14px; color: #ff9db0; }
.shake { animation: shake .4s; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.app.is-narrow { grid-template-columns: 64px minmax(0, 1fr); }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px;
  background: var(--color-surface); border-right: 1px solid var(--color-border-soft); overflow: hidden auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; border-bottom: 1px solid var(--color-border-soft); margin-bottom: 6px; }
.brand-mark { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #3a1a3c, #0c050d); box-shadow: 0 0 0 2px var(--gold), 0 6px 16px -6px #ff3fa4;
  font: 15px/1 var(--font-display); color: #fff; text-shadow: 0 0 8px #ff4fae; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 18px; }
.brand-sub { font: 10px/14px var(--font-display); letter-spacing: .18em; color: var(--color-muted); text-transform: uppercase; white-space: nowrap; }
.side-group { margin: 10px 10px 2px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--color-faint); }
.side-item { position: relative; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 10px;
  color: var(--color-muted); text-decoration: none; font-size: 14px; font-weight: 550; white-space: nowrap;
  transition: background .12s, color .12s, transform .12s var(--spring); }
.side-item svg { flex: none; width: 20px; height: 20px; }
.side-item:hover { background: var(--color-sunken); color: var(--color-text); transform: translateX(2px); }
.side-item.is-active { color: var(--color-text); background: linear-gradient(90deg, var(--accent-tint), transparent 140%); }
.side-item.is-active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.side-item .key { margin-left: auto; font-size: 11px; color: var(--color-faint); opacity: 0; transition: opacity .12s; }
.side-item:hover .key { opacity: 1; }
.side-item .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--warn); margin-left: auto; animation: breathe 2s infinite; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--color-border-soft); }
.role-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--color-sunken); font-size: 13px; }
.role-chip b { font-weight: 650; }
.is-narrow .brand-text, .is-narrow .side-item span, .is-narrow .side-group, .is-narrow .side-item .key, .is-narrow .role-chip span { display: none; }
.is-narrow .side-item { justify-content: center; padding: 0; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 28px;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent); backdrop-filter: blur(8px); }
.top h1 { margin: 0; font-size: 21px; line-height: 28px; font-weight: 700; letter-spacing: -.01em; }
.top .grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 650;
  background: var(--color-surface); border: 1px solid var(--color-border-soft); color: var(--color-muted); white-space: nowrap; }
.pill .led { width: 8px; height: 8px; border-radius: 999px; background: var(--color-faint); }
.pill.live .led { background: #2fbf6a; box-shadow: 0 0 0 3px rgb(47 191 106 / .2); animation: breathe 2s infinite; }
.pill.call .led { background: var(--accent); box-shadow: 0 0 0 3px rgb(224 57 143 / .25); animation: breathe 1s infinite; }
.pill.off .led { background: var(--neg); }
.main { min-width: 0; padding: 4px 28px 120px; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; margin: 0 0 18px; border-radius: 999px; background: var(--color-sunken); }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 16px; border-radius: 999px;
  color: var(--color-muted); text-decoration: none; font-size: 14px; font-weight: 600; transition: background .12s, color .12s, box-shadow .12s; }
.tab:hover { color: var(--color-text); }
.tab.is-active { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 2px rgb(28 25 54 / .08), 0 1px 8px rgb(28 25 54 / .06); }
.tab .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--warn); }
.page { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 20px; align-items: start; animation: rise .22s var(--ease); }
.page > .wide { grid-column: 1 / -1; }
.hints { position: fixed; left: 236px; right: 0; bottom: 0; padding: 6px 28px; font-size: 12px; color: var(--color-faint);
  background: linear-gradient(transparent, var(--color-bg) 40%); pointer-events: none; text-align: center; }
body.narrow .hints { left: 64px; }

/* ---------------------------------------------------------------- cards and fields */
.card { background: var(--gloss), var(--color-surface); border: 1px solid var(--color-border-soft); border-radius: var(--radius-panel);
  box-shadow: var(--shadow-card); padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card h2 { margin: 0; font-size: 17px; line-height: 24px; font-weight: 700; }
.card .lead { margin: -12px 0 0; color: var(--color-muted); font-size: 14px; line-height: 21px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > label, .field > .label { font-size: 15px; line-height: 21px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
.field .meta { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--color-faint); display: flex; gap: 12px; align-items: baseline; }
.field .meta button { border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; font-size: 12px; font-weight: 600; }
.hint { font-size: 13px; line-height: 19px; color: var(--color-muted); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--color-control); border-radius: var(--radius-control);
  background: var(--color-surface); font-size: 15px; transition: border-color .12s, box-shadow .12s; }
textarea.input { min-height: 120px; padding: 12px 14px; resize: vertical; font: 15px/24px var(--font-ui); }
.input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 60%, var(--color-control)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input.is-dirty { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-tint); }
.num { display: flex; align-items: center; gap: 10px; }
.num .input { width: 130px; }
.num .unit { color: var(--color-muted); font-size: 14px; }
.range { display: flex; align-items: center; gap: 14px; }
.range input[type=range] { flex: 1; accent-color: var(--accent); }
.range output { min-width: 54px; padding: 4px 10px; border-radius: 8px; background: var(--color-sunken); font-weight: 650; font-size: 14px; text-align: center; }
.switch { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--color-control); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s var(--spring); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.is-dirty .track { box-shadow: 0 0 0 3px var(--warn-tint); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 10px 12px; border-radius: 14px;
  border: 1.5px solid var(--color-border-soft); background: var(--color-surface); cursor: pointer; text-align: center; font-size: 13px; font-weight: 600;
  transition: border-color .12s, box-shadow .12s, transform .12s var(--spring); }
.tile:hover { transform: translateY(-2px); border-color: var(--color-border); }
.tile.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint), 0 10px 24px -14px var(--accent); }
.tile svg { width: 64px; height: 100px; }
.tile .sub { font-weight: 500; color: var(--color-muted); font-size: 12px; line-height: 16px; }

/* ---------------------------------------------------------------- buttons, status, tables */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius-control);
  border: 1px solid var(--color-border); background: var(--color-surface); font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--color-text);
  transition: background .12s var(--ease), border-color .12s, transform .12s var(--spring); white-space: nowrap; }
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--color-control); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.97); transition-duration: .06s; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: linear-gradient(180deg, #f052a2, var(--accent)); border-color: var(--accent); color: #fff; box-shadow: 0 6px 18px -8px var(--accent); }
.btn-primary:hover:not(:disabled) { border-color: var(--accent-ink); filter: brightness(1.05); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 8px; font-size: 13px; line-height: 18px; font-weight: 650; }
.status-pos { background: var(--pos-tint); color: var(--pos); } .status-pos::before { content: "✓"; }
.status-neg { background: var(--neg-tint); color: var(--neg); } .status-neg::before { content: "×"; }
.status-warn { background: var(--warn-tint); color: var(--warn); } .status-warn::before { content: "!"; }
.status-call { background: var(--accent-tint); color: var(--accent-ink); } .status-call::before { content: "●"; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; border-radius: 14px; background: var(--color-sunken); }
.stat .v { font-size: 28px; line-height: 34px; font-weight: 750; letter-spacing: -.02em; }
.stat .k { font-size: 13px; color: var(--color-muted); font-weight: 550; }
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border-soft); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; line-height: 18px; font-weight: 650; color: var(--color-muted); padding: 10px 16px; background: var(--color-sunken); }
td { padding: 10px 16px; border-top: 1px solid var(--color-border-soft); vertical-align: middle; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.day { cursor: pointer; } tr.day:hover { background: var(--color-sunken); }
tr.day td:first-child::before { content: "▸"; display: inline-block; width: 16px; color: var(--color-faint); transition: transform .15s; }
tr.day.open td:first-child::before { transform: rotate(90deg); }
tr.sub td { background: color-mix(in srgb, var(--color-sunken) 50%, transparent); font-size: 13px; color: var(--color-muted); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.bars i { width: 5px; border-radius: 2px 2px 0 0; background: var(--accent); opacity: .85; }
.empty { padding: 28px; text-align: center; color: var(--color-muted); font-size: 14px; }
pre.prompt { margin: 0; max-height: 65vh; overflow: auto; padding: 16px; border-radius: 12px; background: var(--color-sunken); font: 12.5px/19px ui-monospace, Menlo, monospace; white-space: pre-wrap; }

/* ---------------------------------------------------------------- save bar, toast, overlay */
.publish { position: fixed; z-index: 30; left: calc(236px + (100vw - 236px) / 2); transform: translateX(-50%); bottom: 34px; display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 18px; border-radius: 16px; background: var(--color-surface); border: 1px solid var(--color-border-soft);
  box-shadow: 0 10px 40px rgb(28 25 54 / .22); animation: rise .25s var(--spring); font-size: 14px; font-weight: 600; }
body.narrow .publish { left: calc(64px + (100vw - 64px) / 2); }
.publish .dot { width: 9px; height: 9px; border-radius: 999px; background: var(--warn); animation: breathe 1.6s infinite; }
.publish kbd, .overlay kbd { font: 11px/1 var(--font-ui); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--color-border); background: var(--color-sunken); }
.toast { position: fixed; z-index: 70; right: 24px; bottom: 34px; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--color-surface); box-shadow: 0 10px 30px rgb(28 25 54 / .2); font-weight: 600; font-size: 14px; animation: rise .22s var(--spring); max-width: 420px; }
.toast.ok::before { content: "✓"; color: var(--pos); font-weight: 800; }
.toast.bad { color: var(--neg); } .toast.bad::before { content: "×"; font-weight: 800; }
.overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgb(20 22 26 / .36); animation: fade .12s; }
.overlay .card { width: min(520px, 92vw); animation: pop .24s var(--spring); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 14px; }

@keyframes rise { from { opacity: 0; transform: translate(var(--tx, 0), 12px); } }
.publish { --tx: -50%; }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes fade { from { opacity: 0; } }
@keyframes breathe { 50% { opacity: .45; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 900px) {
  .app, .app.is-narrow { grid-template-columns: 64px minmax(0, 1fr); }
  .app .brand-text, .app .side-item span, .app .side-group, .app .side-item .key, .app .role-chip span { display: none; }
  .app .side-item { justify-content: center; padding: 0; }
  .main, .top { padding-left: 14px; padding-right: 14px; }
  .page { grid-template-columns: 1fr; }
  .hints { display: none; }
  .publish { left: calc(64px + (100vw - 64px) / 2); }
}
[hidden] { display: none !important; }
.role-chip svg { flex: none; width: 18px; height: 18px; }
.btn-primary kbd { background: rgb(255 255 255 / .22); border-color: transparent; color: #fff; }
.login-card .kicker { letter-spacing: .28em; white-space: nowrap; font-size: 11px; }

/* pause in the top bar (every page): red when on */
.pause-top { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 6px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-weight: 700; background: var(--color-sunken); border: 1px solid var(--color-border); user-select: none; }
.pause-top input { position: absolute; opacity: 0; pointer-events: none; }
.pause-top .track { position: relative; width: 34px; height: 22px; border-radius: 999px; background: var(--color-control); transition: background .15s; }
.pause-top .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 999px; background: #fff; transition: transform .15s; }
.pause-top.is-on { background: var(--neg); border-color: var(--neg); color: #fff; }
.pause-top.is-on .track { background: rgb(255 255 255 / .35); }
.pause-top.is-on .track::after { transform: translateX(12px); }
.pause-top input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* the language switch of a two-language text */
.langs { display: inline-flex; gap: 2px; margin-left: 10px; padding: 2px; border-radius: 999px; background: var(--color-sunken); border: 1px solid var(--color-border-soft); vertical-align: middle; }
.langs .lang { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border: 0; border-radius: 999px; background: none;
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; color: inherit; opacity: .6; }
.langs .lang svg { border-radius: 3px; }
.langs .lang.is-active { background: var(--color-surface); opacity: 1; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.langs .lang .dot { width: 6px; height: 6px; }
button.reset[disabled] { opacity: .4; cursor: default; }
.btn svg { vertical-align: -3px; border-radius: 2px; }
