/* Agency Management · v2 design system
   Light, calm, indigo-accented. No external fonts or scripts (works offline). */

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #8b95a8;
  --line: #e6e8f0;
  --line-2: #eef0f6;

  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-50: #eef0ff;
  --brand-100: #e0e4ff;

  --green: #047857;  --green-50: #e8f8f1;
  --amber: #b45309;  --amber-50: #fff6e0;
  --red: #b91c1c;    --red-50: #fdeceb;
  --sky: #0369a1;    --sky-50: #e6f3fb;
  --slate-50: #eef1f6;
  --soft: #f6f7fb;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
  --font: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }
h1, h2, h3, p { margin: 0; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.i { width: 17px; height: 17px; flex: none; vertical-align: -3px; }
.i.lg { width: 22px; height: 22px; }
.i.sm { width: 14px; height: 14px; vertical-align: -2px; }

/* ------------------------------------------------------------- layout */
.shell { display: grid; grid-template-columns: 262px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 22px 14px; color: #c7cdf5;
  background: linear-gradient(185deg, #14163a 0%, #1b1d4d 55%, #1e1b4b 100%);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 26px; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #818cf8, #4f46e5); color: #fff; font-weight: 800; font-size: 19px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .45);
}
.brand-text b { display: block; font-size: 15px; letter-spacing: -.2px; }
.brand-text small { display: block; color: #9aa3e0; font-size: 11.5px; margin-top: 1px; }

.nav-label { padding: 0 12px; margin: 18px 0 8px; font-size: 10.5px; font-weight: 700; letter-spacing: 1.3px; color: #7e86c9; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0; border-radius: 10px;
  color: #c7cdf5; font-weight: 550; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active { background: rgba(129, 140, 248, .2); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }

.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 6px 8px 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand-100); color: var(--brand-600); font-weight: 800; font-size: 13px;
}
.user-chip b { display: block; color: #fff; font-size: 13px; }
.user-chip small { color: #9aa3e0; }
.signout {
  width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: rgba(255, 255, 255, .06);
  color: #d5d9fb; padding: 9px 12px; border-radius: 10px; font: inherit; font-weight: 550; cursor: pointer;
}
.signout:hover { background: rgba(255, 255, 255, .13); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 14px 34px;
  background: rgba(245, 246, 251, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topsearch { position: relative; flex: 1; min-width: 0; max-width: 520px; }
.topsearch .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topsearch input { padding-left: 38px; background: var(--surface); }
.topbar .spacer { flex: 1; }
.content { padding: 28px 34px 56px; width: 100%; max-width: 1480px; margin: 0 auto; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  padding: 9px 15px; border-radius: var(--radius-sm); font: inherit; font-weight: 650; font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(79, 70, 229, .28); }
.btn.primary:hover { background: var(--brand-600); color: #fff; }
.btn.secondary { background: var(--brand-50); color: var(--brand-600); }
.btn.secondary:hover { background: var(--brand-100); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: #cfd4e4; color: var(--ink); background: var(--surface-2); }
.btn.danger { background: var(--red-50); color: var(--red); }
.btn.danger:hover { background: #fbd9d6; }
.btn.danger-solid { background: var(--red); color: #fff; }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn.full { width: 100%; }
.btn-icon {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); cursor: pointer; padding: 0;
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon.danger:hover { background: var(--red-50); color: var(--red); border-color: #f5c6c2; }
form.inline { display: inline; margin: 0; }

/* ------------------------------------------------------------- cards */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 20px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { font-size: 15px; letter-spacing: -.2px; }
.panel-head p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.panel-head .link { font-size: 12.5px; font-weight: 650; }
.section-gap { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.page-intro { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.page-intro h1 { font-size: 26px; letter-spacing: -.6px; margin-bottom: 4px; }
.page-intro p { color: var(--ink-2); }
.eyebrow { font-size: 10.5px; font-weight: 750; letter-spacing: 1.3px; color: var(--brand); text-transform: uppercase; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------- stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stats-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card { padding: 18px 20px; position: relative; overflow: hidden; }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 14px; }
.stat-icon.blue { background: var(--brand-50); color: var(--brand); }
.stat-icon.green { background: var(--green-50); color: var(--green); }
.stat-icon.amber { background: var(--amber-50); color: var(--amber); }
.stat-icon.red { background: var(--red-50); color: var(--red); }
.stat-label { display: block; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.stat-card strong { display: block; font-size: 26px; letter-spacing: -.7px; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stat-card strong small { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.stat-card > small { color: var(--muted); }

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
  font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 13px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-agency { display: flex; align-items: center; gap: 12px; min-width: 190px; }
.cell-agency b { display: block; color: var(--ink); font-size: 13.5px; }
.cell-agency small { color: var(--muted); }
.table-link { color: var(--ink); }
.table-link:hover b { color: var(--brand); }
.tx-void td { color: var(--muted); }
.tx-void td.amount-cell { text-decoration: line-through; }
.empty { padding: 34px 16px !important; text-align: center; color: var(--muted) !important; }
.empty-state { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty-state .i { width: 30px; height: 30px; margin-bottom: 8px; opacity: .6; }
.empty-state p { margin-bottom: 12px; }

.amount-pos { color: var(--red); font-weight: 650; }      /* agency owes us */
.amount-neg { color: var(--green); font-weight: 650; }    /* agency has credit */
.amount-zero { color: var(--muted); }
.margin-pos { color: var(--green); font-weight: 650; }
.margin-neg { color: var(--red); font-weight: 650; }

/* ---------------------------------------------------- avatars & pills */
.mini-avatar {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--brand-50); color: var(--brand-600); font-weight: 800; font-size: 13px;
}
.mini-avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; background: linear-gradient(135deg, #818cf8, #4f46e5); color: #fff; box-shadow: 0 8px 20px rgba(79, 70, 229, .3); }
.mini-avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.green-pill { background: var(--green-50); color: var(--green); }
.amber-pill { background: var(--amber-50); color: var(--amber); }
.red-pill { background: var(--red-50); color: var(--red); }
.blue-pill { background: var(--brand-50); color: var(--brand-600); }
.sky-pill { background: var(--sky-50); color: var(--sky); }
.gray-pill { background: var(--slate-50); color: #64748b; }
.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ----------------------------------------------------------- alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: 11px; margin-bottom: 14px; font-weight: 550; background: var(--green-50); color: var(--green); border: 1px solid #c4ecd9; }
.alert.error { background: var(--red-50); color: var(--red); border-color: #f6cbc8; }
.alert.warning { background: var(--amber-50); color: var(--amber); border-color: #f5dfae; }
.alert.info { background: var(--sky-50); color: var(--sky); border-color: #c5e3f4; }

.notice { display: flex; gap: 12px; padding: 12px 14px; border-radius: 11px; background: var(--amber-50); color: var(--amber); border: 1px solid #f5dfae; align-items: flex-start; }
.notice.red { background: var(--red-50); color: var(--red); border-color: #f6cbc8; }
.notice b { display: block; }
a.notice:hover { color: var(--amber); filter: brightness(.97); }
a.notice.red:hover { color: var(--red); }
.notice small { color: inherit; opacity: .85; }

/* ------------------------------------------------------ attention list */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line-2); color: inherit; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-row > span:nth-child(2) { min-width: 0; flex: 1; }
.list-row b { display: block; color: var(--ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row small { display: block; color: var(--muted); margin-top: 1px; }
.list-row .tail { margin-left: auto; text-align: right; flex: none; }
.file-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--slate-50); color: #64748b; flex: none; }
.file-icon.pdf { background: var(--red-50); color: var(--red); }
.file-icon.img { background: var(--sky-50); color: var(--sky); }
.file-icon.xls { background: var(--green-50); color: var(--green); }
.file-icon.doc { background: var(--brand-50); color: var(--brand); }
.section-title { font-size: 11px; font-weight: 750; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }

/* ----------------------------------------------------- filters / forms */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding-bottom: 16px; }
.filterbar .grow { flex: 1 1 240px; }
.filterbar .f { display: flex; flex-direction: column; gap: 4px; }
.filterbar label { font-size: 11px; color: var(--muted); font-weight: 650; }
.filterbar select, .filterbar input { min-width: 130px; }

input, select, textarea {
  width: 100%; border: 1px solid #dadfec; border-radius: var(--radius-sm); padding: 9px 12px; background: var(--surface);
  color: var(--ink); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: #8b85f0; box-shadow: 0 0 0 3px rgba(79, 70, 229, .14); }
textarea { resize: vertical; min-height: 70px; }
input:not([type=checkbox]), select { min-height: 40px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
input[type=file] { padding: 8px; background: var(--surface-2); }
::placeholder { color: #a6aec0; }

.form-panel { max-width: 960px; }
.form-section + .form-section { margin-top: 18px; }
.form-section h2 { font-size: 15px; margin-bottom: 4px; }
.form-section > p { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.field .req { color: var(--red); margin-left: 3px; }
.field.check { flex-direction: row; align-items: center; gap: 9px; }
.field.check label { margin: 0; }
.hint { color: var(--muted); }
.field-error { color: var(--red); font-weight: 600; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-2); }
.callout { background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-600); border-radius: 11px; padding: 12px 14px; margin-bottom: 18px; }

/* --------------------------------------------------- agency profile hero */
.profile-hero { padding: 22px; display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.profile-hero .who { flex: 1; min-width: 260px; }
.profile-hero h1 { font-size: 24px; letter-spacing: -.5px; margin: 5px 0 8px; }
.meta-row { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; color: var(--ink-2); font-size: 13px; }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.quick-links { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.chip-link {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 12.5px;
}
.chip-link:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-50); }
.chip-link.wa { color: #047857; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; color: var(--ink-2); font-weight: 650;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { background: var(--slate-50); color: #64748b; font-size: 11px; padding: 1px 7px; border-radius: 99px; }
.tab.active .count { background: var(--brand-50); color: var(--brand-600); }

.balance-card { padding: 20px; display: flex; flex-direction: column; }
.balance-card .action-row { margin-top: auto; padding-top: 14px; }
.balance-card .cur { display: flex; justify-content: space-between; align-items: center; color: var(--ink-2); font-weight: 650; font-size: 12px; }
.balance-card .amount { font-size: 28px; font-weight: 750; letter-spacing: -.8px; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.balance-card .amount small { font-size: 13px; color: var(--muted); font-weight: 650; letter-spacing: 0; }
.balance-card .sub { color: var(--muted); font-size: 12px; }
.meter { height: 7px; border-radius: 99px; background: var(--slate-50); margin: 14px 0 6px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #818cf8, #4f46e5); }
.meter.warn > i { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.meter.over > i { background: linear-gradient(90deg, #f87171, #dc2626); }

.details { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0; margin: 0; }
.details dt, .details dd { padding: 11px 0; border-bottom: 1px solid var(--line-2); margin: 0; }
.details dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.details dd { color: var(--ink); overflow-wrap: anywhere; }
.details dt:last-of-type, .details dd:last-of-type { border-bottom: 0; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.contact-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.contact-card .head { display: flex; gap: 12px; align-items: center; }
.contact-card .head b { display: block; color: var(--ink); }
.contact-card .head small { color: var(--muted); }
.contact-card .lines { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); }
.contact-card .lines span { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.contact-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 12px; font-weight: 650; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.doc-row { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--line-2); }
.doc-row:last-child { border-bottom: 0; }
.doc-row .info { flex: 1; min-width: 0; }
.doc-row .info b { display: block; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .info small { color: var(--muted); }
.doc-row .actions { display: flex; gap: 6px; align-items: center; }
.doc-row.archived { opacity: .6; }

.note { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.note.pinned { background: #fffdf3; border-color: #f4e3a6; }
.note p { white-space: pre-wrap; color: var(--ink); }
.note .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--muted); font-size: 12px; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid #a5b4fc; }
.tl-item b { display: block; color: var(--ink); font-size: 13px; }
.tl-item p { color: var(--ink-2); font-size: 12.5px; overflow-wrap: anywhere; }
.tl-item small { color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; gap: 10px; }
.pager .btns { display: flex; gap: 6px; }

/* ------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-art {
  position: relative; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #e4e7ff; overflow: hidden;
  background: radial-gradient(circle at 18% 12%, rgba(129, 140, 248, .5), transparent 42%), linear-gradient(160deg, #14163a, #1e1b4b 60%, #312e81);
}
.login-art::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%; border: 60px solid rgba(255, 255, 255, .05); }
.login-art h2 { font-size: 34px; line-height: 1.15; letter-spacing: -1px; color: #fff; max-width: 420px; }
.login-art p { margin-top: 14px; color: #b7bef0; max-width: 400px; font-size: 15px; }
.login-art .feats { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; color: #d7dbff; }
.login-art .feats span { display: flex; gap: 10px; align-items: center; }
.login-form-side { display: grid; place-items: center; padding: 30px; background: var(--surface); }
.login-card { width: min(380px, 100%); }
.login-card h1 { font-size: 27px; letter-spacing: -.7px; margin: 6px 0 6px; }
.login-card form { margin-top: 26px; display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 12px; font-weight: 650; color: var(--ink-2); margin-top: 10px; }

/* ------------------------------------------------ preview & statement */
.preview-frame { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.preview-img { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 10px; }

.statement-page { max-width: 1020px; margin: 0 auto; padding: 28px 22px 60px; }
.statement-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; padding: 16px; }
.statement-sheet { padding: 34px 38px; }
.statement-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--ink); padding-bottom: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.statement-head h1 { font-size: 24px; letter-spacing: -.5px; }
.statement-head .co { font-weight: 800; font-size: 16px; color: var(--brand-600); }
.statement-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.statement-meta small { display: block; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; font-size: 10.5px; }
.statement-meta b { font-size: 14px; }
.statement-total td { font-weight: 800; color: var(--ink); border-top: 2px solid var(--ink); border-bottom: 0; background: var(--surface-2); }
.statement-note { margin-top: 22px; color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 70px minmax(0, 1fr); }
  .sidebar { padding: 18px 9px; align-items: center; }
  .brand { padding: 4px 0 22px; }
  .brand-text, .nav-link span, .nav-label, .user-chip > span:not(.avatar), .signout span { display: none; }
  .nav-link { justify-content: center; padding: 12px; }
  .nav-link.active { box-shadow: none; }
  .signout { justify-content: center; padding: 10px; }
  .topbar { padding: 12px 18px; }
  .content { padding: 20px 16px 48px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 640px) {
  .stats-grid, .stats-grid.three, .grid-2.even { grid-template-columns: 1fr; }
  .form-grid, .form-grid.three, .statement-meta { grid-template-columns: 1fr; }
  .details { grid-template-columns: 112px minmax(0, 1fr); }
  .topbar .btn span { display: none; }
  .page-intro h1 { font-size: 22px; }
  .statement-sheet { padding: 22px 18px; }
}

@media print {
  body { background: #fff; }
  .no-print, .sidebar, .topbar { display: none !important; }
  .statement-page { padding: 0; max-width: none; }
  .statement-sheet { border: 0; box-shadow: none; padding: 0; }
  tbody tr:hover td { background: transparent; }
  @page { margin: 16mm; }
}

/* ---- searchable selects (static/js/searchable-select.js) ---- */
.ss { position: relative; min-width: 0; width: 100%; }
.filterbar .ss { min-width: 130px; }
.ss-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; min-height: 0 !important; padding: 0 !important; border: 0 !important; opacity: 0; pointer-events: none; }
.ss-input {
  padding-right: 32px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b95a8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 10px center;
  text-overflow: ellipsis; cursor: text;
}
.ss-list {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid #dadfec;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.ss-list[hidden] { display: none; }
.ss-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
.ss-list li.ss-active { background: var(--brand-50); color: var(--brand-600); }
.ss-list li.ss-selected { font-weight: 650; }
.ss-list li.ss-blank { color: var(--muted); }
.ss-list li.ss-empty { color: var(--muted); cursor: default; }

/* ---- dd/mm/yyyy date boxes (static/js/date-input.js) ---- */
.dmy { position: relative; width: 100%; min-width: 0; }
.dmy .date-input { padding-right: 38px; }
.dmy-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.dmy-btn:hover { background: var(--brand-50); color: var(--brand-600); }
.dmy-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; padding: 0; border: 0; min-height: 0 !important; }
.filterbar .dmy { min-width: 150px; }

/* ---- reports ---- */
.report-card { display: flex; gap: 14px; align-items: flex-start; padding: 18px; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.report-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.report-card b { display: block; font-size: 15px; margin-bottom: 4px; }
.report-card small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.report-card em { display: block; margin-top: 8px; font-style: normal; font-size: 11.5px; font-weight: 650; color: var(--brand-600); }
.report-table tfoot td { border-top: 2px solid var(--line); background: var(--surface-2); }
@page report { size: A4 landscape; margin: 10mm; }
.report-print { page: report; }
@media print {
  .report-table { font-size: 10px; width: 100%; }
  .report-table th, .report-table td { padding: 4px 5px; }
  .report-print .table-wrap { overflow: visible !important; }
  .report-print { box-shadow: none; border: 0; }
  .stats-grid { break-inside: avoid; }
  tr { break-inside: avoid; }
  thead { display: table-header-group; }
}

/* ---- printing a report (Print button / Save as PDF from the browser) ---- */
.report-print { page: report; }
@page report { size: A4 landscape; margin: 10mm; }
@media print {
  .report-print .table-wrap { overflow: visible !important; }
  .report-print table { width: 100%; table-layout: auto; font-size: 9px; }
  .report-print th, .report-print td { padding: 3px 5px; white-space: normal !important; word-break: break-word; }
  .report-print .panel { border: 0; box-shadow: none; padding: 0; margin-bottom: 10px; }
  .report-print thead { display: table-header-group; }
  .report-print tr { break-inside: avoid; }
  .report-print .stats-grid { display: flex; gap: 8px; flex-wrap: wrap; }
  .report-print .stat-card { box-shadow: none; border: 1px solid #ddd; padding: 6px 10px; }
  .main, main, .content { padding: 0 !important; margin: 0 !important; }
}

/* ---- settings sections ---- */
.settings-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-nav { padding: 12px; position: sticky; top: 16px; }
.settings-nav .nav-label { margin: 12px 8px 4px; color: var(--muted); font-size: 10.5px; letter-spacing: .08em; }
.settings-nav .nav-label:first-child { margin-top: 2px; }
.settings-link { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.settings-link:hover { background: var(--surface-2); }
.settings-link.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
@media (max-width: 860px) { .settings-layout { grid-template-columns: 1fr; } .settings-nav { position: static; } }

.room-rows { display: grid; gap: 8px; margin-bottom: 8px; }
.room-row { display: grid; grid-template-columns: 80px 1fr 140px 36px; gap: 8px; align-items: center; }

/* radio groups (refund settlement / target): small, one option per line */
.field input[type=radio] { width: 16px; height: 16px; min-height: 0 !important; padding: 0; margin: 0; flex: none; accent-color: var(--brand); }
.field div[id$="settlement"], .field div[id$="refund_target"] { display: flex; flex-direction: column; gap: 8px; }
.field div[id$="settlement"] > div, .field div[id$="refund_target"] > div { margin: 0; }
.field div[id$="settlement"] label, .field div[id$="refund_target"] label {
  display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }

/* statistics */
.chart-box { padding: 4px 16px 16px; }
.legend-row { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); align-items: center; }
.legend-row i, .donut-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.rank { padding: 0 16px 14px; display: grid; gap: 12px; }
.rank-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-track { height: 8px; background: var(--line-2); border-radius: 99px; margin: 5px 0 3px; overflow: hidden; }
.rank-track span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.rank-sep { border-top: 1px solid var(--line); margin: 4px 16px 14px; }
.donut-box { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; padding: 0 16px 16px; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }

/* ------------------------------------------------------------------ motion
   Subtle, quick animations. Everything is switched off for people who ask their system for reduced motion. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: -200px 0; } to { background-position: 200px 0; } }

.content > * { animation: rise .42s cubic-bezier(.2, .7, .2, 1) both; }
.content > *:nth-child(2) { animation-delay: .05s; }
.content > *:nth-child(3) { animation-delay: .10s; }
.content > *:nth-child(4) { animation-delay: .15s; }
.content > *:nth-child(5) { animation-delay: .20s; }
.content > *:nth-child(n+6) { animation-delay: .25s; }
.stats-grid > * { animation: pop .4s cubic-bezier(.2, .7, .2, 1) both; }
.stats-grid > *:nth-child(2) { animation-delay: .07s; }
.stats-grid > *:nth-child(3) { animation-delay: .14s; }
.stats-grid > *:nth-child(4) { animation-delay: .21s; }
.stats-grid > *:nth-child(n+5) { animation-delay: .28s; }
.alert { animation: slide-in .35s ease both; }
.sidebar .nav-link { transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease; }
.sidebar .nav-link:hover { transform: translateX(3px); }

.btn, .btn-icon, .chip-link, .tab, .pill { transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active, .btn-icon:active { transform: translateY(0) scale(.97); }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn.ghost.is-loading::after, .btn.secondary.is-loading::after { border-color: var(--line); border-top-color: var(--brand); }

.card, .panel { transition: box-shadow .22s ease, transform .22s ease, border-color .22s ease; }
a.card:hover, .stat-card:hover, .report-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(15, 23, 42, .10); }
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background-color: var(--brand-50); }
input, select, textarea { transition: border-color .15s ease, box-shadow .15s ease; }

.rank-track span { transform-origin: left; animation: grow-x .8s cubic-bezier(.2, .7, .2, 1) both; }
.chart-box svg rect { transform-box: fill-box; transform-origin: bottom; animation: grow-y .7s cubic-bezier(.2, .7, .2, 1) both; }
.chart-box svg rect:hover { filter: brightness(1.12); }
.donut-box svg circle { transition: stroke-width .2s ease; animation: pop .6s ease both; }
.donut-box svg circle:hover { stroke-width: 26; }
.tabs .tab.active { animation: pop .25s ease both; }

/* scroll reveal (added by motion.js only when it is running) */
.js-motion .reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.js-motion .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  .js-motion .reveal { opacity: 1; transform: none; }
}
@media print { * { animation: none !important; transition: none !important; } .js-motion .reveal { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ dark theme */
.theme-toggle .when-dark { display: none; }
html[data-theme="dark"] .theme-toggle .when-light { display: none; }
html[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
.theme-toggle.floating { position: fixed; top: 16px; right: 16px; z-index: 50; background: var(--surface); }
html.theme-fade, html.theme-fade * { transition: background-color .35s ease, color .35s ease, border-color .35s ease !important; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1020; --surface: #161a2e; --surface-2: #1c2138; --soft: #1c2138;
  --ink: #e7e9f5; --ink-2: #aab1cc; --muted: #8189a8; --line: #2a3050; --line-2: #222843;
  --brand: #8b93fb; --brand-600: #aab1ff; --brand-50: rgba(139, 147, 251, .13); --brand-100: rgba(139, 147, 251, .24);
  --green: #34d399; --green-50: rgba(52, 211, 153, .13);
  --amber: #fbbf24; --amber-50: rgba(251, 191, 36, .13);
  --red: #f87171;   --red-50: rgba(248, 113, 113, .13);
  --sky: #38bdf8;   --sky-50: rgba(56, 189, 248, .13);
  --slate-50: #232945;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
}
html[data-theme="dark"] .topbar { background: rgba(13, 16, 32, .86); }
html[data-theme="dark"] .sidebar { background: linear-gradient(185deg, #0b0d22 0%, #12143a 55%, #171538 100%); }
html[data-theme="dark"] .btn.primary { background: #5a52e6; color: #fff; }
html[data-theme="dark"] .btn.primary:hover { background: #6c64f2; color: #fff; }
html[data-theme="dark"] .btn.ghost:hover { border-color: #3a4166; }
html[data-theme="dark"] .btn.danger:hover { background: rgba(248, 113, 113, .24); }
html[data-theme="dark"] .btn-icon.danger:hover { border-color: rgba(248, 113, 113, .4); }
html[data-theme="dark"] .btn-icon, html[data-theme="dark"] .btn.ghost { background: var(--surface); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { border-color: #2f3659; color: var(--ink); }
html[data-theme="dark"] input[type=file] { background: var(--surface-2); }
html[data-theme="dark"] ::placeholder { color: #667098; }
html[data-theme="dark"] .alert.error, html[data-theme="dark"] .notice.red { border-color: rgba(248, 113, 113, .35); }
html[data-theme="dark"] .alert.warning, html[data-theme="dark"] .notice { border-color: rgba(251, 191, 36, .35); }
html[data-theme="dark"] .alert.info { border-color: rgba(56, 189, 248, .35); }
html[data-theme="dark"] .gray-pill, html[data-theme="dark"] .tab .count, html[data-theme="dark"] .file-icon { color: #aab1cc; }
html[data-theme="dark"] .note.pinned { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); }
html[data-theme="dark"] .chip-link.wa { color: var(--green); }
html[data-theme="dark"] .ss-list, html[data-theme="dark"] [class*="ss-"] ul { border-color: #2f3659; }
html[data-theme="dark"] tbody tr:hover { background-color: rgba(139, 147, 251, .08); }
html[data-theme="dark"] a.card:hover, html[data-theme="dark"] .stat-card:hover, html[data-theme="dark"] .report-card:hover { box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
html[data-theme="dark"] .login-wrap { background: var(--bg); }
@media print {
  html[data-theme="dark"] {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #f8f9fd; --soft: #f6f7fb; --ink: #0f172a; --ink-2: #475569; --muted: #8b95a8;
    --line: #e6e8f0; --line-2: #eef0f6; --brand: #4f46e5; --brand-600: #4338ca; --brand-50: #eef0ff; --brand-100: #e0e4ff;
    --green: #047857; --green-50: #e8f8f1; --amber: #b45309; --amber-50: #fff6e0; --red: #b91c1c; --red-50: #fdeceb;
    --sky: #0369a1; --sky-50: #e6f3fb; --slate-50: #eef1f6;
  }
  .theme-toggle { display: none !important; }
}

/* an open dropdown must never be covered by the panels that follow it */
.panel:focus-within, .card:focus-within { position: relative; z-index: 40; }

.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--brand); }

.ticked-total { margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--brand-50); color: var(--brand-600); font-size: 13.5px; display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.ticked-total[hidden] { display: none; }

.select-all { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.select-all input { width: auto; }

.view-controls { display: flex; gap: 4px; padding: 0 8px 8px; }
.view-controls button { flex: 1; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: inherit;
  border-radius: 8px; padding: 5px 0; font: inherit; font-size: 13px; cursor: pointer; }
.view-controls button:hover { background: rgba(255, 255, 255, .14); }

/* ------------------------------------------------ top navigation bar (Windows program)
   The menu becomes a bar across the top instead of a column on the left; it wraps onto a second row
   (and drops the labels) on narrow windows, so it always fits the window. */
.shell.layout-top { display: block; min-height: 100vh; }
.shell.layout-top .sidebar {
  position: sticky; top: 0; z-index: 40; height: auto; width: 100%; flex-direction: row; flex-wrap: wrap;
  align-items: center; gap: 2px 4px; padding: 6px 14px;
  background: linear-gradient(90deg, #14163a 0%, #1b1d4d 55%, #1e1b4b 100%);
  box-shadow: 0 2px 10px rgba(10, 12, 40, .25);
}
.shell.layout-top .brand { padding: 0 14px 0 0; margin-right: 6px; border-right: 1px solid rgba(255, 255, 255, .12); }
.shell.layout-top .brand-text small { display: none; }
.shell.layout-top .brand-text b { font-size: 14px; white-space: nowrap; }
.shell.layout-top .nav-label { display: none; }
.shell.layout-top .nav-link { margin: 0; padding: 9px 11px; gap: 8px; font-size: 13.5px; white-space: nowrap; justify-content: flex-start; }
.shell.layout-top .nav-link.active { box-shadow: inset 0 -3px 0 #818cf8; border-radius: 10px 10px 4px 4px; }
.shell.layout-top .sidebar .nav-link:hover { transform: none; }
.shell.layout-top .sidebar-foot {
  margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.shell.layout-top .user-chip { padding: 0 8px 0 0; }
.shell.layout-top .user-chip small, .shell.layout-top .sidebar-foot > small { display: none; }
.shell.layout-top .view-controls { padding: 0; }
.shell.layout-top .view-controls button { padding: 6px 9px; }
.shell.layout-top .signout { width: auto; padding: 8px 10px; }
.shell.layout-top .sidebar-foot form { margin: 0; }
.shell.layout-top .topbar { position: static; padding: 10px 24px; }
.shell.layout-top .content { padding: 22px 24px 48px; }
@media (max-width: 1280px) {
  .shell.layout-top .nav-link span, .shell.layout-top .signout span { display: none; }
  .shell.layout-top .nav-link { padding: 10px 11px; }
  .shell.layout-top .brand-text { display: none; }
  .shell.layout-top .nav-link, .shell.layout-top .signout { position: relative; }
}
@media (max-width: 900px) {
  .shell.layout-top { display: block; }
  .shell.layout-top .sidebar { align-items: center; }
  .shell.layout-top .content { padding: 18px 14px 40px; }
}

/* Name tooltips for the top bar icons (shown instantly on hover or keyboard focus). */
.shell.layout-top [data-tip] { position: relative; }
.shell.layout-top [data-tip]:hover::after, .shell.layout-top [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 8px;
  z-index: 200; padding: 5px 10px; border-radius: 7px; background: #0f172a; color: #fff; font-size: 12px; font-weight: 600;
  line-height: 1.3; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.shell.layout-top [data-tip]:hover::before, .shell.layout-top [data-tip]:focus-visible::before {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 2px; z-index: 200;
  border: 6px solid transparent; border-bottom-color: #0f172a; border-top-width: 0; pointer-events: none;
}
/* Items at the right edge: keep the tooltip inside the window. */
.shell.layout-top .sidebar-foot > :nth-last-child(-n+2)[data-tip]:hover::after,
.shell.layout-top .sidebar-foot form [data-tip]:hover::after { left: auto; right: 0; transform: none; }
/* Labels are visible on wide windows, so only icon-only items need the tooltip there. */
@media (min-width: 1281px) {
  .shell.layout-top .nav-link[data-tip]:hover::after, .shell.layout-top .nav-link[data-tip]:hover::before,
  .shell.layout-top .signout[data-tip]:hover::after, .shell.layout-top .signout[data-tip]:hover::before { display: none; }
}

/* ---- reconnecting screen and drafts */
.conn-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; background: rgba(8, 11, 24, .72); backdrop-filter: blur(4px); }
.conn-card { max-width: 440px; margin: 20px; padding: 28px 26px; border-radius: 16px; text-align: center; background: var(--surface, #fff); color: var(--ink, #0f172a); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.conn-card h2 { margin: 14px 0 6px; font-size: 20px; }
.conn-card p { margin: 6px 0; color: var(--muted, #64748b); line-height: 1.5; }
.conn-card .conn-note { font-size: 13px; }
.conn-card .btn { margin-top: 12px; }
.conn-spinner { width: 36px; height: 36px; margin: 0 auto; border-radius: 50%; border: 4px solid rgba(99, 102, 241, .25); border-top-color: #6366f1; animation: conn-spin 1s linear infinite; }
@keyframes conn-spin { to { transform: rotate(360deg); } }
.conn-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 10001; background: #16a34a; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
.draft-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: rgba(99, 102, 241, .10); border: 1px solid rgba(99, 102, 241, .35); font-size: 14px; }

/* ---- everything can be selected and copied (links and pictures do not start a drag, so a drag selects text) */
body, body * { -webkit-user-select: text; user-select: text; }
a, img { -webkit-user-drag: none; }
body :is(.conn-overlay, [data-ctool]), body :is(.conn-overlay, [data-ctool]) * { -webkit-user-select: none; user-select: none; }
::selection { background: rgba(99, 102, 241, .35); color: inherit; }

/* ---- copy tool */
html.ctool-on, html.ctool-on * { cursor: crosshair !important; }
.ctool-box { position: fixed; z-index: 10002; pointer-events: none; border: 2px solid #6366f1; background: rgba(99, 102, 241, .12); border-radius: 3px; transition: all .05s linear; }
.ctool-hint { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 10004; display: flex; gap: 12px; align-items: center; padding: 8px 14px; border-radius: 10px; background: #1e293b; color: #fff; font: 14px system-ui, sans-serif; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
.ctool-hint button { background: #6366f1; color: #fff; border: 0; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.ctool-menu { position: fixed; z-index: 10004; display: flex; gap: 4px; padding: 6px; border-radius: 12px; background: #1e293b; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.ctool-menu button { background: transparent; color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; font: 14px system-ui, sans-serif; cursor: pointer; white-space: nowrap; }
.ctool-menu button:hover { background: #6366f1; }
.ctool-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 10005; background: #16a34a; color: #fff; padding: 9px 16px; border-radius: 10px; font: 14px system-ui, sans-serif; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
.ctool-toast.bad { background: #dc2626; }
@media print { .ctool-box, .ctool-hint, .ctool-menu, .ctool-toast { display: none !important; } }
.ctool-ctx { flex-direction: column; min-width: 220px; gap: 0; padding: 6px; }
.ctool-ctx button { text-align: left; }

/* ---- who is online (Users and Roles pages) */
.pr { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; }
.pr small { flex-basis: 100%; color: var(--muted); }
.pr-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9aa3b5; align-self: center; }
.pr-dot.online { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .2); }
.pr-dot.away { background: #f59e0b; }
.pr-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 3px 0; }

/* Home page and Appearance settings */
.home-hero { padding: 28px 30px; margin-bottom: 20px; border-radius: var(--radius); color: #fff;
  background: radial-gradient(circle at 15% 10%, rgba(255, 255, 255, .18), transparent 45%), linear-gradient(135deg, var(--brand-600), var(--brand)); box-shadow: var(--shadow); }
.home-hero h1 { font-size: 28px; letter-spacing: -.6px; color: #fff; max-width: 820px; }
.home-hero .eyebrow { color: rgba(255, 255, 255, .8); }
.home-hero .btn.primary { background: #fff; color: var(--brand-600); box-shadow: none; }
.home-hero .btn.primary:hover { background: rgba(255, 255, 255, .88); color: var(--brand-600); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.home-side { display: grid; gap: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.announce { padding: 14px 0; border-top: 1px solid var(--line-2); }
.announce h3 { font-size: 16px; margin: 2px 0 4px; }
.announce p { color: var(--ink-2); }
.announce-meta { font-size: 12.5px; color: var(--muted); }
.announce.latest { border: 1px solid var(--brand-100); background: var(--brand-50); border-radius: var(--radius-sm, 10px); padding: 16px 18px; margin-bottom: 6px; }
.announce.latest h3 { font-size: 19px; }
.home-links { display: grid; gap: 8px; margin-top: 10px; }
.home-links a { display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.home-links a:hover { border-color: var(--brand); background: var(--brand-50); }
.home-links small { color: var(--muted); }
.colour-in { width: 64px; height: 38px; padding: 2px; cursor: pointer; }
.login-preview { height: 130px; margin: 10px 0; border-radius: 10px; border: 1px solid var(--line); background-size: cover; background-position: center; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }

/* Menu categories (drop-downs) */
.sidebar .nav-group { margin: 2px 0; }
.sidebar .nav-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; margin-top: 8px; border-radius: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: 1.3px; color: #7e86c9; user-select: none; }
.sidebar .nav-group > summary::-webkit-details-marker { display: none; }
.sidebar .nav-group > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s ease; opacity: .8; }
.sidebar .nav-group[open] > summary::after { transform: rotate(45deg); }
.sidebar .nav-group > summary:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-group.has-active > summary { color: #c7cdf5; }
.sidebar .nav-group-body { padding-left: 4px; }
@media (max-width: 900px) { .sidebar .nav-group > summary { display: none; } .sidebar .nav-group-body { padding-left: 0; } }
.shell.layout-top .sidebar .nav-group { position: relative; margin: 0; }
.shell.layout-top .sidebar .nav-group > summary { margin: 0; padding: 9px 12px; gap: 8px; font-size: 12px; letter-spacing: .8px; color: #c7cdf5; }
.shell.layout-top .sidebar .nav-group[open] > summary, .shell.layout-top .sidebar .nav-group.has-active > summary { background: rgba(129, 140, 248, .2); color: #fff; }
.shell.layout-top .sidebar .nav-group-body { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 210px; padding: 6px;
  border-radius: 12px; background: #1b1d4d; box-shadow: 0 12px 30px rgba(10, 12, 40, .45); }
.shell.layout-top .sidebar .nav-group-body .nav-link { display: flex; }
.shell.layout-top .sidebar .nav-group-body .nav-link span { display: inline !important; }
.shell.layout-top .sidebar .nav-group-body .nav-link.active { box-shadow: inset 3px 0 0 #818cf8; border-radius: 10px; }

/* Settings list: categories with drop-downs */
.settings-nav .nav-group { margin: 0 0 4px; }
.settings-nav .nav-group > summary { margin-top: 4px; padding: 8px 10px; color: var(--muted); font-size: 11px; }
.settings-nav .nav-group > summary:hover { background: var(--surface-2); color: var(--ink); }
.settings-nav .nav-group.has-active > summary { color: var(--brand-600); }
.settings-nav .nav-group-body { padding: 0 0 4px 6px; }

/* Announcement editor and shown text */
.rich-editor { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.rich-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 10px 10px 0 0; }
.rich-bar button, .rich-bar select, .rich-bar label { height: 30px; min-width: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; margin: 0; width: auto; }
.rich-bar button:hover, .rich-bar label:hover { border-color: var(--brand); }
.rich-bar input[type=color] { width: 22px; height: 20px; padding: 0; border: 0; background: none; cursor: pointer; }
.rich-bar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.rich-area { min-height: 160px; max-height: 420px; overflow: auto; padding: 12px 14px; outline: none; }
.rich-area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rich-body { overflow-wrap: anywhere; line-height: 1.6; }
.rich-body h1, .rich-body h2 { font-size: 20px; margin: 10px 0 6px; }
.rich-body h3, .rich-body h4 { font-size: 16px; margin: 8px 0 4px; }
.rich-body p, .rich-body div { margin: 0 0 6px; }
.rich-body ul, .rich-body ol { margin: 4px 0 8px; padding-left: 24px; }
.rich-body blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--brand); color: var(--ink-2); }
.rich-body hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.rich-body a { text-decoration: underline; }
.rich-body code, .rich-body pre { background: var(--surface-2); border-radius: 6px; padding: 1px 5px; font-family: Consolas, monospace; }

.settings-nav .nav-group > summary { display: flex; background: none; }
.settings-nav .nav-group-body { position: static; background: none; box-shadow: none; min-width: 0; }
.settings-nav .nav-group > summary { list-style: none; cursor: pointer; align-items: center; justify-content: space-between; border-radius: 8px; font-weight: 700; letter-spacing: 1.3px; user-select: none; }
.settings-nav .nav-group > summary::-webkit-details-marker { display: none; }
.settings-nav .nav-group > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .18s ease; opacity: .8; }
.settings-nav .nav-group[open] > summary::after { transform: rotate(45deg); }

/* Without the "Select & copy text" privilege the page text cannot be selected or copied (fields stay usable). */
body.no-copy { -webkit-user-select: none; user-select: none; }
body.no-copy input, body.no-copy textarea, body.no-copy select, body.no-copy [contenteditable] { -webkit-user-select: text; user-select: text; }

/* Account menu: zoom, full screen, version, change password and sign out in one drop-down */
.sidebar-foot { position: relative; }
.user-menu > summary.user-chip { list-style: none; cursor: pointer; border-radius: 10px; padding: 8px 10px; user-select: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary.user-chip::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-135deg); transition: transform .18s ease; opacity: .8; }
.user-menu[open] > summary.user-chip::after { transform: rotate(45deg); }
.user-menu > summary.user-chip:hover, .user-menu[open] > summary.user-chip { background: rgba(255, 255, 255, .08); }
.user-menu-body { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 70; padding: 8px; border-radius: 12px;
  background: #1b1d4d; box-shadow: 0 12px 30px rgba(10, 12, 40, .45); display: flex; flex-direction: column; gap: 4px; }
.user-menu-body .view-controls { padding: 0 0 4px; }
.user-menu-body form { margin: 0; }
.user-menu-body .signout { width: 100%; }
.shell.layout-top .sidebar-foot .user-menu { position: relative; }
.shell.layout-top .user-menu-body { bottom: auto; top: calc(100% + 6px); left: auto; right: 0; min-width: 260px; }
.shell.layout-top .user-menu > summary.user-chip { padding: 5px 10px; }
.shell.layout-top .user-menu-body .signout { width: 100%; padding: 9px 12px; }
.shell.layout-top .user-menu-body .signout span { display: inline !important; }
@media (max-width: 900px) { .shell:not(.layout-top) .user-menu-body { left: 0; right: auto; min-width: 230px; } .shell:not(.layout-top) .user-menu > summary.user-chip::after { display: none; } }

/* Logo and icon */
.brand-mark.has-logo { background: transparent; box-shadow: none; overflow: hidden; }
.brand-logo { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.brand-preview { margin: 10px 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); display: inline-block; }
.brand-preview img { max-width: 120px; max-height: 80px; display: block; }

/* Scroll bars: slim, rounded, follow the theme colours (light, dark and custom accent) */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--brand); background-clip: content-box; }
*::-webkit-scrollbar-thumb:active { background: var(--brand-600); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }
html::-webkit-scrollbar { width: 12px; height: 12px; }
html::-webkit-scrollbar-track { background: color-mix(in srgb, var(--line) 35%, transparent); }
.sidebar { scrollbar-color: rgba(255, 255, 255, .28) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .25); background-clip: content-box; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .45); background-clip: content-box; }
.table-wrap::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 10px; }
.rich-area::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb { background-clip: content-box; }

.sql-row td { padding-top: 0; }
.sql-row summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.sql-list { margin: 8px 0 4px; padding-left: 22px; font-size: 12px; line-height: 1.5; }
.sql-list code { color: var(--ink-2); word-break: break-all; }

/* performance test */
.selftest-bar{height:10px;border-radius:99px;background:var(--line,#e5e7eb);overflow:hidden;margin:10px 0}
.selftest-fill{height:100%;width:0;background:var(--brand,#2563eb);transition:width .3s}
.selftest-summary{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:8px 0 12px}
.selftest-summary .pill{padding:2px 10px;border-radius:99px;font-size:12px;font-weight:600}
.selftest-summary .pill.ok{background:var(--green-50,#dcfce7);color:var(--green,#15803d)}
.selftest-summary .pill.warn{background:var(--amber-50,#fef3c7);color:var(--amber,#b45309)}
.selftest-summary .pill.bad{background:var(--red-50,#fee2e2);color:var(--red,#b91c1c)}
#selftest-rows tr.st-error td{background:var(--red-50,#fee2e2)}
#selftest-rows tr.st-warn td{background:var(--amber-50,#fef3c7)}
