/* 11 administration web - Brand Board v1.1 and the approved M01 Design (AdminView): UI yellow #E2B81F (hover #D8AD18,
   pressed #B88F0A), charcoal #2A2A2E, background #F2F1EE, Plus Jakarta Sans, controls 14px / cards 16px, 44px touch
   targets. Functional colors (error / success) are used only for states, never as brand colors. */

@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/fonts/PlusJakartaSans-wght.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --yellow: #e2b81f;
  --yellow-hover: #d8ad18;
  --yellow-pressed: #b88f0a;
  --yellow-soft: #fbf1cf;
  --yellow-subtle: #fdf8e6;
  --charcoal: #2a2a2e;
  --white: #ffffff;
  --surface: #f2f1ee;
  --line: #e3e1db;
  --line-strong: #cfccc3;
  --muted: #55555b;
  --placeholder: #8c8c92;
  --neutral-bg: #efede8;
  --error: #c23b32;
  --error-ink: #8e2a22;
  --error-bg: #fbe9e7;
  --error-line: #e9b5af;
  --ok: #2e7d4f;
  --ok-ink: #1f5c38;
  --ok-bg: #e4f3ea;
  --ok-line: #a9d4b8;
  --warning: var(--charcoal); /* warnings use the soft yellow with charcoal ink */
  --warning-bg: var(--yellow-soft);
  --warning-line: var(--yellow);
  --info: var(--charcoal);
  --info-bg: var(--white);
  --radius-card: 16px;
  --radius-control: 14px;
  --control-height: 48px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--surface);
  color: var(--charcoal);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header: small on desktop, as the design asks. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 8px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-tile {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--white);
}

.brand-logo {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
}

.brand-name {
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px 56px;
}

/* Signed-out pages (login, 2FA, activation, reset): dark ADMIN panel on the left, the card on the light side. */
.page-auth {
  flex-direction: row;
}

.auth-aside {
  flex: none;
  width: 420px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 48px;
  background: var(--charcoal);
  color: var(--white);
}

/* The logo's ink is dark: on the dark panel it sits on a white tile (the logo itself is never recolored). */
.auth-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--white);
}

.auth-logo {
  display: block;
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.auth-intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.auth-badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--charcoal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.auth-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.auth-text,
.auth-slogan {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--line);
}

.auth-slogan {
  font-size: 13px;
}

.page-auth .card {
  max-width: 460px;
  padding: 28px;
}

/* Narrow screens: the panel becomes a band above the card (logo, ADMIN, title); the long text is dropped. */
@media (max-width: 900px) {
  .page-auth {
    flex-direction: column;
  }

  .auth-aside {
    width: auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    padding: 14px 16px;
  }

  .auth-tile {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .auth-logo {
    width: 36px;
    height: 36px;
  }

  .auth-intro {
    flex-direction: row-reverse;
    align-items: center;
    gap: 10px;
  }

  .auth-title {
    font-size: 17px;
    letter-spacing: 0;
  }

  .auth-text,
  .auth-slogan {
    display: none;
  }
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 32px;
}

.card-quiet {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.title {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.title:focus {
  outline: none;
}

.lead {
  margin: 0 0 24px;
  font-size: 15px;
  color: var(--muted);
}

.muted {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 600;
}

.input-wrap {
  position: relative;
  display: flex;
}

.input-wrap input {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 14px;
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
  font-weight: 600;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input-wrap input::placeholder {
  color: var(--placeholder);
  font-weight: 500;
}

.input-wrap input:hover {
  border-color: var(--line-strong);
}

/* Focus: yellow 2px border with a soft-yellow ring; error: red border with a soft-red ring (M01 Design inputs). */
.input-wrap input:focus-visible {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 1px var(--yellow), 0 0 0 4px var(--yellow-soft);
}

.input-wrap input[aria-invalid='true'] {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.input-wrap input[aria-invalid='true']:focus-visible {
  box-shadow: 0 0 0 1px var(--error), 0 0 0 4px var(--error-bg);
}

.input-wrap input[readonly] {
  background: #fafaf8;
}

#password {
  padding-right: 52px;
}

.icon-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--charcoal);
  border-radius: 10px;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface);
}

.icon-btn:focus-visible,
.btn:focus-visible,
.link-btn:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}

.code-input {
  font-size: 22px !important;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--control-height);
  padding: 0 20px;
  border-radius: var(--radius-control);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn-primary {
  background: var(--yellow);
  color: var(--charcoal);
  border: 1px solid var(--yellow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--yellow-hover);
  border-color: var(--yellow-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--yellow-pressed);
  border-color: var(--yellow-pressed);
}

.btn-secondary {
  background: var(--white);
  color: var(--charcoal);
  border: 1px solid var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface);
}

.btn:disabled {
  cursor: not-allowed;
  background: #edebe5;
  border-color: #edebe5;
  color: var(--placeholder);
}

.btn[aria-busy='true'] {
  background: var(--yellow-hover);
  border-color: var(--yellow-hover);
  color: var(--charcoal);
  cursor: progress;
}

.btn-secondary[aria-busy='true'] {
  background: var(--surface);
  border-color: var(--line);
}

.btn-compact {
  width: auto;
  min-height: 44px;
  font-size: 15px;
}

.link-btn {
  align-self: flex-start;
  min-height: 44px;
  padding: 0 4px;
  margin: 0 0 4px -4px;
  border: 0;
  background: transparent;
  color: var(--yellow-pressed);
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  cursor: pointer;
}

