/* Shared theme for the salesperson keypad and manager dashboard pages.
   Brand colors match the invoice PDF letterhead (app/templates/invoice.html):
   navy #1b3b6f, red #c8202c. Chart colors follow a single-hue "sequential" rule
   (one navy tone per bar, never a per-bar value ramp on nominal categories) —
   see the dataviz skill this was built against. */

:root {
  --navy: #1b3b6f;
  --navy-dark: #12294f;
  --navy-light: #e8edf5;
  --red: #c8202c;
  --red-dark: #a01722;
  --red-light: #fbe9ea;
  --green: #1c8a4b;
  --green-light: #e6f4ec;

  --page-bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e8ef;
  --gridline: #edf1f6;

  --text-primary: #16202b;
  --text-secondary: #5b6b7d;
  --text-muted: #94a1b0;

  --chart-bar: #3d5c94;
  --chart-bar-hover: #1b3b6f;

  --shadow-sm: 0 1px 2px rgba(16, 35, 63, .06);
  --shadow-md: 0 8px 24px rgba(16, 35, 63, .12);
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

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

/* ---------- Auth screen ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 55%, #0b1930 100%);
  padding: 1rem;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(6, 14, 28, .4);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.auth-logo { width: 64px; height: 64px; border-radius: 50%; display: block; margin: 0 auto 1rem; box-shadow: var(--shadow-sm); }
.auth-title { text-align: center; font-weight: 700; font-size: 1.25rem; color: var(--navy); margin: 0 0 .15rem; }
.auth-subtitle { text-align: center; font-size: .82rem; color: var(--text-muted); margin: 0 0 1.75rem; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.navbar-brand { display: flex; align-items: center; gap: .75rem; }
.navbar-logo { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow-sm); }
.navbar-titles { line-height: 1.15; }
.navbar-title { font-weight: 700; color: var(--navy); font-size: 1.02rem; }
.navbar-subtitle { font-size: .72rem; color: var(--text-muted); }
.navbar-right { position: relative; display: flex; align-items: center; gap: .75rem; }
.navbar-name { font-size: .85rem; color: var(--text-secondary); }

.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--navy); color: #fff; font-weight: 700; font-size: .92rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none;
}
.avatar-btn:hover { background: var(--navy-dark); }
.avatar-menu {
  position: absolute; right: 0; top: 48px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); min-width: 210px; overflow: hidden; z-index: 60;
}
.avatar-menu-header { padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.avatar-menu-name { font-weight: 700; font-size: .9rem; }
.avatar-menu-role { font-size: .74rem; color: var(--text-muted); text-transform: capitalize; }
.avatar-menu-item {
  display: block; width: 100%; text-align: left; padding: .7rem 1rem;
  background: none; border: none; cursor: pointer; font-size: .87rem; color: var(--text-primary);
}
.avatar-menu-item:hover { background: var(--page-bg); }

/* ---------- Edit profile modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22, 32, 43, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 1.75rem; width: 100%; max-width: 380px;
}

/* ---------- App shell (sidebar layout for manager pages) ---------- */
.app-shell { display: flex; align-items: flex-start; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 1.5rem 1rem; position: sticky; top: 64px; height: calc(100vh - 64px); box-sizing: border-box;
  overflow-y: auto;
}
.sidebar-link {
  display: flex; align-items: center; gap: .6rem; padding: .65rem .9rem; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none; font-size: .89rem; font-weight: 600;
  margin-bottom: .25rem;
}
.sidebar-link:hover { background: var(--page-bg); }
.sidebar-link.active { background: var(--navy-light); color: var(--navy); }
.sidebar-icon { width: 1.2em; text-align: center; }
.main-content { flex: 1; min-width: 0; }

.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 1.1rem 0; }
.sidebar-section-title {
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin: 0 0 .6rem .1rem;
}
.sidebar-widget select {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: .85rem; background: #fff; color: var(--text-primary); font-family: inherit;
  margin-bottom: .5rem;
}
.sidebar-widget .btn { width: 100%; padding: .55rem .9rem; font-size: .83rem; }
.commission-code-result {
  margin-top: .65rem; padding: .65rem .7rem; border-radius: 8px; background: var(--navy-light);
  font-size: .82rem; color: var(--navy); text-align: center;
}
.commission-code-result .code-value {
  display: block; font-size: 1.3rem; font-weight: 700; letter-spacing: .1em; margin-top: .15rem;
}

