/* GuerrillaRMS shell and shared components: the classic flat look
   (docs/research/classic-ui-spec.md). Colours come only from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: var(--font-size-base); -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-height) + 8px); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-page-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}

a { color: var(--color-link); text-decoration: none; }
a:hover { color: var(--color-link-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; }
p { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }
img { max-width: 100%; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--color-surface); padding: 6px 10px; z-index: 300; }
.skip-link:focus { left: 8px; top: 8px; }

.inline-form { display: inline; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.text-muted { color: var(--color-text-muted); }
.fa-fw { width: 1.28571429em; }

/* ------------------------------------------------------------ top bar (one 56px charcoal bar) */

.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  height: var(--topbar-height);
  padding: 0 10px 0 var(--gutter);
  background: var(--color-topbar-bg);
  color: var(--color-topbar-muted);
}
.topbar :focus-visible { outline-color: var(--color-topbar-text); outline-offset: -2px; }
.brand { align-self: center; color: var(--color-topbar-muted); font-size: 17px; font-weight: 600; }
.brand:hover { color: var(--color-topbar-text); text-decoration: none; }
.nav-toggle { display: none; }

/* ------------------------------------------------------------ main nav */

.main-nav { display: flex; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 3px; }
.nav-item { position: relative; height: var(--topbar-height); }
.nav-item::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--nav-color, transparent); }
.nav-dashboard { --nav-color: var(--module-dashboard); }
.nav-people { --nav-color: var(--module-people); }
.nav-opportunities { --nav-color: var(--module-opportunities); }
.nav-resources { --nav-color: var(--module-resources); }
.nav-activities { --nav-color: var(--module-activities); }
.nav-reports { --nav-color: var(--module-reports); }
.nav-link {
  position: relative;
  display: block;
  padding: 20px 16px 16px;
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  color: var(--color-nav-text);
  background: none;
  border: 0;
  cursor: pointer;
}
a.nav-link:hover, button.nav-link:hover { color: var(--color-topbar-text); text-decoration: none; }
.nav-item.is-active > .nav-link,
.nav-item.is-open > .nav-link { color: var(--color-topbar-text); background: var(--nav-color); }
.nav-item.is-active > .nav-link { padding-bottom: calc(16px + var(--nav-overhang)); z-index: 1; }
/* White on the light module colours needs a shadow to stay legible. */
.nav-resources.is-active > .nav-link, .nav-resources.is-open > .nav-link,
.nav-activities.is-active > .nav-link, .nav-activities.is-open > .nav-link,
.nav-reports.is-active > .nav-link, .nav-reports.is-open > .nav-link { text-shadow: 0 1px 2px var(--color-nav-text-shadow); }
.nav-item > .dropdown-menu { top: var(--topbar-height); z-index: 2; }

/* ------------------------------------------------------------ user block (right of the bar) */

.user-menu { position: relative; margin-left: auto; display: flex; align-items: stretch; }
.user-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-height);
  padding: 0;
  font: inherit;
  color: var(--color-topbar-muted);
  background: none;
  border: 0;
  cursor: pointer;
}
.user-name {
  align-self: flex-start;
  max-width: 220px;
  margin-top: 5px;
  overflow: hidden;
  font-size: 17px;
  line-height: 24px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.user-toggle:hover .user-name, .user-menu.is-open .user-name { color: var(--color-topbar-text); }
.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  font-size: 24px;
  line-height: 1;
  color: var(--color-text-inverse);
  background: var(--color-avatar-bg);
}
.user-store {
  position: absolute;
  top: 29px;
  right: 52px;
  max-width: 220px;
  overflow: hidden;
  font-size: 13px;
  line-height: 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--color-store-link);
}
span.user-store { color: var(--color-store-link); }
a.user-store:hover { color: var(--color-store-link); }
.user-store .fa { color: var(--color-text-inverse); margin-right: 3px; }
.user-menu > .dropdown-menu { top: var(--topbar-height); left: auto; right: 0; min-width: 220px; }
.dropdown-menu .user-card { padding: 10px 20px; line-height: 1.35; }
.user-card strong { display: block; font-size: 15px; font-weight: 400; color: var(--color-text); }
.user-card span { font-size: 12px; color: var(--color-text-muted); }

/* ------------------------------------------------------------ dropdowns */