.message {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.field .message-error {
  padding: 0;
  border: 0;
  background: none;
  color: var(--error-ink);
  font-size: 13px;
}

/* Banners (M01 Design): error = soft red, success = soft green, warning = soft yellow, notice = white with a border. */
.form > .message,
.card > .message,
.shell-main > .message {
  padding: 12px 14px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
}

.message-error {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-ink);
}

.message-notice {
  background: var(--info-bg);
  border-color: var(--line);
  color: var(--info);
}

.message-warning {
  background: var(--warning-bg);
  border-color: var(--warning-line);
  color: var(--warning);
  font-variant-numeric: tabular-nums;
}

.card > .message {
  margin-bottom: 16px;
}

.card > .btn {
  margin-top: 8px;
}

.steps {
  margin: 0 0 16px;
  padding-left: 22px;
  font-size: 15px;
  color: var(--charcoal);
}

.steps li + li {
  margin-top: 4px;
}

.qr {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 224px;
  height: 224px;
  margin: 0 auto 8px;
  padding: 7px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.qr svg {
  display: block;
  width: 208px;
  height: 208px;
}

.qr-loading {
  background: repeating-linear-gradient(45deg, #faf9f6, #faf9f6 8px, #f2f1ee 8px, #f2f1ee 16px);
}

.setup-key {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
}

.role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--charcoal);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

.lead .role-badge {
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--charcoal);
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

.noscript {
  margin: 40px 16px;
  text-align: center;
}

/* Mobile: one column that fits the viewport, no horizontal scroll. */
@media (max-width: 520px) {
  .topbar {
    padding: 8px 16px;
  }

  .main {
    align-items: flex-start;
    padding: 24px 16px 40px;
  }

  .card {
    padding: 24px 20px;
  }

  .title {
    font-size: 24px;
  }

  .topbar .role-badge {
    display: none;
  }
}

.title + .steps,
.title + .message + .steps {
  margin-top: 12px;
}

.lead-last {
  margin-bottom: 0;
}

.lead-last + .message {
  margin-top: 16px;
}

/* ---- M01-D-ADMIN-WEB: signed-in shell (dark-grey sidebar), invitation screens, activation page. Same tokens. ---- */

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

.input-wrap textarea,
.input-wrap select,
.select {
  width: 100%;
  min-height: var(--control-height);
  padding: 10px 14px;
  font-size: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.input-wrap textarea {
  resize: vertical;
  line-height: 1.45;
}

.input-wrap textarea:focus-visible,
.input-wrap select:focus-visible,
.select:focus-visible,
.link-input:focus-visible,
.nav-link:focus-visible,
.btn-link:focus-visible,
.check input:focus-visible,
.perm-table input:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}

.input-wrap textarea[aria-invalid='true'],
.input-wrap input[aria-invalid='true'] {
  border-color: var(--error);
}

.step-label {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.subtitle {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}

.subtitle:focus {
  outline: none;
}

.hint {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.test-display {
  margin: 12px 0 0;
  padding: 10px 14px;
  border: 1px dashed var(--yellow-pressed);
  border-radius: var(--radius-control);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 14px;
  font-weight: 600;
}

.card > .form,
.card > .test-display + .form {
  margin-top: 16px;
}

.card > .btn-primary + .test-display {
  margin-top: 12px;
}

.btn-link {
  text-decoration: none;
}

.btn-danger {
  background: var(--white);
  color: var(--error-ink);
  border: 1px solid var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: var(--error-bg);
}

.content {
  max-width: 960px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.content-narrow {
  max-width: 640px;
}

.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.content-head .title {
  margin: 0;
}

.content .btn-link {
  width: auto;
}

.content .link-btn {
  margin: 0;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar .btn {
  width: auto;
}

.toolbar .field {
  min-width: 220px;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1.4fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}

.row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-name {
  overflow-wrap: anywhere;
}

.row-phone,
.row-date {
  font-size: 14px;
  color: var(--muted);
}

.status {
  display: inline-block;
  justify-self: start;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--muted);
}

.status-wait,
.status-warn {
  background: var(--yellow-soft);
  color: var(--charcoal);
}

.status-ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.empty {
  margin: 0;
  padding: 24px 0;
  color: var(--muted);
}

.detail-status {
  display: flex;
}

.kvs {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px;
}

.kv dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.kv dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.summary {
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--yellow-subtle);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.perm-table caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: 6px;
}

.perm-table th,
.perm-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.perm-edit td,
.perm-edit th:not(:first-child) {
  text-align: center;
}

.perm-edit input[type='checkbox'] {
  width: 24px;
  height: 24px;
  accent-color: var(--charcoal);
}

.perm-box {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.perm-box legend {
  padding: 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--charcoal);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.actions .btn {
  width: auto;
  min-width: 140px;
}

.link-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-input {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 14px;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.link-block .btn {
  width: auto;
  align-self: flex-start;
}

.step-up,
.retry,
.done {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-up .lead {
  margin: 0;
}

/* Narrow screens: rows stack, nothing scrolls sideways. (The sidebar becomes a drawer: see the shell block below.) */
@media (max-width: 800px) {
  .shell-main {
    padding: 16px 16px 40px;
  }

  .content {
    padding: 20px 16px;
  }

  .row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .row-date {
    grid-column: 1 / -1;
  }

  .actions .btn {
    flex: 1 1 100%;
  }
}

/* ---- Shell (D03): sidebar 240 px / rail 64 px / drawer, top bar with breadcrumb. Same tokens. ---- */

:root {
  --sidebar-width: 232px;
  --sidebar-rail: 64px;
  --sidebar-bg: #1a1a1a;
  --sidebar-hover: #2d2d32;
  --sidebar-text: #ffffff;
  --sidebar-muted: #ece9e1;
  --sidebar-line: #3d3d44;
}

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

.icon {
  flex: none;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.shell-collapsed {
  --sidebar-width: var(--sidebar-rail);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 76px;
  padding: 16px 8px 8px 16px;
}

/* The logo's ink is dark: on the dark sidebar it sits on the white tile of .brand-tile. */
.sidebar .brand {
  gap: 12px;
}

.sidebar .brand-name {
  color: var(--sidebar-muted);
}

.side-toggle,
.shellbar-menu,
.shellbar-help,
.side-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.side-toggle:hover,
.side-more:hover {
  background: var(--sidebar-hover);
}

.side-toggle:focus-visible,
.side-more:focus-visible,
.side-link:focus-visible,
.menu-item:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: -3px;
}

.shellbar-menu:focus-visible,
.shellbar-help:focus-visible,
.shell-scrim:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}

.side-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 12px 16px;
  scrollbar-width: thin;
}

.side-list,
.side-sub {
  list-style: none;
  margin: 0;
  padding: 0;
}

.side-group + .side-group {
  margin-top: 4px;
}

.side-rule {
  display: none;
  height: 1px;
  margin: 8px 4px;
  background: var(--sidebar-line);
}

.side-heading {
  margin: 16px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #d6d3ca;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.side-link:hover {
  background: var(--sidebar-hover);
}

.side-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-active,
.side-active:hover {
  background: var(--yellow);
  color: var(--charcoal);
  font-weight: 700;
}

.side-active-parent .icon {
  color: var(--yellow);
}

.side-child {
  min-height: 40px;
  padding-left: 48px;
  font-weight: 500;
}

.side-sub {
  margin-top: 2px;
}

.side-chevron {
  display: inline-flex;
  color: var(--sidebar-muted);
}

.side-soon {
  color: #a9a79f;
  cursor: default;
}

.side-soon:hover {
  background: transparent;
}

.side-badge {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--sidebar-line);
  font-size: 11px;
  font-weight: 600;
  color: #a9a79f;
  white-space: nowrap;
}

.side-foot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  border-top: 1px solid var(--sidebar-line);
}

.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--charcoal);
}

