/* ══════════════════════════════════════════════════════════════════════════
   Corebalt Back Office — v2 design layout, Corebalt NAVY/BLUE brand (not the teal
   from the mockup): warm-cream canvas, navy rail (#16223f), brand-blue primary
   (#4D8BFF), coral accent, semantic success-green. The page
   markup is unchanged: every page styles itself through the shared classes below
   (.card, table, .btn, input, .pill, .toolbar, .row …), so restyling here restyles
   the whole back office without touching a single page's logic.
   ══════════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #F2EFE9;           /* content canvas */
  --bg-sunken: #FAF8F4;    /* table header / footer, inset panels */
  --panel: #FFFFFF;
  --line: #E3DFD6;         /* card / table outer border */
  --line-soft: #F0EDE5;    /* row dividers */
  --ink: #1B2A3F;          /* cool navy-dark headings */
  --ink-2: #26333f;        /* strong body */
  --muted: #6E7C8C;
  --muted-2: #8794a3;
  --accent: #4D8BFF;       /* Corebalt brand blue */
  --accent-strong: #3b78ec;
  --accent-deep: #2f63cf;
  --accent-soft: #EAF1FF;
  --coral: #F4795B;        /* accent — badges, dots, logo receipt */
  --sidebar: #16223f;      /* brand navy */
  --sidebar-hover: #1d2c4f;
  --sidebar-fg: #EEF3FB;
  --sidebar-muted: #8fa1c0;
  --input-line: #D6D1C6;
  --danger: #B0532F;
  --danger-soft: #FBEDE7;
  --danger-line: #F3D6C9;
  --ok: #1e7e34;           /* semantic success (unchanged from before) */
  --ok-soft: #e6f4ea;
  --warn: #8A6E22;
  --warn-soft: #F7F0DD;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-btn: 0 1px 2px rgba(22,34,63,0.2);
  /* legacy aliases kept so any older rule/inline reference still resolves */
  --navy: #16223f;
  --navy-2: #1d2c4f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Segoe UI', 'Segoe UI Variable', system-ui, -apple-system, 'Inter', sans-serif;
  color: var(--ink-2); background: var(--bg); -webkit-font-smoothing: antialiased; }
* { scrollbar-width: thin; scrollbar-color: #C9C4BA transparent; }
h1 { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.4px; margin: 0 0 6px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }
@keyframes cbPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.32; } }

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

/* ═══════════ Sidebar (dark teal rail) ═══════════ */
.sidebar { width: 248px; flex: none; background: var(--sidebar); color: #C7D2E5;
  display: flex; flex-direction: column; padding: 14px 0 10px; }
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 2px 16px 14px; }
.sidebar .brand .logo { width: 24px; height: 24px; object-fit: contain; }
.sidebar .brand .logo-plate, .sidebar .brand > img.logo { display: inline-flex; align-items: center;
  justify-content: center; width: 38px; height: 38px; background: var(--sidebar-hover);
  border-radius: 10px; flex: 0 0 auto; padding: 6px; }
.sidebar .brand .logo-plate .logo { width: 100%; height: 100%; }
.sidebar .brand .brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0;
  font-size: 14.5px; font-weight: 700; color: var(--sidebar-fg); letter-spacing: -0.1px; }
.sidebar .brand .biz { font-size: 11px; font-weight: 500; color: var(--sidebar-muted);
  text-transform: none; letter-spacing: 0; margin-top: 1px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; overflow-y: auto; flex: 1; }

/* Collapsible group: native <details>; <summary> = clickable header. */
.sidebar nav .nav-group-wrap { border-radius: var(--radius-sm); }
.sidebar nav .nav-group { list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 10px; height: 35px; padding: 0 12px; border-radius: var(--radius-sm);
  font-size: 10.5px; font-weight: 700; color: var(--sidebar-muted); text-transform: uppercase; letter-spacing: 0.9px; }
