:root {
  --brand-gradient: linear-gradient(120deg, #0e2a66 0%, #1a4fb8 60%, #3d6bff 100%);
  --brand-solid: #1a4fb8;
  --brand-deep: #0e2a66;
  --brand-bright: #3d6bff;
  --surface: #ffffff;
  --bg: #f3f5f8;
  --bg-soft: #eef1f6;
  --ink: #152033;
  --muted: #66758a;
  --line: #d9e0ea;
  --line-strong: #c5cedb;
  --danger: #c81e1e;
  --danger-soft: #fde8e8;
  --success: #0f7a4c;
  --success-soft: #e5f7ef;
  --warning: #b76a00;
  --warning-soft: #fff4e0;
  --shadow: 0 10px 30px rgba(14, 42, 102, 0.08);
  --shadow-sm: 0 2px 8px rgba(21, 32, 51, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --header-h: 64px;
  --nav-h: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-solid); text-decoration: none; }
a:hover { text-decoration: underline; }
.related-link { font-weight: 650; border-bottom: 1px solid rgba(23, 70, 165, 0.35); }
.related-link:hover { border-bottom-color: var(--brand-solid); }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

/* ========== Design system: buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:focus-visible { outline: 3px solid rgba(61, 107, 255, 0.35); outline-offset: 2px; }
.btn:disabled, .btn.is-loading { opacity: .65; cursor: wait; }
.btn-primary { background: var(--brand-solid); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1746a5; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-soft); }
.btn-tertiary { background: transparent; color: var(--brand-solid); }
.btn-tertiary:hover:not(:disabled) { background: rgba(26, 79, 184, 0.08); }
.btn-destructive { background: var(--danger); color: #fff; }
.btn-destructive:hover:not(:disabled) { background: #b42318; }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.35); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0.4rem 0.75rem; font-size: 0.86rem; }

/* Compact modern row action buttons */
.action-group {
  display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
}
.btn-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-width: 34px; min-height: 34px; padding: 0.35rem 0.55rem;
  border-radius: 999px; border: 1px solid transparent;
  background: #f3f6fb; color: #334155; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.01em; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.btn-action svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 40, 80, 0.1);
}
.btn-action:focus-visible { outline: 3px solid rgba(61, 107, 255, 0.3); outline-offset: 2px; }
.btn-action:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-action--view { background: #eef4ff; color: #1a4fb8; border-color: #d7e4ff; }
.btn-action--view:hover:not(:disabled) { background: #dfeaff; }
.btn-action--edit { background: #f4f6f8; color: #334155; border-color: #e2e8f0; }
.btn-action--edit:hover:not(:disabled) { background: #e8edf3; }
.btn-action--primary { background: #1a4fb8; color: #fff; border-color: #1a4fb8; }
.btn-action--primary:hover:not(:disabled) { background: #1746a5; }
.btn-action--danger { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.btn-action--danger:hover:not(:disabled) { background: #fee4e2; }
.btn-action--neutral { background: #fff; color: #475569; border-color: #e2e8f0; }
.btn-action--neutral:hover:not(:disabled) { background: #f8fafc; }
.btn-action--success { background: #ecfdf3; color: #027a48; border-color: #a6f4c5; }
.btn-action--success:hover:not(:disabled) { background: #d1fadf; }
.btn-action.is-icon-only { padding: 0.35rem; width: 34px; }
.btn-action .btn-action-label { display: none; }
@media (min-width: 1100px) {
  .btn-action .btn-action-label { display: inline; }
  .btn-action.is-icon-only .btn-action-label { display: none; }
}

/* View canvas detail layout */
.detail-canvas { display: grid; gap: 1.25rem; }
.detail-hero {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 0.85rem; padding: 1.1rem 1.2rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #f7f9fc 0%, #eef3fb 55%, #f8fafc 100%);
  border: 1px solid #e4ebf5;
}
.detail-hero-main { display: grid; gap: 0.35rem; min-width: 0; }
.detail-hero-kicker {
  margin: 0; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.detail-hero-title {
  margin: 0; font-size: 1.35rem; font-weight: 780; letter-spacing: -0.03em; color: var(--ink);
  word-break: break-word;
}
.detail-hero-sub { margin: 0; color: var(--muted); font-size: 0.92rem; }
.detail-hero-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.detail-section {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff;
}
.detail-section-head {
  margin: 0; padding: 0.7rem 1rem; font-size: 0.75rem; font-weight: 750;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  background: #fafbfd; border-bottom: 1px solid var(--line);
}
.detail-kv {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0;
}
.detail-kv-item {
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  display: grid; gap: 0.25rem; min-width: 0;
}
.detail-kv-item:nth-child(2n) { border-right: 0; }
.detail-kv-item.is-full { grid-column: 1 / -1; border-right: 0; }
.detail-kv-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.detail-kv-value {
  font-size: 0.95rem; font-weight: 600; color: var(--ink); word-break: break-word;
}
.detail-kv-value.is-muted { color: var(--muted); font-weight: 500; }
.detail-table-wrap { overflow: auto; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.detail-table th, .detail-table td {
  padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top;
}
.detail-table th {
  font-size: 0.72rem; font-weight: 750; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); background: #fafbfd;
}
.detail-table td.num, .detail-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.detail-empty { padding: 1.25rem; color: var(--muted); text-align: center; }
.detail-related {
  display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.9rem 1rem;
}
.detail-related a {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.75rem; border-radius: 999px;
  background: #eef4ff; color: #1a4fb8; font-size: 0.82rem; font-weight: 700;
  border: 1px solid #d7e4ff; text-decoration: none;
}
.detail-related a:hover { background: #dfeaff; text-decoration: none; }
@media (max-width: 700px) {
  .detail-kv { grid-template-columns: 1fr; }
  .detail-kv-item { border-right: 0; }
}

/* ========== Design system: forms ========== */
.field { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.field label { font-size: 0.9rem; font-weight: 650; color: var(--ink); }
.field .req { color: var(--danger); }
.field-help { margin: 0; color: var(--muted); font-size: 0.82rem; }
.field-error { margin: 0; color: var(--danger); font-size: 0.85rem; }
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #1a4fb8;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  background: #fff;
  color: var(--ink);
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: #1a4fb8;
  box-shadow: 0 0 0 3px rgba(26, 79, 184, 0.22);
}
.filters .input,
.filters .select,
.filters .textarea,
.form-grid .input,
.form-grid .select,
.form-grid .textarea,
.form-section-grid .input,
.form-section-grid .select,
.form-section-grid .textarea,
.table .input,
.table .select {
  border-color: #1a4fb8;
}
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 3.4rem; }
/* Hide browser-native password reveal (Edge/IE/Chrome) — we use the Show/Hide control. */
.input-wrap input[type="password"]::-ms-reveal,
.input-wrap input[type="password"]::-ms-clear,
.input-wrap input[type="text"]::-ms-reveal,
.input-wrap input[type="text"]::-ms-clear {
  display: none;
}
.input-wrap input[type="password"]::-webkit-credentials-auto-fill-button,
.input-wrap input[type="password"]::-webkit-textfield-decoration-container {
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  right: 0;
}
.input-action {
  position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0.4rem 0.55rem;
  z-index: 2;
}
.checkbox-row { display: flex; align-items: center; gap: 0.55rem; margin: 0.25rem 0 1rem; }
.checkbox-row input { width: 16px; height: 16px; }

/* Temporary OTP helper modal (when email is not configured) */
.otp-modal {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; padding: 1rem;
}
.otp-modal[hidden] { display: none !important; }
.otp-modal-backdrop {
  position: absolute; inset: 0; border: 0; padding: 0; cursor: pointer;
  background: rgba(15, 39, 72, 0.45);
}
.otp-modal-card {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  background: #fff; border-radius: 14px; border: 1px solid var(--line);
  box-shadow: 0 22px 50px rgba(15, 39, 72, 0.28);
  padding: 1.35rem 1.35rem 1.2rem;
}
.otp-modal-card h3 { margin: 0 0 0.55rem; font-size: 1.15rem; }
.otp-modal-msg { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.otp-modal-code {
  margin: 1rem 0 1.15rem; padding: 0.85rem 1rem;
  text-align: center; font-size: 1.85rem; font-weight: 800; letter-spacing: 0.28em;
  color: var(--brand-solid); background: #eef4ff; border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.otp-modal-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.form-alert {
  display: none; margin: 0 0 1rem; padding: 0.75rem 0.9rem; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-size: 0.92rem;
}
.form-alert.is-visible { display: block; }
.form-alert.is-success { background: var(--success-soft); color: var(--success); }

/* ========== Login 50/50 ========== */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-brand {
  background: var(--brand-gradient);
  color: #fff;
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-brand::before,
.login-brand::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  pointer-events: none;
}
.login-brand::before { width: 320px; height: 320px; top: -80px; right: -60px; }
.login-brand::after { width: 220px; height: 220px; bottom: 10%; left: -70px; }
.login-brand-inner { position: relative; z-index: 1; max-width: 520px; }
.login-kicker {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.35rem 0.7rem; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.14); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700;
}
.login-brand h1 {
  margin: 1.1rem 0 0.75rem;
  font-size: clamp(2rem, 3.4vw, 2.85rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.login-brand p { margin: 0; color: rgba(255,255,255,0.9); line-height: 1.55; font-size: 1.02rem; }
.capability-list { list-style: none; padding: 0; margin: 1.6rem 0 0; display: grid; gap: 0.7rem; }
.capability-list li {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.75rem 0.9rem; border-radius: 10px; background: rgba(255,255,255,0.1);
}
.capability-list .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #9ec0ff; margin-top: 0.45rem; flex: 0 0 auto;
}
.login-brand-footer { position: relative; z-index: 1; display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 2rem; }
.placeholder-btn {
  border: 1px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.08); color: #fff;
  border-radius: var(--radius-pill); min-height: 38px; padding: 0.45rem 1rem; cursor: default; font-weight: 600;
}
.placeholder-btn:focus-visible { outline: 3px solid rgba(255,255,255,0.35); }

.login-panel {
  display: grid; place-items: center; padding: 2rem 1.25rem; background: var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.login-card h2 { margin: 0 0 0.35rem; font-size: 1.55rem; letter-spacing: -0.02em; }
.login-card .lead { margin: 0 0 1.4rem; color: var(--muted); }
.login-switch { margin-top: 1.15rem; text-align: center; color: var(--muted); font-size: 0.92rem; }

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { min-height: auto; padding: 1.75rem 1.25rem 1.5rem; }
  .login-brand h1 { font-size: 1.85rem; }
  .capability-list { display: none; }
}

/* ========== Full-width horizontal app shell ========== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.app-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 70;
}
.brand-lockup { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand-gradient);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 0.72rem;
  letter-spacing: 0.02em;
}
.brand-text { display: grid; min-width: 0; }
.brand-text strong { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(42vw, 320px); }
.brand-text span { color: var(--muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(42vw, 320px); }
.header-actions { display: flex; align-items: center; gap: 0.65rem; }
.user-chip {
  display: flex; align-items: center; gap: 0.55rem;
  border: 1px solid var(--line); background: #fff; border-radius: var(--radius-pill);
  padding: 0.25rem 0.55rem 0.25rem 0.3rem; min-height: 40px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand-gradient); color: #fff;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700;
}
.user-meta { display: grid; line-height: 1.15; padding-right: 0.25rem; }
.user-meta strong { font-size: 0.82rem; }

.header-dropdown { position: relative; }
.header-tool-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  height: 40px; padding: 0 0.85rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  background: #fff; color: var(--ink); font-weight: 650; font-size: 0.86rem; cursor: pointer;
}
.header-tool-btn:hover { background: var(--bg-soft); border-color: var(--brand-solid); color: var(--brand-solid); }
.header-tool-btn .nav-caret { width: 1rem; height: 1rem; opacity: 0.7; transition: transform 0.15s ease; }
.header-dropdown.is-open .header-tool-btn {
  border-color: var(--brand-solid); color: var(--brand-solid);
  box-shadow: 0 0 0 3px rgba(26, 79, 184, 0.12);
}
.header-dropdown.is-open .header-tool-btn .nav-caret { transform: rotate(180deg); }
/* Portaled to body + high z-index so it paints above sticky .app-nav (55). */
.header-mega-menu {
  display: none;
  position: fixed;
  z-index: 200;
  min-width: 460px;
  max-width: min(92vw, 560px);
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 39, 72, 0.18);
  overflow: hidden;
}
.header-mega-menu.is-open { display: grid; }
.header-mega-col {
  padding: 0.85rem 0.9rem 1rem;
  border-right: 1px solid var(--line);
}
.header-mega-col:last-child { border-right: 0; background: #fafbfd; }
.header-mega-col h4 {
  margin: 0 0 0.55rem; padding: 0 0.45rem 0.45rem;
  font-size: 0.72rem; font-weight: 750; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.header-mega-link {
  display: block; padding: 0.48rem 0.55rem; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: 0.88rem; font-weight: 550;
}
a.header-mega-link:hover { background: rgba(26, 79, 184, 0.08); color: var(--brand-solid); text-decoration: none; }
.header-mega-link.is-soon {
  color: var(--muted); cursor: default; font-weight: 500;
}
.header-mega-link.is-soon::after {
  content: 'Soon';
  float: right; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; opacity: 0.75; margin-top: 0.15rem;
}
@media (max-width: 720px) {
  .header-mega-menu { min-width: min(92vw, 360px); grid-template-columns: 1fr; }
  .header-mega-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .header-mega-col:last-child { border-bottom: 0; }
}

.sa-company-banner {
  background: linear-gradient(90deg, #860031 0%, #a31845 55%, #c4285a 100%);
  color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.sa-company-banner-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.55rem 1.25rem; flex-wrap: wrap;
}
.sa-company-banner-inner span { font-size: 0.9rem; font-weight: 650; }
.sa-company-banner .btn {
  background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.35); color: #fff;
}
.sa-company-banner .btn:hover { background: rgba(255,255,255,0.24); }

.app-nav {
  position: sticky;
  top: var(--header-h);
  z-index: 55;
  height: var(--nav-h);
  background: var(--brand-gradient);
  display: flex; align-items: stretch; gap: 0.15rem;
  padding: 0 0.75rem; overflow-x: auto; overflow-y: hidden;
  box-shadow: 0 2px 10px rgba(14, 42, 102, 0.18);
}
.nav-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: rgba(255,255,255,0.88); text-decoration: none; white-space: nowrap;
  padding: 0 0.95rem; font-weight: 600; font-size: 0.92rem; border-bottom: 3px solid transparent;
  background: transparent; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; font: inherit;
}
.nav-link:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,0.12); }
.nav-link:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.nav-link.is-active { color: #fff; border-bottom-color: #cfe0ff; background: rgba(255,255,255,0.1); }
.nav-link.is-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.nav-dropdown { position: relative; display: inline-flex; align-items: stretch; flex-shrink: 0; }
.nav-dropdown-toggle .nav-caret {
  width: 14px; height: 14px; opacity: 0.85; transition: transform .15s ease;
}
.nav-dropdown.is-open .nav-caret { transform: rotate(180deg); }
.nav-dropdown-menu {
  display: none;
  position: fixed;
  z-index: 120;
  min-width: 220px;
  padding: 0.4rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(15, 39, 72, 0.22);
}
.nav-dropdown.is-open .nav-dropdown-menu { display: grid; gap: 0.15rem; }
.nav-dropdown-item {
  display: block; padding: 0.65rem 0.8rem; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-weight: 650; font-size: 0.9rem;
}
.nav-dropdown-item:hover { background: #eef4ff; color: #1a4fb8; text-decoration: none; }
.nav-dropdown-item.is-active { background: #eef4ff; color: #1a4fb8; }

/* Roles & staff pages */
.roles-layout {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: start;
}
.roles-nav {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.roles-nav-head {
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--line);
  font-size: 0.75rem; font-weight: 750; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted); background: #fafbfd;
}
.role-nav-btn {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 0.5rem;
  border: 0; background: transparent; text-align: left; cursor: pointer;
  padding: 0.85rem 1rem; font: inherit; font-weight: 650; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.role-nav-btn:last-child { border-bottom: 0; }
.role-nav-btn:hover { background: #f8fafc; }
.role-nav-btn.is-active { background: #eef4ff; color: #1a4fb8; box-shadow: inset 3px 0 0 #1a4fb8; }
.role-nav-count {
  min-width: 1.6rem; height: 1.6rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e2e8f0; color: #334155; font-size: 0.75rem; font-weight: 750;
}
.role-nav-btn.is-active .role-nav-count { background: #d7e4ff; color: #1a4fb8; }
.role-detail-card { border-radius: 14px; }
.perm-groups { display: grid; gap: 1rem; }
.perm-group {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff;
}
.perm-group-head {
  margin: 0; padding: 0.7rem 0.95rem; background: #fafbfd; border-bottom: 1px solid var(--line);
  font-size: 0.78rem; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.perm-chips {
  display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.85rem;
}
.perm-chip {
  display: inline-flex; align-items: center;
  padding: 0.35rem 0.65rem; border-radius: 999px;
  background: #eef4ff; color: #1a4fb8; border: 1px solid #d7e4ff;
  font-size: 0.78rem; font-weight: 650;
}
.perm-chip.is-muted { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }

.staff-hero-meta {
  display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.85rem;
}
.staff-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.75rem; border-radius: 999px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.22);
  color: #fff; font-size: 0.84rem; font-weight: 650;
}
.staff-pill strong { font-weight: 780; }
.staff-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a4fb8, #3d6bff); color: #fff;
  font-weight: 750; font-size: 0.85rem; flex-shrink: 0;
}
.staff-person { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.staff-person-text { min-width: 0; }
.staff-person-text strong { display: block; font-size: 0.95rem; }
.staff-person-text span { display: block; color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; }
.role-badge {
  display: inline-flex; align-items: center; padding: 0.28rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 750; letter-spacing: 0.02em; text-transform: capitalize;
  background: #eef4ff; color: #1a4fb8; border: 1px solid #d7e4ff;
}
.role-badge.is-admin { background: #ecfdf3; color: #027a48; border-color: #a6f4c5; }
.role-badge.is-client { background: #fff6eb; color: #b54708; border-color: #f9dbaf; }
.staff-tabs { margin-bottom: 1rem; }
@media (max-width: 900px) {
  .roles-layout { grid-template-columns: 1fr; }
}

.app-main { flex: 1; width: 100%; }
.app-container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.35rem clamp(1rem, 2vw, 2rem) 2.25rem;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.15rem; flex-wrap: wrap;
}
.page-head h1 { margin: 0.15rem 0 0; font-size: 1.65rem; letter-spacing: -0.02em; }
.breadcrumbs { color: var(--muted); font-size: 0.84rem; margin: 0; }
.page-desc { margin: 0.35rem 0 0; color: var(--muted); max-width: 70ch; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.stat-card .label { color: var(--muted); font-size: 0.82rem; margin: 0; }
.stat-card .value { margin: 0.35rem 0 0; font-size: 1.7rem; font-weight: 750; letter-spacing: -0.03em; }
.stat-card .hint { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.78rem; }

/* ========== Modern dashboard ========== */
.dash-hero {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem;
  padding: 1.25rem 1.35rem;
  border-radius: 16px;
  background:
    radial-gradient(1200px 280px at 100% -20%, rgba(61, 107, 255, 0.16), transparent 55%),
    linear-gradient(135deg, #0f2748 0%, #163a6b 48%, #1a4fb8 100%);
  color: #fff;
  box-shadow: 0 14px 36px rgba(15, 39, 72, 0.22);
}
.dash-hero .breadcrumbs { color: rgba(255,255,255,0.72); }
.dash-hero h1 { margin: 0.2rem 0 0; font-size: clamp(1.45rem, 2.4vw, 1.9rem); letter-spacing: -0.03em; color: #fff; }
.dash-hero .page-desc { margin: 0.4rem 0 0; color: rgba(255,255,255,0.78); max-width: 58ch; }
.page-head-actions,
.dash-hero-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
/* Light-on-dark buttons only inside the blue dash hero */
.dash-hero .dash-hero-actions .btn-primary {
  background: #fff; color: #163a6b; border-color: #fff;
}
.dash-hero .dash-hero-actions .btn-primary:hover:not(:disabled) { background: #eef4ff; }
.dash-hero .dash-hero-actions .btn-secondary {
  background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.28);
}
.dash-hero .dash-hero-actions .btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.18); }

.form-card {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 0.9rem 1rem 1rem;
  margin-top: 0.25rem;
}
.form-card-title {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-card .form-grid { margin: 0; }
.featured-image-field { display: flex; flex-direction: column; gap: 0.55rem; }
.featured-image-preview {
  width: 96px; height: 96px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff center/cover no-repeat; object-fit: cover;
  display: none;
}
.featured-image-preview.is-visible { display: block; }
.toggle-row {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.35rem 0; grid-column: 1 / -1;
}
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand-solid); }
.toggle-row label { margin: 0; font-weight: 600; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.15rem;
}
.kpi-grid-secondary { margin-top: -0.35rem; }

.sa-context-banner {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #d7e4ff;
  background: #f4f8ff;
  color: #1e3a5f;
  font-size: 0.92rem;
}
.sa-context-banner.is-ready {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
}
.sa-context-banner a { font-weight: 700; color: inherit; }

.sa-modules-panel { margin-bottom: 1rem; }
.sa-module-group { margin-bottom: 1.25rem; }
.sa-module-group:last-child { margin-bottom: 0; }
.sa-module-group-head h3 {
  margin: 0; font-size: 0.95rem; font-weight: 750; color: var(--ink);
}
.sa-module-group-head p {
  margin: 0.2rem 0 0.65rem; color: var(--muted); font-size: 0.82rem;
}
.sa-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.55rem;
}
.sa-module-card {
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fafbfd;
  color: var(--ink);
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
  min-height: 72px;
}
a.sa-module-card:hover {
  background: #eef4ff; border-color: #d7e4ff; text-decoration: none; transform: translateY(-1px);
}
.sa-module-card.is-disabled {
  opacity: 0.55; cursor: not-allowed; background: #f8fafc;
}
.sa-module-card.needs-company {
  border-style: dashed;
}
.sa-module-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;
}
.sa-module-card-top strong { font-size: 0.88rem; font-weight: 700; line-height: 1.25; }
.sa-module-count {
  font-size: 0.78rem; font-weight: 750; color: #1a4fb8;
  background: #eef4ff; border-radius: 999px; padding: 0.1rem 0.45rem;
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.sa-module-meta {
  display: flex; flex-wrap: wrap; gap: 0.35rem 0.55rem; align-items: center;
}
.sa-module-scope {
  font-size: 0.68rem; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
}
.sa-module-hint { font-size: 0.72rem; color: #b54708; font-weight: 650; }

.sa-qb-dropdown { position: relative; display: inline-flex; }
.sa-qb-dropdown[hidden] { display: none !important; }
.sa-qb-dropdown .header-tool-btn .nav-caret {
  width: 1rem; height: 1rem; margin-left: 0.15rem; opacity: 0.75;
  transition: transform 0.15s ease;
}
.sa-qb-dropdown.is-open .header-tool-btn {
  border-color: var(--brand-solid); color: var(--brand-solid);
  box-shadow: 0 0 0 3px rgba(26, 79, 184, 0.12);
}
.sa-qb-dropdown.is-open .header-tool-btn .nav-caret { transform: rotate(180deg); }
.sa-qb-menu {
  display: none;
  position: fixed;
  z-index: 210;
  width: min(360px, calc(100vw - 1.5rem));
  max-height: min(420px, calc(100vh - 5rem));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 39, 72, 0.2);
  overflow: hidden;
  flex-direction: column;
}
.sa-qb-menu.is-open { display: flex; }
.sa-qb-menu-head {
  padding: 0.75rem 0.85rem 0.65rem;
  border-bottom: 1px solid var(--line);
  background: #fafbfd;
  display: grid; gap: 0.45rem;
}
.sa-qb-menu-head strong {
  font-size: 0.72rem; font-weight: 750; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
}
.sa-qb-menu-list {
  overflow: auto;
  padding: 0.35rem;
  max-height: 320px;
}
.sa-qb-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.65rem;
  width: 100%; text-align: left;
  padding: 0.65rem 0.7rem; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); cursor: pointer; font: inherit;
}
.sa-qb-item:hover:not(:disabled) { background: #eef4ff; color: #1a4fb8; }
.sa-qb-item:disabled { opacity: 0.55; cursor: not-allowed; }
.sa-qb-item-main { min-width: 0; }
.sa-qb-item-main strong {
  display: block; font-size: 0.9rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sa-qb-item-main span {
  display: block; font-size: 0.75rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sa-qb-item-status {
  flex-shrink: 0; font-size: 0.68rem; font-weight: 750;
  text-transform: uppercase; letter-spacing: 0.03em;
  color: #0f7a4c; background: #e5f7ef; border-radius: 999px; padding: 0.15rem 0.45rem;
}
.sa-qb-item.is-inactive .sa-qb-item-status {
  color: #66758a; background: #eef1f6;
}
.kpi-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.05rem 1.05rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 40, 80, 0.08);
}
.kpi-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--kpi-accent, var(--brand-solid));
}
.kpi-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
}
.kpi-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--kpi-soft, #eef4ff); color: var(--kpi-accent, var(--brand-solid));
  flex-shrink: 0;
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-label {
  margin: 0; color: var(--muted); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.kpi-value {
  margin: 0.45rem 0 0; font-size: 1.55rem; font-weight: 780;
  letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums;
}
.kpi-hint { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.8rem; }
.kpi-card.is-blue { --kpi-accent: #1a4fb8; --kpi-soft: #eef4ff; }
.kpi-card.is-teal { --kpi-accent: #0f766e; --kpi-soft: #e6fffa; }
.kpi-card.is-amber { --kpi-accent: #b54708; --kpi-soft: #fff6eb; }
.kpi-card.is-rose { --kpi-accent: #b42318; --kpi-soft: #fef3f2; }
.kpi-card.is-slate { --kpi-accent: #475569; --kpi-soft: #f1f5f9; }
.kpi-card.is-green { --kpi-accent: #027a48; --kpi-soft: #ecfdf3; }

.dash-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.dash-grid-3 {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.chart-panel .panel-body { padding: 0.85rem 1rem 1rem; }
.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 240px;
}
.chart-wrap canvas { width: 100% !important; max-height: 280px; }
.chart-empty {
  min-height: 220px; display: grid; place-items: center;
  color: var(--muted); font-size: 0.92rem; text-align: center; padding: 1rem;
}

.quick-actions-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem;
}
.quick-action {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fafbfd;
  color: var(--ink); text-decoration: none; font-weight: 650; font-size: 0.9rem;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.quick-action:hover {
  background: #eef4ff; border-color: #d7e4ff; text-decoration: none; transform: translateY(-1px);
}
.quick-action-icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #eef4ff; color: #1a4fb8; flex-shrink: 0;
}
.quick-action-icon svg { width: 15px; height: 15px; }

.activity-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.activity-list li {
  display: grid; gap: 0.15rem;
  padding: 0.8rem 0; border-bottom: 1px solid var(--line);
}
.activity-list li:last-child { border-bottom: 0; }
.activity-list .when { color: var(--muted); font-size: 0.78rem; }
.activity-list strong { font-size: 0.88rem; }

.mini-table-wrap { overflow: auto; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.mini-table th, .mini-table td {
  padding: 0.7rem 0.85rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.mini-table th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: #fafbfd; font-weight: 750;
}
.mini-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.mini-table tbody tr:hover { background: #f8fafc; }

.panel-link {
  font-size: 0.84rem; font-weight: 700; color: var(--brand-solid); text-decoration: none;
}
.panel-link:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .dash-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .quick-actions-grid { grid-template-columns: 1fr; }
  .dash-hero { padding: 1.1rem; }
}

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 1rem; }
.panel-body { padding: 1rem; }
.panel-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem;
}

.filters {
  display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: end;
}
.filters-wrap { width: 100%; }
.filters .field { margin: 0; min-width: 180px; }
.filters .field.grow { flex: 1; min-width: 220px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.chip {
  display: inline-flex; align-items: center;
  padding: 0.12rem 0.45rem; border-radius: 999px;
  background: #eef4ff; color: #1a4fb8;
  font-size: 0.68rem; font-weight: 700; line-height: 1.3;
}

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td {
  text-align: left; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line);
  font-size: 0.92rem; vertical-align: middle;
}
.table th {
  color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
  background: #fafbfd; font-weight: 700;
}
.table tbody tr:hover { background: #f8fafc; }
.badge {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 700;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--bg-soft); color: var(--muted); }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.85rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.pagination .meta { color: var(--muted); font-size: 0.85rem; }
.pagination .controls { display: flex; gap: 0.45rem; }

.empty-state, .loading-state, .error-state {
  padding: 2rem 1rem; text-align: center; color: var(--muted);
}
.error-state { color: var(--danger); }
.note-banner {
  margin: 0 0 1rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm);
  background: #eef3ff; color: #1a3f8a; border: 1px solid #d5e0ff; font-size: 0.9rem;
}
.toast-region { position: fixed; top: 1rem; right: 1rem; z-index: 110; display: grid; gap: 0.5rem; width: min(360px, calc(100vw - 2rem)); }
.toast {
  background: #123057; color: #fff; padding: 0.8rem 1rem; border-radius: 10px; box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ========== Right slide-over canvas (~75% desktop) ========== */
body.slide-over-open { overflow: hidden; }
.slide-over {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  visibility: hidden;
}
.slide-over.is-open {
  pointer-events: auto;
  visibility: visible;
}
.slide-over-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: rgba(15, 28, 48, 0.42);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.slide-over.is-open .slide-over-backdrop { opacity: 1; }
.slide-over-canvas {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(75vw, 1180px);
  max-width: 100%;
  height: 100%;
  background: #fff;
  box-shadow: -18px 0 48px rgba(14, 42, 102, 0.18);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.slide-over.is-open .slide-over-canvas { transform: translateX(0); }
.slide-over-canvas--wide { width: min(88vw, 1280px); }
.file-uploader { display: grid; gap: 0.75rem; }
.file-drop {
  display: grid; justify-items: center; gap: 0.35rem; text-align: center;
  padding: 1.35rem 1rem; border: 1.5px dashed #c5d0e0; border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f6fb 100%);
  cursor: pointer; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.file-drop:hover, .file-drop.is-dragover {
  border-color: var(--brand-solid, #1a4fb8);
  background: #eef4ff;
  box-shadow: inset 0 0 0 1px rgba(26, 79, 184, 0.08);
}
.file-drop.is-disabled { opacity: 0.55; pointer-events: none; }
.file-drop-icon {
  width: 3rem; height: 3rem; border-radius: 12px;
  display: grid; place-items: center;
  background: #fff; color: var(--brand-solid, #1a4fb8);
  border: 1px solid #d7e4ff; box-shadow: 0 4px 12px rgba(26, 79, 184, 0.08);
}
.file-drop-icon svg { width: 1.45rem; height: 1.45rem; }
.file-drop-title { font-size: 0.95rem; font-weight: 700; color: var(--ink); }
.file-drop-hint { font-size: 0.8rem; color: var(--muted); }
.file-drop-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.file-preview-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem;
}
.file-card {
  display: grid; gap: 0.55rem; padding: 0.7rem;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.file-card-top { display: flex; align-items: flex-start; gap: 0.65rem; }
.file-thumb {
  width: 3rem; height: 3rem; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb svg { width: 1.25rem; height: 1.25rem; }
.file-thumb.is-pdf { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.file-thumb.is-doc { background: #eef4ff; color: #1a4fb8; border-color: #d7e4ff; }
.file-thumb.is-sheet { background: #ecfdf3; color: #027a48; border-color: #a6f4c5; }
.file-meta { min-width: 0; flex: 1; display: grid; gap: 0.1rem; }
.file-name {
  font-size: 0.84rem; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-size { font-size: 0.75rem; color: var(--muted); }
.file-card-actions { display: flex; justify-content: flex-end; }
.file-progress {
  height: 6px; border-radius: 999px; background: #e8eef7; overflow: hidden;
}
.file-progress > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #1a4fb8, #3d6bff);
  transition: width .12s linear;
}
.file-progress-label { font-size: 0.72rem; color: var(--muted); }
.file-card.is-done .file-progress > span { background: #12b76a; }
.file-card.is-error { border-color: #fecdca; }
.file-card.is-error .file-progress > span { background: #f04438; }

.expense-lines-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.expense-lines-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.expense-lines-table th, .expense-lines-table td { padding: 0.55rem 0.65rem; vertical-align: middle; }
.expense-lines-table .col-line-no { width: 2.5rem; text-align: center; color: var(--muted); }
.expense-lines-table .input,
.expense-lines-table .select { width: 100%; min-width: 0; }
.expense-lines-table .line-amount,
.expense-lines-table .line-debit,
.expense-lines-table .line-credit { text-align: right; }
.journal-lines-table th:nth-child(2),
.journal-lines-table td:nth-child(2) { min-width: 11rem; }
.journal-lines-table th:nth-child(5),
.journal-lines-table td:nth-child(5) { min-width: 8rem; }
.journal-lines-table th:nth-child(6),
.journal-lines-table td:nth-child(6) { min-width: 8rem; }
#diff-display.is-unbalanced { color: #b42318; }
.expense-line-actions { display: inline-flex; gap: 0.25rem; justify-content: flex-end; width: 100%; }
.expense-totals {
  margin-top: 0.85rem; margin-left: auto; width: min(280px, 100%);
  display: grid; gap: 0.35rem;
}
.expense-totals-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-size: 0.92rem; color: var(--muted);
}
.expense-totals-row strong {
  font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700;
}
.expense-totals-row.is-total {
  margin-top: 0.2rem; padding-top: 0.45rem; border-top: 1px solid var(--line);
  font-size: 1rem; color: var(--ink); font-weight: 700;
}
.expense-form-actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
}
.expense-form-actions .btn { white-space: nowrap; }
.slide-over-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfe 0%, #fff 100%);
}
.slide-over-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.slide-over-close {
  min-width: 40px;
  min-height: 40px;
  padding: 0.4rem 0.75rem;
}
.slide-over-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 1.15rem 1.25rem 1.5rem;
  -webkit-overflow-scrolling: touch;
}
.slide-over-foot {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--line);
  background: #fafbfd;
}
.slide-over-foot .btn { min-width: 7rem; }
@media (max-width: 900px) {
  .slide-over-canvas { width: min(92vw, 100%); }
}
@media (max-width: 640px) {
  .slide-over-canvas { width: 100%; }
  .slide-over-head, .slide-over-body, .slide-over-foot { padding-left: 1rem; padding-right: 1rem; }
}

.tabs {
  display: flex; gap: 0.25rem; flex-wrap: wrap;
  margin-bottom: 1rem; border-bottom: 1px solid var(--line); padding-bottom: 0.35rem;
}
.tab {
  border: 0; background: transparent; color: var(--muted); font-weight: 650;
  padding: 0.55rem 0.9rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0; cursor: pointer;
}
.tab:hover { color: var(--ink); background: rgba(26, 79, 184, 0.06); }
.tab.is-active { color: var(--brand-solid); background: #fff; box-shadow: inset 0 -2px 0 var(--brand-bright); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }
.tab-panel[hidden] { display: none !important; }
.form-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem 0.9rem;
}
.form-grid .field { margin: 0; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3, .form-grid .span-full { grid-column: 1 / -1; }
.form-section {
  grid-column: 1 / -1;
  margin: 0.35rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--line);
}
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section-title {
  margin: 0 0 0.55rem; font-size: 0.78rem; font-weight: 750;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.form-section-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem 0.9rem;
}
.form-section-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.row-actions { display: flex; flex-wrap: nowrap; gap: 0.35rem; align-items: center; }
.row-check {
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0; cursor: pointer;
}
.row-check-input {
  width: 1rem; height: 1rem; margin: 0; accent-color: var(--brand-solid, #1a4fb8);
  cursor: pointer;
}
.table th.col-check, .table td.col-check { width: 2.25rem; text-align: center; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.col-balance,
.table td.col-balance {
  text-align: right;
  white-space: nowrap;
  min-width: 8rem;
  width: 8.5rem;
}
.table th.col-actions,
.table td.col-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
  min-width: 11rem;
  padding-right: 1rem;
}
.table td.col-actions .row-actions,
.table td.col-actions .action-group {
  justify-content: flex-end;
  flex-wrap: nowrap;
  width: 100%;
}
.table .acct-name { display: grid; gap: 0.1rem; }
.table .acct-name-code { font-size: 0.75rem; color: var(--muted); }
.row-menu { position: relative; display: inline-flex; }
.row-menu-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.row-menu-toggle .nav-caret { width: 0.9rem; height: 0.9rem; }
.row-menu-panel {
  display: none;
  position: fixed;
  z-index: 130;
  min-width: 210px;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}
.row-menu.is-open .row-menu-panel { display: grid; gap: 0.1rem; }
.row-menu-item {
  appearance: none; border: 0; background: transparent; text-align: left;
  padding: 0.55rem 0.7rem; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 0.88rem; color: var(--ink); width: 100%;
}
.row-menu-item:hover:not(:disabled) { background: rgba(26, 79, 184, 0.08); }
.row-menu-item.is-danger { color: #b42318; }
.row-menu-item.is-danger:hover:not(:disabled) { background: rgba(180, 35, 24, 0.08); }
.row-menu-item:disabled { opacity: 0.45; cursor: not-allowed; }
.row-menu-divider { height: 1px; background: var(--line); margin: 0.25rem 0.35rem; }
@media (max-width: 900px) {
  .form-grid, .form-section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-section-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: span 2; }
}
@media (max-width: 700px) {
  .form-grid, .form-section-grid, .form-section-grid--4 { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3, .form-grid .span-full { grid-column: 1; }
  .table th.col-actions, .table td.col-actions { min-width: 7rem; }
}

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .stats-grid { grid-template-columns: 1fr; }
  .app-container { padding: 1rem; }
  .user-meta { display: none; }
}

/* ========== Searchable select ========== */
.search-select { position: relative; width: 100%; }
.search-select-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #1a4fb8;
  border-radius: var(--radius-sm);
  padding: 0.65rem 2.1rem 0.65rem 0.85rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='%231a4fb8'%3E%3Cpath d='M5.25 7.5L10 12.25 14.75 7.5'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  color: var(--ink);
}
.search-select-input:focus {
  outline: none;
  border-color: #1a4fb8;
  box-shadow: 0 0 0 3px rgba(26, 79, 184, 0.22);
}
.search-select.is-open .search-select-input {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.search-select-menu {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 80;
  max-height: 240px; overflow: auto;
  background: #fff; border: 1px solid #1a4fb8; border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: 0 10px 24px rgba(14, 42, 102, 0.12);
}
.search-select-option {
  display: grid; gap: 0.1rem; width: 100%; text-align: left;
  padding: 0.55rem 0.85rem; border: 0; background: transparent;
  cursor: pointer; font: inherit; color: var(--ink);
}
.search-select-option:hover,
.search-select-option.is-active { background: rgba(26, 79, 184, 0.08); }
.search-select-option strong { font-size: 0.9rem; font-weight: 700; }
.search-select-option span { font-size: 0.78rem; color: var(--muted); }
.search-select-empty {
  padding: 0.75rem 0.85rem; color: var(--muted); font-size: 0.85rem;
}
.line-actions {
  display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap;
}
.btn-line-icon {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid #1a4fb8; background: #fff; color: #1a4fb8;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; line-height: 1; font-size: 1.05rem; font-weight: 700;
}
.btn-line-icon:hover { background: #eef4ff; }
.btn-line-icon.is-danger { border-color: #b42318; color: #b42318; }
.btn-line-icon.is-danger:hover { background: #fef3f2; }
.btn-line-icon svg { width: 14px; height: 14px; }