.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 150;
  min-width: 180px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  background: var(--color-menu-bg);
  border: 1px solid var(--color-menu-border);
  box-shadow: 0 6px 12px var(--color-shadow);
}
.dropdown-menu-right { left: auto; right: 0; }
.dropdown.is-open > .dropdown-menu { display: block; }
.dropdown-menu > li > a,
.dropdown-menu > li > button,
.dropdown-menu > li > .inline-form > button {
  display: block;
  width: 100%;
  padding: 9px 20px;
  font: inherit;
  font-size: 15px;
  line-height: 22px;
  text-align: left;
  white-space: nowrap;
  color: var(--color-text);
  background: none;
  border: 0;
  cursor: pointer;
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus-visible,
.dropdown-menu > li > button:hover, .dropdown-menu > li > button:focus-visible,
.dropdown-menu > li > .inline-form > button:hover,
.dropdown-menu > li.is-active > a {
  color: var(--color-menu-hover-text);
  background: var(--color-menu-hover-bg);
  text-decoration: none;
  outline: none;
}
.dropdown-menu .fa { width: 18px; margin-right: 8px; text-align: center; }
.dropdown-menu > li.divider { height: 1px; margin: 0; background: var(--color-menu-border); }
.dropdown-menu > li.is-disabled > a, .dropdown-menu > li.is-disabled > button { color: var(--color-text-faint); pointer-events: none; }

/* ------------------------------------------------------------ flash bars (full width, under the bar) */

.flashes { display: flex; flex-direction: column; }
.flash {
  position: relative;
  min-height: 32px;
  padding: 6px var(--gutter) 6px calc(var(--gutter) + 24px);
  font-weight: 600;
  color: var(--color-text-inverse);
  background: var(--color-flash-info);
}
.flash::before {
  position: absolute;
  left: var(--gutter);
  top: 6px;
  width: 16px;
  font-family: FontAwesome;
  font-weight: 400;
  text-align: center;
  content: "\f05a";
}
.flash + .flash { border-top: 1px solid var(--color-surface); }
.flash-success { background: var(--color-flash-success); }
.flash-success::before { content: "\f058"; }
.flash-error { background: var(--color-flash-error); }
.flash-error::before { content: "\f132"; }
.flash-info { background: var(--color-flash-info); }

/* ------------------------------------------------------------ page frame */

.page { flex: 0 0 auto; width: 100%; padding: 20px var(--gutter) 40px; background: var(--color-surface); }
.site-footer { margin-top: auto; padding: 8px var(--gutter); font-size: 12px; color: var(--color-text-muted); background: var(--color-page-bg); }
.site-footer .version { margin-left: 4px; }

.crumbs ol { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; font-size: 13px; color: var(--color-text-muted); }
.crumbs a { color: var(--color-text-muted); }
.crumbs a:hover { color: var(--color-link-hover); }
.crumbs li + li::before { content: "/"; margin: 0 6px; color: var(--color-text-faint); }

.page-header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 20px; }
.page-heading { display: flex; flex: 1 1 320px; flex-wrap: wrap; align-items: center; gap: 4px 16px; min-width: 0; }
.page-title { font-size: 30px; font-weight: 600; line-height: 1.2; color: var(--color-text); }
.page-subtitle, .page-heading .page-meta { flex-basis: 100%; }
.page-subtitle { font-size: 15px; color: var(--color-text-muted); }
.page-subtitle .fa { margin-right: 6px; }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.count-pill {
  display: inline-block;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  vertical-align: middle;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
}

.page-body { min-width: 0; }
.page-content { min-width: 0; }
.page-content > * + * { margin-top: 20px; }
.section-title, .page-content > h2 { font-size: 24px; font-weight: 600; }

/* Detail pages: 2/3 white main column + full-height 1/3 grey sidebar, flush to the bar and the right edge. */
.page-body.with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  margin: -20px calc(-1 * var(--gutter)) -40px;
}
.page-body.with-sidebar > .page-content { padding: 20px var(--gutter) 40px; }
.page-sidebar { min-width: 0; padding: 20px 30px 40px; background: var(--color-surface-alt); }
.page:has(> .page-body.with-sidebar),
.page:has(> .page-body > .page-content > .page-body.with-sidebar) { display: flex; flex-direction: column; flex: 1 0 auto; }
.page > .page-body.with-sidebar,
.page > .page-body:has(> .page-content > .page-body.with-sidebar) { flex: 1 0 auto; }
.page > .page-body:has(> .page-content > .page-body.with-sidebar),
.page > .page-body:has(> .page-content > .page-body.with-sidebar) > .page-content { display: flex; flex-direction: column; }
.page > .page-body:has(> .page-content > .page-body.with-sidebar) > .page-content,
.page-content > .page-body.with-sidebar { flex: 1 0 auto; }
.page-content > .page-body.with-sidebar:not(:first-child),
* + .page-body > .page-content > .page-body.with-sidebar:first-child { margin-top: 0; }

/* ------------------------------------------------------------ sections and panels */

.panel { background: var(--color-surface); }
.panel-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-header h2 { font-size: 24px; font-weight: 600; }
.panel-body { min-width: 0; }
.table-scroll { position: relative; max-width: 100%; overflow-x: auto; }
/* Row menus open outside the scroll box on wide screens, where tables rarely need to scroll. */
@media (min-width: 981px) {
  .table-scroll:has(.dropdown.is-open) { overflow: visible; }
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  min-height: 30px;
  padding: 5px 15px;
  font-size: 13px;
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.table-footer > :only-child, .table-footer > .is-right { margin-left: auto; }
.table-scroll + .table-footer, .data-table + .table-footer, .items-table + .table-footer { margin-top: 0; }

/* Sidebar sections: 22px regular grey headings, separated by whitespace only. */
.sidebar-panel + .sidebar-panel { margin-top: 14px; }
.sidebar-panel > h3 {
  position: relative;
  padding-right: 24px;
  font-size: 22px;
  font-weight: 400;
  line-height: 40px;
  color: var(--color-text-muted);
}
.sidebar-panel > h3[role="button"] { cursor: pointer; }
.sidebar-panel > h3[role="button"]::after {
  position: absolute;
  right: 0;
  top: 0;
  font-family: FontAwesome;
  font-size: 14px;
  color: var(--color-text-faint);
  content: "\f077";
}
.sidebar-panel.is-collapsed > h3[role="button"]::after { content: "\f078"; }
.sidebar-panel.is-collapsed > :not(h3) { display: none; }
.sidebar-panel > :not(h3):not(.action-list):not(.stat-tiles) { padding: 4px 0 4px 40px; }

.action-list { list-style: none; margin: 4px 0 0; padding: 0; }
.action-list li > a, .action-list li > .inline-form > button, .action-list li > button {
  position: relative;
  display: block;
  width: 100%;
  padding: 5px 0 5px 40px;
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  text-align: left;
  color: var(--color-text);
  background: none;
  border: 0;
  cursor: pointer;
}
.action-list li > a:hover, .action-list li > .inline-form > button:hover { color: var(--color-link); text-decoration: none; }
.action-list .fa, .action-list li > a:not(:has(> .fa))::before, .action-list li > .inline-form > button:not(:has(> .fa))::before {
  position: absolute;
  left: 0;
  top: 7px;
  width: 20px;
  font-family: FontAwesome;
  font-size: 16px;
  line-height: 1;
  text-align: center;
  color: var(--color-text-muted);
}
.action-list li > a:not(:has(> .fa))::before, .action-list li > .inline-form > button:not(:has(> .fa))::before { content: "\f105"; color: var(--color-text-faint); }
.action-list .is-danger, .action-list .is-danger .fa { color: var(--color-danger); }
.action-list li > button:disabled, .action-list li > button:disabled:hover { color: var(--color-text-muted); text-decoration: none; cursor: not-allowed; }
.action-list li > button:disabled .fa { color: var(--color-text-faint); }
.action-list .divider { border-top: 1px solid var(--color-border); margin: 6px 0; }

/* ------------------------------------------------------------ tabs (the classic function strip) */

.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 3px solid var(--color-create); }
.tab { padding: 7px 16px; color: var(--color-label); background: var(--color-surface-alt); }
.tab:hover { color: var(--color-text); background: var(--color-surface-sunken); text-decoration: none; }
.tab.is-active { color: var(--color-on-button); background: var(--color-create); }

