* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --blue: #2f6bff;
  --blue-dark: #1f52d6;
  --red: #e4393c;
  --green: #17a673;
  --text: #1f2430;
  --muted: #8a91a0;
  --line: #e8ebf1;
  --bg: #f4f6fa;
}

html, body { margin: 0; padding: 0; }

body {
  background: #e9edf4;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.app {
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 30px rgba(30, 50, 90, .06);
}

.topbar {
  background: var(--blue);
  color: #fff;
  padding: 18px 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 11px; }

.logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
}

.brand-text h1 { margin: 0; font-size: 17px; font-weight: 600; }
.brand-text p { margin: 2px 0 0; font-size: 11px; opacity: .78; }

.status-pill {
  font-size: 11px;
  background: rgba(255,255,255,.16);
  padding: 5px 10px;
  border-radius: 20px;
  display: flex; align-items: center; gap: 5px;
}
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: #ffd66b; }
.status-pill.ok i { background: #5ef0b0; }
.status-pill.bad i { background: #ff8a8a; }

.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.tab {
  flex: 1; padding: 13px 0 11px;
  border: 0; background: transparent;
  font-size: 14px; color: var(--muted);
  position: relative; cursor: pointer;
  font-family: inherit;
}
.tab.active { color: var(--blue); font-weight: 600; }
.tab.active::after {
  content: ""; position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 3px; background: var(--blue);
}

.page { display: none; padding: 14px 14px 28px; }
.page.active { display: block; }

.hero {
  background: linear-gradient(135deg, #2f6bff, #4d8bff);
  color: #fff;
  border-radius: 14px;
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: flex-end;
}
.hero-tag {
  font-size: 11px; background: rgba(255,255,255,.2);
  padding: 3px 8px; border-radius: 4px;
}
.hero h2 { margin: 10px 0 4px; font-size: 19px; font-weight: 600; }
.hero p { margin: 0; font-size: 11px; opacity: .82; }
.hero-price { text-align: right; }
.hero-price span { font-size: 25px; font-weight: 600; }
.hero-price small { display: block; font-size: 10px; opacity: .8; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}
.form-card { padding-bottom: 18px; }

.field { margin-bottom: 15px; min-width: 0; flex: 1; }
.field label, .switch-label {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 7px; color: #343a46;
}
.required { color: var(--red); }

input[type="text"], input[type="password"], input[type="number"], input[type="time"], select {
  width: 100%; height: 42px;
  border: 1px solid #dfe3eb;
  border-radius: 8px;
  padding: 0 11px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,107,255,.09); }
input::placeholder { color: #b3b9c5; }

.hint { margin: 6px 0 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.field-row { display: flex; gap: 12px; }

.school-wrap { position: relative; }
.school-arrow {
  position: absolute; right: 12px; top: 9px;
  color: var(--muted); pointer-events: none; font-size: 16px;
}
.school-list {
  display: none;
  position: absolute; top: 45px; left: 0; right: 0;
  max-height: 220px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; z-index: 30;
  box-shadow: 0 8px 24px rgba(20,40,80,.12);
}
.school-list.show { display: block; }
.school-item { padding: 10px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f2f4f8; }
.school-item:last-child { border-bottom: 0; }
.school-item:hover, .school-item.active { background: #eef3ff; color: var(--blue); }
.school-empty { padding: 12px; font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid #dfe3eb; background: #fff; color: #5d6473;
  padding: 7px 13px; border-radius: 20px; font-size: 12px;
  cursor: pointer; font-family: inherit;
}
.chip.active { border-color: var(--blue); color: var(--blue); background: #eef3ff; font-weight: 600; }

.input-unit { position: relative; }
.input-unit input { padding-right: 48px; }
.input-unit span { position: absolute; right: 12px; top: 11px; color: var(--muted); font-size: 13px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.day {
  aspect-ratio: 1; border-radius: 50%;
  border: 1px solid #dfe3eb; background: #fff;
  color: #7a8290; font-size: 13px; cursor: pointer;
  font-family: inherit; padding: 0;
}
.day.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch-row .switch-label { margin-bottom: 2px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #d5dae4; border-radius: 26px;
  cursor: pointer; transition: .2s;
}
.slider::before {
  content: ""; position: absolute; width: 20px; height: 20px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.total-bar {
  border-top: 1px dashed var(--line);
  padding-top: 14px; margin: 18px 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.total-label { font-size: 13px; font-weight: 600; }
.total-bar strong { font-size: 23px; color: var(--red); font-weight: 600; white-space: nowrap; }

.primary-btn {
  width: 100%; height: 46px;
  border: 0; border-radius: 10px;
  background: var(--blue); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.primary-btn:disabled { background: #a9bdf0; cursor: not-allowed; }
.form-hint { text-align: center; font-size: 11px; color: var(--muted); margin: 10px 0 0; }

.card-title { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }
.search-row select { width: 116px; flex-shrink: 0; padding: 0 6px; font-size: 12px; }
.mini-btn {
  border: 0; border-radius: 8px; background: var(--blue); color: #fff;
  padding: 0 14px; font-size: 13px; cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.text-btn { border: 0; background: transparent; color: var(--blue); font-size: 12px; cursor: pointer; font-family: inherit; }

.result-box { margin-top: 12px; }
.result-box:empty { display: none; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.info-item span { display: block; font-size: 11px; color: var(--muted); }
.info-item b { font-size: 13px; font-weight: 500; word-break: break-all; }
.info-item.full { grid-column: 1 / -1; }

.status-tag {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 4px; background: #eef3ff; color: var(--blue);
}
.status-tag.success { background: #e6f8f0; color: var(--green); }
.status-tag.fail { background: #fdecec; color: var(--red); }
.status-tag.wait { background: #fff4e0; color: #b8760b; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 12px; display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.history-item:hover { border-color: var(--blue); }
.history-main { flex: 1; min-width: 0; }
.history-main b { font-size: 13px; font-weight: 600; }
.history-main p { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.history-amount { font-size: 14px; font-weight: 600; color: var(--red); }

.empty { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 0; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.action-btn {
  border: 1px solid #dfe3eb; background: #fff; color: #4a5261;
  border-radius: 8px; height: 40px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.action-btn:hover { border-color: var(--blue); color: var(--blue); }
.action-btn.danger { color: var(--red); }
.action-btn.danger:hover { border-color: var(--red); }
.action-btn.full { width: 100%; margin-top: 10px; }

.kv {
  display: flex; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid #f2f4f8; font-size: 13px;
}
.kv span { color: var(--muted); }
.kv b { font-weight: 500; }

.mask {
  display: none; position: fixed; inset: 0;
  background: rgba(18,26,44,.45); z-index: 100;
}
.mask.show { display: block; }

.modal {
  display: none; position: fixed; z-index: 101;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 40px); max-width: 420px;
  background: #fff; border-radius: 14px; overflow: hidden;
}
.modal.show { display: block; }
.modal-head {
  padding: 15px 16px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.close-btn { border: 0; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 16px; max-height: 60vh; overflow-y: auto; }
.modal-foot { padding: 0 16px 16px; display: flex; gap: 8px; }
.modal-foot:empty { display: none; }
.modal-foot button { flex: 1; }
.modal-foot .ghost {
  border: 1px solid #dfe3eb; background: #fff; color: #5d6473;
  border-radius: 9px; height: 42px; cursor: pointer; font-family: inherit; font-size: 14px;
}

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #293143; color: #fff; font-size: 13px;
  padding: 10px 16px; border-radius: 8px; z-index: 200;
  opacity: 0; pointer-events: none; transition: .2s;
  max-width: calc(100% - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
