:root {
  --navy: #1f3a5f;
  --navy-dark: #152a46;
  --bg: #f3f5f8;
  --border: #d5dbe3;
  --text: #1d2733;
  --muted: #5f6b7a;
  --error: #b42318;
  --success: #067647;
  --accent: #f2a65a;
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }

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

a { color: var(--navy); }

/* ---------- App shell: sidebar + main ---------- */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #13263f 0%, #0d1b2e 100%);
  color: #c9d4e3;
  z-index: 30;
  transition: transform 0.25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.7rem; padding: 1.25rem 1.25rem 1rem; text-decoration: none; color: #fff; }
.sidebar-brand span { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand strong { font-size: 1.02rem; }
.sidebar-brand small { color: #8fa3bd; font-size: 0.78rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.25rem 0.75rem 1rem; scrollbar-width: thin; scrollbar-color: #2a4061 transparent; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.nav-heading { margin: 1.1rem 0.6rem 0.35rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #6f84a1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  margin: 1px 0;
  border-radius: 8px;
  color: #c9d4e3;
  text-decoration: none;
  font-size: 0.92rem;
  position: relative;
}
a.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link.active { background: rgba(242, 166, 90, 0.14); color: #fff; font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -0.75rem; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-link.active .icon { color: var(--accent); }
.nav-link.disabled { color: #627590; cursor: default; }
.badge { margin-left: auto; font-style: normal; font-size: 0.65rem; font-weight: 600; padding: 0.1rem 0.45rem; border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: #7d90aa; }

.sidebar-user { display: flex; align-items: center; gap: 0.6rem; padding: 0.9rem 1rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #13263f; font-weight: 700; font-size: 0.85rem; }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-user-text strong { color: #fff; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-text small { color: #8fa3bd; font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-actions { margin-left: auto; display: flex; gap: 0.15rem; }
.sidebar .icon-btn { color: #9fb0c6; }
.sidebar .icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: #e9edf3; color: var(--text); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.menu-toggle { display: none; }
.appbar-search { position: relative; flex: 1; max-width: 460px; margin: 0; }
.appbar-search .search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.appbar-search input[type="search"] { padding-left: 2.4rem; border-radius: 999px; background: #f3f5f8; border-color: transparent; }
.appbar-search input[type="search"]:focus { background: #fff; border-color: var(--border); }
.appbar-new { margin-left: auto; display: inline-flex; align-items: center; gap: 0.4rem; border-radius: 999px; }
.appbar-new .icon { width: 18px; height: 18px; }

.sidebar-backdrop { display: none; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.75rem; }
body.plain .container { max-width: 1100px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.muted { color: var(--muted); }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 420px; margin: 3rem auto; }
fieldset.card { min-width: 0; }
legend { font-weight: 600; padding: 0 0.4rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.75rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  font: inherit;
  font-weight: 400;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  width: 100%;
}
input[readonly] { background: #eef1f5; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid #4a7fc1; outline-offset: 1px; }
input.upper { text-transform: uppercase; }
label.check { flex-direction: row; align-items: center; font-weight: 400; gap: 0.5rem; }

button, .button {
  font: inherit;
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
button.primary, .button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--navy-dark); }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; }
form.inline { display: inline; margin: 0; }

.toolbar { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar label { margin-bottom: 0; }
.toolbar .grow { flex: 1 1 260px; }
.toolbar .status { margin-left: auto; color: var(--muted); align-self: center; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 1rem; }
.span-2 { grid-column: span 2; }
.checks { display: flex; flex-direction: column; justify-content: center; }

/* ---------- Record forms ---------- */
.form-heading { margin-bottom: 1.35rem; }
.back-link { display: inline-flex; align-items: center; margin-bottom: 1rem; color: var(--muted); font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--navy); }
.form-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.form-title-row h1 { margin: 0; color: #172b45; font-size: clamp(1.65rem, 2.5vw, 2rem); letter-spacing: -0.035em; }
.eyebrow { margin: 0 0 0.35rem; color: #8a5a22; font-size: 0.7rem; font-weight: 750; letter-spacing: 0.13em; text-transform: uppercase; }
.form-subtitle { margin: 0.4rem 0 0; color: var(--muted); }
.mode-badge { display: inline-flex; align-items: center; gap: 0.45rem; flex: none; padding: 0.45rem 0.75rem; border: 1px solid #c8d8ed; border-radius: 999px; background: #edf4fc; color: #274a73; font-size: 0.78rem; font-weight: 650; }
.mode-badge::before { width: 7px; height: 7px; border-radius: 50%; background: #4c7eb5; content: ""; }
.mode-badge.mode-new { border-color: #c7e8d5; background: #effaf3; color: #17613b; }
.mode-badge.mode-new::before { background: #2b9a5b; }
.modern-form .form-section { padding: 1.35rem; border-color: #e0e5ec; border-radius: 12px; box-shadow: 0 2px 8px rgba(20, 38, 63, 0.035); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; padding-bottom: 0.85rem; border-bottom: 1px solid #edf0f4; }
.section-heading h2, .related-section h2 { margin: 0; color: #203752; font-size: 1rem; }
.section-heading p, .section-subtitle { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.84rem; }
.modern-form label { gap: 0.4rem; margin-bottom: 1rem; color: #344256; font-size: 0.82rem; font-weight: 650; }
.modern-form input[type="text"], .modern-form input[type="email"], .modern-form input[type="number"], .modern-form select {
  min-height: 42px;
  padding: 0.6rem 0.75rem;
  border-color: #d6dde7;
  border-radius: 7px;
  color: #1d2733;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.modern-form textarea { min-height: 82px; padding: 0.65rem 0.75rem; border: 1px solid #d6dde7; border-radius: 7px; font: inherit; resize: vertical; transition: border-color 0.15s, box-shadow 0.15s; }
.modern-form input:not([type="checkbox"]):focus, .modern-form select:focus { outline: none; border-color: #5279a8; box-shadow: 0 0 0 3px rgba(52, 100, 157, 0.14); }
.modern-form textarea:focus { outline: none; border-color: #5279a8; box-shadow: 0 0 0 3px rgba(52, 100, 157, 0.14); }
.modern-form input[readonly] { border-style: dashed; color: #657286; }
.modern-form input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--navy); }
.modern-form .check-cards { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.65rem; }
.modern-form .check-card { display: flex; flex-direction: row; align-items: center; gap: 0.7rem; min-height: 64px; margin: 0 0 0.25rem; padding: 0.7rem 0.8rem; border: 1px solid #e0e5ec; border-radius: 8px; background: #fafbfd; cursor: pointer; }
.modern-form .check-card:has(input:checked) { border-color: #b7cae0; background: #f1f6fc; }
.modern-form .check-card span { display: flex; flex-direction: column; gap: 0.1rem; }
.modern-form .check-card strong { color: #2d3d52; font-size: 0.8rem; }
.modern-form .check-card small { color: var(--muted); font-size: 0.72rem; font-weight: 400; }
.modern-form .compact-check { align-self: end; }
.field-note { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.8rem; }
.form-actions { position: sticky; bottom: 12px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.25rem 0; padding: 0.8rem 1rem; border: 1px solid rgba(210, 218, 229, 0.95); border-radius: 12px; background: rgba(255, 255, 255, 0.94); box-shadow: 0 8px 24px rgba(20, 38, 63, 0.11); backdrop-filter: blur(12px); }
.form-actions .status { color: var(--muted); font-size: 0.84rem; }
.form-action-buttons { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.form-actions button, .form-actions .button { min-height: 40px; padding: 0.55rem 0.95rem; }
.form-actions .primary { box-shadow: 0 2px 5px rgba(31, 58, 95, 0.2); font-weight: 650; }
.related-section { border-radius: 12px; }
.related-section .page-head { align-items: flex-start; }
.related-link { margin: 0 0 0.8rem; font-size: 0.85rem; font-weight: 600; }
.form-tabs { display: none; }
.tabbed-form.is-tabbed .form-tabs { display: flex; align-items: center; gap: 0.25rem; margin: 0 0 1rem; padding: 0.3rem; overflow-x: auto; border: 1px solid #e0e5ec; border-radius: 10px; background: #e9edf3; }
.form-tabs [role="tab"] { position: relative; min-height: 42px; flex: 1 0 auto; padding: 0.6rem 1rem; border-color: transparent; border-radius: 7px; background: transparent; color: #536174; font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.form-tabs [role="tab"]:hover { background: rgba(255, 255, 255, 0.55); color: #253a56; }
.form-tabs [role="tab"][aria-selected="true"] { border-color: #fff; background: #fff; color: #1f3a5f; box-shadow: 0 1px 3px rgba(20, 38, 63, 0.12); }
.form-tabs [role="tab"]:focus-visible { outline: 2px solid #4a7fc1; outline-offset: 1px; }
.form-panel[hidden] { display: none !important; }
.tabbed-form.has-errors .form-tabs { display: none; }

/* ---------- Sales ---------- */
.sales-search { padding: 1rem; border: 1px solid #e0e5ec; border-radius: 12px; background: #fff; }
.sale-reference { font-weight: 700; text-decoration: none; }
.sales-actions { width: 64px; text-align: center !important; }
.sale-edit { color: var(--navy); }
.sale-edit:hover { background: #e9edf3; color: var(--navy-dark); }
.table-secondary { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.75rem; }
.sale-status { display: inline-block; padding: 0.25rem 0.55rem; border: 1px solid transparent; border-radius: 999px; font-size: 0.72rem; font-weight: 650; white-space: nowrap; }
.sale-status.is-paid { border-color: #bce4cb; background: #effaf3; color: #17613b; }
.sale-status.is-due { border-color: #f3d7a5; background: #fff8e8; color: #885d17; }
.sale-status.is-posted { border-color: #cbd8e7; background: #eff4fa; color: #3b536f; }
.sale-status.is-draft { border-color: #f0d2ac; background: #fff6ea; color: #80501a; }
.sale-ref-chip { padding: 0.45rem 0.7rem; border: 1px solid #d9e2ed; border-radius: 7px; background: #f5f8fc; color: #334c69; font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.sale-flags { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.65rem; margin-top: 0.25rem; }
.modern-form .sale-flags .check-card, .modern-form .delivery-toggle { margin-bottom: 0; }
.sale-lock-notice { margin-bottom: 1rem; }
.sale-line { margin-bottom: 0.85rem; padding: 1rem; border: 1px solid #e0e5ec; border-radius: 10px; background: #fbfcfe; }
.sale-line-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; color: #33465f; font-size: 0.85rem; }
.sale-line-grid { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(125px, 1fr)); gap: 0 0.8rem; }
.sale-line-grid label { min-width: 0; }
.sale-product-field { grid-column: span 2; }
.sale-line-notes { grid-column: span 2; }
.sale-product-description { min-height: 1em; color: var(--muted); font-size: 0.74rem; font-weight: 400; line-height: 1.35; }
.sale-line-totals { display: flex; align-items: center; justify-content: flex-end; gap: 1.4rem; padding-top: 0.65rem; border-top: 1px solid #e7ebf1; color: var(--muted); font-size: 0.78rem; }
.sale-line-totals strong { margin-left: 0.25rem; color: #273c57; font-variant-numeric: tabular-nums; }
.button-subtle { padding: 0.3rem 0.6rem; color: var(--muted); font-size: 0.75rem; }
.button-subtle:hover:not(:disabled) { border-color: #efc0bd; background: #fff4f3; color: var(--error); }
.button-subtle:disabled { opacity: 0.45; cursor: not-allowed; }
.sale-lines-ready [data-add-sale-line] { display: inline-block; }
.sale-total-bar { display: flex; justify-content: flex-end; gap: 1.5rem; margin-top: 1rem; padding: 1rem 1.1rem; border: 1px solid #d9e2ed; border-radius: 9px; background: #f3f7fc; color: #485a70; font-size: 0.82rem; }
.sale-total-bar span:last-child { color: #203752; }
.sale-total-bar strong { display: block; margin-top: 0.2rem; color: #203752; font-size: 1rem; font-variant-numeric: tabular-nums; }
.read-only-total { margin-left: auto; max-width: 360px; }
.packing-heading { margin-top: 1.5rem; }
.sale-form [data-add-sale-line] { display: none; }
.sale-form.sale-lines-ready [data-add-sale-line] { display: inline-block; flex: none; }
.sale-form [data-remove-sale-line] { display: none; }
.sale-form.sale-lines-ready [data-remove-sale-line] { display: inline-block; }

.alert { padding: 0.75rem 1rem; border-radius: 6px; background: #eef4ff; border: 1px solid #c7d7f5; }
.alert.error { background: #fef3f2; border-color: #fecdca; color: var(--error); }
.alert.success { background: #ecfdf3; border-color: #abefc6; color: var(--success); }
.alert ul { margin: 0.25rem 0 0; }
.alert p { margin: 0; }

/* ---------- Dashboard ---------- */
.dash-hero { margin-bottom: 1.5rem; }
.dash-hero h1 { font-size: 1.75rem; margin: 0 0 0.2rem; }
.dash-hero p { margin: 0; }
.dash-date { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #b8643a; margin-bottom: 0.3rem !important; }
.dashboard .dash-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.financial-privacy-toggle { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; font-size: 0.85rem; position: relative; }
.financial-privacy-toggle input { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 44px; height: 24px; margin: 0; opacity: 0; z-index: 1; cursor: pointer; }
.financial-privacy-slider { width: 44px; height: 24px; background: #667085; border-radius: 12px; position: relative; flex: none; }
.financial-privacy-slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; }
.financial-privacy-toggle input:checked + .financial-privacy-slider { background: var(--navy); }
.financial-privacy-toggle input:checked + .financial-privacy-slider::after { transform: translateX(20px); }
.financial-privacy-toggle input:focus-visible + .financial-privacy-slider { outline: 2px solid var(--navy); outline-offset: 3px; }
.financial-data { display: inline-block; }
.dashboard:has(#blur-financial-data:checked) .financial-data { filter: blur(8px); user-select: none; pointer-events: none; }
.dashboard-stat-content { display: flex; flex-direction: column; padding: 1.25rem; }
.dashboard-card-toggle { cursor: pointer; list-style: none; }
.dashboard-card-toggle::-webkit-details-marker { display: none; }
.dashboard-card-toggle::after { content: "+"; font-size: 1.25rem; font-weight: 600; }
.dashboard-stat-panel[open] > .dashboard-card-toggle::after { content: "-"; }
.dashboard-card-toggle:focus-visible { outline: 2px solid var(--navy); outline-offset: -3px; }
.dashboard-stat-panel:not([open]) > .dashboard-card-toggle { border-bottom: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: transform 0.15s, box-shadow 0.15s;
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16, 24, 40, 0.08); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat-icon .icon { width: 24px; height: 24px; }
.stat-body { display: flex; flex-direction: column; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.88rem; }
.tone-navy .stat-icon { background: #e6edf6; color: var(--navy); }
.tone-green .stat-icon { background: #e3f6ec; color: var(--success); }
.tone-amber .stat-icon { background: #fdf0e1; color: #b8643a; }
.tone-blue .stat-icon { background: #e5f1fb; color: #1d6fb8; }
.sales-stat-card { align-items: flex-start; }
.sales-stat-body { flex: 1; min-width: 0; gap: 0.35rem; }
.sales-period-heading { font-size: 0.88rem; font-weight: 600; }
.sales-comparison { display: grid; gap: 0.5rem; margin-top: 0.25rem; }
.sales-comparison-row { display: grid; grid-template-columns: minmax(3rem, 0.35fr) repeat(2, minmax(0, 1fr)) minmax(9rem, auto); gap: 1rem; align-items: center; }
.sales-comparison-row > span { display: flex; flex-direction: column; }
.sales-comparison-row > span > strong { font-size: 1.15rem; }
.sales-comparison-row small { color: var(--muted); font-size: 0.78rem; }
.sales-comparison-row > .sales-change { display: inline-flex; flex-direction: row; justify-self: start; align-items: center; gap: 0.25rem; border-radius: 999px; padding: 0.35rem 0.65rem; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.sales-change.is-increase { background: #e3f6ec; color: var(--success); }
.sales-change.is-decrease { background: #fde9e7; color: #b42318; }
.sales-change.is-unchanged { background: #f1f3f5; color: var(--muted); }
.due-stat-card { color: var(--text); }
.tone-green .stat-icon { background: #e3f6ec; color: var(--success); }
.due-sales-count { font-size: 1.5rem; font-weight: 700; }
.due-sales-values { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.due-overdue-section { display: flex; flex-direction: column; gap: 0.35rem; border-top: 1px solid var(--border); margin-top: 0.5rem; padding-top: 0.75rem; }
.due-sales-actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.2rem; }
.due-sales-link-hint { color: var(--accent); font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.due-sales-link-hint:hover { text-decoration: underline; }

.monthly-sales-panel { margin-bottom: 1.25rem; }
.monthly-sales-toggle, .top-customers-toggle { cursor: pointer; list-style: none; }
.monthly-sales-toggle::-webkit-details-marker, .top-customers-toggle::-webkit-details-marker { display: none; }
.monthly-sales-toggle::after, .top-customers-toggle::after { content: "+"; font-size: 1.25rem; font-weight: 600; }
.monthly-sales-panel[open] > .monthly-sales-toggle::after, .top-customers-panel[open] > .top-customers-toggle::after { content: "-"; }
.monthly-sales-toggle:focus-visible, .top-customers-toggle:focus-visible { outline: 2px solid var(--navy); outline-offset: -3px; }
.monthly-sales-panel:not([open]) > .monthly-sales-toggle, .top-customers-panel:not([open]) > .top-customers-toggle { border-bottom: 0; }
.monthly-sales-note { margin: 1rem 1.25rem; font-size: 0.85rem; }
.monthly-sales-legend { display: flex; gap: 1.25rem; padding: 0 1.25rem; font-size: 0.85rem; }
.monthly-sales-legend span { display: flex; align-items: center; gap: 0.4rem; }
.monthly-sales-legend i { width: 14px; height: 14px; border-radius: 3px; }
.monthly-bar-current { fill: #1f3a5f; background: #1f3a5f; }
.monthly-bar-previous { fill: #b8643a; background: #b8643a; }
.monthly-sales-chart { margin: 1.25rem; }
.monthly-sales-chart figcaption { font-weight: 600; margin-bottom: 0.5rem; }
.monthly-sales-scroll { overflow-x: auto; }
.monthly-sales-scroll svg { display: block; width: 100%; min-width: 760px; }
.monthly-grid-line { stroke: #e5e7eb; stroke-width: 1; }
.monthly-baseline { stroke: #667085; stroke-width: 1; }
.monthly-axis-label { fill: #667085; font-size: 12px; }
.monthly-sales-details summary { cursor: pointer; font-size: 0.85rem; margin: 0.5rem 0; }
.monthly-sales-details caption { text-align: left; padding: 0.5rem 0; }

.top-customers-panel { margin-bottom: 1.25rem; }
.top-customers-note { margin: 1rem 1.25rem; font-size: 0.85rem; }
.top-customers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 1.25rem; padding: 0 1.25rem 1.25rem; }
.top-customers-list { min-width: 0; overflow-x: auto; }
.top-customers-list h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.top-customers-caption { text-align: left; font-size: 0.85rem; padding-bottom: 0.5rem; }
.top-customers-amount { white-space: nowrap; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.quick {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1.1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #1f3a5f, #2c5282);
  color: #fff;
  text-decoration: none;
  transition: filter 0.15s;
}
.quick:hover { filter: brightness(1.12); }
.quick .icon { width: 22px; height: 22px; color: var(--accent); }
.quick span { display: flex; flex-direction: column; }
.quick small { opacity: 0.75; font-size: 0.8rem; }

.dash-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 1rem; }
.panel-head a { font-size: 0.85rem; font-weight: 600; text-decoration: none; }
.panel .empty { padding: 1.25rem; margin: 0; }
table.data.compact th, table.data.compact td { padding: 0.6rem 1.25rem; }
table.data.compact th { background: #fafbfc; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.05em; }
table.data.compact tr:last-child td { border-bottom: 0; }
table.data.compact a { text-decoration: none; }

.pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pill-green { background: #e3f6ec; color: var(--success); }
.pill-grey { background: #eef1f5; color: var(--muted); }

.activity { list-style: none; margin: 0; padding: 0.5rem 1.25rem 1rem; }
.activity li { display: flex; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px dashed var(--border); }
.activity li:last-child { border-bottom: 0; }
.activity .dot { width: 9px; height: 9px; margin-top: 0.4rem; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 0 3px #fdf0e1; }
.activity span { display: flex; flex-direction: column; min-width: 0; }
.activity strong { font-size: 0.88rem; font-weight: 600; overflow-wrap: anywhere; }
.activity small { color: var(--muted); font-size: 0.78rem; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
table.data th { background: #f7f9fb; font-size: 0.85rem; }
table.data tbody tr:hover { background: #f5f8fc; }

@media (max-width: 1100px) {
  .dash-columns { grid-template-columns: 1fr; }
}

/* Sidebar becomes an off-canvas drawer on tablets and phones. */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(9, 18, 32, 0.45); z-index: 25; }
  body.sidebar-open { overflow: hidden; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .appbar { padding: 0.6rem 1rem; }
  .container { padding: 1.25rem 1rem; }
}

@media (max-width: 600px) {
  .span-2 { grid-column: auto; }
  .form-title-row { align-items: flex-start; }
  .form-title-row h1 { font-size: 1.55rem; }
  .mode-badge { padding: 0.35rem 0.55rem; font-size: 0.7rem; }
  .modern-form .form-section { padding: 1rem; }
  .form-tabs [role="tab"] { padding-inline: 0.75rem; }
  .form-actions { align-items: stretch; flex-direction: column; bottom: 8px; }
  .form-actions .status { display: none; }
  .form-action-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .form-action-buttons > * { text-align: center; }
  .sale-line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 0.65rem; }
  .sale-product-field, .sale-line-notes { grid-column: 1 / -1; }
  .sale-line-totals { justify-content: space-between; gap: 0.4rem; font-size: 0.72rem; }
  .sale-total-bar { justify-content: space-between; gap: 0.5rem; padding: 0.8rem; font-size: 0.72rem; }
  .sale-total-bar strong { font-size: 0.9rem; }
  .sales-table th, .sales-table td { white-space: nowrap; }
  .appbar-new span { display: none; }
  .appbar-new { padding: 0.5rem; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 0.6rem; padding: 1rem; }
  .sales-comparison-row { grid-template-columns: minmax(2.5rem, 0.3fr) repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .sales-comparison-row > .sales-change { grid-column: 2 / -1; }
  .sales-comparison-row > span > strong { font-size: 1rem; }
  table.data.compact th:nth-child(3), table.data.compact td:nth-child(3) { display: none; }
}

/* ---------- Login ---------- */
.login-page { background: #fff; }
.login-split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); min-height: 100vh; }

.login-hero { position: relative; overflow: hidden; background: #0b1a30; }
.login-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center bottom; }
.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 26, 48, 0.55) 0%, rgba(11, 26, 48, 0) 40%);
}
.login-hero-text { position: relative; z-index: 1; padding: 3.5rem 3rem; color: #fff; max-width: 34rem; }
.login-hero-text h2 { font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; margin: 0.25rem 0 0.75rem; }
.login-hero-text p { margin: 0; opacity: 0.85; font-size: 1.05rem; }
.login-hero-text .eyebrow { text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.8rem; font-weight: 700; color: #f2a65a; opacity: 1; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.login-box { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2.5rem; }
.login-brand strong { display: block; font-size: 1.15rem; color: var(--navy); }
.login-brand span { font-size: 0.85rem; color: var(--muted); }
.login-box h1 { font-size: 1.9rem; margin: 0 0 0.35rem; }
.login-box > .muted { margin: 0 0 1.75rem; }
.login-box .alert { margin-bottom: 1.25rem; }

.login-form label { margin-bottom: 1.1rem; }
.login-form input[type="email"], .login-form input[type="password"], .login-form input[type="text"] {
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-form input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.18); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 4.5rem !important; }
.toggle-password {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
}
button.block { width: 100%; padding: 0.8rem 1rem; font-weight: 600; border-radius: 8px; margin-top: 0.4rem; }
.login-help { font-size: 0.88rem; color: var(--muted); margin: 1.5rem 0 0; text-align: center; }
.login-footer { font-size: 0.78rem; color: var(--muted); margin: 3rem 0 0; text-align: center; }

@media (max-width: 860px) {
  .login-split { grid-template-columns: 1fr; grid-template-rows: 240px auto; }
  .login-hero-text { padding: 1.75rem 1.5rem; }
  .login-hero-text h2 { font-size: 1.5rem; }
  .login-hero-text p:not(.eyebrow) { display: none; }
  .login-brand { margin-bottom: 1.75rem; }
}

@media print {
  .sidebar, .sidebar-backdrop, .appbar, .toolbar, .form-actions, .page-head a, .back-link { display: none !important; }
  .main { margin-left: 0; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
}