/* ------------------------------------------------------------ detail pairs */

.detail-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 20px; margin: 0; }
.detail-grid dt { color: var(--color-text-muted); }
.detail-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
/* In the sidebar the classic shows plain "Label: value" lines. */
.page-sidebar .detail-grid { display: block; font-size: 15px; line-height: 30px; }
.page-sidebar .detail-grid dt { display: inline; color: var(--color-text); }
.page-sidebar .detail-grid dt::after { content: ": "; }
.page-sidebar .detail-grid dd { display: inline; }
.page-sidebar .detail-grid dd::after { content: "\A"; white-space: pre; }

.empty-state { padding: 20px 15px; text-align: center; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); }

/* ------------------------------------------------------------ list pages */

.list-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.list-toolbar > .toolbar-actions, .list-toolbar > :last-child:not(:first-child):not(.list-search):not(.filter-tabs) { margin-left: auto; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.toolbar-actions .btn, .list-toolbar > .btn { height: 36px; padding: 7px 14px; font-size: 16px; line-height: 22px; }
.list-search { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 12px; }
.list-search > label { flex-basis: 100%; font-size: 12px; line-height: 16px; color: var(--color-text-muted); }
.list-search input[type="search"], .list-search input[type="text"] { width: 490px; max-width: 100%; height: 36px; }
.list-search select { height: 36px; }
.list-search button, .list-search .btn { min-width: 42px; height: 36px; padding: 7px 12px; color: var(--color-on-primary); background: var(--color-primary); }
.list-search button:hover, .list-search .btn:hover { color: var(--color-on-primary); background: var(--color-primary-hover); }
.list-search .btn-link, .list-search a.btn-link { min-width: 0; color: var(--color-link); background: none; }

.filter-tabs { display: flex; flex-wrap: wrap; }
.filter-tab { padding: 6px 12px; line-height: 20px; color: var(--color-text-muted); background: var(--color-surface); border: 1px solid var(--color-input-border); }
.filter-tab + .filter-tab { border-left: 0; }
.filter-tab:hover { color: var(--color-text); background: var(--color-row-hover); text-decoration: none; }
.filter-tab.is-active { color: var(--color-on-button); background: var(--color-text-muted); border-color: var(--color-text-muted); }

.list-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px; font-size: 15px; color: var(--color-text); }
.list-meta > .dropdown { display: inline-block; }
.list-meta [data-dropdown] {
  padding: 0;
  font: inherit;
  color: var(--color-text);
  background: none;
  border: 0;
  cursor: pointer;
}
.list-meta .list-icons { display: flex; gap: 14px; margin-left: auto; font-size: 18px; }
.list-icons a, .list-icons button { color: var(--color-text); background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.list-icons a:hover, .list-icons button:hover, .list-icons .is-active { color: var(--color-link); text-decoration: none; }
.list-meta [data-dropdown]:not(:has(.fa))::after,
.btn[data-dropdown]:not(:has(.fa-caret-down))::after, .btn-link[data-dropdown]:not(:has(.fa))::after {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  content: "";
  border-top: 5px solid;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
}

/* ------------------------------------------------------------ tables */

.data-table, .items-table { width: 100%; border-collapse: collapse; background: var(--color-surface); font-size: 14px; }
.data-table th, .data-table td, .items-table th, .items-table td { padding: 7px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); }
.data-table thead th, .items-table thead th {
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
  color: var(--color-th-text);
  background: var(--color-th-bg);
  border-top: 1px solid var(--color-border);
  border-bottom: 2px solid var(--color-th-border);
}
.data-table th:first-child, .data-table td:first-child, .items-table th:first-child, .items-table td:first-child { padding-left: 15px; }
.data-table thead th:first-child, .items-table thead th:first-child { box-shadow: inset 5px 0 0 var(--color-th-bar); }
.data-table tbody th { font-weight: 400; color: var(--color-label); }
.data-table tbody tr:hover > td { background: var(--color-row-hover); }
.data-table td.num, .data-table th.num, .items-table td.num, .items-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tr[data-href] { cursor: pointer; }
.data-table tr.is-muted > td, .items-table tr.is-muted > td { color: var(--color-text-muted); }
.data-table td.actions, .items-table td.actions, td.row-menu { width: 1%; text-align: right; white-space: nowrap; }
.data-table tfoot td { background: var(--color-surface-alt); }
.cell-sub { display: block; font-size: 13px; color: var(--color-text-muted); }
.cell-link { font-size: 18px; }
.thumb { display: block; width: 40px; height: 40px; object-fit: contain; }

.sort-link { color: var(--color-link); }
.sort-link:hover { color: var(--color-link-hover); }
.sort-link.sort-asc::after { content: " \25B2"; font-size: .8em; }
.sort-link.sort-desc::after { content: " \25BC"; font-size: .8em; }

