/* Aadhya ERP — SAP Fiori–inspired, desktop-first, single light theme. */

:root {
  color-scheme: light;
  --shell-bg: #16212e;
  --shell-fg: #ffffff;
  --shell-muted: #aab8c6;
  --shell-hover: rgba(255, 255, 255, 0.08);
  --shell-active: #58a6ff;

  --page: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f4;
  --line: #e2e6eb;
  --line-2: #cbd3dc;

  --ink: #1b2733;
  --ink-2: #4f6072;
  --ink-3: #66768a;

  --accent: #0a6ed1;
  --accent-hover: #0859ab;
  --accent-soft: #e8f2fc;
  --accent-ink: #ffffff;

  /* Status (fixed meaning; always shown with a label) */
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --good-ink: #17651a;
  --good-bg: #e9f6ea;
  --warn-ink: #7a5200;
  --warn-bg: #fff4d9;
  --serious-ink: #9c3d14;
  --serious-bg: #fdede6;
  --crit-ink: #a3201f;
  --crit-bg: #fbe8e8;
  --neutral-ink: #4f6072;
  --neutral-bg: #eef1f4;

  --series-1: #2a78d6;
  --grid: #e8ebef;
  --focus: #0a6ed1;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(22, 33, 46, 0.05);
  --shadow-pop: 0 10px 30px rgba(22, 33, 46, 0.18), 0 0 0 1px rgba(22, 33, 46, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* ---------- Shell bar + menu ---------- */
.shell {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 52px;
  padding: 0 16px;
  background: var(--shell-bg);
  color: var(--shell-fg);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 18px;
  margin-right: 6px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0a6ed1, #0b8fd6);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.brand-name { display: block; font-weight: 600; font-size: 15px; line-height: 1.1; }
.brand-sub { display: block; font-size: 11px; color: var(--shell-muted); letter-spacing: 0.04em; text-transform: uppercase; }

.menu { display: flex; align-items: stretch; gap: 2px; list-style: none; margin: 0; padding: 0; }
.menu > li { position: relative; display: flex; }
.menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: 0;
  background: none;
  color: var(--shell-muted);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  border-top: 3px solid transparent;
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { color: var(--shell-fg); background: var(--shell-hover); }
.menu-btn.active { color: var(--shell-fg); border-bottom-color: var(--shell-active); }
.menu-btn svg { width: 14px; height: 14px; }
.menu-btn .chev { width: 12px; height: 12px; opacity: 0.8; }

.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 300px;
  padding: 6px;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  z-index: 60;
}
.dropdown-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--accent-soft); outline: none; }
.dropdown-item .di-icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--accent);
}
.dropdown-item .di-icon svg { width: 17px; height: 17px; }
.dropdown-item strong { display: block; font-weight: 600; }
.dropdown-item small { display: block; color: var(--ink-3); font-size: 12.5px; }

.shell-right { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--shell-muted); font-size: 12.5px; }
.live { display: inline-flex; align-items: center; gap: 6px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.25); }
.live.offline .live-dot { background: var(--crit); box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.25); }
.shell :focus-visible { outline-color: var(--shell-active); }
.shell .dropdown :focus-visible { outline-color: var(--focus); }

