:root {
  --bg: #0d0d0f;
  --bg-strong: #18191b;
  --surface: rgba(28, 28, 30, 0.58);
  --surface-strong: rgba(34, 34, 36, 0.72);
  --text: #ececec;
  --muted: #a8a8a8;
  --muted-strong: #c9c9c9;
  --line: rgba(255, 215, 120, 0.12);
  --accent: #f6d27a;
  --accent-strong: #d6b15d;
  --accent-soft: rgba(246, 210, 122, 0.14);
  --success: #f6d27a;
  --danger: #d98d7e;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --inset: inset 0 1px rgba(255, 255, 255, 0.04);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", "Times New Roman", Georgia, serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 15%, rgba(255, 194, 82, 0.1), transparent 28%),
    radial-gradient(circle at 90% 10%, rgba(255, 170, 0, 0.06), transparent 22%),
    linear-gradient(180deg, #0d0d0f, #111214, #18191b);
  background-attachment: fixed;
}

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

::selection {
  background: rgba(246, 210, 122, 0.24);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(13, 13, 15, 0.65);
}

::-webkit-scrollbar-thumb {
  border: 2px solid rgba(13, 13, 15, 0.65);
  border-radius: 999px;
  background: rgba(246, 210, 122, 0.38);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 34%, rgba(255,255,255,0.01) 72%),
    rgba(28, 28, 30, 0.58);
  color: var(--text);
  backdrop-filter: blur(22px) saturate(1.55);
  box-shadow: var(--shadow), var(--inset);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.72;
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.05;
  background: linear-gradient(135deg, #a5b4fc, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-copy {
  max-width: 640px;
  margin: 14px 0 0;
  line-height: 1.7;
  opacity: 0.88;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 34%, rgba(255,255,255,0.01) 72%),
    var(--surface);
  backdrop-filter: blur(22px) saturate(1.55);
  box-shadow: var(--shadow), var(--inset);
}

.metric-card {
  padding: 18px 20px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 34%, rgba(255,255,255,0.01) 72%),
    rgba(24, 24, 26, 0.76);
}

.metric-card span {
  display: block;
  font-size: 13px;
  opacity: 0.76;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.account-area {
  position: relative;
  flex: 0 0 auto;
}

.guest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-menu {
  position: relative;
}

.avatar-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(24, 24, 26, 0.76);
  color: var(--accent);
  font-weight: 800;
  backdrop-filter: blur(14px);
}

.account-popover {
  position: absolute;
  top: 54px;
  right: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  width: 180px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(22, 22, 24, 0.9);
  color: var(--text);
  backdrop-filter: blur(28px) saturate(1.1);
  box-shadow: var(--shadow), var(--inset);
}

.account-popover[hidden],
.user-menu[hidden],
.guest-actions[hidden] {
  display: none;
}

.account-popover strong {
  word-break: break-word;
}

.layout {
  display: block;
}

.app-toast {
  position: sticky;
  top: 12px;
  z-index: 20;
  width: min(100%, 620px);
  margin: -8px auto 18px;
  padding: 14px 18px;
  border: 1px solid rgba(246, 210, 122, 0.3);
  border-radius: var(--radius-md);
  background: rgba(24, 24, 26, 0.92);
  color: var(--success);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35), 0 0 28px rgba(246, 210, 122, 0.12);
  font-weight: 800;
  text-align: center;
}

.app-toast.error {
  border-color: rgba(217, 141, 126, 0.34);
  background: rgba(34, 24, 24, 0.94);
  color: var(--danger);
}

.panel {
  padding: 22px;
}

.tab-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.tab-button {
  border: 1px solid var(--line);
  background: rgba(24, 24, 26, 0.76);
  color: var(--muted);
  font-weight: 700;
  backdrop-filter: blur(14px);
}

.tab-button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 26px rgba(246, 210, 122, 0.1);
}

.view-section {
  display: none;
}

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

.auth-view.is-active {
  min-height: 460px;
  place-items: center;
}