/* Opportunity rows: 5px state bar, ring icon + uppercase state name, grey date bands. */
.data-table tr.state-enquiry > td:first-child { box-shadow: inset 5px 0 0 var(--state-enquiry); }
.data-table tr.state-draft > td:first-child { box-shadow: inset 5px 0 0 var(--state-draft); }
.data-table tr.state-quotation > td:first-child { box-shadow: inset 5px 0 0 var(--state-quotation); }
.data-table tr.state-order > td:first-child { box-shadow: inset 5px 0 0 var(--state-order); }
td.state-cell {
  width: 100px;
  padding: 8px 6px 6px 11px;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
/* The ring draws on an empty element. */
.state-icon {
  --seg-on: var(--color-state-seg-on);
  --seg-off: var(--color-state-seg-off);
  display: block;
  width: 36px;
  height: 36px;
  margin: 0;
  border-radius: 50%;
  background: conic-gradient(from 20deg,
    var(--seg1, var(--seg-off)) 0 70deg, transparent 0 90deg,
    var(--seg2, var(--seg-off)) 0 160deg, transparent 0 180deg,
    var(--seg3, var(--seg-off)) 0 250deg, transparent 0 270deg,
    var(--seg4, var(--seg-off)) 0 340deg, transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent 64%, var(--mask-opaque) 66%);
  mask: radial-gradient(farthest-side, transparent 64%, var(--mask-opaque) 66%);
}
span.state-icon { display: inline-block; vertical-align: middle; }
td.state-cell > .state-icon { display: block; margin: 0 auto 4px; }
.state-enquiry { --seg1: var(--seg-on); }
.state-draft { --seg1: var(--seg-on); --seg2: var(--seg-on); }
.state-quotation { --seg1: var(--seg-on); --seg2: var(--seg-on); --seg3: var(--seg-on); }
.state-order { --seg1: var(--seg-on); --seg2: var(--seg-on); --seg3: var(--seg-on); --seg4: var(--seg-on); }
.data-table tr.state-enquiry:hover > td.state-cell { background: var(--state-enquiry); }
.data-table tr.state-draft:hover > td.state-cell { background: var(--state-draft); }
.data-table tr.state-quotation:hover > td.state-cell { background: var(--state-quotation); }
.data-table tr.state-order:hover > td.state-cell { background: var(--state-order); }
.data-table tr[class*="state-"]:hover > td.state-cell { color: var(--color-text-inverse); box-shadow: none; }
.data-table tr[class*="state-"]:hover > td.state-cell .state-icon { --seg-on: var(--color-state-seg-on-inverse); --seg-off: var(--color-state-seg-off-inverse); }

.data-table tr.date-band > td, .items-table tr.date-band > td {
  padding-top: 4px;
  padding-bottom: 4px;
  line-height: 22px;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
}
.data-table tr.date-band > td:first-child, .items-table tr.date-band > td:first-child { box-shadow: inset 5px 0 0 var(--color-date-band-bar); }
.data-table tr.date-band:hover > td { background: var(--color-surface-alt); }

/* Shortage: the whole row turns pink and a warning triangle follows the quantity. */
.data-table tr.is-shortage > td, .items-table tr.is-shortage > td,
.data-table tr.is-shortage:hover > td, .items-table tr.is-shortage:hover > td { background: var(--color-shortage-bg); }
.warn-icon { display: inline-block; margin-left: 4px; color: var(--color-text); }
.warn-icon:empty::before { font-family: FontAwesome; content: "\f071"; }

/* Row menu: a blue chevron at the far right of a row. */
.btn-chevron { padding: 2px 4px; font: inherit; font-size: 16px; line-height: 1; color: var(--color-link); background: none; border: 0; cursor: pointer; }
.btn-chevron:hover { color: var(--color-link-hover); }
.btn-chevron:empty::before { font-family: FontAwesome; content: "\f078"; }

/* ------------------------------------------------------------ items tree */

.items-table td { padding-top: 8px; padding-bottom: 8px; }
.items-table tr.item-group > td { padding-top: 7px; padding-bottom: 7px; font-size: 18px; font-weight: 600; line-height: 22px; }
.items-table tr.item-group > td.num, .items-table tr.item-group > td .badge { font-size: 14px; font-weight: 400; }
.items-table tr.item-group > td .badge { font-size: 12px; }
.items-table td.item-gutter { width: 50px; }
.items-table td.item-name { width: 40%; }
.items-table tr.is-shortage > td.item-gutter { background: none; }
.items-table tr:not(.item-group) > td.item-gutter { border-bottom-color: transparent; }
.items-table .depth-0 { --item-indent: 10px; }
.items-table .depth-1 { --item-indent: 40px; }
.items-table .depth-2 { --item-indent: 70px; }
.items-table .depth-3 { --item-indent: 100px; }
.items-table .depth-4 { --item-indent: 130px; }
.items-table td[class*="depth-"], .items-table tr[class*="depth-"] > td.item-name { padding-left: var(--item-indent); }
/* A leading drag handle hangs in the indent so wrapped names line up under the first line. */
.items-table td.item-name:has(> .drag-handle:first-child) { padding-left: calc(var(--item-indent, 10px) + 30px); }
.items-table td.item-name > .drag-handle:first-child { margin-left: -30px; }
.item-name .text-marker { float: right; margin-left: 8px; }
.item-desc { display: block; font-style: italic; color: var(--color-text); }
.drag-handle { display: inline-block; width: 18px; margin-right: 12px; font-size: 16px; color: var(--color-text); }
.item-toggle { display: inline-block; width: 12px; margin-right: 12px; padding: 0; font: inherit; font-weight: 400; color: var(--color-text); background: none; border: 0; cursor: pointer; }
.items-table tfoot.totals td { font-size: 15px; background: none; border-bottom: 0; }
.items-table tfoot.totals td.num { box-shadow: inset 0 1px 0 var(--color-text); }
.text-marker {
  display: inline-block;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  vertical-align: middle;
  color: var(--color-label);
  border: 1px solid var(--color-text-muted);
}

/* ------------------------------------------------------------ summary tiles and sidebar stats */

/* Tiles share a row equally but never get narrower than their text; a row that cannot hold them wraps. */
.summary-tiles { display: flex; flex-wrap: wrap; gap: 4px; }
.summary-tile {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  justify-content: center;
  min-width: max-content;
  min-height: 50px;
  padding: 3px 10px;
  color: var(--color-text-inverse);
  background: var(--color-tile);
}
.summary-tile:hover { color: var(--color-text-inverse); background: var(--color-tile-hover); text-decoration: none; }
.summary-tile strong { font-size: 18px; font-weight: 400; line-height: 24px; }
.summary-tile span { font-size: 14px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-tile span .fa { margin-right: 6px; }

.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 4px 0 6px; }
.stat-tiles.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-tile { min-width: 0; padding: 8px 12px; border-left: 1px solid var(--color-border); }
.stat-tiles > .stat-tile:nth-child(n+4) { border-top: 1px solid var(--color-border); }
.stat-tiles.cols-4 > .stat-tile:nth-child(n+5) { border-top: 1px solid var(--color-border); }
.stat-tiles.cols-4 > .stat-tile:nth-child(4) { border-top: 0; }
.stat-tile strong { display: block; overflow: hidden; font-size: 18px; font-weight: 700; line-height: 26px; white-space: nowrap; text-overflow: ellipsis; color: var(--color-label); }
.stat-tile span { display: block; font-size: 12px; line-height: 16px; color: var(--color-text-muted); }
.stat-tile.is-warn { background: var(--avail-warn); border-left-color: var(--avail-warn); }
.stat-tile.is-short { background: var(--avail-short); border-left-color: var(--avail-short); }
.stat-tile.is-warn strong, .stat-tile.is-warn span, .stat-tile.is-short strong, .stat-tile.is-short span { color: var(--color-text-inverse); }

/* ------------------------------------------------------------ header icon buttons */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  font: inherit;
  font-size: 18px;
  color: var(--color-icon-btn);
  background: var(--color-surface);
  border: 3px solid var(--color-icon-btn-ring);
  border-radius: 50%;
  cursor: pointer;
}
.icon-btn:hover { color: var(--color-text); border-color: var(--color-text-muted); text-decoration: none; }
.icon-btn.is-danger:hover, .icon-btn.btn-danger:hover { color: var(--color-danger); border-color: var(--color-danger); }
.page-actions .icon-btn + .icon-btn, .page-actions .inline-form + .icon-btn, .page-actions .icon-btn + .inline-form { margin-left: 0; }

