:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --text: #18211d;
  --muted: #65736d;
  --line: #dce4df;
  --primary: #0e6b5b;
  --primary-strong: #084f43;
  --accent: #b84d35;
  --accent-soft: #fff1eb;
  --blue-soft: #eef4ff;
  --gold-soft: #fff7e1;
  --shadow: 0 14px 36px rgba(16, 32, 27, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(14, 107, 91, 0.12), rgba(184, 77, 53, 0.04) 260px, transparent 520px),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(14, 107, 91, 0.22);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 3px 0 0;
  font-size: 25px;
  line-height: 1.18;
}

h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.3;
}

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

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
  width: min(100%, 420px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.login-panel {
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(30px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 2px 16px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.eyebrow,
.panel-label,
.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 5px;
  margin: 0 0 12px;
  border: 1px solid rgba(220, 228, 223, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.tab,
.segment {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tab.is-active,
.segment.is-active {
  background: var(--primary);
  color: #fff;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 12px;
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

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

.status-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  background:
    linear-gradient(135deg, rgba(238, 245, 242, 0.95), rgba(255, 247, 225, 0.9)),
    var(--surface-soft);
}

.today-result {
  display: grid;
  gap: 7px;
  margin-top: 9px;
  font-size: 16px;
  font-weight: 800;
}

.today-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.today-meta span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid rgba(14, 107, 91, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.module-grid {
  display: grid;
  gap: 10px;
}

.module-card {
  width: 100%;
  min-height: 88px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
}

.module-card:nth-child(2n) {
  background: var(--blue-soft);
}

.module-card:nth-child(3n) {
  background: var(--gold-soft);
}

.module-restaurant {
  background: #fff7e1;
}

.module-driver {
  background: #eef4ff;
}

.module-ledger {
  background: #eef5f2;
}

.module-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.module-card strong {
  font-size: 18px;
  line-height: 1.3;
}

.module-card::after {
  content: "进入";
  justify-self: end;
  margin-top: -26px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.back-button {
  justify-self: start;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--primary);
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(16, 32, 27, 0.06);
}

.back-button::before {
  content: "< ";
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  min-width: 126px;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8f7;
}

.mode-block {
  display: grid;
  gap: 12px;
}

.subpanel {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.panel-heading.compact {
  margin-bottom: 0;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 800;
}

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

.primary-button:active {
  background: var(--primary-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button {
  border: 1px solid rgba(14, 107, 91, 0.2);
  background: rgba(255, 255, 255, 0.68);
  color: var(--primary);
  white-space: nowrap;
}

.danger-button {
  background: var(--accent-soft);
  color: var(--accent);
}

.full {
  width: 100%;
}

.recommendation {
  min-height: 84px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px;
  border: 1px dashed #b9c9c1;
  border-radius: 8px;
  background: #fbfcfa;
}

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

.recommendation strong {
  display: block;
  font-size: 23px;
  line-height: 1.25;
}

.compact-recommendation {
  min-height: 62px;
}

.check-list {
  display: grid;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 750;
}

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

.date-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ledger-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ledger-list,
.manage-list {
  display: grid;
  gap: 10px;
}

.ledger-card,
.manage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ledger-card {
  display: grid;
  gap: 5px;
  padding: 14px;
}

.ledger-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.ledger-card time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ledger-card strong {
  display: block;
  font-size: 18px;
  line-height: 1.35;
}

.ledger-card span {
  color: var(--muted);
}

.ledger-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.pager {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 2px;
}

.pager span {
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.manage-card {
  padding: 12px;
}

.manage-title-row,
.restaurant-row,
.driver-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
}

.restaurant-row,
.driver-row {
  margin-top: 8px;
}

.restaurant-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.no-margin {
  margin-bottom: 0;
}

.empty {
  padding: 18px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.72);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(calc(100% - 28px), 460px);
  transform: translateX(-50%) translateY(20px);
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(24, 33, 29, 0.92);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  padding: 14px;
  background: rgba(24, 33, 29, 0.36);
}

.dialog-panel {
  width: min(100%, 460px);
  margin: 0 auto max(8px, env(safe-area-inset-bottom));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 22px 60px rgba(16, 32, 27, 0.22);
}

.dialog-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.dialog-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 520px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    width: 108px;
  }

  .topbar-actions .ghost-button {
    width: 100%;
  }

  h1 {
    font-size: 22px;
  }

  .status-panel,
  .date-filters {
    grid-template-columns: 1fr;
  }

  .status-panel .primary-button {
    width: 100%;
  }

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

  .ledger-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
  }

  .manage-title-row,
  .restaurant-row,
  .driver-row,
  .inline-form {
    grid-template-columns: 1fr;
  }
}