.auth-card {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 34%, rgba(255,255,255,0.01) 72%),
    rgba(28, 28, 30, 0.72);
  backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: var(--shadow), var(--inset);
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.auth-message {
  min-height: 24px;
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-message.success {
  color: var(--success);
  font-weight: 700;
}

.auth-message.error {
  color: var(--danger);
  font-weight: 700;
}

.auth-page-form {
  display: grid;
  gap: 14px;
}

.auth-page-form label {
  display: grid;
  gap: 8px;
}

.auth-page-form span {
  font-weight: 700;
}

.link-button {
  width: 100%;
  margin-top: 14px;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

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

.stats-grid .metric-card {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 34%, rgba(255,255,255,0.01) 72%),
    rgba(24, 24, 26, 0.76);
}

.records-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(220px, 280px) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.inline-metric {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(24, 24, 26, 0.76);
}

.inline-metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.inline-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.filter-field {
  display: grid;
  gap: 8px;
}

.filter-field span {
  font-weight: 600;
}

.fare-panel {
  padding: 0;
  overflow: hidden;
}

.fare-panel .panel-heading {
  margin: 0;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.fare-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(170px, 220px) minmax(170px, 220px) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(24, 24, 26, 0.56);
}

.fare-toolbar label {
  display: grid;
  gap: 8px;
}

.fare-toolbar label span {
  font-weight: 700;
}

.fare-summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(246, 210, 122, 0.08);
  color: var(--muted);
  font-weight: 800;
}

.fare-table-wrap {
  max-height: 620px;
  overflow: auto;
  background: rgba(13, 13, 15, 0.42);
}

.fare-table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: rgba(13, 13, 15, 0.42);
}

.fare-table th:nth-child(1),
.fare-table td:nth-child(1) {
  width: 24%;
}

.fare-table th:nth-child(2),
.fare-table td:nth-child(2) {
  width: 34%;
}

.fare-table th:nth-child(3),
.fare-table td:nth-child(3),
.fare-table th:nth-child(4),
.fare-table td:nth-child(4) {
  width: 21%;
}

.fare-table th,
.fare-table td {
  padding: 12px 14px;
  border-right: 1px solid rgba(255, 215, 120, 0.12);
  border-bottom: 1px solid rgba(255, 215, 120, 0.12);
  vertical-align: middle;
}

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

.fare-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(24, 24, 26, 0.96);
  color: var(--text);
  font-size: 14px;
  text-align: center;
}

.fare-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}

.fare-table tbody tr:hover {
  background: rgba(246, 210, 122, 0.08);
}

.fare-table td:nth-child(1),
.fare-table td:nth-child(2) {
  font-weight: 700;
}

.fare-table td:nth-child(3),
.fare-table td:nth-child(4) {
  text-align: center;
  font-weight: 900;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.panel-heading h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

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

.trip-form {
  display: grid;
  gap: 18px;
}

.trip-form label,
.mode-switch {
  display: grid;
  gap: 8px;
}

.trip-form span,
.mode-switch legend {
  font-weight: 600;
}

input[type="date"],
input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  box-shadow: var(--inset);
}

input[type="date"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: rgba(246, 210, 122, 0.42);
  box-shadow: var(--inset), 0 0 0 3px rgba(246, 210, 122, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: var(--dim2, #6f6f6f);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

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

.mode-switch {
  border: 0;
  padding: 0;
  margin: 0;
}

.mode-switch legend {
  margin-bottom: 10px;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  margin-right: 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(24, 24, 26, 0.76);
}

.radio-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-pill span {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  transition: 180ms ease;
}

.radio-pill input:checked + span {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 22px rgba(246, 210, 122, 0.1);
}

.fee-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.fee-preview > div {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(24, 24, 26, 0.76);
  border: 1px solid var(--line);
}

.fee-preview span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 500;
}

.fee-preview strong {
  font-size: 28px;
}

.money-amount,
#transport-fee-preview,
#meal-fee-preview,
#trip-fee-preview,
#filtered-records-total,
#month-total-fee {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(246, 210, 122, 0.06);
}

.fee-total {
  background: rgba(246, 210, 122, 0.1) !important;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  background: rgba(24, 24, 26, 0.76);
  color: var(--text);
  backdrop-filter: blur(14px);
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(246, 210, 122, 0.34);
  color: var(--accent);
  box-shadow: 0 0 22px rgba(246, 210, 122, 0.1);
}

button[type="submit"] {
  background: rgba(24, 24, 26, 0.88);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 24px rgba(246, 210, 122, 0.08);
}

.ghost-button,
.month-nav button {
  background: rgba(24, 24, 26, 0.66);
  color: var(--text);
}

.top-records {
  display: grid;
  gap: 14px;
}

.top-record-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 34%, rgba(255,255,255,0.01) 72%),
    rgba(24, 24, 26, 0.76);
  border: 1px solid var(--line);
}

.top-record-card h3,
.records-item h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

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

.top-record-list li {
  display: grid;
  grid-template-columns: minmax(90px, 0.28fr) 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 215, 120, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.top-record-list strong {
  color: var(--accent);
}

.top-record-meta,
.records-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  margin-bottom: 10px;
}

