:root {
  --ink:#182235;
  --muted:#64748b;
  --line:#e5eaf0;
  --blue:#1769aa;
  --blue-dark:#0f4f82;
  --navy:#102a43;
  --navy-light:#173b5b;
  --bg:#f4f7fa;
  --white:#ffffff;
  --success:#087f5b;
  --success-bg:#e7f6f0;
  --warning:#a15c00;
  --warning-bg:#fff4df;
  --danger:#b42318;
  --danger-bg:#fff0ee;
  --shadow:0 8px 24px rgba(16,42,67,.07);
}

.profile-heading-row { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:24px; }

.profile-heading-row .profile-heading { margin:0; }
.profile-heading-row .primary { padding:8px 12px; font-size:13px; }
.invoice-paper{background:#fff;border:1px solid #cbd5e1;padding:30px;color:#172033;font-size:13px;line-height:1.5}.invoice-paper h2{font-size:19px;margin:0 0 7px;color:#102a43}.invoice-top,.invoice-bill,.invoice-summary{display:grid;grid-template-columns:1fr 1fr;gap:22px}.invoice-top>div:last-child{text-align:right}.invoice-top p,.invoice-summary p{margin:0}.invoice-bill{padding:15px 0;min-height:90px}.invoice-bill strong{font-size:14px}.invoice-table{width:100%;border-collapse:collapse;margin:10px 0 22px}.invoice-table th,.invoice-table td{border:1px solid #64748b;padding:9px;text-align:left}.invoice-table th{background:#e8f1f7;font-size:11px}.invoice-summary{border-top:1px solid #94a3b8;padding-top:16px}.invoice-summary>div:last-child{text-align:right}.invoice-summary strong{display:inline-block;margin-top:5px;font-size:16px}.invoice-declaration{border-top:1px solid #94a3b8;margin-top:25px;padding-top:15px;font-size:11px}.invoice-paper .service-update{padding:7px 0;border-bottom:1px solid #e2e8f0;display:grid;gap:2px}
@media print{body{background:#fff}.invoice-paper{border:0;padding:0}.invoice-paper *{color:#000!important}.actions,dialog+*,.shell{display:none!important}}

/* =========================
   BASIC
========================= */

* {
  box-sizing:border-box;
}

html {
  scroll-behavior:smooth;
}

body {
  margin:0;
  font-family:Inter,Segoe UI,Arial,sans-serif;
  color:var(--ink);
  background:var(--bg);
}

button,
input,
select,
textarea {
  font:inherit;
}

button {
  cursor:pointer;
}

/* =========================
   MAIN LAYOUT
========================= */

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

/* =========================
   SIDEBAR
========================= */

aside {
  position:fixed;
  left:0;
  top:0;
  bottom:0;
  width:250px;
  display:flex;
  flex-direction:column;
  height:100vh;
  background:linear-gradient(
    180deg,
    #102a43 0%,
    #0d2439 100%
  );
  padding:20px 14px 14px;
  color:#e8f0f7;
  z-index:10;
  overflow:hidden;
}

.brand {
  display:flex;
  align-items:center;
  gap:11px;
  margin:2px 6px 20px;
  flex-shrink:0;
}

.brand img {
  display:block;
  width:44px;
  height:44px;
  object-fit:contain;
  border-radius:10px;
  background:rgba(232,240,247,.08);
  padding:4px;
  flex-shrink:0;
}

.brand-text {
  display:flex;
  flex-direction:column;
  min-width:0;
  line-height:1.3;
}

.brand-text strong {
  font-size:15px;
  letter-spacing:.5px;
  color:#fff;
  white-space:nowrap;
}

.brand-text span {
  font-size:10.5px;
  letter-spacing:.2px;
  color:#9db4c8;
  white-space:nowrap;
}

nav {
  display:flex;
  flex-direction:column;
  gap:2px;
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  padding:2px 2px 10px;
  scrollbar-width:thin;
  scrollbar-color:#2c4a68 transparent;
}

nav::-webkit-scrollbar {
  width:6px;
}

nav::-webkit-scrollbar-thumb {
  background:#2c4a68;
  border-radius:999px;
}

.nav {
  border:0;
  background:transparent;
  display:flex;
  align-items:center;
  gap:11px;
  width:100%;
  height:42px;
  flex-shrink:0;
  text-align:left;
  padding:0 12px;
  color:#c4d3df;
  border-radius:9px;
  margin:0;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:background .15s ease,color .15s ease;
}

.nav svg {
  width:18px;
  height:18px;
  flex-shrink:0;
  opacity:.92;
}

.nav:hover {
  background:#173b5b;
  color:#fff;
}

.nav.active {
  background:#1769aa;
  color:#fff;
  box-shadow:0 5px 15px rgba(23,105,170,.25);
}

.nav-group-label {
  margin:12px 10px 7px;
  font-size:10px;
  font-weight:800;
  letter-spacing:1.4px;
  text-transform:uppercase;
  color:#7f99b0;
  flex-shrink:0;
}

.nav-group-label:first-child {
  margin-top:4px;
}

.nav-divider {
  height:1px;
  background:rgba(232,240,247,.14);
  margin:12px 8px;
  flex-shrink:0;
}

.sidebar-footer {
  flex-shrink:0;
  display:flex;
  align-items:center;
  gap:11px;
  margin:10px 2px 0;
  padding:10px 12px;
  background:rgba(23,59,91,.55);
  border:1px solid rgba(232,240,247,.12);
  border-radius:12px;
}

.avatar {
  width:34px;
  height:34px;
  flex-shrink:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  background:linear-gradient(135deg,#1769aa,#125b93);
  color:#fff;
  font-size:14px;
  font-weight:800;
}

#session-user {
  min-width:0;
  font-size:13px;
  line-height:1.4;
  color:#dbe7f1;
  overflow:hidden;
  text-overflow:ellipsis;
}

#session-user strong {
  color:#fff;
  font-size:12px;
}

.nav.logout {
  margin-top:8px;
}

#topbar-username {
  font-size:13px;
  font-weight:700;
  color:var(--ink);
}

#topbar-role {
  font-size:12px;
  color:var(--muted);
}

