[hidden] { display: none !important; }

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #e4e9f2;
  --text: #1b2537;
  --muted: #6b7690;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #d64545;
  --success: #17845c;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand-mark { width: 20px; height: 20px; border-radius: 6px; background: var(--primary); position: relative; }
.brand-mark::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 2px; background: #fff; top: 6px; left: 6px; }
.ghost-link { color: var(--muted); font-size: 13px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; }
.ghost-link:hover { color: var(--primary); border-color: var(--primary); }

.main { padding-top: 40px; padding-bottom: 60px; }
.hero { margin-bottom: 24px; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 600; letter-spacing: .08em; margin-bottom: 8px; }
.hero h1 { font-size: 26px; margin: 0 0 8px; font-weight: 600; }
.hero p { color: var(--muted); margin: 0 0 10px; }
.meta { font-size: 12px; color: #8a94a8; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.field { margin-bottom: 20px; }
.field-label { display: block; font-weight: 500; margin-bottom: 8px; font-size: 14px; }
.req { color: var(--danger); margin-left: 4px; }
.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fff; outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
textarea.input { resize: vertical; min-height: 76px; }
.choice-group { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13px; }
.choice:hover { border-color: var(--primary); }
.choice input { accent-color: var(--primary); }

.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.btn {
  padding: 10px 20px; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; font-size: 14px; font-family: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 12px 0; }
.alert.error { background: #fdf0f0; color: var(--danger); border: 1px solid #f6d4d4; }
.alert.ok { background: #ebf7f1; color: var(--success); border: 1px solid #cfeade; }

.success-card { text-align: center; padding: 40px 28px; }
.success-icon { width: 48px; height: 48px; border-radius: 50%; background: #ebf7f1; margin: 0 auto 16px; position: relative; }
.success-icon::after { content: ""; position: absolute; width: 14px; height: 24px; border: solid var(--success); border-width: 0 3px 3px 0; transform: rotate(45deg); top: 8px; left: 17px; }
.success-card h2 { font-size: 20px; margin: 0 0 24px; font-weight: 600; }
.receipt { max-width: 420px; margin: 0 auto 24px; text-align: left; border: 1px solid var(--line); border-radius: 10px; }
.receipt div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.receipt div:last-child { border-bottom: none; }
.receipt span { color: var(--muted); }
.receipt strong { font-weight: 500; }
.receipt strong.ok { color: var(--success); }
.receipt strong.warn { color: #b8791a; }
.footer { text-align: center; color: #9aa3b5; font-size: 12px; margin-top: 28px; }

/* admin */
.admin-shell { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.login-card { max-width: 380px; margin: 12vh auto 0; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; }
.login-card p { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.admin-head h1 { font-size: 20px; margin: 0; font-weight: 600; }
.admin-head .sub { color: var(--muted); font-size: 12px; }
.layout { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; }
.nav { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.nav button {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: transparent;
  color: var(--text); font-size: 13px; font-family: inherit; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
}
.nav button:hover { background: #f2f5fb; }
.nav button.active { background: #eaf0fe; color: var(--primary); font-weight: 500; }
.panel { display: none; }
.panel.active { display: block; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; margin: 0; font-weight: 600; }
.panel-head p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

.tpl-basic { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; }
.field-row { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 10px; background: #fcfdff; }
.field-row-top { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.field-row-top .input { flex: 1; }
.field-row-top select.input { flex: 0 0 130px; }
.row-actions { display: flex; gap: 6px; }
.field-row-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
.inline-check { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.inline-check input { accent-color: var(--primary); }
.mini-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: auto; flex: 1; min-width: 160px; }
.toolbar select.input { flex: 0 0 130px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafd; color: var(--muted); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8fafd; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; }
.tag.pending { background: #fff3e0; color: #a8680e; }
.tag.done { background: #ebf7f1; color: var(--success); }
.tag.fail { background: #fdf0f0; color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; font-size: 13px; }

.detail-list { display: grid; grid-template-columns: 140px 1fr; gap: 0; font-size: 13px; }
.detail-list div { padding: 9px 0; border-bottom: 1px solid var(--line); }
.detail-list div:nth-child(odd) { color: var(--muted); }
.detail-list div:last-child, .detail-list div:nth-last-child(2) { border-bottom: none; }

.settings-grid { display: grid; gap: 16px; max-width: 640px; }
.setting-row { display: flex; flex-direction: column; gap: 6px; }
.setting-row .input { width: 100%; }
.status-line { font-size: 12px; color: var(--muted); }
.status-line b { color: var(--text); font-weight: 500; }
.modal-mask { position: fixed; inset: 0; background: rgba(20,28,45,.42); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px; max-height: 80vh; overflow: auto; padding: 24px; }
.modal h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .nav { display: flex; overflow-x: auto; }
  .nav button { width: auto; white-space: nowrap; flex: 0 0 auto; }
  .tpl-basic, .field-row-bottom { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .hint { text-align: center; }
}