/* ------------------------------------------------------------ forms */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 30px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.form-grid > .span-all { grid-column: 1 / -1; }
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.form-grid .form-row { margin-bottom: 0; }
.form-row > label, .form-label { display: flex; align-items: center; gap: 4px; font-size: 13px; line-height: 18px; color: var(--color-label); }
.required { order: -1; color: inherit; }
.form-row > label > input[type="checkbox"], .form-row > label > input[type="radio"] { margin: 0 4px 0 0; }
.field-hint { font-size: 12px; color: var(--color-text-muted); }
.field-error { font-size: 12px; color: var(--color-danger); }
.form-row.has-error input, .form-row.has-error select, .form-row.has-error textarea { border-color: var(--color-danger); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.form-actions .btn { height: 36px; padding: 7px 16px; font-size: 16px; line-height: 22px; }
.form-row > .toggle-yesno, .form-row > .btn, .form-row > .filter-tabs { align-self: flex-start; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="tel"], input[type="url"], select, textarea {
  max-width: 100%;
  height: var(--control-height);
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  color: var(--color-text-input);
  background: var(--color-input-bg);
  border: 1px solid var(--color-input-border);
  border-radius: 0;
  box-shadow: inset 0 1px 1px var(--color-input-shadow);
}
select { padding: 6px 8px; }
textarea { height: auto; min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--color-focus); outline: 0; box-shadow: inset 0 1px 1px var(--color-input-shadow), 0 0 0 3px var(--color-focus-ring); }
input[type="checkbox"], input[type="radio"] { width: 15px; height: 15px; accent-color: var(--color-primary); }
input[disabled], select[disabled], textarea[disabled], input[readonly] { background: var(--color-addon-bg); }
::placeholder { color: var(--color-text-muted); opacity: 1; }

.input-group { display: flex; align-items: stretch; min-width: 0; }
.input-group > input, .input-group > select { flex: 1 1 auto; min-width: 0; width: 1%; }
.input-addon {
  display: flex;
  flex: none;
  align-items: center;
  padding: 0 10px;
  font-size: 14px;
  white-space: nowrap;
  color: var(--color-text-input);
  background: var(--color-addon-bg);
  border: 1px solid var(--color-input-border);
}
.input-group > .input-addon:first-child { border-right: 0; }
.input-group > .input-addon:last-child { border-left: 0; }
.input-group > .btn { flex: none; height: var(--control-height); }
.input-group > .autocomplete { flex: 1 1 auto; min-width: 0; }

/* The classic centred grey form panel with pictograms in a left gutter and dotted section rules. */
.form-panel { max-width: var(--form-panel-width); margin: 0 auto; padding: 20px 30px 30px; background: var(--color-surface-alt); border: 1px solid var(--color-border-strong); }
.form-panel .page-title, .form-title { font-size: 30px; font-weight: 600; color: var(--color-label); }
.form-subtitle { margin-top: 6px; font-size: 20px; font-weight: 600; color: var(--color-label); }
.form-panel .form-actions { justify-content: flex-end; padding-top: 20px; border-top: 1px dotted var(--color-border-strong); }
.form-panel .form-actions .btn:not(.btn-primary):not(.btn-create):not(.btn-danger):not(.btn-warning) { color: var(--color-on-button); background: var(--color-cancel); }
.form-section { display: grid; grid-template-columns: 130px minmax(0, 1fr); margin: 0; padding: 20px 0; border: 0; border-top: 1px dotted var(--color-border-strong); }
.form-section:first-of-type { border-top: 0; padding-top: 10px; }
.form-section > .form-section-icon { grid-column: 1; align-self: start; padding-top: 16px; font-size: 50px; line-height: 1; text-align: center; color: var(--color-pictogram); }
.form-section > :not(.form-section-icon) { grid-column: 2; }
.form-section > legend { float: left; padding: 0; margin-bottom: 8px; font-size: 14px; color: var(--color-label); }
.page:has(> .page-body > .page-content > .form-panel:first-child) { padding-top: 0; }
.page:has(> .page-body > .page-content > .form-panel:first-child) > .page-header {
  max-width: var(--form-panel-width);
  margin: 0 auto;
  padding: 20px 30px 0;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-strong);
  border-top: 0;
  border-bottom: 0;
}
.page:has(> .page-body > .page-content > .form-panel:first-child) > .page-header .page-title { color: var(--color-label); }
.page > .page-header + .page-body > .page-content > .form-panel:first-child { border-top: 0; }
/* Breadcrumbs above a joined form panel line up with the panel (the page's top padding is dropped there). */
.page:has(> .page-body > .page-content > .form-panel:first-child) > .crumbs { max-width: var(--form-panel-width); margin: 0 auto; padding: 14px 0 6px; }