.sidebar nav .nav-group::-webkit-details-marker { display: none; }
.sidebar nav .nav-group:hover { background: var(--sidebar-hover); color: #C7D2E5; }
.sidebar nav details[data-nav-active="true"] > .nav-group { color: #C7D2E5; }
.sidebar nav .nav-ico { display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 16px; width: 16px; height: 16px; opacity: 0.9; }
.sidebar nav .nav-ico svg { width: 16px; height: 16px; }
.sidebar nav .nav-group-title { flex: 1; white-space: nowrap; }
.sidebar nav .nav-caret { width: 10px; height: 10px; margin-left: 4px; opacity: 0.7; flex: none;
  background: no-repeat center/10px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M4 2.5 7.5 6 4 9.5' stroke='%23B9C6DE' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  transition: transform .15s ease; }
.sidebar nav details[open] > .nav-group .nav-caret { transform: rotate(90deg); }
.sidebar nav .nav-group .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--coral);
  flex: none; animation: cbPulse 2.4s ease-in-out infinite; }
.sidebar nav details[open] > .nav-group .dot { display: none; }

.sidebar nav .nav-group-items { display: flex; flex-direction: column; gap: 2px; padding: 3px 0 7px; }
.sidebar nav a { color: #AEB9D0; height: 33px; padding: 0 12px 0 36px; border-radius: var(--radius-sm);
  font-size: 13px; display: flex; align-items: center; justify-content: space-between; position: relative; }
.sidebar nav a:hover { background: var(--sidebar-hover); color: #EAF1FF; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-hover); color: #EAF1FF; font-weight: 700; }
.sidebar nav a.active::before { content: ""; position: absolute; left: 22px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px; background: #6FA0FF; }
.sidebar nav a .badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--coral);
  color: #2A130D; font-size: 10.5px; font-weight: 700; }

/* Rail status card + sign out */
.sidebar .rail-status { margin: 10px 14px 6px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--sidebar-hover); border: 1px solid rgba(140,160,200,0.28); }
.sidebar .rail-status .row1 { display: flex; align-items: center; gap: 8px; font-size: 12px;
  font-weight: 600; color: #E6EDF8; }
.sidebar .rail-status .live { width: 7px; height: 7px; border-radius: 50%; background: #4FBF7E;
  animation: cbPulse 2s ease-in-out infinite; }
.sidebar .rail-status .sub { font-size: 11.5px; color: var(--sidebar-muted); margin-top: 5px; line-height: 1.45; }
.sidebar .logout { padding: 8px 14px 2px; }
.sidebar .logout button { width: 100%; background: transparent; color: #9FB0CC;
  border: 1px solid rgba(140,160,200,0.32); border-radius: var(--radius-sm); padding: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; }
.sidebar .logout button:hover { color: #fff; border-color: var(--accent); background: var(--sidebar-hover); }

/* ═══════════ Main column + topbar ═══════════ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar { flex: none; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 26px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar .where { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .where b { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .userchip { display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 5px 0 12px;
  border-radius: 99px; background: #E8E4DC; flex: none; }
.topbar .userchip .name { font-size: 12px; font-weight: 600; color: #3D4A47; white-space: nowrap; }
.topbar .userchip .avatar { width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(140deg,#4D8BFF,#16223f); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700; }

/* Which department these screens are for. A yard with one has no picker at all, so this only ever
   shows where there is a real choice to make. */
.topbar .areapick { display: flex; align-items: center; gap: 7px; flex: none; margin: 0; }
.topbar .areapick label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 0; }
.topbar .areapick select { height: 30px; padding: 0 26px 0 10px; font-size: 12.5px; font-weight: 600;
  border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }

/* Content */
.content { flex: 1; min-width: 0; overflow: auto; padding: 24px 28px 32px; }

/* ═══════════ Tables ═══════════ */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
  font-variant-numeric: tabular-nums; }
th { background: var(--bg-sunken); color: var(--muted); font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid #E9E5DC; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAF9F5; }
.inactive td { color: var(--muted); font-style: italic; }

/* ═══════════ Cards / forms / buttons ═══════════ */
.toolbar { display: flex; gap: 10px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 19px 20px; margin-bottom: 18px; }
.card h2 { font-size: 14.5px; font-weight: 700; color: var(--ink); margin: 0 0 14px; }
label { display: block; font-size: 11.5px; font-weight: 600; color: #6B7A76; margin: 10px 0 6px; }
input, select, textarea { padding: 9px 12px; height: 40px; border: 1px solid var(--input-line);
  border-radius: var(--radius-sm); font-size: 13.5px; color: var(--ink-2); background: var(--panel);
  width: 100%; max-width: 340px; outline: none; font-variant-numeric: tabular-nums; }
textarea { height: auto; min-height: 76px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,139,255,0.15); }
input[type=checkbox] { width: auto; height: auto; accent-color: var(--accent); }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 150px; }

button, .btn { background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 0 17px; height: 38px; font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; box-shadow: var(--shadow-btn); line-height: 1; }
button:hover, .btn:hover { background: var(--accent-strong); text-decoration: none; color: #fff; }
button.ghost, .btn.ghost { background: var(--panel); color: #3D4A47; border: 1px solid #DDD8CE; box-shadow: none; }
button.ghost:hover, .btn.ghost:hover { background: var(--bg-sunken); color: var(--ink); }
button.danger, .btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
button.danger:hover, .btn.danger:hover { background: #F7E1D7; color: var(--danger); }
.error { color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line);
  padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px; }

/* ═══════════ Login ═══════════ */
.login-card { max-width: 380px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 30px; box-shadow: 0 24px 60px rgba(22,34,63,0.16); }
.login-card h1 { text-align: center; }
.login-card p { text-align: center; color: var(--muted); margin-top: 0; }
.login-card input { max-width: none; }
.login-card button { width: 100%; margin-top: 16px; height: 42px; }

/* ═══════════ Pills / badges (statuses across pages) ═══════════ */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; background: var(--line-soft); color: var(--muted); }
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--danger-soft); color: var(--danger); }