/* ---------- Login and user menu ---------- */
body.signed-out .menu, body.signed-out .shell-right { display: none; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  border: 0; border-radius: 999px; background: none; color: var(--shell-fg); font: inherit; cursor: pointer;
}
.user-btn:hover { background: var(--shell-hover); }
.user-mark {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--shell-active); color: var(--shell-bg); font-weight: 700; font-size: 13px;
}
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-wrap { min-height: calc(100vh - 64px); display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 28px 28px 22px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-brand h1, .login-title { margin: 0; font-size: 21px; font-weight: 600; }
.login-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.login-form .input { width: 100%; font-size: 16px; padding-top: 10px; padding-bottom: 10px; }
.login-form .btn.primary { justify-content: center; padding-top: 11px; padding-bottom: 11px; font-size: 15px; }
.login-foot { margin: 16px 0 0; color: var(--ink-3); font-size: 12.5px; text-align: center; }

/* ---------- Page ---------- */
.page-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px 16px;
}
.page-head-row { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; }
.page-title { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.005em; }
.page-sub { margin: 3px 0 0; color: var(--ink-2); font-size: 13.5px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-body { padding: 20px 28px 48px; display: flex; flex-direction: column; gap: 18px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.grid.align-start { align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-7-5 { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
  flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 15px; font-weight: 600; }
.card-sub { color: var(--ink-3); font-size: 12.5px; }
.card-head .spacer + * { margin-left: auto; }
.card-body { padding: 4px 18px 16px; }
.card-foot { padding: 10px 18px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }

/* ---------- KPI tiles ---------- */
.kpi { padding: 14px 18px 14px; display: flex; flex-direction: column; gap: 6px; border-top: 3px solid var(--kpi-top, var(--accent)); }
.kpi-label { font-size: 13px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi-label svg { width: 16px; height: 16px; color: var(--ink-3); }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.kpi-value .unit { font-size: 15px; font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.kpi-foot { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--line-2); }
.kpi-accent { --kpi-top: var(--accent); }
.kpi-low { --kpi-top: var(--warn); }
.kpi-crit { --kpi-top: var(--serious); }
.kpi-out { --kpi-top: var(--crit); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-soft); border-color: #a9c7e8; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--crit-ink); }
.btn.danger.primary { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Inputs ---------- */
.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}
.textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 110, 209, 0.15); }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--crit); }
.search { position: relative; min-width: 240px; flex: 0 1 320px; }
.search svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--ink-3); }
.search .input { padding-left: 34px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field-label .req { color: var(--crit); margin-left: 2px; }
.field-hint { font-size: 12px; color: var(--ink-3); }
.field-error { font-size: 12px; color: var(--crit-ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; margin: 6px 0 -4px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-3); border-top: 1px solid var(--line); padding-top: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.toolbar .select { width: auto; min-width: 150px; }
.count-pill { font-size: 12.5px; color: var(--ink-3); }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12.5px;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .sort { display: inline-block; width: 10px; margin-left: 4px; color: var(--accent); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover td { background: #f6f9fd; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.dim td { color: var(--ink-3); }
table.data tbody tr.row-short td { background: var(--crit-bg); }
table.data tbody tr.row-short:hover td { background: #f8dcdc; }
table.data tfoot td { padding: 10px 12px; font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line-2); }
table.data td.actions { width: 1%; white-space: nowrap; text-align: right; padding: 4px 8px; }
table.data .cell-main { font-weight: 600; }
table.data .cell-sub { font-size: 12px; color: var(--ink-3); }
table.data .cell-sub.temp-note { color: var(--accent-hover); font-weight: 600; }
.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 36px 18px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); font-size: 14.5px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--neutral-ink);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.chip.ok { background: var(--good-bg); color: var(--good-ink); }
.chip.ok::before { background: var(--good); }
.chip.low { background: var(--warn-bg); color: var(--warn-ink); }
.chip.low::before { background: var(--warn); }
.chip.critical { background: var(--serious-bg); color: var(--serious-ink); }
.chip.critical::before { background: var(--serious); }
.chip.out { background: var(--crit-bg); color: var(--crit-ink); }
.chip.out::before { background: var(--crit); }
.chip.info { background: var(--accent-soft); color: var(--accent-hover); }
.chip.info::before { background: var(--accent); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.qty-in { color: var(--good-ink); font-weight: 600; }
.qty-out { color: var(--crit-ink); font-weight: 600; }

/* ---------- Message strips ---------- */
.strip { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 8px; border: 1px solid; font-size: 13.5px; }
.strip svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.strip.success { background: var(--good-bg); border-color: #b9e0bb; color: var(--good-ink); }
.strip.error { background: var(--crit-bg); border-color: #f0c2c2; color: var(--crit-ink); }
.strip.warning { background: var(--warn-bg); border-color: #f3dca0; color: var(--warn-ink); }
.strip.info { background: var(--accent-soft); border-color: #c4dcf5; color: #0b4f96; }
.strip ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; scrollbar-width: thin; }
.tab { flex: none; white-space: nowrap; border: 0; background: none; padding: 11px 12px 9px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:disabled { color: var(--ink-3); cursor: default; opacity: 0.8; }
.tab .soon { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin-left: 5px; }

/* ---------- Dialogs ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(16, 24, 34, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}
.dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
}
.dialog.wide { width: min(760px, 100%); }
.dialog.xwide { width: min(980px, 100%); }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.dialog-title { margin: 0; font-size: 17px; font-weight: 600; }
.dialog-sub { color: var(--ink-3); font-size: 12.5px; }
.dialog-body { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.dialog-foot .left { margin-right: auto; }
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-radius: 8px;
  background: #22303f;
  color: #fff;
  box-shadow: var(--shadow-pop);
  font-size: 13.5px;
  max-width: 560px;
}
.toast svg { width: 16px; height: 16px; flex: none; }
.toast.success svg { color: #6fdc6f; }
.toast.error { background: #7d1b1b; }
.toast button { border: 0; background: none; color: #9fd0ff; font-weight: 600; cursor: pointer; padding: 0 0 0 6px; }

/* ---------- Popover menu (row actions) ---------- */
.popmenu { position: fixed; z-index: 150; min-width: 180px; padding: 6px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-pop); }
.popmenu button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; }
.popmenu button:hover, .popmenu button:focus-visible { background: var(--surface-3); outline: none; }
.popmenu button svg { width: 15px; height: 15px; color: var(--ink-3); }
.popmenu button.danger { color: var(--crit-ink); }
.popmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- Combobox ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 120;
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
}
.combo-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--accent-soft); }
.combo-list li .code { font-weight: 600; min-width: 110px; }
.combo-list li .meta { margin-left: auto; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.combo-list .none { color: var(--ink-3); cursor: default; }

/* ---------- Charts ---------- */
.health-bar { display: flex; height: 22px; gap: 2px; margin: 6px 0 14px; }
.health-seg { min-width: 4px; border-radius: 0; cursor: pointer; }
.health-seg:first-child { border-radius: 4px 0 0 4px; }
.health-seg:last-child { border-radius: 0 4px 4px 0; }
.health-seg:only-child { border-radius: 4px; }
.health-seg:hover { filter: brightness(1.08); }
.legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.legend-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; background: none; text-align: left; }
.legend-item:hover { border-color: var(--line-2); background: var(--surface-2); }
.legend-key { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.legend-key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-val { font-size: 20px; font-weight: 600; }
.legend-val small { font-size: 12px; color: var(--ink-3); font-weight: 500; margin-left: 4px; }

.barchart svg { display: block; width: 100%; overflow: visible; }
.barchart .bar { fill: var(--series-1); }
.barchart .bar-hit { fill: transparent; cursor: default; }
.barchart .bar-row:hover .bar, .barchart .bar-row:focus .bar { fill: #1c5cab; }
.barchart text { fill: var(--ink-2); font-size: 12.5px; }
.barchart .val { fill: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.barchart .gridline { stroke: var(--grid); stroke-width: 1; }
.barchart .baseline { stroke: var(--line-2); stroke-width: 1; }
.chart-tip {
  position: fixed;
  z-index: 180;
  pointer-events: none;
  padding: 7px 10px;
  border-radius: 7px;
  background: #22303f;
  color: #fff;
  font-size: 12.5px;
  box-shadow: var(--shadow-pop);
}
.chart-tip b { display: block; font-size: 14px; }

.meter { position: relative; height: 6px; border-radius: 3px; background: var(--surface-3); min-width: 90px; overflow: hidden; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.meter.low i { background: var(--warn); }
.meter.critical i { background: var(--serious); }
.meter.out i { background: var(--crit); }
.meter.ok i { background: var(--good); }

/* ---------- Item master layout ---------- */
.master-detail { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.master-detail .search { flex: 0 1 240px; min-width: 180px; }
table.data.dense td { padding: 7px 10px; }
table.data.dense th { padding: 9px 10px; }
.clip-sm { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Laptop screens: keep the whole Item Master table, including the edit icons, in view (a Windows scrollbar takes ~17 px) */
@media (max-width: 1500px) {
  .master-detail { grid-template-columns: 200px minmax(0, 1fr); gap: 14px; }
  table.data.dense td { padding: 7px 8px; }
  table.data.dense th { padding: 9px 8px; }
  .clip-sm { max-width: 120px; }
}
@media (max-width: 1300px) { .clip-sm { max-width: 90px; } }
/* Narrow screens: the item list goes above the table, as a row of cards */
@media (max-width: 1289px) {
  .master-detail { grid-template-columns: minmax(0, 1fr); }
  .master-detail .item-list { flex-direction: row; flex-wrap: wrap; }
  .master-detail .item-list li { flex: 1 1 220px; }
}
.item-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.item-list button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: none;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.item-list button:hover { background: var(--surface-2); }
.item-list button[aria-current="true"] { background: var(--accent-soft); border-color: #bcd6f2; }
.item-list .il-code { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.item-list .il-name { color: var(--ink-2); font-size: 13px; }
.item-list .il-meta { color: var(--ink-3); font-size: 12px; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; padding: 16px 18px 12px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.detail-figs { display: flex; gap: 22px; margin-left: auto; }
.fig small { display: block; font-size: 12px; color: var(--ink-3); }
.fig strong { font-size: 18px; font-weight: 600; }

/* ---------- Production ---------- */
.prod-form { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(120px, 1fr) minmax(140px, 1fr) minmax(200px, 2fr); gap: 14px; align-items: end; }
@media (max-width: 1000px) { .prod-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* Sets: items in one set (item + qty per set + remove) */
.set-lines { display: flex; flex-direction: column; gap: 8px; }
.set-line { display: grid; grid-template-columns: minmax(0, 1fr) 120px 36px; gap: 8px; align-items: center; }
.short-list { margin: 6px 0 0; padding-left: 18px; }
.set-line-head { font-size: 12px; color: var(--ink-3); font-weight: 600; }

.placeholder-card { padding: 28px; display: flex; gap: 18px; align-items: flex-start; }
.placeholder-card .di-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--accent); flex: none; }
.placeholder-card .di-icon svg { width: 22px; height: 22px; }

/* ---------- Phone (floor use: Stock In, production, sales on the go) ---------- */
@media (max-width: 640px) {
  .shell { padding: 0 8px; gap: 2px; }
  .brand { padding-right: 8px; margin-right: 2px; }
  .brand > span:last-child { display: none; }
  .shell-right > :not(.live):not(#user-slot), .live > span:last-child, .user-name { display: none; }
  .user-btn { padding: 4px; }
  .login-wrap { padding: 20px 12px; align-items: flex-start; }
  .login-card { padding: 22px 18px; }
  .menu-btn { padding: 0 9px; gap: 4px; }
  .menu-btn > svg:first-child { display: none; }
  .menu > li { position: static; }
  .dropdown { position: fixed; top: 58px; left: 8px; right: 8px; min-width: 0; }
  .page-head { padding: 14px 14px 12px; }
  .page-body { padding: 12px 12px 32px; gap: 12px; }
  .page-actions { margin-left: 0; }
  .grid { gap: 12px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 20px; }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prod-form { grid-template-columns: minmax(0, 1fr); }
  .toolbar { padding: 10px 12px; }
  .search, .master-detail .search { min-width: 0; flex: 1 1 100%; }
  .card-head { padding: 12px 14px 8px; }
  .card-body { padding: 4px 14px 14px; }
  .overlay { padding: 8px; }
  .dialog { max-height: calc(100vh - 16px); }
  .dialog-head, .dialog-body { padding-left: 14px; padding-right: 14px; }
  .dialog-foot { padding: 10px 14px 14px; flex-wrap: wrap; }
  /* 16px inputs stop phones from zooming in when a field is tapped */
  .input, .select, .textarea { font-size: 16px; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

.loading { opacity: 0.55; transition: opacity 0.15s; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