.avatar-small {
  width: 32px;
  height: 32px;
}

.side-account {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.side-account-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.side-account-caption {
  font-size: 12px;
  color: var(--sidebar-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 6px);
  z-index: 30;
  padding: 6px;
  border-radius: var(--radius-control);
  background: var(--white);
  color: var(--charcoal);
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}

.menu-slot {
  display: contents;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--charcoal);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--surface);
}

.menu-item[aria-disabled='true'] {
  color: var(--muted);
  cursor: default;
}

.menu-item[aria-disabled='true']:hover {
  background: transparent;
}

.menu-item-danger {
  color: var(--error);
}

.menu-item:focus-visible {
  outline-color: var(--charcoal);
}

.account-menu .side-badge {
  margin-left: auto;
  border-color: var(--line-strong);
  color: var(--muted);
}

/* Collapsed rail: icons only, tooltips and aria-labels carry the names. */
.shell-collapsed .side-head {
  flex-direction: column;
  justify-content: center;
  padding: 10px 0;
  min-height: 96px;
}

.shell-collapsed .brand-text,
.shell-collapsed .side-label,
.shell-collapsed .side-badge,
.shell-collapsed .side-heading,
.shell-collapsed .side-chevron,
.shell-collapsed .side-sub,
.shell-collapsed .side-account {
  display: none;
}

.shell-collapsed .side-nav {
  padding: 8px;
}

.shell-collapsed .side-rule {
  display: block;
}

.shell-collapsed .side-link {
  justify-content: center;
  padding: 0;
}

.shell-collapsed .side-active-parent {
  background: var(--yellow);
  color: var(--charcoal);
}

.shell-collapsed .side-active-parent .icon {
  color: inherit;
}

.shell-collapsed .side-foot {
  justify-content: center;
  flex-direction: column;
  padding: 12px 4px;
}

.shell-collapsed .account-menu {
  left: calc(100% + 8px);
  right: auto;
  bottom: 8px;
  width: 232px;
}

/* Top bar and content. */
.shell-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.shellbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 0 24px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.shellbar-menu {
  display: none;
  margin-left: -8px;
}

.shellbar-help {
  margin-left: auto;
  color: var(--muted);
}

.shellbar-help[aria-disabled='true'] {
  cursor: default;
}

.shellbar-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 4px;
}

.shellbar-role {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.crumbs-nav {
  min-width: 0;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--muted);
}

.crumbs li + li::before {
  content: '/';
  margin-right: 6px;
  color: var(--line-strong);
}

.crumbs [aria-current='page'] {
  color: var(--charcoal);
  font-weight: 700;
}

.shell-main {
  min-width: 0;
  padding: 32px 32px 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.content-area {
  min-width: 0;
}

.content-area:focus {
  outline: none;
}

.shell-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  border: 0;
  padding: 0;
  background: rgb(26 26 30 / 0.5);
}