/* YES/NO segmented toggle: grey inactive half, green YES / red NO when chosen. */
.toggle-yesno { position: relative; display: inline-flex; }
.toggle-yesno > input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.toggle-yesno > label {
  min-width: 52px;
  height: var(--control-height);
  padding: 0 12px;
  font-size: 13px;
  line-height: var(--control-height);
  text-align: center;
  text-transform: uppercase;
  color: var(--color-toggle-off-text);
  background: var(--color-toggle-off);
  cursor: pointer;
  user-select: none;
}
.toggle-yesno > label:hover { color: var(--color-on-button); }
.toggle-yesno > input:checked + label { color: var(--color-on-button); background: var(--color-create); }
.toggle-yesno > input:checked + label:last-of-type { background: var(--color-danger); }
.toggle-yesno > input:focus-visible + label { position: relative; z-index: 1; outline: 2px solid var(--color-focus); outline-offset: 1px; }
.toggle-yesno > input:disabled + label { opacity: .65; cursor: not-allowed; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-block;
  height: var(--control-height);
  padding: 7px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--color-on-button);
  background: var(--color-cancel);
  border: 0;
  border-radius: 0;
  cursor: pointer;
}
.btn:hover { color: var(--color-on-button); background: var(--color-cancel-hover); text-decoration: none; }
.btn .fa { margin-right: 6px; }
.btn-icon .fa { margin-right: 0; }
.btn-primary { color: var(--color-on-primary); background: var(--color-primary); }
.btn-primary:hover { color: var(--color-on-primary); background: var(--color-primary-hover); }
.btn-create { color: var(--color-on-button); background: var(--color-create); }
.btn-create:hover { color: var(--color-on-button); background: var(--color-create-hover); }
.btn-danger, .btn.is-danger { color: var(--color-on-danger); background: var(--color-danger); }
.btn-danger:hover, .btn.is-danger:hover { color: var(--color-on-danger); background: var(--color-danger-hover); }
.btn-warning { color: var(--color-on-button); background: var(--color-warning); }
.btn-warning:hover { color: var(--color-on-button); background: var(--color-warning-hover); }
.btn-small { height: auto; padding: 3px 8px; font-size: 12px; line-height: 18px; }
.btn-icon { min-width: 42px; padding-left: 10px; padding-right: 10px; }
.btn-link { height: auto; padding: 0; font: inherit; color: var(--color-link); background: none; border: 0; cursor: pointer; }
.btn-link:hover { color: var(--color-link-hover); text-decoration: underline; background: none; }
.btn[disabled], .btn.is-disabled, .btn:disabled { opacity: .65; cursor: not-allowed; pointer-events: none; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.btn .count-bubble {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  font-size: 12px;
  line-height: 18px;
  border-radius: 9px;
  color: var(--color-primary);
  background: var(--color-surface);
}

/* ------------------------------------------------------------ badges, chips, availability */

.badge {
  display: inline-block;
  padding: .2em .6em .3em;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  vertical-align: baseline;
  text-align: center;
  color: var(--color-text-inverse);
  background: var(--status-inactive);
  border-radius: var(--radius-badge);
}
.badge-enquiry, .badge-inquiry { background: var(--state-enquiry); }
.badge-draft { background: var(--state-draft); }
.badge-quotation { background: var(--state-quotation); }
.badge-order { background: var(--state-order); }
.badge-open { background: var(--status-open); }
.badge-provisional { background: var(--status-provisional); }
.badge-reserved { background: var(--status-reserved); }
.badge-active { background: var(--status-active); }
.badge-invoiced, .badge-paid { background: var(--status-invoiced); }
.badge-issued { background: var(--status-provisional); }
.badge-partially-paid { background: var(--status-open); }
.badge-completed, .badge-cancelled, .badge-lost, .badge-dead, .badge-postponed, .badge-voided, .badge-inactive, .badge-mixed { background: var(--status-inactive); }
.badge-allocated { background: var(--item-allocated); }
.badge-prepared { background: var(--item-prepared); }
.badge-booked-out { background: var(--item-booked-out); }
.badge-part-checked-in { background: var(--item-part-checked-in); }
.badge-checked-in { background: var(--item-checked-in); }
.badge-deal-price { background: var(--item-deal-price); }
.badge-rental { background: var(--type-rental); }
.badge-sale { background: var(--type-sale); }
.badge-service { background: var(--type-service); }
.badge-optional { background: var(--incl-optional); }
.badge-default { background: var(--incl-default); }
.badge-mandatory { background: var(--incl-mandatory); }
.badge-active-record, .badge-signed-in { background: var(--color-create); }
.badge-locked, .badge-failed { background: var(--color-danger); }
.badge-role-admin { background: var(--module-admin); }
.badge-role-staff { background: var(--color-primary); }
.badge-role-warehouse { background: var(--module-rfid); }
.badge-manual { background: var(--color-primary); }
.badge-inferred { background: var(--color-warning); }
/* Item statuses share keys with opportunity statuses but use the item colours. */
.items-table .badge-open, .items-table .badge-provisional, .item-status .badge-open, .item-status .badge-provisional { background: var(--item-open); }
.items-table .badge-reserved, .item-status .badge-reserved { background: var(--item-reserved); }
.items-table .badge-completed, .item-status .badge-completed { background: var(--item-completed); }

.tag-chip {
  display: inline-block;
  padding: 1px 6px;
  font-size: 12px;
  line-height: 16px;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-tag-border);
  border-radius: var(--radius-chip);
}
.section-count {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 400;
  line-height: 14px;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--color-text-inverse);
  background: var(--color-section-count);
}