/* =========================
   COMPACT SINGLE-SCREEN DASHBOARD (desktop)
   Only applies when body.is-dashboard (set by render() in app.js).
   Other pages keep their existing spacing.
========================= */
body.is-dashboard main {
  padding:10px 20px 10px;
  max-width:none;
}
body.is-dashboard header {
  margin-bottom:0;
  min-height:0;
}
body.is-dashboard header > div:first-child {
  display:none;
}
body.is-dashboard #subtitle {
  display:none;
}
body.is-dashboard .toolbar {
  padding:8px 10px;
  margin-bottom:8px;
}
body.is-dashboard .toolbar input {
  padding:7px 10px;
}
body.is-dashboard .toolbar .dashboard-user-row {
  display:flex;
  align-items:center;
  gap:9px;
  flex:0 0 auto;
  margin-left:auto;
}

body.is-dashboard .toolbar .avatar {
  width:34px;
  height:34px;
  border-radius:50%;
  object-fit:cover;
  background:#e5eaf0;
  border:2px solid #fff;
  box-shadow:0 1px 3px rgba(16,42,67,.18);
}

body.is-dashboard .toolbar #topbar-username {
  font-weight:600;
  color:var(--ink);
  line-height:1.2;
}

body.is-dashboard .toolbar #topbar-role {
  font-size:11px;
  font-weight:700;
  color:#fff;
  background:var(--blue);
  padding:2px 7px;
  border-radius:999px;
  letter-spacing:.3px;
  text-transform:uppercase;
  white-space:nowrap;
}

body.is-dashboard .toolbar input {
  flex:1 1 auto;
  min-width:120px;
}

@media(max-width:720px) {
  body.is-dashboard .toolbar {
    flex-wrap:nowrap;
  }

  body.is-dashboard .toolbar .dashboard-user-row {
    margin-left:0;
  }

  body.is-dashboard .toolbar #topbar-role {
    display:none;
  }
}

body.is-dashboard #content.dw-content {
  padding-bottom:0;
}
@media(min-width:861px) {
  body.is-dashboard main {
    height:100vh;
    overflow-y:auto;
    overflow-x:hidden;
  }
}

/* =========================
   MAIN
========================= */

main {
  width:calc(100% - 250px);
  margin-left:250px;
  padding:16px 32px 44px;
  max-width:1500px;
}

/* =========================
   HEADER
========================= */

header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:12px;
}

h1 {
  font-size:23px;
  letter-spacing:-.4px;
  margin:2px 0;
}

h2 {
  font-size:20px;
  margin:4px 0;
}

.eyebrow {
  font-size:10px;
  letter-spacing:1.4px;
  color:var(--blue);
  font-weight:800;
  margin:0;
}

#subtitle {
  margin:0;
  color:var(--muted);
  font-size:14px;
}

