/* ==========================================================================
   IT Answers admin
   One stylesheet: design tokens -> base -> app shell -> shared components
   -> dashboard -> legacy page classes (kept so every older page still works).
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Surfaces */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #e2e6ec;
  --border-strong: #cdd3dd;

  /* Text */
  --text: #161c26;
  --muted: #5d6979;

  /* Brand */
  --navy: #2b3a47;
  --navy-deep: #1b2733;
  --navy-light: #3b4d5d;
  --accent: #b3202e;
  --accent-bright: #c52f3d;
  --accent-dark: #7d1520;
  --accent-soft: #fbeaec;
  --on-accent: #ffffff;
  --focus: #2f6fed;

  /* Status */
  --live: #12945a;
  --live-soft: #e3f5ec;
  --warn: #a86a0c;
  --warn-soft: #fbf0dc;
  --success-bg: #e3f5ec;
  --success-text: #11703f;
  --error-bg: #fcebec;
  --error-text: #b3261e;
  --info-soft: #e8eef8;
  --info-text: #35527f;

  /* The dark "desk" console stays dark in both themes */
  --desk-bg: #17212b;
  --desk-bg-2: #1f2b37;
  --desk-line: #2e3b49;
  --desk-text: #eaf0f6;
  --desk-muted: #9aa9b9;

  --font: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: var(--font);
  --font-body: var(--font);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(22, 28, 38, .05);
  --shadow-2: 0 10px 30px rgba(22, 28, 38, .14);

  --field-fs: 14px;
  --rail-w: 248px;
  --topbar-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2029;
    --surface-2: #222a35;
    --border: #2a3340;
    --border-strong: #3a4554;
    --text: #e9edf3;
    --muted: #9aa6b6;
    --navy: #cfd8e3;
    --navy-deep: #e9edf3;
    --navy-light: #2a3340;
    --accent: #d93a49;
    --accent-bright: #e5505e;
    --accent-dark: #ff8a94;
    --accent-soft: #3a1b20;
    --focus: #6d9bff;
    --live: #3ccf8e;
    --live-soft: #14301f;
    --warn: #e5a63d;
    --warn-soft: #36290f;
    --success-bg: #14301f;
    --success-text: #5fd69b;
    --error-bg: #3a1b1d;
    --error-text: #ff8f88;
    --info-soft: #1c2a40;
    --info-text: #9bbcf0;
    --desk-bg: #0d131a;
    --desk-bg-2: #16202a;
    --desk-line: #243140;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 14px 40px rgba(0, 0, 0, .55);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.ico { flex: none; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; z-index: 3000; }
.skip-link:focus { left: 8px; }

h1 { font-family: var(--font); font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin: 0 0 20px; color: var(--text); }
h2 { font-family: var(--font); font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; color: var(--text); }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.text-danger { color: var(--error-text); font-weight: 600; }
kbd {
  font-family: inherit; font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 6px;
}

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail-w);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px 12px;
  overflow-y: auto;
}
.rail-brand, .topbar-brand { display: block; line-height: 0; background: #fff; border-radius: 10px; }
.rail-brand { padding: 8px 12px; margin: 0 6px 18px; align-self: flex-start; }
.rail-brand img { width: 104px; height: auto; }
.rail-nav { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-group-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 12px 4px; }
.rail-link {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 10px;
  font-size: 14.5px; font-weight: 500; color: var(--text);
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
  background: none; border: 0; box-shadow: none; width: 100%; text-align: left; font-family: inherit; cursor: pointer;
}
.rail-link:hover { background: var(--surface-2); text-decoration: none; filter: none; transform: none; box-shadow: none; }
.rail-link .ico { color: var(--muted); }
.rail-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 700; position: relative; }
.rail-link.is-active .ico { color: var(--accent); }
.rail-link.is-active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail-foot { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.rail-who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.rail-who strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-who small { font-size: 12px; color: var(--muted); font-weight: 400; }
.rail-logout:hover { color: var(--error-text); }

.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--navy-deep);
  border: 1px solid var(--border);
}
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }

.count-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--live); color: #fff; font-size: 11.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: none; padding: 5px 10px; }
.topbar-brand img { width: 72px; height: auto; }