/* ---------- Layout ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.page-header { margin-bottom: 1.5rem; }
.page-welcome { font-size: 1.4rem; font-weight: 700; margin: 0 0 .2rem; }
.page-subtitle { font-size: .92rem; color: var(--text-secondary); margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 1.5rem;
}

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.25rem; border-radius: 8px; font-size: .89rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s;
  font-family: inherit;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { background: var(--page-bg); }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red-light); }
.btn-danger:hover { background: var(--red-light); }
.btn-approve { background: var(--green); color: #fff; }
.btn-approve:hover { background: #156b3a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: none; color: var(--navy); font-weight: 600; cursor: pointer; padding: 0; font-size: .87rem; font-family: inherit; }
.btn-block { width: 100%; }

.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .35rem; font-size: .82rem; font-weight: 600; color: var(--text-secondary); }
.field input, .field select {
  width: 100%; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: .92rem; background: #fff; color: var(--text-primary); font-family: inherit;
}
.field input:focus, .field select:focus { outline: 3px solid var(--navy-light); border-color: var(--navy); }

.err-msg { color: var(--red); font-size: .85rem; margin: .5rem 0 0; min-height: 1.1em; }
.info-msg { color: var(--navy); font-size: .85rem; margin: .5rem 0 0; }

.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.pill-green { background: var(--green-light); color: var(--green); }
.pill-red { background: var(--red-light); color: var(--red); }
.pill-navy { background: var(--navy-light); color: var(--navy); }

/* ---------- Stepper (sales wizard) ---------- */
.stepper { display: flex; align-items: flex-start; margin: .5rem 0 2rem; }
.stepper-step { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; width: 130px; }
.stepper-circle {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .88rem; border: 2px solid var(--border); background: #fff; color: var(--text-muted);
  transition: all .15s;
}
.stepper-step.active .stepper-circle { border-color: var(--navy); background: var(--navy); color: #fff; }
.stepper-step.done .stepper-circle { border-color: var(--navy); background: var(--navy-light); color: var(--navy); }
.stepper-label { margin-top: .5rem; font-size: .76rem; text-align: center; color: var(--text-muted); font-weight: 600; }
.stepper-step.active .stepper-label, .stepper-step.done .stepper-label { color: var(--text-primary); }
.stepper-line { flex: 1 1 auto; height: 2px; background: var(--border); margin-top: 17px; }
.stepper-line.done { background: var(--navy); }

/* ---------- Keypad ---------- */
.keypad { display: grid; grid-template-columns: repeat(auto-fill, minmax(188px, 1fr)); gap: .6rem; }
.keypad-btn {
  min-height: 117px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  color: var(--text-primary); cursor: pointer; padding: .75rem .6rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .225rem;
  transition: all .12s; font-family: inherit;
}
.keypad-btn:hover:not(:disabled) { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-light); }
.keypad-btn:disabled { background: var(--page-bg); color: var(--text-muted); border-color: var(--border); text-decoration: line-through; cursor: not-allowed; }
.keypad-btn.in-cart {
  background: var(--navy); color: #fff; border-color: var(--navy); text-decoration: none; cursor: pointer;
}
.keypad-btn.in-cart:hover { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 3px var(--red-light); }
.keypad-num { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.keypad-name { font-size: .98rem; font-weight: 400; line-height: 1.1; text-align: center; opacity: .7; }

/* ---------- Sales cart (multi-item wizard, step 1) ---------- */
.cart-summary { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.cart-summary h4 { margin: 0 0 .6rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.cart-line { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--gridline); font-size: .87rem; }
.cart-line-name { flex: 1 1 auto; }
.cart-line-remove {
  background: none; border: none; color: var(--red); cursor: pointer; font-size: 1.1rem;
  line-height: 1; padding: 0 .2rem; font-family: inherit;
}
.cart-subtotal { display: flex; justify-content: space-between; padding-top: .75rem; font-weight: 700; font-size: .92rem; }

/* ---------- KPI tiles ---------- */
.kpi-row { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0 0 1.5rem; }
.kpi-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 1.15rem 1.4rem; min-width: 170px; flex: 1 1 170px;
}
.kpi-value { font-size: 1.9rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi-label { font-size: .8rem; color: var(--text-secondary); margin-top: .3rem; }

/* ---------- Charts ---------- */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.chart-row .chart-card { margin-bottom: 0; }
@media (max-width: 720px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.5rem; margin-bottom: 1.5rem; }
.chart-title { font-size: .95rem; font-weight: 700; color: var(--text-primary); margin: 0 0 .15rem; }
.chart-subtitle { font-size: .78rem; color: var(--text-muted); margin: 0 0 1rem; }
.chart-empty { font-size: .85rem; color: var(--text-muted); padding: 2rem 0; text-align: center; }

.chart-tooltip {
  position: fixed; pointer-events: none; background: var(--navy-dark); color: #fff;
  padding: .5rem .7rem; border-radius: 8px; font-size: .78rem; box-shadow: var(--shadow-md);
  z-index: 100; white-space: nowrap; opacity: 0; transition: opacity .08s;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-value { font-weight: 700; font-size: .85rem; display: block; }
.chart-tooltip .tt-label { color: #c7d2e3; }

/* SVG chart marks (see static/charts.js) */
.chart-gridline { stroke: var(--gridline); stroke-width: 1; }
.chart-baseline { stroke: var(--border); stroke-width: 1; }
.chart-axis-text { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.chart-bar-rect { fill: var(--chart-bar); transition: fill .1s; }
.chart-bar-rect.hovered { fill: var(--chart-bar-hover); }
.chart-hit { fill: transparent; cursor: pointer; }

/* ---------- Data tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: .6rem .9rem .6rem 0; border-bottom: 1px solid var(--border); }
.data-table td { padding: .65rem .9rem .65rem 0; border-bottom: 1px solid var(--gridline); font-size: .87rem; }
.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr.sp-row { cursor: pointer; }
.data-table tr.sp-row:hover { background: var(--page-bg); }
.data-table tr.expand-row > td { padding: 0; }
.expand-inner { padding: .75rem 1rem .75rem 2rem; background: var(--page-bg); }
.expand-inner table.data-table { margin-bottom: 0; }
.caret { display: inline-block; width: 1em; color: var(--navy); }

h2.section-title { font-size: 1rem; font-weight: 700; margin: 2rem 0 .75rem; color: var(--text-primary); }