.avail {
  display: inline-block;
  min-width: 28px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-inverse);
  background: var(--avail-ok);
}
.avail-ok { background: var(--avail-ok); }
.avail-warn { background: var(--avail-warn); }
.avail-short { background: var(--avail-short); }

/* ------------------------------------------------------------ pager (small and flat) */

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.pager-count { color: var(--color-text-muted); }
.pager-pages { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
.pager-pages a, .pager-pages span { display: inline-block; min-width: 28px; padding: 3px 8px; text-align: center; }
.pager-pages a:hover { color: var(--color-on-primary); background: var(--color-primary); text-decoration: none; }
.pager-pages .is-current { color: var(--color-on-primary); background: var(--color-primary); }
.pager-pages .is-disabled { color: var(--color-text-faint); }
.pager-pages .gap { color: var(--color-text-muted); }

/* ------------------------------------------------------------ modals (dialog.modal) */

dialog.modal {
  width: 600px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--color-text);
  background: var(--color-surface);
  border: 0;
  border-radius: 0;
  box-shadow: 0 5px 15px var(--color-modal-shadow);
}
dialog.modal::backdrop { background: var(--color-backdrop); }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 14px 20px; color: var(--color-text-inverse); background: var(--color-primary); }
.modal-header h2 { flex: 1; font-size: 18px; font-weight: 600; }
.modal-close { padding: 0 4px; font-size: 22px; line-height: 1; color: var(--color-text-inverse); opacity: .6; background: none; border: 0; cursor: pointer; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 20px 30px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 30px; border-top: 1px dotted var(--color-border-strong); }

/* ------------------------------------------------------------ inline notice (pink warning box) */

.notice { padding: 10px 15px; color: var(--color-error-ink); background: var(--color-error-bg); border: 1px solid var(--color-error-border); }
.notice-info { color: var(--color-info-ink); background: var(--color-info-bg); border-color: var(--color-info-border); }
.notice-warn { color: var(--color-warn-ink); background: var(--color-warn-bg); border-color: var(--color-warn-border); }

/* Error summary: the classic red bar at the top of a form panel after a failed save, one link
   per field error (the field itself carries .has-error and a .field-error line). */
.error-summary { position: relative; margin: 0 0 16px; padding: 8px 15px 10px 40px; color: var(--color-on-danger); background: var(--color-danger); }
.error-summary::before { position: absolute; left: 15px; top: 8px; width: 16px; font-family: FontAwesome; line-height: 20px; text-align: center; content: "\f132"; }
.error-summary h2 { margin: 0 0 2px; font-size: 15px; font-weight: 600; line-height: 20px; color: inherit; }
.error-summary ul { margin: 0; padding-left: 18px; }
.error-summary li { line-height: 20px; }
.error-summary a, .error-summary a:hover { color: inherit; text-decoration: underline; }
.error-summary:focus, .error-summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.form-panel > .error-summary:first-child, .form-panel > form > .error-summary:first-of-type { margin-top: 4px; }

/* ------------------------------------------------------------ dashboard */

/* The page's h1 is visually hidden above the panel, so the panel takes no sibling gap. */
.dash-panel { margin: 0; padding: 16px 30px 26px; color: var(--color-text-inverse); background: var(--color-dash-panel); }
.dash-panel h2 { margin-bottom: 24px; font-size: 20px; font-weight: 600; }
.dash-counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2fr); gap: 20px 40px; }
.dash-counter { display: flex; flex-direction: column; min-width: 0; }
.dash-counter a, .dash-counter a:hover { color: inherit; text-decoration: none; }
.dash-counter > a:first-child { display: flex; flex: 1 0 auto; flex-direction: column; }
.dash-counter a:hover span, .dash-counter a:hover small { text-decoration: underline; }
.dash-counter strong { display: block; font-size: 44px; font-weight: 400; line-height: 1.1; overflow-wrap: anywhere; }
.dash-counter span { display: block; margin-top: auto; font-size: 14px; text-transform: uppercase; }
.dash-counter small { display: block; margin-top: 4px; font-size: 13px; text-transform: uppercase; color: var(--color-text-muted); }
.dash-counter.is-value { grid-column: 5; }
.dash-bar { height: 10px; margin-top: 8px; background: var(--color-dash-track); }
.dash-bar > i { display: block; height: 100%; background: var(--color-primary); }
.dash-bar.is-enquiry > i { background: var(--state-enquiry); }
.dash-bar.is-quotation > i { background: var(--state-quotation); }
.dash-bar.is-order > i { background: var(--state-order); }
.dash-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.dash-tile {
  display: flex;
  flex-direction: column;
  min-height: 190px;
  padding: 14px 16px;
  text-align: center;
  color: var(--color-text-inverse);
  background: var(--tile-bg, var(--tile-blue));
}
a.dash-tile:hover { color: var(--color-text-inverse); text-decoration: none; filter: brightness(.93); }
.dash-tile h3 { font-size: 18px; font-weight: 600; }
.dash-tile strong { margin: auto 0; font-size: 72px; font-weight: 600; line-height: 1; }
.dash-tile small { font-size: 14px; }
.tile-green { --tile-bg: var(--tile-green); }
.tile-orange { --tile-bg: var(--tile-orange); }
.tile-blue { --tile-bg: var(--tile-blue); }
.tile-red { --tile-bg: var(--tile-red); }
.tile-purple { --tile-bg: var(--module-dashboard); }