/* Narrow screens: the sidebar is a drawer opened by the top bar's menu button; the collapsed rail is desktop-only (the script never sets .shell-collapsed in drawer mode). */
@media (max-width: 900px) {
  .shell {
    --sidebar-width: 280px;
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(var(--sidebar-width), 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 180ms ease, visibility 0s linear 180ms;
  }

  .shell-drawer-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    transition: transform 180ms ease;
  }

  /* Crossing the breakpoint switches the mode at once (no sliding, no delayed visibility). */
  .shell-instant .sidebar {
    transition: none;
  }

  .side-toggle {
    display: none;
  }

  .shellbar {
    padding: 0 16px;
  }

  .shellbar-menu {
    display: inline-flex;
  }

  .shell-main {
    padding: 16px 16px 40px;
  }

  .shellbar-role {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

@media (min-width: 901px) {
  .shell-scrim {
    display: none;
  }
}

/* ---- Account pages (D81 users, D86 detail, administrators), states, dialogs ---- */

.content-wide {
  max-width: none;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head .title {
  margin: 0 0 4px;
}

.btn-inline {
  width: auto;
  min-width: 0;
}

.btn-anchor {
  text-decoration: none;
}

/* Filter bars stay on one row (Owner 2026-11-20); they wrap only when the screen is too narrow for it. */
.toolbar-filters {
  align-items: center;
  flex-wrap: nowrap;
}

@media (max-width: 1100px) {
  .toolbar-filters {
    flex-wrap: wrap;
  }
}

.search {
  position: relative;
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search .icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px 0 42px;
  font-size: 15px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.search-input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}

.toolbar-filters .select {
  width: auto;
  min-width: 160px;
}

.search-input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface);
  color: var(--muted);
  cursor: not-allowed;
}

/* Dense "spreadsheet" tables (Owner 2026-11-20): small text, short rows, a sticky header, thin grid lines.
   The card scrolls on both axes so the sticky header can stick; wide tables scroll sideways on narrow screens. */
.table-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: auto;
  max-height: min(72vh, 760px);
  background: var(--white);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.table tbody tr:nth-child(even) td {
  background: #faf9f6;
}

.table tbody tr:hover td {
  background: var(--yellow-subtle);
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 5px 10px;
  background: var(--yellow-subtle);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table th:last-child,
.table td:last-child {
  border-right: 0;
}

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

.cell-end {
  text-align: right;
}

.table .row-panel td {
  padding: 0;
  max-width: none;
  white-space: normal;
  text-overflow: clip;
}

/* Row actions inside dense tables keep a short row; the phone layout below restores the full touch target. */
.table td .table-link {
  min-height: 28px;
  padding: 0 6px;
}

.table td .table-link:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 1px;
}

.more {
  display: flex;
  justify-content: center;
  padding-top: 16px;
}

.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chip-shop-owner {
  background: var(--yellow);
  color: var(--charcoal);
}

.chip-driver {
  background: var(--charcoal);
  color: var(--white);
}

/* Status chips (M01 Design): pill, no border; green = active, red = locked, soft yellow = waiting / soon. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.badge-lock {
  background: var(--error-bg);
  color: var(--error-ink);
}

.badge-wait,
.badge-soon {
  background: var(--yellow-soft);
  color: var(--charcoal);
}

.table-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  color: var(--yellow-pressed);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Page states (C01-C10). */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
}

.state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
}

.state-error .state-icon {
  background: var(--error);
  color: var(--white);
}

.state-warning .state-icon {
  background: var(--yellow);
  color: var(--charcoal);
}

.state-title {
  margin: 8px 0 0;
  font-size: 20px;
  font-weight: 800;
}

.state-text {
  margin: 0;
  max-width: 460px;
  font-size: 15px;
  color: var(--muted);
}

.state-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.skeleton {
  display: flex;
  flex-direction: column;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 2fr 1.4fr 1fr;
  gap: 24px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.skeleton-bar {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #ebe9e3 25%, #f6f5f1 50%, #ebe9e3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-short {
  width: 60%;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-bar {
    animation: none;
  }
}

/* User detail. */
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-block {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-item {
  display: flex;
  gap: 12px;
}

.timeline-dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid var(--charcoal);
}

.timeline-label,
.timeline-meta,
.timeline-reason {
  margin: 0;
}

.timeline-label {
  font-weight: 600;
}

.timeline-meta,
.timeline-reason {
  font-size: 14px;
  color: var(--muted);
}

/* Dialog (lock / unlock). */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(26 26 30 / 0.55);
}

.dialog {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.3);
}

.dialog:focus {
  outline: none;
}

.dialog-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.dialog-text {
  margin: 0;
  color: var(--muted);
}

.dialog-target {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--surface);
}

.dialog-target-name,
.dialog-target-meta {
  margin: 0;
}

.dialog-target-name {
  font-weight: 700;
}

.dialog-target-meta {
  font-size: 14px;
  color: var(--muted);
}

.dialog-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  font-size: 14px;
  line-height: 1.45;
}

.dialog-warning .icon {
  margin-top: 1px;
}

.dialog-warning-danger {
  background: var(--error-bg);
  border: 1px solid var(--error-line);
  color: var(--error-ink);
}