/* ═══════════ Page header (title + description + head action) ═══════════ */
.page-head { display: flex; align-items: flex-start; gap: 16px; }
.page-head .titles { flex: 1; min-width: 0; }
.page-head .titles h1 { margin: 0; }
.page-head p, p.lead { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 8px 0 0; max-width: 920px; }
.page-head .head-action { flex: none; }

/* ═══════════ Stat tiles ═══════════ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 20px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; }
.stat .label { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.stat .value { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.stat .value .n { font-size: 23px; font-weight: 700; color: var(--ink); letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .value .n.alert { color: var(--danger); }
.stat .value .note { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ═══════════ Quick-action chips ═══════════ */
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 4px; }
.chip { display: inline-flex; align-items: center; height: 38px; padding: 0 17px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--bg-sunken); text-decoration: none; color: var(--ink); }
.chip.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-btn); }
.chip.primary:hover { background: var(--accent-strong); color: #fff; }

/* ═══════════ Grouped card-forms (Details / Pricing / Stock …) ═══════════ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; margin-top: 20px;
  align-items: start; }
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 19px 20px; display: flex; flex-direction: column; }
.form-card > h3 { font-size: 14.5px; font-weight: 700; color: var(--ink); margin: 0; }
.form-card > .sub { font-size: 12px; color: var(--muted); margin: 4px 0 0; line-height: 1.45; }
.form-card .fields { display: flex; flex-wrap: wrap; gap: 13px 14px; margin-top: 15px; }
.form-card .field { flex: 1 1 150px; min-width: 150px; display: flex; flex-direction: column; }
.form-card .field.wide { flex: 1 1 100%; }
.form-card .field label { margin: 0 0 6px; }
.form-card .field input, .form-card .field select, .form-card .field textarea { max-width: none; width: 100%; }
.form-card .field input[type=checkbox] { width: auto; }
.form-card .field .checkline { display: flex; align-items: center; gap: 9px; min-height: 38px; font-size: 13px; color: var(--ink-2); }
.form-card .actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.form-card .actions button, .form-card .actions .btn { height: 38px; }
/* a full-width form card that should span the whole grid row */
.form-card.span-all { grid-column: 1 / -1; }

/* Tabbed form: a segmented control above a single card; one panel visible at a time. */
.form-tabs { display: inline-flex; flex-wrap: wrap; background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 3px; gap: 2px; margin: 20px 0 12px; max-width: 100%; }
.form-tab { background: transparent; color: var(--muted); border: none; box-shadow: none; height: 34px;
  padding: 0 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.form-tab:hover { background: rgba(22,34,63,0.04); color: var(--ink); }
.form-tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(22,34,63,0.1); }
.form-tab-panel { display: none; }
.form-tab-panel.active { display: block; }

/* ═══════════ Module manager ═══════════ */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.module { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; background: var(--panel); cursor: pointer; }
.module.on { border-color: var(--accent); background: var(--accent-soft); }
.module strong { display: block; font-size: 14px; color: var(--ink); }
.module .module-desc { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Account payment method: the till picker shows only for cash (PaymentMethodFields.razor). */
.pm-fields { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pm-fields .pm-till { display: none; }
.pm-fields:has(select.pm-method option[value="Cash"]:checked) .pm-till { display: inline; }
