/* ServCopilot Hub — admin design system. Navy anchor #2554C7. */

:root {
  --navy: #2554C7;
  --navy-deep: #1B3E95;
  --navy-ink: #10214B;
  --ink: #1A2340;
  --ink-soft: #5A648A;
  --ink-faint: #8B93B4;
  --bg: #F3F5FB;
  --card: #FFFFFF;
  --line: #E3E7F3;
  --line-strong: #CBD2E8;
  --green: #157F5F;
  --green-bg: #E2F5EE;
  --red: #B3372E;
  --red-bg: #FBE9E7;
  --amber: #8A6116;
  --amber-bg: #FBF0D9;
  --blue-bg: #E8EEFB;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 33, 75, .05), 0 8px 24px -12px rgba(16, 33, 75, .12);
  --shadow-pop: 0 24px 64px -16px rgba(16, 33, 75, .28);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex-shrink: 0;
  background: linear-gradient(180deg, #12224E 0%, #0D1A3C 100%);
  color: #C6D0EC;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 20px 18px 16px;
  color: #fff;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #4D7BE8, #2554C7);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff;
  box-shadow: 0 4px 12px -2px rgba(37, 84, 199, .5);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.brand-sub {
  margin-left: 6px; font-size: 9px; font-weight: 800; letter-spacing: .18em;
  color: #7FA0F0; vertical-align: 2px;
}
.side-tenant {
  margin: 0 12px 8px; padding: 8px 10px;
  background: rgba(255,255,255,.06); border-radius: 8px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: #E4EAFA;
}
.side-tenant-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.side-tenant-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: #AAB8DE; font-weight: 500; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.side-link svg { width: 17px; height: 17px; opacity: .85; }
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-link.active { background: rgba(77,123,232,.22); color: #fff; }
.side-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user { padding: 8px 10px 4px; }
.side-user-name { font-size: 12.5px; font-weight: 600; color: #E4EAFA; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-out { font-size: 12px; color: #7FA0F0; }

.main { flex: 1; min-width: 0; padding: 28px 32px 64px; }
.impersonation-bar {
  margin: -12px 0 18px; padding: 8px 14px;
  background: #FFF4D6; border: 1px solid #EAD189; border-radius: 8px;
  color: #6B4E0C; font-size: 13px;
}
.impersonation-bar a { margin-left: 10px; font-weight: 600; }

/* ---------- page furniture ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; color: var(--navy-ink); }
.page-sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--navy-ink); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; margin-bottom: 20px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid.cols-4, .grid.cols-2 { grid-template-columns: 1fr; } }

.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.stat-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--navy-ink); margin-top: 4px; letter-spacing: -.02em; }
.stat-hint { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 10px 16px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-faint); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.rowlink { cursor: pointer; }
table.data tr.rowlink:hover td { background: #F7F9FE; }
.td-main { font-weight: 600; color: var(--navy-ink); }
.td-sub { font-size: 12px; color: var(--ink-soft); }
.td-num { font-variant-numeric: tabular-nums; }

.empty {
  padding: 44px 20px; text-align: center; color: var(--ink-soft);
}
.empty-icon { font-size: 26px; margin-bottom: 8px; }
.empty b { color: var(--ink); display: block; margin-bottom: 3px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.bad { background: var(--red-bg); color: var(--red); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.info { background: var(--blue-bg); color: var(--navy); }
.badge.dim { background: #EEF0F7; color: var(--ink-soft); }

.pill-key {
  font-family: var(--mono); font-size: 11.5px; background: #EEF2FB;
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
  color: var(--navy-deep);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: 9px; border: 1px solid transparent;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .13s; white-space: nowrap;
  text-decoration: none !important;
}
.btn.primary { background: var(--navy); color: #fff; box-shadow: 0 2px 8px -2px rgba(37,84,199,.45); }
.btn.primary:hover { background: var(--navy-deep); }
.btn.ghost { background: var(--card); color: var(--navy-ink); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn.danger { background: var(--card); color: var(--red); border-color: #E7C4C0; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .spin { display: none; }
.btn.loading .spin { display: inline-block; }

/* ---------- forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy-ink); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 8.5px 12px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  font-family: var(--font); font-size: 13.5px; color: var(--ink);
  background: #fff; transition: border-color .12s, box-shadow .12s;
}
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(37,84,199,.14); }
textarea.input { resize: vertical; min-height: 90px; }
.input-row { display: flex; gap: 12px; }
.input-row > .field { flex: 1; }
.input.color-swatch { width: 52px; height: 38px; padding: 3px; cursor: pointer; }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .tk {
  width: 38px; height: 22px; border-radius: 999px; background: #CDD4E8;
  position: relative; transition: background .15s; flex-shrink: 0;
}
.toggle .tk::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s;
}
.toggle input:checked + .tk { background: var(--navy); }
.toggle input:checked + .tk::after { left: 19px; }
.toggle .tl { font-size: 13.5px; font-weight: 600; color: var(--navy-ink); }

/* ---------- code / embed snippet ---------- */
.snippet {
  position: relative; background: #10214B; color: #D6E1FA;
  border-radius: 10px; padding: 14px 16px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre;
}
.snippet .copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,.12); border: 0; color: #fff;
  border-radius: 6px; padding: 4px 10px; font-size: 11.5px; font-weight: 600;
  cursor: pointer;
}
.snippet .copy-btn:hover { background: rgba(255,255,255,.22); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(13, 26, 60, .55);
  display: none; align-items: flex-start; justify-content: center;
  padding: 8vh 16px; z-index: 200; backdrop-filter: blur(2px);
}
.modal-back.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-pop);
  width: 100%; max-width: 460px; overflow: hidden;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { padding: 16px 20px 0; font-size: 16px; font-weight: 700; color: var(--navy-ink); }
.modal-body { padding: 14px 20px 4px; }
.modal-foot { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #10214B; color: #fff; border-radius: 10px;
  padding: 11px 16px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-pop); max-width: 380px;
  animation: toast-in .18s ease-out;
}
.toast.err { background: #7A241D; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 400px at 85% -10%, rgba(77,123,232,.18), transparent),
    radial-gradient(600px 380px at -10% 110%, rgba(37,84,199,.14), transparent),
    var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff;
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-pop); padding: 34px 34px 30px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; color: var(--navy-ink); font-weight: 700; font-size: 17px; }
.auth-title { font-size: 20px; font-weight: 700; color: var(--navy-ink); margin-bottom: 4px; }
.auth-sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 20px; }
.auth-err {
  background: var(--red-bg); color: var(--red); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px; font-weight: 500;
}
.auth-ok {
  background: var(--green-bg); color: var(--green); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px; font-weight: 500;
}

/* ---------- misc ---------- */
.muted { color: var(--ink-soft); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex.between { justify-content: space-between; }
.spacer { flex: 1; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.dropzone {
  border: 2px dashed var(--line-strong); border-radius: 12px;
  padding: 30px 20px; text-align: center; color: var(--ink-soft);
  cursor: pointer; transition: all .15s; background: #FAFBFE;
}
.dropzone:hover, .dropzone.drag { border-color: var(--navy); background: var(--blue-bg); color: var(--navy-deep); }
.dropzone b { color: var(--navy); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
  border: 0; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--navy); border-bottom-color: var(--navy); }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { display: none; }
  .main { padding: 18px 14px 48px; }
}