.dialog-warning-info {
  background: var(--info-bg);
  border: 1px solid var(--line);
  color: var(--info);
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.dialog-actions .btn {
  width: auto;
  min-width: 120px;
}

.textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.45;
  resize: vertical;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.textarea[aria-invalid='true'] {
  border-color: var(--error);
}

.hint-end {
  text-align: right;
}

.hint-block {
  margin-top: 4px;
}

.btn-danger-solid {
  background: var(--error);
  color: var(--white);
  border: 1px solid var(--error);
}

.btn-danger-solid:hover:not(:disabled) {
  background: var(--error-ink);
}

.link-center {
  align-self: center;
  margin: 8px 0 0;
}

/* Narrow screens (Owner 2026-11-20): the table keeps its columns and scrolls sideways inside its card, the header stays readable. */
@media (max-width: 720px) {
  .table {
    min-width: 640px;
  }

  .table td .table-link {
    min-height: 44px;
    padding: 0 8px;
  }

  .table .row-panel td {
    display: table-cell;
    text-align: center;
  }

  .toolbar-filters .select {
    flex: 1 1 140px;
  }

  .toolbar-filters .btn {
    flex: 1 1 100%;
  }

  .skeleton-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* Cài đặt hệ thống (Owner decision 2026-10-14): one row per switch, label and help on the left, state and the switch on the right. */
.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line, rgba(0, 0, 0, 0.12));
}
.setting-text {
  flex: 1 1 auto;
  min-width: 0;
}
.setting-title {
  font-weight: 600;
}
.setting-state {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.setting-value {
  min-width: 2.5em;
  text-align: right;
}
.switch-input {
  width: 44px;
  height: 24px;
  accent-color: var(--charcoal);
  cursor: pointer;
}
.switch-input:disabled {
  cursor: not-allowed;
}
@media (max-width: 600px) {
  .setting-row {
    flex-direction: column;
  }
}

/* Danh mục › Nhóm món (M02): row actions that are buttons, numeric columns, the pager under the table. */
.table-action {
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.table-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 8px;
}
.cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
}
.pager-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.pager-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pager-buttons .btn {
  width: auto;
  min-width: 88px;
}
.pager-page {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
@media (max-width: 760px) {
  .cell-num {
    text-align: right;
  }
  .table-actions {
    justify-content: flex-end;
  }
  .pager {
    flex-direction: column;
    align-items: stretch;
  }
  .pager-buttons {
    justify-content: space-between;
  }
}

/* ---- M04 finance (UI phase): tabs, KPI cards, filters, chart, status steps. Colors only from the tokens above. ---- */
.cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-person {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cell-person .muted {
  font-size: 13px;
}

.amount-in {
  color: var(--ok-ink);
  font-weight: 700;
}

.amount-out {
  color: var(--error-ink);
  font-weight: 700;
}

/* A hold / release row moves only the held part: neutral, never green like a deposit. */
.amount-hold {
  color: var(--muted);
  font-weight: 600;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 12px;
}

.tab {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--charcoal);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab:hover:not(:disabled) {
  border-color: var(--line-strong);
}

.tab-active {
  background: var(--yellow);
  border-color: var(--yellow);
  font-weight: 700;
}

.tab:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}

.tab:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.kpi {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  color: var(--charcoal);
  text-decoration: none;
}

.kpi-link:hover {
  border-color: var(--yellow);
}

.kpi-link:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}

.kpi-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--neutral-bg);
}

.kpi-ok .kpi-icon {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.kpi-warn .kpi-icon {
  background: var(--yellow-soft);
}

.kpi-info .kpi-icon {
  background: var(--charcoal);
  color: var(--white);
}

.kpi-bad {
  border-color: var(--error-line);
  background: var(--error-bg);
}

.kpi-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.date-input {
  min-height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.date-input:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}

.date-input:disabled {
  background: var(--surface);
  color: var(--muted);
  cursor: not-allowed;
}

.toolbar-wrap {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter .label {
  font-size: 13px;
}

.export {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

.proof {
  display: flex;
  align-items: center;
  gap: 12px;
}

.proof-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--neutral-bg);
  color: var(--muted);
}

.proof .cell-name,
.proof .muted {
  display: block;
}

.detail-block-quiet {
  border-style: dashed;
}

.timeline-item-todo .timeline-dot {
  background: var(--white);
  border-color: var(--line-strong);
}

.timeline-item-todo .timeline-label {
  color: var(--muted);
  font-weight: 500;
}

.timeline-item-current .timeline-dot {
  box-shadow: 0 0 0 4px var(--yellow-soft);
}

.timeline-item-current .timeline-label {
  font-weight: 800;
}

.chart-wrap {
  margin-top: 12px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font);
}

.chart-topup {
  fill: var(--ok);
}

.chart-withdraw {
  fill: var(--error);
}

.chart-commission {
  fill: var(--yellow-pressed);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-swatch.chart-topup {
  background: var(--ok);
}

.legend-swatch.chart-withdraw {
  background: var(--error);
}

.legend-swatch.chart-commission {
  background: var(--yellow-pressed);
}

.detail-block > .field {
  margin-top: 14px;
}

.detail-block > .hint + .field,
.detail-block > .message + .detail-actions,
.detail-block > .hint + .detail-actions {
  margin-top: 14px;
}

.detail-block > .detail-actions {
  margin-top: 16px;
}

/* ---- M06-A: Phí & điều kiện giao (shipping-fee table) ---- */
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--yellow-pressed);
}

.sp-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
}

.sp-card {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--white);
}

.sp-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.sp-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sp-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.sp-from {
  min-height: var(--control-height);
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: var(--radius-control);
  background: var(--neutral-bg);
  color: var(--muted);
  font-weight: 700;
}

.sp-row-head {
  padding: 10px 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 0;
  padding-left: 12px;
}

.sp-remove {
  height: var(--control-height);
  width: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--white);
  color: var(--error);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.sp-remove:hover {
  background: var(--error-bg);
}

.sp-tail-title {
  margin: 20px 0 8px;
  font-size: 15px;
}

.sp-tail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sp-verdict {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--warning-bg);
  border: 1px solid var(--warning-line);
  font-size: 14px;
}

.sp-verdict-bad {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-ink);
}

.sp-result {
  margin: 12px 0;
  padding: 16px 18px;
  border-radius: var(--radius-card);
  background: var(--surface);
}

.sp-result-label,
.sp-result-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sp-result-amount {
  margin: 6px 0;
  font-size: 32px;
  font-weight: 800;
}

.sp-result-none {
  font-size: 20px;
  color: var(--muted);
}

.sp-note {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--yellow-subtle);
  border: 1px solid var(--yellow-soft);
  font-size: 14px;
}

.sp-condition {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.sp-condition-title {
  margin: 0;
  font-weight: 800;
}

.sp-value {
  padding: 10px 16px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line);
  white-space: nowrap;
  font-weight: 700;
}

