/* Hanbang Market inventory UI — plain CSS, no build step. */
:root {
  --bg: #f7f2ea;
  --bg-elevated: #fffdf9;
  --surface: #ffffff;
  --border: #e6dbcd;
  --border-strong: #d3c3ae;
  --text: #241c15;
  --text-muted: #6f6156;
  --primary: #b4451f;
  --primary-hover: #963718;
  --primary-soft: #fbe9e1;
  --accent: #2f6f4f;
  --accent-soft: #e4f1ea;
  --warn: #8a5a00;
  --warn-soft: #fdf2d8;
  --danger: #a3231b;
  --danger-soft: #fbe6e3;
  --ring: rgba(180, 69, 31, 0.35);
  --chart-1: #b4451f;
  --chart-2: #2f6f4f;
  --chart-3: #c98a2b;
  --chart-4: #4f6f9e;
  --chart-5: #8a4f7d;
  --chart-6: #5f7f7a;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(36, 28, 21, 0.06);
  --shadow: 0 12px 32px -18px rgba(36, 28, 21, 0.35);
  --font: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system,
    sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120e;
    --bg-elevated: #1e1813;
    --surface: #231c16;
    --border: #352a21;
    --border-strong: #4a3a2c;
    --text: #f6eee4;
    --text-muted: #b3a294;
    --primary: #e3714a;
    --primary-hover: #f08a63;
    --primary-soft: #3a231a;
    --accent: #7fc3a0;
    --accent-soft: #1f2f27;
    --warn: #f0c469;
    --warn-soft: #352a12;
    --danger: #f08d82;
    --danger-soft: #3a1f1c;
    --ring: rgba(227, 113, 74, 0.45);
    --chart-1: #e3714a;
    --chart-2: #7fc3a0;
    --chart-3: #e6b35a;
    --chart-4: #8fb0d9;
    --chart-5: #c98fb8;
    --chart-6: #8fbdb5;
    --shadow: 0 14px 34px -20px rgba(0, 0, 0, 0.8);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/*
 * The app toggles whole screens with the `hidden` attribute. Author rules such
 * as `.auth { display: grid }` would otherwise beat the UA `[hidden]` rule.
 */
[hidden] {
  display: none !important;
}

.muted {
  color: var(--text-muted);
  font-weight: 400;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 60ms ease;
}

.button:hover {
  border-color: var(--text-muted);
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff8f2;
}

.button--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.button--ghost {
  background: transparent;
}

.button--block {
  width: 100%;
}

:where(button, input, select, a):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field > label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.field input,
.field select {
  min-height: 40px;
  padding: 0 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  font: inherit;
  width: 100%;
}

.field input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.field__group {
  display: flex;
  gap: 0.4rem;
}

/* An inline action inside a field (for example the password toggle) must not
   squeeze the input, so the input takes the leftover width instead of 100%. */
.field__group > input {
  flex: 1 1 auto;
  min-width: 0;
}

.field__group > .button {
  flex: 0 0 auto;
  padding: 0 0.85rem;
}

/* "Add a new …" box that appears under a dropdown (the Unit box in Item Create
   and the Agent box in Delivery Notes). */
.inline-new {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

/* display:flex would otherwise beat the hidden attribute. */
.inline-new[hidden] {
  display: none;
}

.inline-new > input {
  flex: 1 1 8rem;
  min-width: 0;
}

.inline-new > .button {
  flex: 0 0 auto;
  padding: 0 0.85rem;
}

/* Inline errors sit inside a field, so they need no side margin of their own. */
.field > .alert--inline {
  margin: 0.15rem 0 0;
}

.field__toggle {
  flex: 0 0 auto;
  padding: 0 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Item create form */
.panel--form {
  padding: clamp(1rem, 2.5vw, 1.6rem);
}

.panel--form > .alert {
  margin-bottom: 1rem;
}

.form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 1rem;
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.form__actions .button {
  min-width: 130px;
}

.field__hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  align-self: end;
  min-height: 40px;
  font-size: 0.86rem;
  color: var(--text-muted);
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.field textarea {
  min-height: 96px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  font: inherit;
  width: 100%;
  resize: vertical;
}

.field textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

/* "Show in Web" block in Item Create */
.web-fields {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.web-fields > legend {
  padding: 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.web-fields > .field__hint {
  margin: 0 0 0.85rem;
}

.form__grid--web {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0.85rem;
}

/*
 * Photo slots: the whole card opens the file picker because the file input is
 * stretched across it and made transparent. The preview and the Remove button
 * sit underneath and above that overlay respectively.
 */
.upload {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 152px;
  padding: 0.6rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 120ms ease, background-color 120ms ease, opacity 120ms ease;
}

.upload:hover,
.upload:focus-within {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.upload--filled {
  border-style: solid;
  border-color: var(--accent);
}

.upload--busy {
  opacity: 0.6;
}

.upload__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.upload__input:disabled {
  cursor: not-allowed;
}

.upload__preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.upload__title {
  font-size: 0.85rem;
  font-weight: 600;
}

.upload__hint {
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.upload__remove {
  position: relative;
  z-index: 1; /* keep the button clickable above the transparent input */
  align-self: flex-start;
  min-height: 32px;
  margin-top: auto;
  padding: 0 0.7rem;
  font-size: 0.8rem;
}

/* Alerts */
.alert {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
}

.alert[hidden] {
  display: none;
}

.alert--inline {
  margin: 0.75rem 1rem;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--primary);
  color: #fff8f2;
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.brand__name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.brand__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.brand--compact .brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 1.1rem;
}

/* Sign-in */
.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background-image: radial-gradient(
      circle at 15% 15%,
      var(--primary-soft),
      transparent 45%
    ),
    radial-gradient(circle at 85% 85%, var(--accent-soft), transparent 40%);
}

.auth__card {
  width: min(420px, 100%);
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.auth__title {
  margin-top: 1.6rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.auth__lede {
  margin: 0.35rem 0 1.4rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.auth__hint {
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* App shell */
.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: var(--bg-elevated);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

/* Main menu */
.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.menu__item {
  min-height: 34px;
  padding: 0 0.95rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.menu__item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.menu__item[aria-current="page"] {
  background: var(--primary);
  color: #fff8f2;
}

.menu__item:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.user__meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user__name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user__role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 4vw, 2.5rem) 3rem;
}

.page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page__head h1 {
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  letter-spacing: -0.025em;
}

.page__sub {
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Summary cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.stat__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat__value {
  margin-top: 0.3rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat--warn .stat__value {
  color: var(--warn);
}

.stat--danger .stat__value {
  color: var(--danger);
}

/* Summary cards that sit inside a panel need the panel's side padding. */
.stats--inset {
  padding: 0 1rem;
  margin-bottom: 0.75rem;
}

/* Space between the agent's own notes and the shop-wide agent list below. */
.agent-deliveries {
  margin-bottom: 1.25rem;
}

/* Panel + toolbar */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  padding: 1rem 1rem 0.75rem;
}

.panel__head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel__head p {
  margin: 0;
  font-size: 0.85rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.toolbar .field select {
  min-height: 38px;
  width: auto;
  min-width: 8.5rem;
}

.field--search {
  flex: 1 1 220px;
}

.field--search input {
  min-height: 38px;
}

.chip {
  min-height: 38px;
  padding: 0 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.chip:hover {
  border-color: var(--text-muted);
}

.chip[aria-pressed="true"] {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--primary-soft) 35%, transparent);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.product__name {
  font-weight: 600;
}

.product__meta {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sku {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--text-muted);
  white-space: nowrap;
}

.stock {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stock-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.35rem;
}

.stock-group .muted {
  font-weight: 400;
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--low {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--out {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--archived {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}

.badge--ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--confirmed {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--cancelled {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}

.badge--received {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--processed {
  background: var(--accent-soft);
  color: var(--accent);
}

.table__empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.table__empty strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text);
  font-size: 1rem;
}

.row-action {
  min-height: 32px;
  padding: 0 0.7rem;
  font-size: 0.8rem;
}

/* Customer order rows */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* The agent's own notes have no Actions column, so Print sits under the code. */
.agent-delivery__print {
  margin: 0.4rem 0 0.2rem;
}

.order__code {
  display: block;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.order__lines {
  display: grid;
  gap: 0.1rem;
}

.order__line,
.order__note {
  font-size: 0.82rem;
}

.order__note {
  color: var(--text-muted);
}

/* Purchase order builder */
.form__subtitle {
  margin: 1.35rem 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form__grid--line {
  align-items: end;
}

.field--action {
  align-self: end;
}

.field--action .button {
  width: 100%;
}

/* Scan station: a scanner's digits plus Enter add the pack to the draft */
.scan {
  margin-bottom: 1rem;
  padding: 0.8rem 0.9rem 0.65rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.scan__row {
  grid-template-columns: minmax(215px, 2fr) minmax(150px, 0.75fr);
}

.scan .field__hint {
  margin: 0.55rem 0 0;
}

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

.purchase__totals {
  margin: 0.9rem 0 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.purchase__totals strong {
  color: var(--text);
}



/* Pagination */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.pager__info {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.pager__controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pager__size {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.3rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.pager__size select {
  min-height: 34px;
  padding: 0 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.pager .button {
  min-height: 34px;
  padding: 0 0.75rem;
  font-size: 0.83rem;
}

/* Dialog */
.dialog {
  width: min(440px, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.5);
}

.dialog::backdrop {
  background: rgba(24, 16, 10, 0.45);
  backdrop-filter: blur(2px);
}

.dialog .form {
  padding: 1.25rem 1.35rem 1.35rem;
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog__head h2 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.dialog__close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
}

.dialog__close:hover {
  color: var(--text);
}

.dialog__product {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

/* Wider variant: the restock-order editor lists every line at once */
.dialog--wide {
  width: min(620px, calc(100vw - 2rem));
}

.dialog__lines {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 46vh;
  overflow-y: auto;
}

.edit-line {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) 68px 96px 88px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.edit-line__product {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.edit-line__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.edit-line__field input {
  width: 100%;
  min-height: 36px;
  padding: 0 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: inherit;
  font: inherit;
}

.edit-line__total {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .edit-line {
    grid-template-columns: 1fr 1fr;
  }

  .edit-line__product,
  .edit-line__total {
    grid-column: 1 / -1;
  }

  .edit-line__total {
    text-align: left;
  }
}

/* Quantities and unit costs in the purchase-order draft are edited in place, so
   the table stays the working document while the order is built. */
.draft-input {
  width: 6.5rem;
  min-height: 34px;
  padding: 0 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.draft-input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

@media (max-width: 640px) {
  .draft-input {
    width: 100%;
  }
}

/* Toasts */
.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 40;
  pointer-events: none;
}

.toast {
  max-width: 340px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  animation: toast-in 160ms ease-out;
}

.toast--error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Responsive */
@media (max-width: 760px) {
  .form__grid--web {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .form__actions .button {
    flex: 1 1 auto;
  }

  .page__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border);
  }

  .table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.3rem 0.85rem;
    border: 0;
    text-align: right;
  }

  .table td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
  }

  .table td.num {
    text-align: right;
  }

  .table td[data-label="Product"] {
    display: block;
    padding-bottom: 0.35rem;
    text-align: left;
  }

  .table td[data-label="Product"]::before {
    display: none;
  }

  .table__empty {
    padding: 2rem 1rem;
  }

  .pager {
    justify-content: center;
  }

  .auth__card {
    padding: 1.5rem;
  }
}

/* Administration: groups and permission boxes */
#no-access {
  margin: 1rem 1.5rem 0;
}

.group-list {
  display: grid;
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.group-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
}

.group-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.75rem;
}

.group-card__head h3 {
  margin: 0;
  font-size: 1rem;
}

.group-card__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.permission-grid {
  display: grid;
  gap: 0.75rem 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 0.85rem;
}

.permission-grid h4 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.permission {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  font-size: 0.87rem;
  margin-bottom: 0.3rem;
}

.permission input {
  margin-top: 0.2rem;
}

.permission small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.group-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.group-card[data-locked="true"] .permission input {
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Dashboard */
.page__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.field--compact select {
  min-height: 40px;
  width: auto;
  min-width: 9.5rem;
}

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.chart-panel {
  display: flex;
  flex-direction: column;
}

.chart {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 0 1rem 1.25rem;
}

.chart__split {
  display: grid;
  grid-template-columns: minmax(150px, 190px) 1fr;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}

.chart__donut {
  width: 100%;
  max-width: 200px;
  height: auto;
  margin: 0 auto;
}

.chart__total {
  fill: var(--text);
  font-family: var(--font);
  font-size: 7px;
  font-weight: 700;
}

.chart__caption {
  fill: var(--text-muted);
  font-family: var(--font);
  font-size: 4.4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chart__legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.chart__legend--inline {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1rem;
}

.chart__legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chart__swatch {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  background: var(--text-muted);
}

.chart__swatch--revenue {
  background: var(--chart-1);
}

.chart__swatch--profit {
  background: var(--chart-2);
}

.chart__legend-label {
  color: var(--text-muted);
}

.chart__legend-value {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart__legend-share {
  min-width: 3rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart__figure {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.chart__bars {
  width: 100%;
  height: auto;
}

.chart__grid {
  stroke: var(--border);
  stroke-width: 0.7;
}

.chart__axis {
  fill: var(--text-muted);
  font-family: var(--font);
  font-size: 7px;
}

.chart__bar--revenue {
  fill: var(--chart-1);
}

.chart__bar--profit {
  fill: var(--chart-2);
}

.chart__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.chart__empty strong {
  color: var(--text);
}

.dashboard-panel {
  margin-top: 1.25rem;
}

.stat--accent .stat__value {
  color: var(--accent);
}

.table__total th,
.table__total td {
  background: var(--surface);
  border-top: 2px solid var(--border-strong);
  font-weight: 700;
}

@media (max-width: 640px) {
  .chart__split {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .chart__legend {
    width: 100%;
  }
}