.fee-badge,
.day-total {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-nav strong {
  min-width: 112px;
  text-align: center;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.weekday-row div {
  padding: 10px 0;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

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

.calendar-day {
  min-height: 152px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(24, 24, 26, 0.56);
  border: 1px solid rgba(255, 215, 120, 0.08);
  display: grid;
  align-content: start;
  gap: 8px;
}

.calendar-day.muted {
  opacity: 0.35;
}

.calendar-day.has-records {
  background: rgba(246, 210, 122, 0.08);
}

.calendar-date {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.calendar-list {
  display: grid;
  gap: 6px;
}

.calendar-item {
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 215, 120, 0.08);
  background: rgba(0, 0, 0, 0.18);
  font-size: 13px;
  line-height: 1.5;
}

.calendar-item strong {
  display: block;
  margin-bottom: 4px;
}

.calendar-note {
  color: var(--muted);
}

.preview-controls {
  position: sticky;
  top: 0;
  z-index: 2;
}

.preview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.preview-summary span {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(24, 24, 26, 0.76);
}

.forms-preview-list {
  display: grid;
  gap: 22px;
}

.paper-preview {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 34px;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  background: #fff;
  color: #151515;
  box-shadow: 0 18px 36px rgba(30, 30, 30, 0.08);
}

.paper-preview h2,
.paper-preview h3 {
  margin: 0;
  text-align: center;
  font-weight: 700;
}

.paper-preview h2 {
  font-size: 24px;
  margin-bottom: 18px;
}

.paper-preview h3 {
  font-size: 20px;
  margin-bottom: 14px;
}

.paper-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  line-height: 1.8;
}

.paper-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.paper-table th,
.paper-table td {
  border: 1px solid #222;
  padding: 9px 8px;
  min-height: 38px;
  line-height: 1.55;
  vertical-align: middle;
  word-break: break-word;
}

.paper-table th {
  font-weight: 700;
  background: #fafafa;
}

.paper-center {
  text-align: center;
}

.paper-right {
  text-align: right;
}

.amount-digit {
  color: #d01818;
  font-weight: 700;
}

.paper-large-cell {
  height: 96px;
  vertical-align: top !important;
}

.voucher-preview {
  display: grid;
  min-height: 420px;
  align-content: stretch;
}

.voucher-paper {
  padding: 24px;
}

.voucher-table {
  height: 100%;
}

.voucher-title {
  text-align: center;
  writing-mode: vertical-rl;
  font-size: 22px;
  font-weight: 700;
  width: 42px;
}

.voucher-blank {
  height: 280px;
}

.approval-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  border: 1px solid #222;
}

.approval-grid > div {
  min-height: 48px;
  padding: 10px;
  border-right: 1px solid #222;
  border-bottom: 1px solid #222;
}

.approval-grid > div:nth-child(2n) {
  border-right: 0;
}

.approval-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.approval-label {
  display: grid;
  place-items: center;
  font-weight: 700;
  background: #fafafa;
}

.approval-tall {
  min-height: 82px !important;
}

.detail-table th,
.detail-table td {
  text-align: center;
}

.empty-preview {
  width: min(100%, 920px);
  margin: 0 auto;
}

.records-list {
  display: grid;
  gap: 14px;
}

.records-item {
  padding: 18px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 34%, rgba(255,255,255,0.01) 72%),
    rgba(24, 24, 26, 0.76);
  border: 1px solid var(--line);
}

.records-item footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.delete-button {
  padding: 8px 12px;
  background: rgba(217, 141, 126, 0.1);
  color: var(--danger);
}

.empty-state {
  color: var(--muted);
  padding: 20px;
  border: 1px dashed rgba(255, 215, 120, 0.18);
  border-radius: var(--radius-md);
  background: rgba(24, 24, 26, 0.46);
}

@media (max-width: 980px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 100%);
  }

  .selector-grid,
  .fee-preview,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .records-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .fare-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .hero {
    align-items: stretch;
  }

  .guest-actions {
    justify-content: stretch;
  }

  .guest-actions button {
    flex: 1;
  }

  .account-popover {
    left: 0;
    right: auto;
  }

  .paper-preview {
    padding: 18px;
    overflow-x: auto;
  }

  .paper-table {
    min-width: 720px;
  }

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

  .tab-nav {
    flex-direction: column;
  }

  .weekday-row,
  .calendar-grid {
    gap: 6px;
  }

  .calendar-day {
    min-height: 124px;
    padding: 10px;
  }

  .calendar-item {
    font-size: 12px;
  }
}
