:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --surface-strong: #edf2ef;
  --text: #17201c;
  --muted: #66736d;
  --border: #dbe2de;
  --border-strong: #c7d1cc;
  --sidebar: #18201f;
  --sidebar-hover: #252f2c;
  --sidebar-text: #edf3f0;
  --teal: #087b74;
  --teal-dark: #05655f;
  --teal-soft: #e5f5f2;
  --blue: #245cc5;
  --blue-soft: #edf3ff;
  --green: #16834a;
  --green-soft: #eaf7ef;
  --amber: #ad6700;
  --amber-soft: #fff5df;
  --red: #bd342c;
  --red-dark: #9f2722;
  --red-soft: #fff0ee;
  --sidebar-width: 236px;
  --radius: 6px;
  --shadow-dialog: 0 24px 64px rgba(15, 24, 20, 0.22);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body,
button,
input,
select,
textarea {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

body.nav-open {
  overflow: hidden;
}

a {
  color: var(--blue);
}

button,
a,
input,
select,
textarea,
summary {
  outline: none;
}

:focus-visible {
  outline: 3px solid rgba(36, 92, 197, 0.35);
  outline-offset: 2px;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg.lucide {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke-width: 1.8;
}

code,
.mono {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  word-break: break-word;
}

code {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #35413c;
  background: var(--surface-muted);
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 9px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--teal-dark);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  color: var(--sidebar-text);
  background: var(--sidebar);
  border-right: 1px solid #303a37;
}

.sidebar-header {
  height: 76px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #303a37;
}

.brand,
.mobile-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  font-size: 20px;
  font-weight: 720;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #52615b;
  border-radius: var(--radius);
  color: #fff;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.sidebar-close {
  display: none;
  color: var(--sidebar-text);
}

.sidebar-nav {
  flex: 1;
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
}

.nav-link {
  min-height: 46px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius);
  color: #d6dfdb;
  text-decoration: none;
  font-weight: 600;
}

.nav-link:hover {
  color: #fff;
  background: var(--sidebar-hover);
}

.nav-link.is-active {
  color: #fff;
  background: #0b6965;
  box-shadow: inset 3px 0 0 #43c6b8;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid #303a37;
}

.sidebar-user {
  min-width: 0;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
}

.sidebar-user__avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid #53615c;
  border-radius: 50%;
  background: #25302d;
}

.sidebar-user__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-user__meta strong,
.sidebar-user__meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user__meta small {
  color: #aebbb5;
  font-size: 12px;
}

.sidebar-user__logout {
  color: #cad4cf;
}

.sidebar-user__logout:hover {
  color: #fff;
  background: var(--sidebar-hover);
}

.sidebar-scrim {
  display: none;
}

.app-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.mobile-header {
  display: none;
}

.main-content {
  width: 100%;
  max-width: 1640px;
  min-height: 100vh;
  padding: 28px 32px 48px;
  margin: 0 auto;
}