.header-actions {
  display:flex;
  gap:9px;
  align-items:center;
  flex-wrap:wrap;
}

/* =========================
   BUTTONS
========================= */

.primary {
  background:linear-gradient(
    135deg,
    #1769aa,
    #125b93
  );
  border:0;
  border-radius:8px;
  color:#fff;
  padding:11px 17px;
  font-weight:700;
  cursor:pointer;
  box-shadow:0 4px 12px rgba(23,105,170,.18);
  transition:.2s ease;
}

.primary:hover {
  background:var(--blue-dark);
  transform:translateY(-1px);
}

.secondary {
  background:#fff;
  border:1px solid #ccd6e0;
  border-radius:8px;
  padding:10px 15px;
  cursor:pointer;
  color:#334155;
  font-weight:600;
  transition:.2s ease;
}

.secondary:hover {
  border-color:#9db1c3;
  background:#f8fafc;
}

.link-btn {
  border:0;
  background:none;
  color:var(--blue);
  font-weight:700;
  padding:0;
  cursor:pointer;
}

.link-btn:hover {
  text-decoration:underline;
}

.danger {
  color:var(--danger);
}

/* =========================
   TOOLBAR
========================= */

.toolbar {
  background:#fff;
  border:1px solid var(--line);
  padding:13px;
  display:flex;
  gap:10px;
  align-items:center;
  border-radius:11px;
  margin-bottom:14px;
  box-shadow:0 2px 8px rgba(16,42,67,.025);
}

.toolbar input,
.toolbar select {
  border:1px solid #cfd8e3;
  border-radius:8px;
  padding:10px 12px;
  font:inherit;
  background:#fff;
  color:var(--ink);
  outline:none;
}

.toolbar input {
  width:320px;
}

.toolbar input:focus,
.toolbar select:focus {
  border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(23,105,170,.08);
}

.toolbar #count {
  color:var(--muted);
  font-size:13px;
  margin-left:auto;
}

/* =========================
   DASHBOARD
========================= */

.dashboard-grid {
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:16px;
}

/* Dashboard statistics */

.stat-card {
  position:relative;
  overflow:hidden;
  background:#fff;
  border:1px solid var(--line);
  border-radius:13px;
  padding:21px 22px;
  min-height:115px;
  box-shadow:var(--shadow);
  transition:.2s ease;
}

.stat-card::after {
  content:"";
  position:absolute;
  right:-25px;
  top:-25px;
  width:80px;
  height:80px;
  border-radius:50%;
  background:rgba(23,105,170,.055);
}

.stat-card:hover {
  transform:translateY(-2px);
  box-shadow:0 12px 28px rgba(16,42,67,.1);
}

.stat-label {
  display:block;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
  margin-bottom:10px;
  text-transform:uppercase;
  letter-spacing:.5px;
}

.stat-card strong {
  display:block;
  font-size:29px;
  letter-spacing:-.7px;
  color:var(--navy);
}

.money-card strong {
  color:var(--success);
}

/* Dashboard panels */

.dashboard-panel {
  background:#fff;
  border:1px solid var(--line);
  border-radius:13px;
  padding:22px;
  box-shadow:var(--shadow);
}

.dashboard-panel:nth-of-type(10) {
  grid-column:span 2;
}

.panel-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:18px;
}

.panel-head h2 {
  margin-top:5px;
}

/* Status rows */

.status-list {
  display:grid;
  gap:8px;
}

.status-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 12px;
  border:1px solid #edf0f4;
  border-radius:8px;
  background:#fafcfd;
  font-size:13px;
}

.status-row span {
  color:#475569;
}

.status-row strong {
  min-width:30px;
  text-align:center;
  padding:3px 8px;
  border-radius:20px;
  background:#eaf3f9;
  color:var(--blue);
}

/* Quick actions */