/* ------------------------------------------------------------ autocomplete */

.autocomplete { position: relative; }
.form-row .autocomplete > input, .input-group .autocomplete > input { width: 100%; }
.autocomplete-list {
  position: absolute;
  z-index: 160;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 300px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--color-menu-bg);
  border: 1px solid var(--color-menu-border);
  box-shadow: 0 6px 12px var(--color-shadow);
}
.autocomplete-list li { padding: 7px 12px; cursor: pointer; }
.autocomplete-list li.is-active, .autocomplete-list li:hover { color: var(--color-menu-hover-text); background: var(--color-menu-hover-bg); }
.autocomplete-list .sub { display: block; font-size: 12px; color: var(--color-text-muted); }
.autocomplete-list li.is-active .sub, .autocomplete-list li:hover .sub { color: var(--color-text-faint); }

/* ------------------------------------------------------------ login and errors */

.is-bare .page { background: transparent; }
.login-box { max-width: 400px; margin: 40px auto 0; padding: 24px 30px 30px; background: var(--color-surface-alt); border: 1px solid var(--color-border-strong); }
.login-box .panel-header { margin-bottom: 16px; }
.login-box .panel-header h2 { font-size: 24px; color: var(--color-label); }
.login-form input[type="email"], .login-form input[type="password"] { width: 100%; }
.login-form .form-actions { margin-top: 8px; }
.login-form .form-actions .btn { width: 100%; }
.error-panel { max-width: 640px; }
.error-detail { margin: 12px 0 0; padding: 10px; overflow-x: auto; font-size: 12px; background: var(--color-surface-alt); border: 1px solid var(--color-border); white-space: pre-wrap; }

/* ------------------------------------------------------------ narrower screens */

@media (max-width: 1100px) {
  .user-name, .user-store { max-width: 140px; }
  .dash-counters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-counter.is-value { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .topbar { padding-left: 0; }
  .nav-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 var(--gutter);
    font: inherit;
    font-size: 15px;
    color: var(--color-topbar-text);
    background: none;
    border: 0;
    border-top: 4px solid var(--nav-color, var(--color-topbar-bg));
    border-bottom: 4px solid transparent;
    cursor: pointer;
  }
  .nav-toggle[aria-expanded="true"] { background: var(--color-nav-hover-bg); }
  .main-nav {
    display: none;
    position: absolute;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    max-height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    background: var(--color-nav-bg);
    box-shadow: 0 6px 12px var(--color-shadow);
  }
  .main-nav.is-open { display: block; }
  .nav-list { flex-direction: column; gap: 0; padding-bottom: 8px; }
  .nav-item { height: auto; border-left: 4px solid var(--nav-color, transparent); }
  .nav-item::before { content: none; }
  .nav-link, .nav-item.is-active > .nav-link { width: 100%; padding: 10px 16px; text-align: left; }
  .nav-item:not(.dropdown) > .nav-link { font-size: 15px; color: var(--color-topbar-text); }
  .nav-item.dropdown > .nav-link { padding-bottom: 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; cursor: default; }
  .nav-item.is-open > .nav-link { color: var(--color-nav-text); background: none; text-shadow: none; }
  .nav-item.is-active > .nav-link, .nav-item.is-active.is-open > .nav-link { color: var(--color-topbar-text); background: var(--nav-color); }
  .nav-item > .dropdown-menu { display: block; position: static; min-width: 0; padding: 0 0 6px; background: none; border: 0; box-shadow: none; }
  .nav-item > .dropdown-menu > li > a { padding: 8px 16px 8px 28px; font-size: 15px; color: var(--color-topbar-text); }
  .nav-item > .dropdown-menu > li > a:hover { background: var(--color-nav-hover-bg); }
  .page-body.with-sidebar { grid-template-columns: minmax(0, 1fr); }
  .page-body.with-sidebar > .page-content { padding-bottom: 30px; }
}

@media (max-width: 760px) {
  .table-scroll > .items-table { min-width: 720px; }
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .form-section { grid-template-columns: minmax(0, 1fr); }
  .form-section > .form-section-icon { display: none; }
  .form-section > :not(.form-section-icon) { grid-column: 1; }
  .stat-tiles.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-tiles.cols-4 > .stat-tile:nth-child(n+3) { border-top: 1px solid var(--color-border); }
}

@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .page-title, .form-panel .page-title, .form-title { font-size: 24px; }
  .page-header { margin-bottom: 14px; }
  .page-actions { margin-left: 0; }
  .list-search { flex-wrap: nowrap; width: 100%; }
  .list-search > label { display: none; }
  .list-search input[type="search"], .list-search input[type="text"] { flex: 1 1 auto; width: auto; min-width: 0; }
  .list-toolbar > .toolbar-actions { margin-left: 0; }
  .form-panel, .page:has(> .page-body > .page-content > .form-panel:first-child) > .page-header { padding-left: 16px; padding-right: 16px; }
  .page:has(> .page-body > .page-content > .form-panel:first-child) { padding-left: 0; padding-right: 0; }
  .page:has(> .page-body > .page-content > .form-panel:first-child) > .crumbs { padding-left: 16px; padding-right: 16px; }
  .page-sidebar { padding: 20px var(--gutter) 30px; }
  .sidebar-panel > :not(h3):not(.action-list):not(.stat-tiles) { padding-left: 0; }
  .user-name { max-width: 150px; font-size: 15px; }
  .user-store { max-width: 150px; }
  .summary-tile { flex-basis: calc(50% - 2px); }
  .dash-panel { padding: 14px 16px 20px; }
  .dash-panel h2 { margin-bottom: 16px; font-size: 18px; }
  .dash-counters { gap: 16px; }
  .dash-counter strong { font-size: 32px; }
  .dash-counter span { font-size: 12px; }
  .dash-counter small { font-size: 12px; }
  .dash-tile { min-height: 150px; }
  .dash-tile strong { font-size: 56px; }
  .login-box { margin-top: 16px; padding: 20px 16px; }
}