/* Page hierarchy */
.page-header {
  min-height: 56px;
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.page-header__main,
.page-header > div:first-child {
  min-width: 0;
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: 25px;
  line-height: 1.25;
  font-weight: 740;
}

.page-title,
.page-subtitle,
.section-heading h2,
.notice,
.key {
  overflow-wrap: anywhere;
}

.page-subtitle,
.section-meta,
.muted {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.page-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-status {
  min-height: 34px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #b9dcc6;
  border-radius: var(--radius);
  color: var(--green);
  background: var(--green-soft);
  font-weight: 650;
  white-space: nowrap;
}

.service-status > span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.panel,
.dashboard-section {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  padding: 20px;
}

.section-heading {
  min-height: 38px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.section-title {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  font-weight: 700;
}

.section-heading > svg {
  color: var(--amber);
}

/* Buttons and controls */
.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 650;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 14px;
  white-space: nowrap;
}

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

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

.button--secondary {
  color: #26312c;
  background: var(--surface);
  border-color: var(--border-strong);
}

.button--secondary:hover,
.button--ghost:hover {
  background: var(--surface-strong);
}

.button--ghost {
  color: #35413c;
  background: transparent;
  border-color: var(--border);
}

.button--danger,
button.danger,
.btn.danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.button--danger:hover,
button.danger:hover,
.btn.danger:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.button--link {
  min-height: 32px;
  padding: 0 5px;
  color: var(--blue);
  background: transparent;
  border-color: transparent;
}

.button--link:hover {
  color: #17479f;
  background: var(--blue-soft);
}

.button--small {
  min-height: 32px;
  padding: 0 9px;
  font-size: 13px;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: inherit;
  background: transparent;
}

.icon-button:hover {
  background: rgba(111, 129, 120, 0.12);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.filter-toolbar {
  justify-content: flex-start;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.filter-field {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.filter-field select {
  width: auto;
  min-width: 112px;
}

.search-field {
  position: relative;
  min-width: 240px;
  flex: 1 1 280px;
}

.search-field > svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  padding-left: 38px;
}

.segmented {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.segmented a,
.segmented button,
.segmented__item {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  color: #48534e;
  background: transparent;
  text-decoration: none;
  white-space: nowrap;
}

.segmented a:last-child,
.segmented button:last-child,
.segmented__item:last-child {
  border-right: 0;
}

.segmented .is-active,
.segmented [aria-current="page"],
.segmented__item.is-active {
  color: #fff;
  background: var(--teal);
}

/* orders/logs 筛选栏里的状态下拉：跟随内容宽度，与搜索框同行排列 */
select.segmented {
  width: auto;
  min-width: 132px;
  overflow: visible;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field--wide {
  grid-column: 1 / -1;
}

.field-label {
  color: #26312c;
  font-size: 13px;
  font-weight: 680;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
}

div.field-help {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-size: 14px;
}

input,
select {
  min-height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 180px;
  padding: 11px 12px;
  resize: vertical;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  line-height: 1.6;
}

input::placeholder,
textarea::placeholder {
  color: #9aa59f;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #aebbb5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 123, 116, 0.12);
}

form > .toolbar {
  margin-top: 16px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

/* Tables */
.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overscroll-behavior-x: contain;
}

.data-table,
table {
  width: 100%;
  min-width: 720px;
  border: 0;
  border-collapse: collapse;
  background: var(--surface);
}

.data-table--compact {
  min-width: 560px;
}

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

.data-table th,
table th {
  color: #46514c;
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.data-table tbody tr:hover,
table tbody tr:hover {
  background: #fbfcfb;
}

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

.data-table form,
table form {
  margin: 0;
}

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

.cell-nowrap {
  white-space: nowrap;
}

.cell-truncate {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail {
  max-width: 420px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

/* Status and summaries */
.status,
.badge {
  min-height: 24px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: #4f5b55;
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status svg,
.badge svg {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

.status[data-status="active"],
.status[data-status="unused"],
.status[data-status="delivered"],
.status[data-status="healthy"],
.status--active,
.status--delivered,
.status-DELIVERED {
  color: var(--green);
  border-color: #b8ddc7;
  background: var(--green-soft);
}

.status[data-status="archived"],
.status[data-status="closed"],
.status[data-status="disabled"],
.status[data-status="neutral"],
.status--closed,
.status-CLOSED {
  color: #68746e;
  border-color: #ccd4d0;
  background: #f0f3f1;
}

.status[data-status="card"],
.status[data-status="resource"],
.status[data-status="event"] {
  color: var(--blue);
  border-color: #c8d7f5;
  background: var(--blue-soft);
}

.status[data-status="reserved"],
.status[data-status="pending"],
.status[data-status="fulfilling"],
.status[data-status="scheduled"],
.status--pending,
.status-PENDING,
.status-FULFILLING {
  color: var(--amber);
  border-color: #eed29f;
  background: var(--amber-soft);
}

.status[data-status="failed"],
.status[data-status="error"],
.status[data-status="void"],
.status--failed,
.status-FAILED {
  color: var(--red);
  border-color: #e9b9b4;
  background: var(--red-soft);
}

.stats {
  margin: 0 0 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  min-height: 116px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat__label {
  color: #3f4b45;
  font-size: 14px;
  font-weight: 650;
}

.stat__value {
  color: var(--teal);
  font-size: 36px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

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

.stat--pending .stat__value {
  color: #d37a00;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(520px, 1.7fr);
  gap: 16px;
  align-items: start;
}

.dashboard-grid > *,
.panel {
  min-width: 0;
}

.dashboard-section .section-heading {
  min-height: 62px;
  padding: 13px 16px 10px;
  margin: 0;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.dashboard-section .table-wrap {
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}

.stock-warning,
.error-text,
.warn {
  color: var(--red);
  font-weight: 680;
}

.inventory-strip {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 220px));
  gap: 14px;
}

.inventory-strip--four {
  grid-template-columns: repeat(4, minmax(0, 220px));
}

.inventory-strip > div {
  min-height: 82px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  background: var(--surface);
}

.inventory-strip > div:nth-child(2) {
  border-left-color: var(--amber);
}

.inventory-strip > div:nth-child(3) {
  border-left-color: var(--blue);
}

.inventory-strip > div:nth-child(4) {
  border-left-color: var(--red);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.action-group form {
  margin: 0;
}

.text-link {
  color: var(--blue);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.form-panel {
  max-width: 960px;
}

.form-actions {
  margin-top: 22px;
  justify-content: flex-end;
}

.inline-edit {
  min-width: 250px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 36px;
  gap: 5px;
  align-items: center;
}

.inline-edit input {
  min-width: 0;
}

.detail-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-grid > div {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.detail-grid dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}

.split-layout > * {
  min-width: 0;
}

.code-block {
  max-height: 520px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f4f7f6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.inventory-strip strong {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  min-height: 150px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 25px;
  height: 25px;
  color: var(--green);
}

.empty-state p {
  margin: 0;
}

/* Upload and notices */
.upload-zone {
  position: relative;
  min-height: 190px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed #aebbb5;
  border-radius: var(--radius);
  color: #46524c;
  background: var(--surface-muted);
  text-align: center;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.is-dragging {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.upload-zone > svg {
  width: 38px;
  height: 38px;
  color: var(--teal);
}

.upload-zone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-zone__file,
[data-file-name] {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice,
.alert {
  margin-bottom: 18px;
  padding: 15px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid #ecd09a;
  border-radius: var(--radius);
  color: #775019;
  background: var(--amber-soft);
}

.notice--success {
  color: #146b3d;
  border-color: #b8ddc7;
  background: var(--green-soft);
}

.key,
.key-display {
  min-width: 0;
  padding: 9px 11px;
  display: block;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: #28332e;
  background: var(--surface);
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
}

/* Flash messages */
.flash-stack {
  position: relative;
  z-index: 5;
}

.flash {
  min-height: 46px;
  padding: 10px 10px 10px 13px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  border: 1px solid #bed5ed;
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  color: #244b74;
  background: #eff6fd;
}

.flash--error,
.flash-error {
  color: #852b25;
  border-color: #e5b7b3;
  border-left-color: var(--red);
  background: var(--red-soft);
}

.flash--success,
.flash-success {
  color: #146b3d;
  border-color: #b8ddc7;
  border-left-color: var(--green);
  background: var(--green-soft);
}

.flash-dismiss {
  color: inherit;
}

/* Settings and audit details */
.settings-list,
.status-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.settings-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.settings-section:first-of-type {
  padding-top: 4px;
}

.settings-section:last-of-type {
  border-bottom: 0;
}

.settings-section__header {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.settings-section__icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--teal-dark);
  background: var(--surface-strong);
}

.settings-section h2 {
  margin: 0;
  font-size: 18px;
}

.status-list li,
.settings-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.health-ok,
.health-bad {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 650;
}

.health-ok {
  color: var(--green);
}

.health-bad {
  color: var(--red);
}

.audit-details {
  margin: 0;
}

.audit-details summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--blue);
  cursor: pointer;
}

.audit-details__content {
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #3f4b45;
  background: var(--surface-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Native dialogs */
.drawer-dialog {
  width: min(470px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  padding: 24px;
  margin: 0 0 0 auto;
  border: 0;
  border-left: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}

.drawer-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(12, 20, 17, 0.48);
}

.drawer-dialog .form-grid {
  grid-template-columns: 1fr;
}

.drawer-dialog form {
  min-height: calc(100vh - 90px);
  display: flex;
  flex-direction: column;
}

.drawer-dialog form > .toolbar {
  margin-top: auto;
  padding-top: 24px;
}

.confirm-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}

.confirm-dialog__content {
  padding: 22px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
}

.confirm-dialog__icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--amber);
  background: var(--amber-soft);
}

.confirm-dialog h2 {
  margin: 1px 0 5px;
  font-size: 18px;
}

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

.confirm-dialog__actions {
  grid-column: 1 / -1;
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Login */
.login-body {
  min-height: 100vh;
  background: #f6f8f7;
}

.login-shell {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(410px, 100%);
  padding: 34px;
  display: flex;
  flex-direction: column;
  gap: 17px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(31, 45, 39, 0.08);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 740;
}

.login-brand__mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.login-brand__mark svg {
  width: 24px;
  height: 24px;
}

.login-heading h1 {
  margin: 5px 0 3px;
  text-align: center;
  font-size: 26px;
}

.login-error {
  min-height: 42px;
  padding: 9px 12px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e5b7b3;
  border-radius: var(--radius);
  color: #852b25;
  background: var(--red-soft);
  font-size: 13px;
}

.login-error svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--red);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 2px;
  right: 3px;
  color: var(--muted);
}

.password-eye-off {
  display: none;
}

.password-toggle.is-visible .password-eye {
  display: none;
}

.password-toggle.is-visible .password-eye-off {
  display: block;
}

.login-submit {
  margin-top: 3px;
}

.login-security {
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.login-security svg {
  width: 15px;
  height: 15px;
  color: var(--green);
}

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

  .split-layout {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (max-width: 960px) {
  .sidebar {
    width: min(286px, calc(100vw - 42px));
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-grid;
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 40;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(12, 20, 17, 0.48);
  }

  .nav-open .sidebar-scrim {
    display: block;
  }

  .app-content {
    margin-left: 0;
  }

  .mobile-header {
    position: sticky;
    z-index: 30;
    top: 0;
    height: 58px;
    padding: 0 14px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
  }

  .mobile-brand {
    justify-self: center;
    color: var(--text);
    font-size: 17px;
  }

  .mobile-brand svg,
  .mobile-user svg {
    width: 20px;
    height: 20px;
  }

  .mobile-user {
    justify-self: end;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
  }

  .main-content {
    min-height: calc(100vh - 58px);
    padding-top: 22px;
  }
}

@media (min-width: 961px) {
  .sidebar .sidebar-close {
    display: none;
  }
}

@media (max-width: 680px) {
  .main-content {
    padding: 18px 14px 36px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .inline-edit {
    min-width: 220px;
  }

  .page-header {
    min-height: 0;
    margin-bottom: 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .page-title {
    font-size: 22px;
  }

  .page-header .toolbar,
  .page-actions {
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    min-height: 94px;
    padding: 15px;
  }

  .stat__value {
    font-size: 29px;
  }

  .panel {
    padding: 15px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .inventory-strip {
    grid-template-columns: 1fr;
  }

  .inventory-strip > div {
    min-height: 66px;
  }

  .filter-toolbar {
    align-items: stretch;
  }

  .search-field,
  .filter-field {
    flex: 1 1 100%;
    width: 100%;
  }

  .filter-field {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .filter-field select {
    width: 100%;
  }

  .segmented,
  select.segmented {
    width: 100%;
    overflow-x: auto;
  }

  .segmented a,
  .segmented button,
  .segmented__item {
    flex: 1 0 auto;
    min-height: 44px;
  }

  .button {
    min-height: 44px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  input,
  select {
    min-height: 44px;
  }

  .table-wrap {
    margin-right: -1px;
  }

  .data-table,
  table {
    min-width: 760px;
  }

  .data-table--compact {
    min-width: 600px;
  }

  .drawer-dialog {
    width: 100vw;
    padding: 18px;
  }

  .settings-row,
  .status-list li {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 8px 0;
  }

  .upload-zone {
    min-height: 170px;
  }
}

@media (max-width: 420px) {
  .login-shell {
    padding: 14px;
  }

  .login-panel {
    padding: 25px 20px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar > .button,
  .toolbar > button.button,
  .toolbar > a.button {
    flex: 1 1 auto;
  }

  .section-heading {
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