.quick-actions {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.quick-btn {
  border:1px solid #d7e0e8;
  background:#f8fafc;
  border-radius:9px;
  padding:13px;
  color:#28445b;
  font-weight:700;
  transition:.2s ease;
}

.quick-btn:hover {
  background:#eef6fb;
  border-color:#a9c9df;
  color:var(--blue);
  transform:translateY(-1px);
}

/* =========================
   CLIENT / APPLICATION CARDS
========================= */

.cards {
  display:grid;
  grid-template-columns:
    repeat(auto-fill,minmax(300px,1fr));
  gap:16px;
}

.card {
  background:#fff;
  border:1px solid var(--line);
  border-radius:12px;
  padding:19px;
  box-shadow:0 4px 14px rgba(16,42,67,.04);
  transition:.2s ease;
}

.card:hover {
  transform:translateY(-2px);
  box-shadow:0 9px 24px rgba(16,42,67,.09);
  border-color:#d6e1ea;
}

.card h3 {
  font-size:17px;
  margin:0 0 7px;
}

.card .sub {
  color:var(--muted);
  font-size:14px;
  margin:0 0 14px;
}

.details {
  border-top:1px solid var(--line);
  padding-top:12px;
  font-size:13px;
  color:#475569;
  display:grid;
  gap:7px;
}

.details b {
  color:var(--ink);
  font-weight:600;
}

.card-foot {
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-top:16px;
}

.badge {
  font-size:11px;
  background:var(--success-bg);
  color:var(--success);
  padding:5px 9px;
  border-radius:999px;
  font-weight:800;
}

.empty {
  padding:55px 25px;
  text-align:center;
  background:#fff;
  border:1px dashed #cbd5e1;
  border-radius:12px;
  color:var(--muted);
  grid-column:1/-1;
}

/* =========================
   DIALOG
========================= */

dialog {
  width:min(760px,94vw);
  border:0;
  border-radius:14px;
  padding:0;
  box-shadow:0 25px 80px rgba(0,0,0,.22);
}

dialog::backdrop {
  background:rgba(16,42,67,.45);
  backdrop-filter:blur(2px);
}

dialog form {
  padding:27px;
}

.dialog-head {
  display:flex;
  justify-content:space-between;
  align-items:start;
  margin-bottom:22px;
}

.dialog-head h2 {
  margin:5px 0 0;
}

.close {
  border:0;
  background:none;
  font-size:27px;
  cursor:pointer;
  color:var(--muted);
  line-height:1;
}

.close:hover {
  color:var(--ink);
}

.form-grid {
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:14px;
}

/* Prevent wide content (fee table, document rows, selects) from forcing a
   horizontal scrollbar inside dialogs: grid children may shrink below their
   content's intrinsic minimum width. */
.form-grid > * {
  min-width:0;
}

.field {
  display:flex;
  flex-direction:column;
  gap:6px;
}

.field label {
  font-size:12px;
  font-weight:800;
  color:#334155;
}

.field input,
.field select,
.field textarea {
  border:1px solid #cfd8e3;
  border-radius:8px;
  padding:10px 11px;
  font:inherit;
  background:#fff;
  color:var(--ink);
  outline:none;
  transition:.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(23,105,170,.08);
}

.field.full {
  grid-column:1/-1;
}

.field textarea {
  min-height:78px;
  resize:vertical;
}

.client-summary {
  grid-column:1/-1;
  padding:14px;
  background:#eef6fb;
  border:1px solid #c9e1f1;
  border-radius:8px;
  color:#35546b;
  font-size:13px;
  display:grid;
  gap:4px;
}

.client-summary b {
  color:var(--navy);
  font-size:14px;
}

.gst-preview {
  grid-column:1/-1;
  padding:14px;
  background:#eef6fb;
  border:1px solid #c9e1f1;
  border-radius:8px;
  color:#35546b;
  font-size:13px;
  display:grid;
  gap:5px;
}

.gst-preview b { color:var(--navy); font-size:14px; }
.required-mark { color:var(--danger); }

.form-section-title{font-size:15px;margin:22px 0 10px}.quotation-line{display:grid;grid-template-columns:1.4fr 1.7fr .8fr .6fr 1fr 1fr .7fr .9fr auto;gap:7px;align-items:end;background:#f8fafc;border:1px solid var(--line);border-radius:8px;padding:10px;margin:8px 0}.quotation-line label{font-size:11px;font-weight:700;color:var(--muted);display:grid;gap:4px}.quotation-line input{width:100%;padding:8px;border:1px solid #cfd8e3;border-radius:6px}.quotation-doc{display:grid;grid-template-columns:1fr 2fr .7fr .8fr auto;gap:7px;align-items:end;margin:7px 0}.quotation-doc input,.quotation-doc select{padding:8px;border:1px solid #cfd8e3;border-radius:6px}.icon-button{border:0;background:#fff;color:var(--danger);font-size:18px;cursor:pointer;padding:6px}.quotation-card-actions{display:flex;gap:9px;flex-wrap:wrap}.quotation-texts{margin-top:15px}

/* Application page: multi-service picker + service-wise fee table. */
.ms-multi{position:relative;min-width:0}
.ms-toggle{width:100%;display:flex;align-items:center;justify-content:space-between;gap:8px;border:1px solid #cfd8e3;border-radius:8px;padding:10px 11px;background:#fff;color:var(--ink);text-align:left;cursor:pointer;min-width:0}
.ms-chips{display:flex;flex-wrap:wrap;gap:6px;min-width:0}
.ms-chip{display:inline-block;background:#eef6fb;border:1px solid #c9e1f1;color:#123a5a;border-radius:999px;padding:2px 10px;font-size:12px;font-weight:700;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ms-placeholder{color:var(--muted);font-size:13px}
.ms-caret{color:var(--muted);flex:0 0 auto}
/* Compact popup: fixed maximum height, scrolls internally only when there are
   more options than fit. It overlays the form (position:absolute) so it never
   grows the dialog or adds a second nested scroll container. */
.ms-panel{position:absolute;left:0;right:0;top:calc(100% + 6px);background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow);padding:8px;display:grid;gap:2px;max-height:200px;overflow-y:auto;z-index:30}
.ms-opt{display:flex;align-items:center;gap:8px;font-size:13px;padding:5px 8px;border-radius:6px;cursor:pointer;min-width:0}
.ms-opt span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ms-opt:hover{background:#f1f5f9}
.service-fees{display:grid;gap:8px;border:1px solid var(--line);border-radius:10px;background:#fbfdff;padding:10px;min-width:0}
.sf-grid,.sf-row{display:grid;grid-template-columns:1.3fr .9fr 1fr .6fr .9fr .9fr;gap:7px;align-items:center;min-width:0}
.sf-header{font-size:11px;font-weight:800;color:var(--muted);text-transform:uppercase;padding:2px 2px 8px}
.sf-row{background:#f8fafc;border:1px solid var(--line);border-radius:8px;padding:8px;margin:0}
.sf-name{font-size:13px;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
/* Each fee field is a labelled cell. Labels (em) are hidden on wide screens
   where the header row provides them, and rendered inline on narrow screens as
   a stacked service card (see the media query below). */
.sf-cell{display:flex;flex-direction:column;gap:3px;min-width:0}
.sf-cell em{display:none;font-style:normal;font-size:11px;font-weight:700;color:var(--muted)}
.sf-row input{width:100%;min-width:0;padding:8px;border:1px solid #cfd8e3;border-radius:6px}
.sf-gst-amount,.sf-total{font-size:13px;font-weight:700;color:#0f4f82;text-align:right;min-width:0}
.sf-empty{color:var(--muted);font-size:13px;background:#f8fafc;border:1px dashed var(--line);border-radius:8px;padding:12px}
.sf-summary{border-top:1px solid var(--line);padding-top:8px;display:grid;gap:4px}
.sf-summary-row{display:flex;justify-content:space-between;font-size:13px;color:#35546b;gap:12px}
.sf-summary-row.grand{font-size:15px;color:var(--navy);font-weight:800}
/* Application document rows must not overflow the dialog either. The Application
   rows use 4 columns (name / required / status / remove) unlike the 5-column
   quotation checklist, so the grid is scoped to #app-documents. */
#app-documents .quotation-doc{min-width:0;grid-template-columns:2.2fr 1fr 1fr auto}
#app-documents .quotation-doc input,#app-documents .quotation-doc select{min-width:0}
/* Plastic EPR Word generation (Covering / Any Other) — reuses the existing
   secondary button style; the rows sit under the Required Documents checklist
   and disappear entirely when Plastic EPR is not selected. */
.epr-docs{display:flex;flex-direction:column;gap:6px;margin-top:10px}
.epr-docs:empty{display:none;margin:0}
.epr-doc-row{display:flex;align-items:center;justify-content:space-between;gap:10px;border:1px solid var(--line);border-radius:8px;padding:8px 10px;background:var(--white)}
.epr-doc-row .epr-doc-name{font-weight:600;font-size:13px;color:var(--ink)}
@media(max-width:720px){
  .ms-panel{max-height:180px}
  .sf-grid{display:none}
  .sf-row{grid-template-columns:1fr;row-gap:8px;padding:12px}
  .sf-name{grid-column:1/-1;font-size:14px;margin-bottom:2px}
  .sf-cell{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px}
  .sf-cell em{display:block}
  .sf-cell input{width:120px;text-align:right}
  .sf-out .sf-gst-amount,.sf-out .sf-total{display:block;text-align:right}
  /* Documents: name takes the full row; required/status/remove wrap below. */
  #app-documents .quotation-doc{grid-template-columns:1fr 1fr auto}
  #app-documents .quotation-doc .qd-name{grid-column:1/-1}
}

.profile-summary {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(130px,1fr));
  gap:9px;
  margin:0 0 20px;
}

.profile-summary > div {
  background:#eef6fb;
  border:1px solid #c9e1f1;
  border-radius:8px;
  padding:11px;
}

.profile-summary span,.profile-summary strong { display:block; }
.profile-summary span { font-size:11px; color:var(--muted); font-weight:700; text-transform:uppercase; }
.profile-summary strong { margin-top:5px; color:var(--navy); font-size:17px; }
.profile-heading { margin:21px 0 10px; font-size:17px; }
.profile-info { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; font-size:13px; }
.service-profile { border:1px solid var(--line); border-radius:10px; padding:15px; margin:12px 0; background:#fbfdff; }
.service-profile-head { display:flex; justify-content:space-between; gap:12px; align-items:start; }
.service-profile h4,.service-profile h5 { margin:0 0 9px; }
.service-profile h5 { margin-top:15px; font-size:13px; }
.service-update { border-top:1px solid var(--line); padding:9px 0; display:grid; gap:3px; font-size:13px; }
.service-update b { color:var(--blue); }
.service-update small { color:var(--muted); }

.actions {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:24px;
}

.error {
  color:var(--danger);
  min-height:18px;
  margin:12px 0 0;
  font-size:14px;
}

/* =========================
   TOAST
========================= */

#toast {
  position:fixed;
  right:24px;
  bottom:24px;
  background:#123a5a;
  color:#fff;
  padding:12px 17px;
  border-radius:9px;
  opacity:0;
  transform:translateY(10px);
  transition:.2s;
  pointer-events:none;
  box-shadow:0 8px 25px rgba(0,0,0,.16);
  z-index:100;
}

#toast.show {
  opacity:1;
  transform:none;
}

/* =========================
   LOGIN PAGE
========================= */

.login-page {
  min-height:100vh;
  display:grid;
  place-items:center;
  background:
    radial-gradient(
      circle at top left,
      #e4f0f8,
      transparent 40%
    ),
    linear-gradient(
      135deg,
      #edf3f7,
      #f8fafc
    );
}

.login-card {
  width:min(420px,92vw);
  background:#fff;
  border:1px solid var(--line);
  border-radius:15px;
  padding:38px;
  box-shadow:0 18px 55px rgba(16,42,67,.1);
}

.login-brand {
  margin:0 0 25px;
}

.login-brand img {
  width:205px;
  max-height:170px;
}

.login-card h1 {
  font-size:26px;
  margin:6px 0;
}

.login-card #auth-copy {
  color:var(--muted);
  margin:0 0 22px;
  line-height:1.5;
}

.login-card .field {
  margin:14px 0;
}

.auth-button {
  width:100%;
  margin-top:4px;
}

.security-note {
  font-size:12px;
  color:var(--muted);
  line-height:1.5;
  margin:23px 0 0;
}

/* =========================
   MOBILE
========================= */

@media(max-width:900px) {

  .dashboard-grid {
    grid-template-columns:repeat(2,1fr);
  }

  .dashboard-panel:nth-of-type(10) {
    grid-column:span 2;
  }

  main {
    padding:30px 25px 45px;
  }

}

@media(max-width:720px) {

  aside {
    width:68px;
    padding:16px 8px;
  }

  .brand {
    justify-content:center;
    margin:0 0 18px;
  }

  .brand img {
    width:38px;
    height:38px;
    padding:2px;
  }

  .brand-text {
    display:none;
  }

  .nav {
    height:44px;
    padding:0;
    justify-content:center;
    gap:0;
    font-size:0;
  }

  .nav svg {
    width:20px;
    height:20px;
  }

  .nav-group-label {
    display:none;
  }

  .nav-divider {
    display:none;
  }

  .sidebar-footer {
    justify-content:center;
    padding:8px 6px;
    gap:0;
  }

  #session-user {
    display:none;
  }

  main {
    width:calc(100% - 68px);
    margin-left:68px;
    padding:12px 14px 32px;
  }

  header {
    align-items:flex-start;
    flex-direction:column;
    gap:10px;
  }

  .header-actions {
    width:100%;
  }

  .header-actions button {
    flex:1;
  }

  h1 {
    font-size:20px;
  }

  .toolbar {
    flex-wrap:wrap;
  }

  .toolbar input {
    width:100%;
  }

  .toolbar #count {
    width:100%;
    margin-left:0;
  }

  .dashboard-grid {
    grid-template-columns:1fr;
  }

  .dashboard-panel:nth-of-type(10) {
    grid-column:auto;
  }

  .quick-actions {
    grid-template-columns:1fr;
  }

  .cards {
    grid-template-columns:1fr;
  }

  .form-grid {
    grid-template-columns:1fr;
  }

  .profile-info { grid-template-columns:1fr; }

  .field.full {
    grid-column:auto;
  }

  dialog {
    width:95vw;
  }

  dialog form {
    padding:21px;
  }

  .actions {
    flex-direction:column-reverse;
  }

  .actions button {
    width:100%;
  }
}

/* GST Report */
.gst-report .form-grid { grid-template-columns:repeat(4,1fr); }
.gst-report .card { margin-bottom:14px; }
.gst-report .card h3 { margin:0 0 10px; font-size:14px; color:var(--navy); border-bottom:1px solid var(--line); padding-bottom:6px; }
.gst-summary-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:8px; margin-bottom:8px; }
.gst-stat-card { background:#fff; border:1px solid var(--line); border-radius:8px; padding:10px 12px; }
.gst-stat-label { display:block; color:var(--muted); font-size:11px; font-weight:600; margin-bottom:4px; text-transform:uppercase; letter-spacing:.3px; }
.gst-stat-card strong { display:block; font-size:18px; color:var(--navy); font-variant-numeric:tabular-nums; }
.gst-table { width:100%; border-collapse:collapse; margin:10px 0; font-size:12px; }
.gst-table th, .gst-table td { border:1px solid var(--line); padding:5px 7px; text-align:right; }
.gst-table th:first-child, .gst-table td:first-child, .gst-table th:nth-child(2), .gst-table td:nth-child(2) { text-align:left; }
.gst-table thead th { background:#eef6fb; color:var(--navy); font-size:11px; position:sticky; top:0; }
.gst-table tbody tr:nth-child(even) { background:#fafbfc; }
.gst-table-wrapper { overflow-x:auto; max-height:500px; overflow-y:auto; border:1px solid var(--line); border-radius:6px; }
.gst-invoice-table { font-size:12px; }
.gst-note { font-size:11px; color:var(--muted); margin-top:12px; line-height:1.5; border-top:1px dashed var(--line); padding-top:8px; }
.gst-month-chart { display:grid; gap:4px; margin:8px 0; }
.gst-bar-row { display:grid; grid-template-columns:110px 1fr 80px; align-items:center; gap:6px; font-size:11px; }
.gst-bar-label { color:var(--muted); text-align:right; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.gst-bar-track { background:#f1f5f9; border-radius:3px; height:12px; overflow:hidden; }
.gst-bar-fill { display:block; height:100%; background:linear-gradient(90deg,#1769aa,#3ba4e8); min-width:1px; transition:width .3s; }
.gst-bar-value { font-variant-numeric:tabular-nums; color:var(--ink); text-align:right; }
.gst-month-table { font-size:12px; }
.gst-zero-month { color:var(--muted); }
.gst-zero-month td { opacity:.6; }
.gst-section { margin-bottom:16px; }
.gst-section-title { font-size:13px; font-weight:600; color:var(--navy); margin:0 0 8px; padding-bottom:4px; border-bottom:1px solid var(--line); }
@media(max-width:900px) { .gst-report .form-grid { grid-template-columns:1fr; } .gst-bar-row { grid-template-columns:90px 1fr 70px; } }

/* =========================
   SMALL MOBILE
========================= */

@media(max-width:450px) {

  aside {
    width:58px;
  }

  main {
    width:calc(100% - 58px);
    margin-left:58px;
    padding:20px 12px 35px;
  }

  .brand img {
    width:34px;
    height:34px;
  }

  .stat-card {
    min-height:100px;
    padding:17px;
  }

  .stat-card strong {
    font-size:25px;
  }

  .header-actions {
    flex-direction:column;
  }

  .header-actions button {
    width:100%;
  }

}

/* ===== AI Assistant (Phase 1) ===== */
.ai-note {
  font-size:11px;
  color:var(--muted);
  margin:8px 0 0;
}

.ai-summary-body {
  max-height:52vh;
  overflow-y:auto;
  padding-right:4px;
}

.ai-section {
  margin:0 0 14px;
}

.ai-section h4 {
  margin:0 0 6px;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.5px;
  color:var(--navy);
}

.ai-kv {
  display:grid;
  grid-template-columns:170px 1fr;
  gap:4px 10px;
  font-size:13px;
}

.ai-chip {
  display:inline-block;
  font-size:10px;
  font-weight:700;
  padding:2px 7px;
  border-radius:999px;
  margin-left:6px;
  vertical-align:middle;
}

.ai-chip-fact {
  background:#e7f4ee;
  color:#087f5b;
}

.ai-chip-suggestion {
  background:#fdf3e0;
  color:#8a5a00;
}

.ai-list {
  margin:4px 0 0;
  padding-left:18px;
  font-size:13px;
}

.ai-risk {
  color:#b42318;
}

.ai-chat-card {
  display:flex;
  flex-direction:column;
  gap:10px;
}

.ai-chat-context {
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

.ai-chat-context label {
  font-size:12px;
  font-weight:700;
  color:var(--muted);
}

.ai-chat-context select {
  border:1px solid var(--line);
  border-radius:7px;
  padding:6px 8px;
  font-size:13px;
  background:#fff;
}

.ai-chat-messages {
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:220px;
  max-height:52vh;
  overflow-y:auto;
  background:#f8fafc;
  border:1px solid var(--line);
  border-radius:10px;
  padding:12px;
}

.ai-msg {
  max-width:85%;
  padding:9px 12px;
  border-radius:10px;
  font-size:13px;
  white-space:pre-wrap;
}

.ai-msg-user {
  align-self:flex-end;
  background:#1769aa;
  color:#fff;
}

.ai-msg-ai {
  align-self:flex-start;
  background:#fff;
  border:1px solid var(--line);
}

.ai-busy {
  color:var(--muted);
  font-size:12px;
}

.ai-chat-input-row {
  display:flex;
  gap:8px;
}

.ai-chat-input-row input {
  flex:1;
}

.ai-followup {
  display:flex;
  gap:8px;
  margin-top:10px;
}

.ai-followup input {
  flex:1;
}

.ai-followup-answer {
  margin-top:10px;
  padding:10px 12px;
  background:#f8fafc;
  border:1px solid var(--line);
  border-radius:10px;
  font-size:13px;
  white-space:pre-wrap;
}

/* =========================
   ROLE & PERMISSION (Users + AI Audit)
========================= */

.users-layout { display:grid; grid-template-columns:1fr; gap:16px; }
.users-layout .card { padding:18px; }
.users-layout .form-grid { grid-template-columns:repeat(3,1fr); }
.user-list { display:grid; gap:10px; }
.user-row {
  display:grid;
  grid-template-columns:1fr auto auto auto auto;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  background:#f8fafc;
  border:1px solid var(--line);
  border-radius:9px;
}
.user-row .badge { }
.user-role { padding:6px 8px; border:1px solid var(--line); border-radius:6px; }
.user-toggle { padding:7px 12px; font-size:12px; }

.ai-audit-card { margin-top:18px; }
.ai-settings-card { margin-top:18px; }
.ai-msg-note {
  margin-top:6px;
  font-size:12px;
  color:var(--warning);
  background:var(--warning-bg);
  border-radius:6px;
  padding:6px 9px;
}
.ai-audit-list { display:grid; gap:10px; margin-top:10px; }
.ai-audit-row {
  padding:10px 12px;
  background:#f8fafc;
  border:1px solid var(--line);
  border-radius:9px;
  display:grid;
  gap:6px;
}
.ai-audit-head { display:flex; justify-content:space-between; gap:10px; font-size:12px; color:var(--muted); }
.ai-audit-body { font-size:13px; color:var(--ink); display:grid; gap:4px; }
.error-text { color:var(--danger); }
.profile-heading-row .secondary { padding:8px 12px; font-size:13px; }

/* ===== WhatsApp click-to-chat (wa.me) ===== */
.wa-btn { color:#0f7a5a; }
.wa-btn:hover { text-decoration:underline; }
button.wa-btn:disabled {
  color:#94a3b8;
  cursor:not-allowed;
  text-decoration:none;
}
.wa-message-field textarea { min-height:190px; }

/* ===== Email composer (mailto: / quick contact) ===== */
.email-btn { color:#1d4ed8; }
.email-btn:hover { text-decoration:underline; }
button.email-btn:disabled {
  color:#94a3b8;
  cursor:not-allowed;
  text-decoration:none;
}
.email-message-field textarea { min-height:190px; }