.sp-value-locked {
  background: var(--neutral-bg);
  color: var(--muted);
}

.sp-tier-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 14px;
}

@media (max-width: 900px) {
  .sp-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sp-tail {
    grid-template-columns: minmax(0, 1fr);
  }

  .sp-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
}

.sp-card .hint {
  margin: 4px 0 12px;
}

.sp-actions {
  justify-content: flex-end;
}

.sp-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sp-value-field {
  display: grid;
  grid-template-columns: 110px auto;
  gap: 4px 10px;
  align-items: center;
}

.sp-value-field .message {
  grid-column: 1 / -1;
}

.sp-unit {
  color: var(--muted);
  font-size: 14px;
}

/* M07.07: delivery counters and the detail drawer ("Vận hành › Giao hàng"). */
.counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.counter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.counter-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}
.counter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.counter-wait {
  background: var(--yellow-subtle);
  border-color: var(--yellow);
}
.counter-ok {
  background: var(--ok-bg);
  border-color: var(--ok-line);
}
.counter-lock {
  background: var(--error-bg);
  border-color: var(--error-line);
}
.drawer {
  margin-top: 24px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.drawer[hidden] {
  display: none;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.counters:empty {
  display: none;
}

/* M08.06 Notifications: sub-table caption, the settings form row and its label. */
.sub-caption {
  caption-side: top;
  padding: 12px 16px 4px;
  text-align: left;
  font-weight: 700;
}
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.field-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

/* M13 "Vận hành hệ thống": status tiles, the incident timeline and a few shared list shapes. Colors keep the project's palette; "no data" and "stale" are
   neutral grey, never green. */
.ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.ops-grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.ops-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--white);
  padding: 16px;
}

.ops-tile-ok {
  border-color: var(--ok-line);
}

.ops-tile-warning {
  border-color: var(--warning-line);
  background: var(--yellow-subtle);
}

.ops-tile-critical {
  border-color: var(--error-line);
  background: var(--error-bg);
}

.ops-tile-no_data,
.ops-tile-stale,
.ops-tile-plain {
  background: var(--neutral-bg);
}

.ops-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ops-tile-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.ops-tile-text {
  margin: 8px 0 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.ops-tile-value {
  margin: 6px 0 0;
  font-size: 22px;
  font-weight: 800;
}

.ops-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.ops-timeline li {
  padding: 10px 12px;
  border-left: 4px solid var(--line-strong);
  background: var(--white);
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
  overflow-wrap: anywhere;
}

.ops-timeline-error {
  border-left-color: var(--error) !important;
}

.ops-timeline-warn {
  border-left-color: var(--yellow) !important;
}

.ops-timeline-info {
  border-left-color: var(--ok) !important;
}

.ops-timeline-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.plain-list {
  margin: 8px 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-right: 16px;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.row-selected td {
  background: #f5f5f3;
}
.row-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--charcoal);
}

/* M11.03: ratings and complaints. */
.stars {
  color: var(--brand-yellow, #d8ad18);
  letter-spacing: 1px;
  white-space: nowrap;
}

.evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.evidence-link img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e3e1db;
}

.detail-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.plain-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

/* M13: keep the everyday log compact; long technical fields wrap on phones. */
.error-log-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  align-items: end;
}
.error-log-filters > details,
.error-log-filters > .actions { grid-column: 1 / -1; }
.error-log-filters input:not([type="checkbox"]),
.error-log-filters select {
  width: 100%;
  min-width: 0;
  min-height: var(--control-height);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--white);
  color: var(--charcoal);
  font: inherit;
}
.error-log-content > * { min-width: 0; }
.error-log-content code { overflow-wrap: anywhere; }
.error-log-content summary { cursor: pointer; padding: 8px 0; }
.error-log-content .btn { width: auto; }
.error-log-auto { display: inline-flex; align-items: center; gap: 8px; }
.error-log-auto input { width: 18px; height: 18px; }
.error-log-table td > div { min-width: 0; }
@media (max-width: 720px) {
  .error-log-table td[data-label="Nội dung"] { flex-direction: column; text-align: left; gap: 8px; }
}