.finder {
  flex: 1 1 auto; max-width: 440px; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 14px; font-weight: 400; text-align: left;
  box-shadow: var(--shadow-1); cursor: pointer; transform: none; filter: none;
}
.finder:hover { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-1); transform: none; filter: none; }
.finder-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder-wide { max-width: none; width: 100%; margin-bottom: 10px; }

.topbar-pills { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; text-decoration: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  max-width: 280px;
}
.pill:hover { text-decoration: none; border-color: var(--border-strong); }
.pill .pill-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-clock { font-weight: 700; font-variant-numeric: tabular-nums; }
.pill-timer.is-live { background: var(--desk-bg); color: var(--desk-text); border-color: var(--desk-bg); }
.pill-wa.is-live { background: var(--live-soft); color: var(--success-text); border-color: transparent; }

.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live); flex: none; box-shadow: 0 0 0 0 rgba(18, 148, 90, .55); animation: live-pulse 2s infinite; }
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(18, 148, 90, .5); }
  70% { box-shadow: 0 0 0 7px rgba(18, 148, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 148, 90, 0); }
}

.icon-btn {
  width: 38px; height: 38px; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text); border: 0; border-radius: 10px;
  box-shadow: none; filter: none; transform: none;
}
.icon-btn:hover { background: var(--surface-2); box-shadow: none; filter: none; transform: none; }
.menu-btn { display: none; }

.content { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 56px; }

/* Bottom tab bar (phones / narrow windows) */
.tabbar { display: none; }
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); text-decoration: none;
  background: none; border: 0; border-radius: 0; box-shadow: none; padding: 6px 0; font-family: inherit; cursor: pointer;
  transform: none; filter: none;
}
.tab-item:hover { text-decoration: none; background: none; box-shadow: none; transform: none; filter: none; }
.tab-item.is-active { color: var(--accent); }
.tab-ico { position: relative; display: inline-flex; }
.tab-ico .count-badge { position: absolute; top: -6px; right: -12px; margin: 0; min-width: 18px; height: 18px; font-size: 10.5px; border: 2px solid var(--surface); }

