:root {
  /* Brand + surface colours: change the look of the whole app here. */
  --bg: #F6F8FB;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;
  --text: #1B2433;
  --muted: #64748B;
  --border: #E2E8F0;
  --primary: #1C3672;
  --primary-dark: #14295A; /* primary hover/pressed */
  --accent: #3CBDC0; /* teal: active-item bar, highlights */
  --accent-tint: #E6F6F7;
  --link: #17808A;
  --alert: #E8743B; /* badges and warnings that need a look */
  --hover-grey: #F1F5F9;
  --chip: #EDF1F7;
  /* Meaning colours: money and status only (paid, approved, overdue, errors). */
  --positive: #2F7D5D;
  --negative: #C0392B;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--link); text-decoration: none; }

/* An account name/code linking through to its ledger drill-down
   (Chart of Accounts, Reports detail tables) — underlines only on
   hover so it doesn't look like every account name is a link. */
.account-link:hover { text-decoration: underline; }

h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 500; color: var(--text); margin: 0; }

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.sidebar-brand { margin-bottom: 4px; padding: 0 4px; }
.sidebar-brand-with-bell { display: flex; justify-content: space-between; align-items: center; }
.sidebar-logo, .mobile-logo, .login-logo { mix-blend-mode: multiply; display: block; }
.sidebar-logo { width: 120px; height: auto; }
.sidebar-nav { display: flex; flex-direction: column; flex: 1; }
.navitem { display: block; padding: 10px 14px 10px 11px; border-radius: 0 8px 8px 0; border-left: 3px solid transparent; color: var(--text); font-size: 14px; font-weight: 500; margin-bottom: 2px; cursor: pointer; border-top: none; border-right: none; border-bottom: none; background: none; text-align: left; font-family: inherit; }
.navitem.active { background: var(--accent-tint); color: var(--primary); font-weight: 700; border-left-color: var(--accent); }
.navitem:hover { background: var(--hover-grey); color: var(--text); }
.navitem.active:hover { background: var(--accent-tint); color: var(--primary); }
.doc-link { font-size: 13px; color: var(--link); text-decoration: underline; cursor: pointer; margin-right: 10px; }
.nav-group-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; box-sizing: border-box; }
.nav-group-caret { width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; margin-right: 2px; }
.nav-group.open .nav-group-caret { transform: rotate(45deg); }
.nav-group-items { display: none; margin-left: 10px; padding-left: 6px; border-left: 1px solid var(--border); }
.nav-group.open .nav-group-items { display: block; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.sidebar-user { font-size: 13px; color: var(--text); margin-bottom: 10px; word-break: break-word; }
.sidebar-switch { font-size: 13px; color: var(--link); cursor: pointer; text-decoration: underline; display: block; margin-bottom: 12px; }
.sidebar-logout { width: 100%; background: var(--surface); color: var(--primary); border: 1px solid var(--primary); padding: 8px 14px; font-size: 13px; border-radius: 8px; cursor: pointer; font-family: inherit; }
.sidebar-logout:hover { background: var(--hover-grey); }
.app-version { font-size: 11px; color: var(--muted); text-align: center; margin-top: 12px; }

/* Mobile top bar + overlay (shown under 820px, see the media query at the end). */
.mobile-topbar, .sidebar-overlay { display: none; }
.hamburger { background: none; border: none; color: var(--text); padding: 8px; display: flex; align-items: center; border-radius: 8px; }
.hamburger:hover:not(:disabled) { background: var(--hover-grey); }

/* ---- Approvals nav badge ---- */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 6px; border-radius: 8px; background: var(--alert); color: #fff; font-size: 10px; font-weight: 700; line-height: 1; vertical-align: middle; }

/* ---- Notification bell ---- */
.notif-bell-wrap { position: relative; }
.notif-bell { position: relative; display: flex; align-items: center; background: none; border: none; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 6px; }
.notif-bell:hover:not(:disabled) { background: var(--hover-grey); color: var(--primary); }
.notif-badge { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--negative); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.notif-dropdown { position: absolute; top: 38px; left: 0; width: 300px; max-width: 80vw; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 28px rgba(15,23,42,0.18); z-index: 60; overflow: hidden; }
.notif-dropdown-header { padding: 10px 14px; font-weight: 600; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
.notif-dropdown-list { max-height: 320px; overflow-y: auto; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--accent-tint); }
.notif-item.unread .notif-title { font-weight: 700; }
.notif-title { font-size: 13px; margin-bottom: 2px; }
.notif-body { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.notif-time { font-size: 11px; color: var(--muted); }
.notif-empty { padding: 18px 14px; font-size: 13px; color: var(--muted); text-align: center; }
.notif-view-all { display: block; text-align: center; padding: 10px; font-size: 13px; font-weight: 600; color: var(--link); border-top: 1px solid var(--border); text-decoration: none; }
.notif-view-all:hover { background: var(--bg); }

/* ---- Seat usage bar (Team page) ---- */
.seat-bar-track { background: var(--border); border-radius: 6px; height: 8px; overflow: hidden; margin: 8px 0 4px; }
.seat-bar-fill { background: var(--primary); height: 100%; border-radius: 6px; transition: width 0.2s; }
.seat-bar-fill.full { background: var(--negative); }

.content { flex: 1; padding: 32px 40px; box-sizing: border-box; max-width: 1100px; }
.content-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; gap: 1rem; flex-wrap: wrap; }
.content-header h1, .content-header h2 { font-size: 28px; margin-bottom: 4px; }
.content-subtitle { color: var(--muted); font-size: 14px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
th { text-align: left; padding: 10px 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
tr:last-child td { border-bottom: none; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px 20px 12px; overflow-x: auto; }
.table-card table { border: none; }

/* ---- Forms ---- */
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
  color: var(--text);
}

/* ---- Buttons ---- */
button {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
button:hover:not(:disabled) { filter: brightness(0.95); }
button:not([class]):hover:not(:disabled), button.small:not(.secondary):not(.danger):hover:not(:disabled) { background: var(--primary-dark); filter: none; }
button:disabled { opacity: 0.6; cursor: default; }
button.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
button.danger { background: #fff; color: var(--negative); border: 1px solid var(--negative); }
button.small { padding: 6px 12px; font-size: 12.5px; }

/* ---- Pills (status/type badges) ---- */
.pill, .status-pill, .type-pill, .badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
  text-transform: capitalize;
  background: var(--chip);
  color: var(--muted);
}

.error { color: var(--negative); font-size: 13px; margin: 0 0 1rem; }
.notice { color: var(--positive); font-size: 13px; margin: 0 0 1rem; }

/* ---- Charts ---- */
.chart-wrap { position: relative; height: 220px; }
.chart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 12px; margin: 0; }

/* ---- Password show/hide toggle ---- */
.password-field { position: relative; }
.password-field input { padding-right: 2.5rem; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  padding: 4px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.password-toggle:hover { color: var(--primary); }

/* ---- Login page (pre-auth, no sidebar) ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { font-size: 22px; margin-bottom: 1.5rem; }
.login-logo { width: 150px; height: auto; margin: 0 auto 1.25rem; }

/* ---- Mobile (under 820px): off-canvas sidebar behind a top bar ---- */
@media (max-width: 819px) {
  .app-shell { flex-direction: column; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 50;
    height: 56px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mobile-logo { height: 34px; width: auto; }
  .mobile-topbar .notif-bell-wrap { margin-left: auto; }
  .mobile-topbar .notif-dropdown { left: auto; right: 0; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw; z-index: 100;
    overflow-y: auto; transform: translateX(-100%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .sidebar.open { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(15,23,42,0.45); }
  body.nav-open .sidebar-overlay { display: block; }
  body.nav-open { overflow: hidden; }
  .content { padding: 16px; max-width: none; width: 100%; min-width: 0; }
  .content-header h1, .content-header h2 { font-size: 22px; }
  .card { overflow-x: auto; }
  .card > table, .table-card > table { min-width: 600px; }
  .form-row, .ec-row { flex-direction: column; flex-wrap: nowrap; }
  .form-field, .filter-field { flex: 1 1 auto !important; width: 100%; max-width: none; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .stat-grid, .counts-grid, .profile-grid { flex-direction: column; }
  .stat-grid > *, .counts-grid > *, .profile-grid > * { flex: 0 0 auto !important; width: 100%; max-width: none; }
  .reports-grid { grid-template-columns: 1fr; }
  .login-card { padding: 1.75rem 1.25rem; margin: 0 16px; }
}