/* M12-A Overview ("Tổng quan › Điều hành"): range switch, figure cards (period and current state), the work list. */
.ov-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.ov-ranges {
  display: inline-flex;
  flex-wrap: wrap;
  align-self: flex-start;
  width: max-content;
  max-width: 100%;
  gap: 4px;
  padding: 4px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
/* Quiet secondary button (Đơn hàng "Làm mới"): still calls the same fetch; white/light-grey outline, no yellow. */
.btn-quiet {
  background: var(--white);
  color: var(--charcoal);
  border: 1px solid var(--line-strong);
}
.btn-quiet:hover:not(:disabled) {
  background: var(--surface-subtle, #f7f8fa);
}
.ov-range {
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  color: var(--charcoal);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.ov-range[aria-pressed='true'] {
  background: var(--yellow);
}
.ov-range:focus-visible,
.ov-card.ov-link:focus-visible {
  outline: 3px solid var(--charcoal);
  outline-offset: 2px;
}
.ov-custom[hidden] {
  display: none;
}
.ov-stamp,
.ov-scope {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.ov-section {
  margin-bottom: 28px;
}
.ov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.ov-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 108px;
  padding: 14px 16px;
  font: inherit;
  text-align: left;
  color: var(--charcoal);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.ov-link {
  cursor: pointer;
}
.ov-link:hover {
  border-color: var(--yellow-hover);
  background: var(--yellow-subtle);
}
.ov-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.ov-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.ov-note,
.ov-reason {
  font-size: 12px;
  color: var(--muted);
}
.ov-reason {
  font-weight: 600;
}
.ov-wait {
  border-color: var(--yellow);
  background: var(--yellow-subtle);
}
.ov-ok {
  border-color: var(--ok-line);
  background: var(--ok-bg);
}
.ov-lock {
  border-color: var(--error-line);
  background: var(--error-bg);
}
.ov-muted {
  background: var(--neutral-bg);
}
.ov-muted .ov-value {
  color: var(--placeholder);
}
.ov-todo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ov-todo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, auto) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
.ov-todo-label {
  font-weight: 600;
}
.ov-todo-count {
  min-width: 40px;
  font-size: 20px;
  font-weight: 800;
  text-align: right;
}
.ov-todo-open {
  color: var(--error-ink);
}
@media (max-width: 700px) {
  .ov-todo-row {
    grid-template-columns: 1fr auto;
  }
  .ov-todo-row .btn {
    grid-column: 1 / -1;
  }
}

/* M12-B Operations: list sub-line, linked-filter notice, plain list in the detail drawer. */
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.linked-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.linked-filter[hidden] {
  display: none;
}
.plain-list {
  margin: 0 0 8px;
  padding-left: 18px;
}
#delivery-map svg {
  display: block;
  max-width: 460px;
  margin: 12px 0;
}

/* M12-C Access matrix: one row per function group, one switch per right. */
.access-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.access-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
.access-group {
  font-weight: 700;
}
.access-switches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--yellow-hover);
}
.textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  resize: vertical;
}
@media (max-width: 700px) {
  .access-row {
    grid-template-columns: 1fr;
  }
}

/* M12-D Configuration hub: one card per group, fixed rules apart. */
.cfg-card {
  margin-bottom: 16px;
  padding: 16px 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.cfg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.cfg-fixed {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--neutral-bg);
  border-radius: var(--radius-control);
}
.cfg-fixed-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
.cfg-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.cfg-history:empty {
  display: none;
}
.cfg-history {
  margin-top: 12px;
}

/* M12-E: reports and the list of exported files. */
.rp-body {
  display: grid;
  gap: 16px;
}
.rp-jobs {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rp-job {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid rgba(42, 42, 46, 0.12);
  border-radius: 10px;
}
.rp-job-title {
  font-weight: 600;
}
.rp-job .btn-inline {
  margin-left: auto;
}

/* M12-F: audit log and backup history. */
.au-body,
.bk-body {
  display: grid;
  gap: 16px;
}
.au-meta {
  margin: 8px 0 0;
  padding: 8px 10px;
  max-width: 560px;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  background: #f6f5f2;
  border-radius: 8px;
}
.au-denied td:first-child,
.au-failure td:first-child {
  box-shadow: inset 3px 0 0 #b3261e;
}
.bk-health {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(42, 42, 46, 0.12);
  background: #fff;
}
.bk-ok {
  border-color: #2e7d32;
  background: #eef7ee;
}
.bk-stale,
.bk-not_offsite {
  border-color: #b26a00;
  background: #fff6e5;
}
.bk-none {
  border-color: #b3261e;
  background: #fdecea;
}
.bk-facts {
  display: grid;
  grid-template-columns: minmax(180px, max-content) 1fr;
  gap: 8px 16px;
  margin: 0;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid rgba(42, 42, 46, 0.12);
  border-radius: 12px;
}
.bk-facts dt {
  font-weight: 600;
}
.bk-facts dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
}
@media (max-width: 640px) {
  .bk-facts {
    grid-template-columns: 1fr;
  }
}
.bk-health strong,
.bk-health span {
  display: block;
}
.bk-body .cell-sub {
  display: block;
}
.bk-body {
  min-width: 0;
}
.bk-body .table-card {
  overflow-x: auto;
}
.bk-facts dd .btn {
  width: auto;
}
.bk-facts {
  min-width: 0;
}
.au-body,
.bk-body,
.rp-body {
  grid-template-columns: minmax(0, 1fr);
}

/* M02 shop management (Vận hành › Quán): logo, dish pictures, the weekly schedule and the customer preview. */
.shop-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  object-fit: cover;
  background: var(--white);
}

.menu-thumb {
  display: block;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--white);
}

.menu-photo {
  display: block;
  width: 100%;
  max-height: 220px;
  margin: 0 0 12px;
  border-radius: 12px;
  object-fit: cover;
}

