:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f9fbff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
  background: radial-gradient(circle at top, #eef4ff 0%, var(--bg) 55%);
  color: var(--text);
}

.topbar {
  background: linear-gradient(135deg, #1e3a8a, #0f766e 72%);
  color: #fff;
  padding: 18px 18px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.25);
}

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
}

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

.brand-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .2px;
}

.brand-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: rgba(255,255,255,.82);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  font-size: 12px;
  font-weight: 600;
}

.auth-actions {
  display: flex;
  gap: 8px;
}

.auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255,255,255,.06);
}

.auth-link.primary {
  background: rgba(255,255,255,.22);
}

.auth-link:hover {
  background: rgba(255,255,255,.2);
}

.nav {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a {
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,.06);
  transition: all .18s ease;
}

.nav a:hover {
  background: rgba(255,255,255,.2);
  transform: translateY(-1px);
}

.container {
  max-width: 1160px;
  margin: 20px auto;
  padding: 0 14px 28px;
  overflow-x: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.account-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.account-tabs .tab {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
}

.account-tabs .tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

h2, h3, h4 { margin: 4px 0 10px; }

.hint {
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.45;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-soft);
  transition: transform .16s ease, box-shadow .16s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.12);
}

.finance-stat-cards {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.finance-stat {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.finance-stat.highlight {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
}

.finance-stat.wallet {
  border-color: #a7f3d0;
  background: linear-gradient(180deg, #ecfdf5, #d1fae5);
}

.finance-stat.income {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #eef2ff, #e0e7ff);
}

.finance-stat.topup {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
}

.finance-stat.refund {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fef2f2, #fee2e2);
}

.finance-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}

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

.finance-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 6px;
  font-size: 14px;
}

.finance-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.finance-list li.empty {
  color: var(--muted);
  border-bottom: 0;
}

.finance-subtotal {
  margin-top: 8px;
  font-weight: 700;
}

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

.card-value {
  font-size: 30px;
  font-weight: 800;
  margin-top: 4px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

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

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

.schedule-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  font-weight: 600;
  font-size: 14px;
}

.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.counter-timeline-stack {
  display: grid;
  gap: 10px;
}

.timeline-court-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  max-width: 100%;
  overflow: hidden;
}

.timeline-court-title {
  font-weight: 800;
  margin-bottom: 8px;
}

.timeline-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}

.timeline-strip {
  display: inline-flex;
  gap: 6px;
  width: max-content;
  min-width: max-content;
  padding-bottom: 2px;
}

.slot-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 62px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  text-decoration: none;
}

.slot-chip.empty {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #94a3b8;
}

.slot-chip.free {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.slot-chip.free.selected {
  background: #16a34a;
  border-color: #15803d;
  color: #fff;
}

.slot-chip.busy {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.slot-chip.past {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #475569;
}

.counter-selected-summary {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fafc;
}

label {
  font-size: 14px;
  font-weight: 700;
}

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

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-row .btn {
  white-space: nowrap;
  flex: 0 0 auto;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-box input {
  padding-right: 36px;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background: #cbd5e1;
}

input:focus,
select:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

input:disabled,
select:disabled {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  text-decoration: none;
  background: linear-gradient(180deg, #3b82f6, var(--primary));
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .25);
}

.btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #4f8ef8, var(--primary-dark));
}

.btn.danger {
  background: linear-gradient(180deg, #ef4444, var(--danger));
  box-shadow: 0 6px 14px rgba(220, 38, 38, .25);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  position: sticky;
  top: 0;
}

tbody tr:nth-child(even) {
  background: #fcfdff;
}

.flash {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.flash li {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-weight: 600;
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px;
}

.record-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.record-id {
  font-weight: 800;
}

.record-status {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  margin-left: auto;
}

.record-status.ok {
  background: #dcfce7;
  color: #166534;
}

.record-status.muted {
  background: #e2e8f0;
  color: #334155;
}

.kind-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  border: 1px solid transparent;
}

.kind-tag.court {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e3a8a;
}

.kind-tag.coach {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.wallet-type {
  font-weight: 700;
  color: #1f2937;
}

.txn-amount {
  font-weight: 800;
  font-size: 15px;
}

.txn-amount.plus {
  color: #166534;
}

.txn-amount.minus {
  color: #b91c1c;
}

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

.record-grid .full {
  grid-column: 1 / -1;
}

.record-grid .k {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.record-grid .v {
  display: block;
  font-weight: 600;
  line-height: 1.32;
  word-break: break-word;
}

@media (max-width: 768px) {
  .brand-title { font-size: 18px; }
  .brand-subtitle { font-size: 12px; }
  .cards { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .schedule-row { grid-template-columns: 1fr; }
  .container { margin-top: 12px; }
}