@media (max-width: 959px) {
  .rail { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-brand { display: block; }
  .finder { max-width: none; }
  .finder-kbd { display: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 18px 14px calc(88px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  h1 { font-size: 24px; }
}
@media (max-width: 560px) {
  .finder-text { font-size: 14px; }
  .pill-timer .pill-label { max-width: 84px; }
  .pill-clock:empty { display: none; }
  .pill { padding: 0 11px; }
  .menu-btn { display: none; }
}

/* ---------- Dialogs: finder + menu sheet ---------- */
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); padding: 0; }
dialog::backdrop { background: rgba(10, 16, 24, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

.palette {
  width: min(640px, calc(100vw - 24px)); margin: 11vh auto 0; border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden;
}
.palette[open] { display: flex; flex-direction: column; max-height: 76vh; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; padding: 10px 0; min-width: 0; box-shadow: none; }
.palette-search input::-webkit-search-cancel-button { display: none; }
.palette-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.palette-heading { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.palette-item.is-selected { background: var(--surface-2); }
.palette-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.palette-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-page-ico { width: 30px; text-align: center; color: var(--muted); font-size: 16px; }
.palette-empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.palette-start { margin: 0; }
.palette-item:not(.is-selected) .palette-start { opacity: 0; }
.palette-item:hover .palette-start, .palette-item.is-selected .palette-start { opacity: 1; }
@media (hover: none) { .palette-item:not(.is-selected) .palette-start { opacity: 1; } }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
@media (max-width: 640px) { .palette { margin-top: 8px; } .palette-foot { display: none; } }

.btn-mini {
  padding: 5px 12px; font-size: 12.5px; border-radius: 8px; box-shadow: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
}
.btn-mini:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: none; transform: none; filter: none; }

.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0; max-height: 88vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-2);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-group { margin-top: 14px; }
.sheet-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.sheet-link { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14.5px; text-decoration: none; }
.sheet-link .ico { color: var(--muted); }
.sheet-link.is-active { background: var(--accent-soft); color: var(--accent); }
.sheet-link.is-active .ico { color: var(--accent); }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 2500; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--desk-bg); color: var(--desk-text); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-2); text-decoration: none; border-left: 4px solid var(--live); transition: opacity .3s ease, transform .3s ease;
}
.toast:hover { text-decoration: none; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); }
@media (max-width: 959px) { .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ---------- Buttons ---------- */
button {
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  padding: 10px 18px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  box-shadow: none;
  transition: background .12s ease, transform .1s ease, filter .12s ease;
}
button:hover { background: var(--accent-bright); }
button:active { transform: translateY(1px); }
button:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; transform: none; filter: none; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); margin-right: 8px; }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--error-text); color: #fff; }
.btn-danger:hover { background: #8f1c15; }
.btn-danger:disabled { background: var(--error-bg); color: var(--muted); }
.btn-stop { background: #c2332b; color: #fff; }
.btn-stop:hover { background: #a82820; }
.btn-pause { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-pause:hover { background: var(--surface-2); }
.btn-lg { padding: 14px 26px; font-size: 16px; border-radius: 12px; }

.link-danger, .link-plain {
  background: none; border: none; padding: 0; font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none; box-shadow: none;
}
.link-danger { color: var(--error-text); }
.link-plain { color: var(--accent); margin-right: 12px; }
.link-danger:hover, .link-plain:hover { text-decoration: underline; background: none; transform: none; filter: none; }

.chip-btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; box-shadow: none;
}
.chip-btn:hover { background: var(--surface-2); }

/* ---------- Forms ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="range"]):not([type="color"]),
select, textarea {
  font-family: inherit; font-size: var(--field-fs); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 9px 12px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { width: 100%; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }

.grid-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.grid-form .full-width { grid-column: 1 / -1; }
.grid-form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.grid-form input:not([type="checkbox"]):not([type="radio"]), .grid-form select { width: 100%; }
.form-actions { grid-column: 1 / -1; }
.field-hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

.checkbox-row { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.checkbox-row label { display: flex; align-items: center; gap: 8px; margin: 0; }
/* Inside a .grid-form, the general rules above would stretch checkboxes
   and force labels back to blocks; these keep a checkbox just its own
   size, right next to its words. */
.grid-form .checkbox-row label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; padding: 0; margin: 0; flex: none; }

.search-form { display: flex; gap: 8px; }
.search-form input { padding: 8px 12px; font-size: 14px; }

.flash { padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; margin-bottom: 18px; border: 1px solid transparent; }
.flash.success { background: var(--success-bg); color: var(--success-text); }
.flash.error { background: var(--error-bg); color: var(--error-text); }

/* ---------- Panels, tables, badges ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow-1);
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.panel-header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-header-row h2 { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; }
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-inactive, .badge-cancelled { background: var(--error-bg); color: var(--error-text); }
.badge-renewed { background: var(--info-soft); color: var(--info-text); }
.badge-expired { background: var(--warn-soft); color: var(--warn); }
.badge-status-open { background: var(--error-bg); color: var(--error-text); }
.badge-status-in_progress { background: var(--warn-soft); color: var(--warn); }
.badge-status-resolved { background: var(--success-bg); color: var(--success-text); }
.badge-status-closed { background: var(--info-soft); color: var(--info-text); }
.badge-priority-low { background: var(--surface-2); color: var(--muted); }
.badge-priority-normal { background: var(--info-soft); color: var(--info-text); }
.badge-priority-high { background: var(--warn-soft); color: var(--warn); }
.badge-priority-urgent { background: var(--error-bg); color: var(--error-text); }
.badge-internal { background: var(--warn-soft); color: var(--warn); }

.tab-row { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--muted); text-decoration: none; }
.tab:hover { background: var(--surface-2); text-decoration: none; }
.tab-active { background: var(--navy-deep); color: var(--bg); font-weight: 600; }
.tab-active:hover { background: var(--navy-deep); }

.kv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 12px 6px 0; vertical-align: top; width: 140px; border: 0; }
.kv-table td { padding: 6px 0; border: 0; }

.thread { display: flex; flex-direction: column; gap: 12px; }
.thread-msg { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.thread-msg.admin { background: var(--info-soft); border-color: transparent; }
.thread-msg.client { background: var(--surface); }
.thread-msg.internal { background: var(--warn-soft); border-color: transparent; }
.thread-msg-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.thread-msg-body { font-size: 14px; white-space: pre-wrap; }

.danger-zone { border-color: color-mix(in srgb, var(--error-text) 40%, var(--border)); background: var(--error-bg); }
.danger-zone h2 { color: var(--error-text); }
.danger-zone label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.danger-zone input[type="text"] { width: 100%; max-width: 320px; margin-bottom: 12px; }

.row-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -4px; }

.usage-list { display: flex; flex-direction: column; gap: 14px; }
.usage-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; font-size: 14px; }
.usage-row-top a { color: var(--text); font-weight: 600; }
.usage-row-top a:hover { color: var(--accent); }
.usage-row-top .muted { font-size: 13px; }
.credit-bar-track { background: var(--surface-2); border-radius: 999px; height: 8px; overflow: hidden; }
.credit-bar-fill { height: 100%; border-radius: 999px; background: var(--live); transition: width .2s ease; }
.credit-bar-fill.warning { background: var(--warn); }
.credit-bar-fill.danger { background: var(--error-text); }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; box-shadow: var(--shadow-1); }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.az-jump { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.az-jump a, .az-jump-disabled { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; font-size: 12.5px; font-weight: 700; text-decoration: none; }
.az-jump a { color: var(--accent); background: var(--accent-soft); }
.az-jump a:hover { color: var(--on-accent); background: var(--accent); text-decoration: none; }
.az-jump-disabled { color: var(--border-strong); }
.az-group-row { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.az-group-row td { background: var(--surface-2); font-weight: 700; font-size: 13px; color: var(--muted); padding: 6px 12px; border-bottom: none; }

.section-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.section-jump a {
  padding: 7px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 13.5px; font-weight: 600; text-decoration: none; transition: background .12s ease, color .12s ease;
}
.section-jump a:hover { background: var(--navy-deep); color: var(--bg); border-color: var(--navy-deep); text-decoration: none; }

.back-to-top {
  position: fixed; bottom: 28px; right: 28px; width: 44px; height: 44px; border-radius: 50%; padding: 0;
  background: var(--navy-deep); color: var(--bg); border: none; font-size: 18px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-2); opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s; z-index: 55;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--accent); color: #fff; }

.attachment-dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 14px; font-size: 13px; color: var(--muted); cursor: text; outline: none; }
.attachment-dropzone:focus { border-color: var(--focus); }
.attachment-dropzone input[type="file"] { display: block; margin-top: 8px; font-size: 13px; }
.attachment-preview-item { margin-top: 10px; display: inline-block; }
.attachment-preview-item img { max-width: 200px; max-height: 200px; border-radius: 10px; display: block; margin-bottom: 6px; border: 1px solid var(--border); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 16, 24, .55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: var(--surface); color: var(--text); border-radius: var(--r-lg); padding: 28px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-2); }
.modal h2 { margin-top: 0; }

/* FullCalendar */
#calendar { font-family: inherit; }
.fc { --fc-button-bg-color: var(--accent); --fc-button-border-color: var(--accent);
      --fc-button-hover-bg-color: var(--accent-bright); --fc-button-hover-border-color: var(--accent-bright);
      --fc-button-active-bg-color: var(--accent-dark); --fc-button-active-border-color: var(--accent-dark);
      --fc-today-bg-color: color-mix(in srgb, var(--accent) 7%, transparent);
      --fc-border-color: var(--border); --fc-page-bg-color: transparent;
      --fc-neutral-bg-color: var(--surface-2); --fc-list-event-hover-bg-color: var(--surface-2);
      color: var(--text); }
.fc .fc-button { border-radius: 10px; font-weight: 600; box-shadow: none; }
.fc .fc-toolbar-title { font-size: 19px; font-weight: 700; color: var(--text); }
.fc .fc-col-header-cell-cushion { color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 10px 4px; }
.fc .fc-timegrid-slot-label-cushion, .fc .fc-daygrid-day-number { color: var(--muted); font-size: 12.5px; }
.fc-day-today .fc-col-header-cell-cushion { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; border-radius: 13px; background: var(--accent); color: #fff !important; margin-top: 2px; }
.fc-event, .fc-timegrid-event, .fc-daygrid-event { border-width: 0 0 0 4px !important; border-style: solid; border-radius: 6px; padding: 2px 6px; font-weight: 600; box-shadow: none; }
.fc-event-title, .fc-event-time { font-weight: 600; }

/* ---------- WhatsApp inbox ---------- */
.wa-inbox-layout { display: flex; gap: 16px; align-items: flex-start; }
.wa-conversation-list { width: 300px; flex-shrink: 0; max-height: 72vh; overflow-y: auto; }
.wa-conversation-item { display: block; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: inherit; margin-bottom: 4px; }
.wa-conversation-item:hover { background: var(--surface-2); text-decoration: none; }
.wa-conversation-item.active { background: var(--accent-soft); }
.wa-conversation-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.wa-conversation-preview { font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-thread { flex: 1; display: flex; flex-direction: column; min-height: 60vh; min-width: 0; }
.wa-thread-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 12px; }
.wa-thread-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.wa-bubble { max-width: 72%; padding: 10px 14px; border-radius: 16px; font-size: 14px; }
.wa-bubble-inbound { background: var(--surface-2); align-self: flex-start; border-bottom-left-radius: 5px; }
.wa-bubble-outbound { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.wa-bubble-outbound .muted { color: rgba(255, 255, 255, .78); }
.wa-bubble-outbound .link-plain { color: #fff; text-decoration: underline; }
.wa-bubble-meta { font-size: 11.5px; margin-top: 4px; display: flex; gap: 10px; align-items: center; }
.wa-bubble-media-img, .wa-bubble-media-video { max-width: 100%; border-radius: 10px; display: block; margin-bottom: 4px; }
.wa-bubble-media-audio { width: 100%; margin-bottom: 4px; }
.wa-bubble-media-doc { display: inline-block; color: inherit; text-decoration: underline; font-size: 14px; }
.wa-reply-form { display: flex; gap: 10px; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.wa-reply-form textarea { flex: 1; resize: none; }
@media (max-width: 720px) {
  .wa-inbox-layout { flex-direction: column; }
  .wa-conversation-list { width: 100%; max-height: 220px; }
  .wa-bubble { max-width: 88%; }
}

/* ---------- Timer page ---------- */
.timer-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.timer-row:last-child { border-bottom: none; }
.timer-row-info { display: flex; flex-direction: column; gap: 4px; }
.timer-elapsed { font-size: 24px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--text); }
.timer-row-actions { display: flex; gap: 10px; align-items: center; }
.timer-row-paused { background: var(--warn-soft); margin: 0 -12px; padding: 14px 12px; border-radius: 12px; }
.timer-row-running { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 14px; }
.timer-row-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.timer-elapsed-block { text-align: right; }
.timer-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.timer-side { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.timer-side label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.timer-side input[type="datetime-local"] { width: 100%; }
.timer-side button { width: 100%; }
.timer-side-idle { opacity: .55; }
.timer-preview { font-size: 13px; }
.timer-preview-bad { color: var(--error-text); }
.timer-preview .link-plain { margin-left: 8px; }
.type-toggle { display: flex; gap: 16px; margin-bottom: 14px; }
.type-toggle label { display: flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }

.quick-client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick-client-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); padding: 16px 12px; border-radius: 12px; font-size: 15px; font-weight: 600; text-align: center; box-shadow: none; }
.quick-client-btn:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---------- Dashboard ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-stat { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--muted); text-decoration: none; }
.mini-stat strong { font-size: 15px; color: var(--text); font-weight: 800; }
a.mini-stat:hover { border-color: var(--border-strong); text-decoration: none; }

/* The desk: where a timer starts and where running ones live. The one
   dark, high-contrast block on an otherwise quiet page. */
.desk {
  background: var(--desk-bg); color: var(--desk-text); border-radius: 20px; padding: 22px;
  margin-bottom: 20px; box-shadow: var(--shadow-2); scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.desk-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--desk-text); }
.desk-title .desk-tag { font-size: 12.5px; font-weight: 500; color: var(--desk-muted); }
.desk-form { display: grid; grid-template-columns: minmax(0, 1.6fr) auto minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 10px; align-items: end; }
.desk-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.desk-field > label, .desk-label { font-size: 12.5px; font-weight: 600; color: var(--desk-muted); }
.desk input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), .desk select {
  background: var(--desk-bg-2); border: 1px solid var(--desk-line); color: var(--desk-text);
  height: 46px; border-radius: 12px; padding: 0 14px; font-size: 15px; width: 100%;
}
.desk input::placeholder { color: var(--desk-muted); }
.desk input:focus, .desk select:focus { border-color: #7fb0ff; box-shadow: 0 0 0 3px rgba(127, 176, 255, .25); }
.desk select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--desk-muted) 50%), linear-gradient(135deg, var(--desk-muted) 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 15px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.desk .btn-start { height: 46px; padding: 0 24px; font-size: 15px; border-radius: 12px; display: inline-flex; align-items: center; gap: 8px; background: var(--accent-bright); color: #fff; }
.desk .btn-start:hover { background: #d8404e; }

.seg { display: inline-flex; background: var(--desk-bg-2); border: 1px solid var(--desk-line); border-radius: 12px; padding: 3px; height: 46px; }
.seg label { margin: 0; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg span { display: inline-flex; align-items: center; padding: 0 16px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--desk-muted); cursor: pointer; }
.seg input:checked + span { background: var(--desk-text); color: var(--desk-bg); }
.seg input:focus-visible + span { outline: 2px solid #7fb0ff; outline-offset: 1px; }

.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-2);
  max-height: 300px; overflow-y: auto;
}
.combo-item { padding: 9px 12px; border-radius: 9px; cursor: pointer; display: flex; flex-direction: column; line-height: 1.25; }
.combo-item small { color: var(--muted); font-size: 12.5px; }
.combo-item.is-selected { background: var(--surface-2); }
.combo-item.is-adhoc { color: var(--muted); }

.desk-recents { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.desk-recents .desk-label { margin-right: 4px; }
.desk-chip {
  background: var(--desk-bg-2); color: var(--desk-text); border: 1px solid var(--desk-line);
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; box-shadow: none;
}
.desk-chip:hover { background: var(--desk-line); }
.desk-chip.is-picked { background: var(--desk-text); color: var(--desk-bg); border-color: var(--desk-text); }
.desk-more { margin-top: 12px; }
.desk-more summary { cursor: pointer; font-size: 13px; color: var(--desk-muted); width: fit-content; }
.desk-more summary:hover { color: var(--desk-text); }
.desk-more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.desk-error { margin-top: 10px; color: #ffb4ae; font-size: 13.5px; }

.desk-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--desk-line); }
.desk-section h3 { font-size: 13px; font-weight: 600; color: var(--desk-muted); margin: 0 0 6px; }
.run-card { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--desk-line); }
.run-card:last-child { border-bottom: 0; padding-bottom: 0; }
.run-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.run-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-name a { color: inherit; }
.run-meta { color: var(--desk-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-text { min-width: 0; display: flex; flex-direction: column; }
.run-clock { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.run-card.is-paused .run-clock { color: var(--desk-muted); }
.run-card.is-paused .live-dot { background: #e5a63d; animation: none; }
.run-actions { display: flex; gap: 8px; }
.run-actions form { margin: 0; }
.desk .btn-pause { color: var(--desk-text); border-color: var(--desk-line); background: var(--desk-bg-2); height: 42px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; }
.desk .btn-pause:hover { background: var(--desk-line); }
.desk .btn-stop { height: 42px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; }
.run-adjust { font-size: 12.5px; color: var(--desk-muted); }
.run-adjust:hover { color: var(--desk-text); }
.desk-empty { color: var(--desk-muted); font-size: 14px; padding: 4px 0; }

.ready-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--desk-line); }
.ready-row:last-child { border-bottom: 0; padding-bottom: 0; }
.ready-row .run-text { flex: 1; }
.ready-dur { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.desk .btn-review { height: 38px; padding: 0 16px; background: var(--desk-text); color: var(--desk-bg); display: inline-flex; align-items: center; }
.desk .btn-review:hover { background: #fff; text-decoration: none; }
.desk .link-danger { color: #ffb4ae; }

.dash-grid {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start;
}
.dash-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.dash-grid .panel { margin: 0; min-width: 0; }
.area-wa { grid-area: wa; } .area-renew { grid-area: renew; } .area-clients { grid-area: clients; }
.area-attention { grid-area: attention; } .area-tickets { grid-area: tickets; }
.scroll-box { max-height: 520px; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
a.btn-mini { display: inline-block; text-decoration: none; font-weight: 600; line-height: 1.2; }
a.btn-mini:hover { text-decoration: none; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.panel-title .count-badge { margin: 0; }
.panel-title a.more { font-size: 13.5px; font-weight: 600; }

.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.row-item:first-child { border-top: 0; padding-top: 2px; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.row-title a { color: inherit; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub.wrap { white-space: normal; }
.row-end { text-align: right; flex: none; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row-end strong { color: var(--text); font-weight: 700; }
.row-actions-inline { display: flex; gap: 8px; align-items: center; flex: none; }
.row-actions-inline form { margin: 0; }

.wa-row { align-items: flex-start; }
.wa-row .avatar { background: var(--live-soft); color: var(--success-text); border-color: transparent; }
.wa-count { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 999px; background: var(--live); color: #fff; font-size: 11.5px; font-weight: 700; margin-left: 8px; vertical-align: 1px; }
.wa-time { font-size: 12.5px; color: var(--muted); flex: none; }

.group-label { font-size: 12.5px; font-weight: 700; padding: 14px 0 2px; display: flex; align-items: center; gap: 8px; }
.group-label:first-child { padding-top: 0; }
.group-label.is-overdue { color: var(--error-text); }
.group-label.is-soon { color: var(--warn); }
.group-label.is-later { color: var(--muted); }
.when { font-weight: 700; color: var(--text); }
.when.is-overdue { color: var(--error-text); }
.when.is-soon { color: var(--warn); }

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--error-bg); color: var(--error-text); }
.tag-ok { background: var(--success-bg); color: var(--success-text); }
.tag-info { background: var(--info-soft); color: var(--info-text); }

.empty { color: var(--muted); font-size: 14px; padding: 6px 0 2px; }
.empty strong { color: var(--text); }

/* Client directory */
.dir-tools { display: flex; gap: 10px; margin-bottom: 12px; }
.dir-tools input { flex: 1; min-width: 0; }
.dir-list { max-height: 560px; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.client-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-top: 1px solid var(--border); border-radius: 10px; }
.client-row:first-child { border-top: 0; }
.client-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.client-row .row-body { flex: 1; }
.client-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.client-link:hover { text-decoration: none; }
.client-link:hover .row-title { color: var(--accent); }
.meter { width: 96px; flex: none; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.meter-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 99px; background: var(--live); }
.meter-bar i.warn { background: var(--warn); }
.meter-bar i.low { background: var(--error-text); }
.meter-text { font-size: 12px; color: var(--muted); text-align: right; }
.dir-hidden { display: none !important; }

@media (max-width: 1099px) {
  .dash-grid { grid-template-columns: 1fr; grid-template-areas: "wa" "renew" "attention" "clients" "tickets"; }
  .dash-col { display: contents; }
  .desk-form { grid-template-columns: 1fr 1fr; }
  .desk-form .desk-client { grid-column: 1 / -1; }
  .desk-form .desk-note { grid-column: 1 / -1; }
  .desk-form .desk-go { grid-column: 1 / -1; }
  .desk .btn-start { width: 100%; justify-content: center; height: 52px; font-size: 16px; }
}
@media (max-width: 640px) {
  .desk { padding: 16px; border-radius: 18px; }
  .desk-form { grid-template-columns: 1fr; }
  .seg { width: 100%; }
  .seg label { flex: 1; }
  .seg span { flex: 1; justify-content: center; }
  .run-card { grid-template-columns: 1fr auto; }
  .run-actions { grid-column: 1 / -1; }
  .run-actions form { flex: 1; }
  .run-actions button { width: 100%; justify-content: center; height: 46px; }
  .run-clock { font-size: 26px; }
  .meter { display: none; }
  .desk-more-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
}

/* ---------- Login ---------- */
.login-body { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; margin: 0; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 36px; width: 380px; max-width: 100%; box-shadow: var(--shadow-2); }
.login-card h1 { font-size: 22px; margin: 0 0 6px; text-align: center; }
.login-card .login-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 5px; }
.login-card input:not([type="checkbox"]) { width: 100%; padding: 11px 12px; font-size: 15px; }
.login-card button { width: 100%; margin-top: 22px; padding: 12px; font-size: 15px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand.center { display: block; text-align: center; padding: 0 0 18px; }
.brand-logo { width: 84px; height: auto; display: block; }
.brand.center .brand-logo { width: 180px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 8px 14px; }
.brand-caption { display: block; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; }

/* ---------- Small screens: shared page adjustments ---------- */
@media (max-width: 720px) {
  .stat-row, .grid-form { grid-template-columns: 1fr; }
  .stat-row { gap: 10px; }
  .panel-header-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-form { width: 100%; }
  .search-form input { flex: 1; min-width: 0; }
  .tab-row { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .section-jump { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .section-jump a { white-space: nowrap; }
  .quick-client-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-client-btn { padding: 18px 10px; font-size: 16px; }
  .timer-elapsed { font-size: 26px; }
  .btn-stop { padding: 12px 22px; font-size: 16px; }
  .timer-pair { grid-template-columns: 1fr; }
  .timer-side-idle { display: none; }
  .timer-side input[type="datetime-local"] { font-size: 16px; } /* 16px stops iOS zooming in on focus */
  :root { --field-fs: 16px; }                                /* same reason, for every field */
  .back-to-top { bottom: calc(78px + env(safe-area-inset-bottom)); right: 14px; width: 40px; height: 40px; }
  .tab { display: inline-block; }
  .panel table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .kv-table, .kv-table tbody, .kv-table tr { display: block; width: 100%; }
  .kv-table th, .kv-table td { display: block; width: 100%; padding: 2px 0; white-space: normal; }
  .kv-table th { padding-top: 10px; }
  .thread-msg-head { flex-wrap: wrap; row-gap: 4px; }
}
@media (max-width: 959px) and (min-width: 721px) {
  .back-to-top { bottom: calc(78px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .login-card { padding: 24px; }
  .stat-value { font-size: 22px; }
}

/* ---------- Needs you (dashboard) ---------- */
.needs { margin-bottom: 20px; }
.needs-title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 15px; }
.needs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.need {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow-1); line-height: 1.25;
}
.need:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
.need strong { font-size: 24px; font-weight: 800; letter-spacing: -.02em; min-width: 28px; text-align: center; }
.need span { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.need-danger { border-left-color: var(--error-text); }
.need-danger strong { color: var(--error-text); }
.need-warn { border-left-color: var(--warn); }
.need-warn strong { color: var(--warn); }
.need-info { border-left-color: var(--info-text); }

/* ---------- Shared bits for newer pages ---------- */
.table-wrap { overflow-x: auto; }
.tab-row.is-spaced { margin-bottom: 12px; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }

/* ---------- Client profile tabs ---------- */
.profile-tabs { position: sticky; top: var(--topbar-h); z-index: 40; background: var(--bg); padding-top: 10px; }
.section-jump a.is-active { background: var(--navy-deep); color: var(--bg); border-color: var(--navy-deep); }
.section-jump a .tab-count { font-weight: 500; opacity: .7; margin-left: 4px; }
.has-tabs .panel[data-tab].tab-off { display: none; }
.glance { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -10px 0 18px; font-size: 14px; color: var(--muted); }
.glance strong { color: var(--text); font-weight: 600; }
@media (max-width: 720px) { .needs-grid { grid-template-columns: 1fr 1fr; } .need strong { font-size: 20px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