.hours-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hours-slot {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.preview-items {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-item .row-name {
  flex: 1;
  min-width: 0;
}

.detail-block + .detail-block {
  margin-top: 16px;
}

/* "Trao đổi đơn hàng" in the order / delivery drawers (issue #191) */
.chat-title {
  margin: 0;
}
.chat-toggle {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.chat-toggle::after {
  content: '';
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.chat-toggle[aria-expanded='true']::after {
  transform: rotate(-135deg);
}
.chat-toggle:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}
.chat-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.chat-body[hidden] {
  display: none;
}
.chat-feed {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: 320px;
  overflow-y: auto;
  overflow-anchor: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius-control);
}
.chat-item {
  max-width: 88%;
  overflow-wrap: anywhere;
}
.chat-message {
  align-self: flex-start;
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.chat-message.chat-mine {
  align-self: flex-end;
  background: var(--yellow-soft);
  border-color: var(--yellow);
}
.chat-meta {
  margin: 0 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
  font-size: 0.8125rem;
  color: var(--muted);
}
.chat-name {
  font-weight: 700;
  color: var(--charcoal);
}
.chat-text {
  margin: 0;
  white-space: pre-wrap;
}
.chat-system {
  align-self: center;
  max-width: 96%;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}
.chat-system .chat-time {
  display: block;
}
.chat-empty {
  text-align: center;
  color: var(--muted);
  padding: 16px 8px;
}
.chat-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-composer[hidden] {
  display: none;
}
.chat-input {
  width: 100%;
  resize: vertical;
}
.chat-composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-count {
  font-size: 0.8125rem;
  color: var(--muted);
}
.chat-count-over {
  color: var(--error-ink);
  font-weight: 700;
}
.chat-note {
  margin: 0;
}
.chat-keep {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.chat-keep-title {
  margin: 0;
  font-size: 1rem;
}
.chat-keep-line {
  margin: 0;
  overflow-wrap: anywhere;
}
.field-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
@media (max-width: 480px) {
  .chat-item {
    max-width: 100%;
  }
}

/* M13 Giám sát VPS (#247): line charts. A hole in the samples is a hatched band and the line stops there (nothing is drawn across missing data). */
.ops-chart-box {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--white);
  padding: 12px;
}

.ops-chart {
  display: block;
  width: 100%;
  height: 120px;
  margin-top: 8px;
  background: var(--neutral-bg);
}

.ops-chart-line {
  stroke: var(--ok);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.ops-chart-dot {
  fill: var(--ok);
}

.ops-chart-gap {
  fill: var(--warning-line);
  opacity: 0.25;
}

/* ---- Desktop polish shared helpers (ui/admin-web-sc001-desktop) ---- */
.content-head-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.content-head-meta .btn {
  width: auto;
}

.updated-stamp {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Multi-column config form grid & bounded numeric inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 340px));
  gap: 16px 24px;
  align-items: start;
}

.config-form input[type='number'],
.config-form .input-num,
.field-num .input-wrap,
.field-num input {
  max-width: 320px;
  width: 100%;
}

/* Horizontal, right-aligned action bars (never 100% full width) */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.form-actions .btn {
  width: auto;
  min-width: 0;
}

.sticky-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

.sticky-save-bar .btn {
  width: auto;
  min-width: 0;
}

/* Flexible 1-row wrapping filter bar */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.filter-row .select,
.filter-row .search-input,
.filter-row input[type='date'],
.filter-row input[type='text'] {
  width: auto;
  min-width: 140px;
  max-width: 100%;
  min-height: 38px;
  font-size: 14px;
}

.filter-row .search {
  flex: 1 1 200px;
  min-width: 160px;
}

.filter-row .btn {
  width: auto;
  min-height: 38px;
}

.quick-filters {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip-filter {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--white);
  color: var(--charcoal);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip-filter:hover {
  border-color: var(--charcoal);
}

.chip-filter[aria-pressed='true'] {
  background: var(--charcoal);
  border-color: var(--charcoal);
  color: var(--white);
}

/* Table numeric/money alignment, min-widths, and signed colors */
.cell-num,
.cell-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 112px;
}

.col-balance {
  min-width: 145px;
}

.table th.cell-end {
  text-align: right;
}

.table td[data-label='Số tiền'],
.table td[data-label='Số dư sau'],
.table td[data-label='Tổng số dư'],
.table td[data-label='Tạm giữ'],
.table td[data-label='Khả dụng'],
.table td[data-label='Kích thước'],
.table td[data-label='Lặp lại'],
.table td[data-label='Số lần thử'],
.table td[data-label='Thiết bị đã báo đang chạy (60 ngày qua)'] {
  min-width: 112px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table td[data-label='Trạng thái'],
.table td[data-label='Người xử lý'],
.table td[data-label='Thành phần'],
.table td[data-label='Phiên bản'] {
  min-width: 112px;
  white-space: nowrap;
}

.col-status {
  min-width: 120px;
  white-space: nowrap;
}

.col-assignee {
  min-width: 130px;
  white-space: nowrap;
}

.money-pos {
  color: #15803d;
  font-weight: 600;
}

.money-neg {
  color: #b91c1c;
  font-weight: 600;
}

.btn-outline {
  background: var(--white);
  color: var(--charcoal);
  border: 1px solid var(--line-strong);
}

.btn-outline:hover:not(:disabled) {
  background: #f5f5f3;
}

/* Active tab highlight */
.tab-active {
  box-shadow: inset 0 -2px 0 var(--charcoal);
}

/* SC-001 Incident Detail Page */
.sc-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #f7f7f5;
  padding: 16px;
  border-radius: var(--radius-card);
}

.sc-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sc-sticky-head {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.sc-sticky-head .content-head-meta {
  align-items: center;
}

.sc-head-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}

.sc-head-title .title {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.sc-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.sc-head-actions .btn {
  width: auto;
  min-height: 38px;
}

.sc-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px;
}

.sc-card + .sc-card {
  margin-top: 0;
}

.sc-card .subtitle {
  margin-top: 0;
}

.sc-discord-details,
.sc-raw-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fafaf8;
  padding: 10px 12px;
}

.sc-discord-details > summary,
.sc-raw-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.sc-raw-pre {
  margin: 10px 0 0;
  padding: 12px;
  background: #f3f3f0;
  border-radius: var(--radius-control);
  font-size: 12px;
  overflow-x: auto;
  max-height: 320px;
}

.sc-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.sc-pager .btn {
  width: auto;
  min-height: 34px;
}

.error-log-filters .field {
  min-width: 150px;
  margin: 0;
}

.error-log-filters > .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sp-row input,
.sp-condition input[type='number'],
.sp-condition input[inputmode='numeric'],
.sp-condition input[inputmode='decimal'] {
  width: 100%;
  max-width: 320px;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .sc-sticky-head {
    position: static;
  }
  .sc-head-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
}
