:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #647181;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b42318;
  --shadow: 0 12px 30px rgba(22, 34, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #e9f2f1 0%, #f6f7fb 45%, #eef2f7 100%);
}

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

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
}

.login-secondary {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.login-secondary:hover {
  color: var(--accent);
}

label {
  display: grid;
  gap: 8px;
  color: #2a3542;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.ghost:hover {
  color: var(--ink);
  background: #fff;
}

.error {
  border: 1px solid rgba(180, 35, 24, 0.28);
  background: #fff4f2;
  color: var(--warn);
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: #101820;
  color: white;
  padding: 18px 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  margin-bottom: 12px;
  padding: 8px 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #0f766e;
  color: white;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong {
  font-size: 19px;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: #d9e2ec;
  text-decoration: none;
  padding: 0 11px;
  border-radius: 8px;
  font-weight: 700;
  border: 1px solid transparent;
}

.sidebar nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar nav a.active {
  color: white;
  background: #0f766e;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.24);
}

.nav-icon {
  display: inline-flex;
  flex: 0 0 28px;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #a7f3d0;
  font-size: 11px;
  font-weight: 900;
}

.sidebar nav a.active .nav-icon {
  background: rgba(255, 255, 255, 0.16);
  color: white;
}

.nav-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-group {
  display: grid;
  gap: 5px;
  padding: 4px 0;
}

.nav-group.active-group {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.nav-sub {
  display: grid;
  gap: 4px;
  padding: 0 0 2px 38px;
}

.sidebar nav .nav-sub a {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.sidebar nav .nav-sub .nav-icon {
  flex-basis: 24px;
  min-width: 24px;
  height: 24px;
  font-size: 10px;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

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

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.metric span,
.panel-head p,
.empty {
  color: var(--muted);
}

.metric strong {
  font-size: 24px;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head p {
  margin: 4px 0 0;
}

.panel-head a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs a,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.tabs a.active,
.button-link:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: #ecfdf5;
  color: var(--accent-strong);
}

.button-link.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.notice {
  border: 1px solid rgba(15, 118, 110, 0.24);
  background: #ecfdf5;
  color: var(--accent-strong);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-weight: 800;
}

.ratio,
.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.ratio div,
.status-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.status-list div > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-list em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.status-list strong {
  white-space: nowrap;
}

.ratio dt {
  color: var(--muted);
}

.ratio dd {
  margin: 0;
  font-weight: 800;
}

.search {
  display: flex;
  gap: 8px;
  min-width: min(360px, 100%);
}

.search button {
  min-width: 76px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(138px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  background: #fbfdff;
}

.filter-grid label {
  gap: 5px;
  color: #334155;
  font-size: 12px;
}

.filter-grid input,
.filter-grid select {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.filter-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.filter-actions button,
.filter-actions .button-link {
  min-height: 34px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.form-grid.wide {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.actions,
.finance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-action {
  margin-top: 14px;
}

.inline-panel {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.table-form {
  display: inline-flex;
  margin: 0 6px 6px 0;
}

.stack-form {
  display: grid;
  gap: 8px;
  min-width: 220px;
  padding-top: 8px;
}

.row-edit {
  display: inline-block;
  margin: 0 6px 6px 0;
}

.row-edit summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

button.danger {
  background: var(--warn);
}

button.danger:hover {
  background: #8f1d14;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  white-space: nowrap;
}

th,
td {
  text-align: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
}

td {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-stack {
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 0;
}

.cell-stack small {
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
}

.payment-cell {
  min-width: 86px;
}

.payment-cell small {
  max-width: 96px;
}

.payment-summary {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.ticket-state {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 900;
}

.ticket-state--yes {
  background: #dcfce7;
  color: #15803d !important;
}

.ticket-state--no {
  background: #f1f5f9;
  color: #64748b !important;
}

.customer-cell form {
  margin: 0;
}

.customer-switch {
  position: relative;
  min-width: 58px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.customer-switch--on {
  background: #0f9f6e;
  color: #fff;
}

.customer-switch--on:hover {
  background: #047857;
}

.customer-switch--off {
  background: #e11d48;
  color: #fff;
}

.customer-switch--off:hover {
  background: #be123c;
}

.time-stack {
  min-width: 88px;
}

.time-stack small {
  white-space: nowrap;
}

.cell-stack.flagged {
  border-radius: 6px;
  background: #ffe4e6;
  padding: 6px;
}

.status-stack {
  min-width: 72px;
}

.status-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.status-button.status-button--danger {
  border-color: #fecaca !important;
  background: #fee2e2 !important;
  color: #b91c1c !important;
}

.status-button.status-button--warning {
  border-color: #fed7aa !important;
  background: #ffedd5 !important;
  color: #c2410c !important;
}

.status-button.status-button--success {
  border-color: #bbf7d0 !important;
  background: #dcfce7 !important;
  color: #15803d !important;
}

.status-button.status-button--muted {
  border-color: #e2e8f0 !important;
  background: #f1f5f9 !important;
  color: #64748b !important;
}

.status-button.status-button--info {
  border-color: #bfdbfe !important;
  background: #dbeafe !important;
  color: #1d4ed8 !important;
}

.status-text {
  font-weight: 800;
}

.cell-stack small.status-text--danger {
  color: #dc2626 !important;
}

.cell-stack small.status-text--warning {
  color: #ea580c !important;
}

.cell-stack small.status-text--success {
  color: #16a34a !important;
}

.cell-stack small.status-text--muted {
  color: #64748b !important;
}

tbody tr:hover {
  background: #f8fbfb;
}

.empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pagination nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.page-link.active {
  border-color: var(--accent);
  background: #ecfdf5;
  color: var(--accent-strong);
}

.page-link.disabled {
  color: #94a3b8;
  background: #f8fafc;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.badge.muted {
  background: #f1f5f9;
  color: #64748b;
}

.popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.34);
}

.popover-backdrop[hidden] {
  display: none;
}

.popover-panel {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.22);
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.popover-head h2 {
  margin: 0;
  font-size: 16px;
}

.popover-close {
  min-height: 32px;
  padding: 0 12px;
}

.popover-body {
  padding: 18px;
}

.payment-popover {
  display: grid;
  gap: 18px;
}

.popover-section {
  display: grid;
  gap: 10px;
}

.popover-section h3 {
  margin: 0;
  color: #334155;
  font-size: 13px;
}

.popover-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}

.popover-row span {
  color: var(--muted);
}

.popover-row strong {
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
  white-space: normal;
  word-break: break-all;
}

.popover-empty {
  margin: 0;
  color: var(--muted);
}

.voucher-link {
  width: fit-content;
}

.voucher-preview {
  display: block;
  width: min(420px, 100%);
}

.voucher-image {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.voucher-missing {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.action-stack {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-width: 112px;
}

.action-button {
  min-height: 28px;
  padding: 0 9px;
  white-space: nowrap;
}

.action-button--copy {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.action-button--copy:hover {
  background: #dbeafe;
}

.action-button--primary {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.action-button--success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #bbf7d0;
}

.action-button--success:hover {
  background: #d1fae5;
}

.action-button--danger {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.action-button--danger:hover {
  background: #ffe4e6;
}

.action-button--more {
  background: #fff;
  color: #475569;
  border: 1px solid var(--line);
}

.action-button--more:hover {
  background: #f8fafc;
  color: var(--ink);
}

.action-more-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 8px;
}

.action-more-grid .action-button {
  width: 100%;
}

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

.description div {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.description dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.description dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

h3 {
  margin: 18px 0 10px;
  font-size: 16px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-group {
    align-content: start;
  }

  .nav-sub {
    padding-left: 0;
  }

  .main {
    padding: 16px;
  }

  .metric-grid,
  .grid-two,
  .filter-grid,
  .form-grid,
  .form-grid.wide,
  .description {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }
}
