/* ===================================================================
   在线计时时间表 · 简约风格
   设计原则：大留白 / 单一强调色 / 细线分隔 / 弱化装饰
   =================================================================== */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --line: #e9ecf1;
  --line-2: #dde2e9;
  --text: #171b22;
  --text-2: #5e6875;
  --text-3: #98a2b0;
  --accent: #2f56c8;
  --accent-2: #3b68e0;
  --accent-soft: #eef2fd;
  --green: #16855f;
  --amber: #b8781a;
  --red: #c93f3a;
  --red-soft: #fff6f5;
  --red-line: #f0d5d3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .035);
  --shadow-lg: 0 20px 60px rgba(16, 24, 40, .14);
  --radius: 12px;
  --radius-sm: 8px;
}

html[data-theme="dark"] {
  --bg: #101318;
  --surface: #171b22;
  --surface-2: #1d222b;
  --line: #282e38;
  --line-2: #353d4a;
  --text: #e9edf4;
  --text-2: #a3adbc;
  --text-3: #727d8e;
  --accent: #8aa6ff;
  --accent-2: #9db4ff;
  --accent-soft: #202a44;
  --green: #4ec99a;
  --amber: #e0b163;
  --red: #f08079;
  --red-soft: #2c1d1f;
  --red-line: #4a2b2d;
  --shadow: none;
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app { max-width: 1480px; margin: 0 auto; padding: 0 40px 36px; }

/* ---------------- 顶部 ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 26px 0 24px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); display: grid; place-items: center; color: var(--accent); background: var(--surface); }
.brand-mark .ic { width: 22px; height: 22px; }
.brand h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: .2px; line-height: 1.3; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.clock { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.clock small { display: block; font-size: 11px; font-weight: 400; color: var(--text-3); letter-spacing: 0; }
.vline { width: 1px; height: 30px; background: var(--line); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); transition: .16s; }
.icon-btn:hover { background: var(--surface-2); color: var(--accent); border-color: var(--line); }
.icon-btn .ic { width: 17px; height: 17px; }

.user-wrap { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 9px 5px 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); transition: .16s; }
.user-chip:hover { border-color: var(--line-2); }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.user-chip .u-name { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.user-chip .u-role { display: block; font-size: 10.5px; color: var(--text-3); line-height: 1.3; }
.user-chip .ic { width: 14px; height: 14px; color: var(--text-3); margin-left: 2px; }
.user-menu { position: absolute; right: 0; top: calc(100% + 9px); width: 190px; z-index: 55; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.user-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; border: 0; border-radius: 7px; background: transparent; font-size: 12.5px; text-align: left; color: var(--text-2); }
.user-menu button:hover { background: var(--surface-2); color: var(--accent); }
.user-menu button .ic { width: 15px; height: 15px; }
.user-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.user-menu .danger:hover { color: var(--red); }

/* ---------------- 到时提醒 ---------------- */
.notice { display: flex; align-items: center; gap: 14px; padding: 12px 18px; margin-bottom: 22px; border: 1px solid var(--red-line); border-left: 3px solid var(--red); border-radius: var(--radius-sm); background: var(--red-soft); color: var(--red); }
.notice .ic { width: 19px; height: 19px; }
.notice-body { flex: 1; min-width: 0; }
.notice strong { font-size: 13.5px; font-weight: 650; }
.notice span { display: block; font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice .link-btn { flex: none; border: 0; background: transparent; color: var(--red); font-size: 12.5px; font-weight: 600; padding: 5px 8px; border-radius: 6px; white-space: nowrap; }
.notice .link-btn:hover { background: var(--red-line); }

/* ---------------- 指标条 ---------------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.metric { padding: 20px 26px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { font-size: 12px; color: var(--text-2); }
.metric-value { font-size: 30px; font-weight: 680; line-height: 1.25; font-variant-numeric: tabular-nums; margin-top: 3px; letter-spacing: -.5px; }
.metric-value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.metric-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.metric.warn .metric-value { color: var(--amber); }
.metric.alert .metric-value { color: var(--red); }

/* ---------------- 布局 ---------------- */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel-hint { font-size: 11.5px; color: var(--text-3); }
.panel-hint b { color: var(--red); font-weight: 500; }
.sync { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.sync.err .sync-dot { background: var(--red); }
.sync.loading .sync-dot { background: var(--amber); }

/* ---------------- 表单 ---------------- */
.form-panel form { padding: 22px 24px 24px; }
.field { margin-bottom: 18px; min-width: 0; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field > label b { color: var(--red); font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
input[type="text"], input[type="number"], input[type="password"], input[type="search"],
input[type="datetime-local"], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); outline: none;
  border: 1px solid var(--line-2); background: var(--surface-2); transition: border-color .16s, box-shadow .16s;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="datetime-local"] { padding: 8px 10px; }
.field-hint { font-size: 11px; color: var(--text-3); margin-top: 7px; }
.field-hint.ok { color: var(--green); }
.input-unit { position: relative; }
.input-unit input { padding-right: 44px; }
.input-unit > span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--text-3); pointer-events: none; }
.input-with-btn { display: flex; gap: 7px; }
.input-with-btn input { flex: 1; min-width: 0; }
.mini-btn { padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 9px; }
.chips button { padding: 9px 2px; font-size: 12.5px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.chips button:hover { border-color: var(--accent); color: var(--accent); }
.chips button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
#fTicketCustom, #eTicketCustom { margin-top: 8px; }
.stepper { display: flex; align-items: stretch; }
.stepper button { width: 33px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); font-size: 16px; }
.stepper button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stepper button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stepper button:hover { color: var(--accent); }
.stepper input { border-radius: 0; text-align: center; padding: 9px 2px; border-left: 0; border-right: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.switch-line { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); cursor: pointer; margin: 2px 0 20px; }
.switch-line input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 36px; height: 20px; border-radius: 20px; background: var(--line-2); position: relative; transition: .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: .2s; }
.switch-line input:checked + .switch { background: var(--accent); }
.switch-line input:checked + .switch::after { transform: translateX(16px); }

/* ---------------- 按钮 ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); font-size: 12.5px; font-weight: 600; transition: .16s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn .ic { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-block { width: 100%; padding: 11px; font-size: 13.5px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--red); border-color: var(--red-line); background: var(--surface); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 工具栏 ---------------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 0 24px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 22px; }
.tab { padding: 14px 0 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-3); font-size: 12.5px; font-weight: 600; margin-bottom: -1px; }
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.toolbar-right { display: flex; align-items: center; gap: 6px; }
.search-box { position: relative; margin-right: 4px; }
.search-box .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.search-box input { width: 210px; padding: 7px 10px 7px 31px; font-size: 12px; border-radius: var(--radius-sm); }

/* ---------------- 行式记录 ---------------- */
.rows { min-height: 150px; }
.rec-row { --sc: var(--green); padding: 18px 24px; border-bottom: 1px solid var(--line); transition: background .16s; }
.rec-row:last-child { border-bottom: 0; }
.rec-row:hover { background: var(--surface-2); }
.rec-row.s-soon { --sc: var(--amber); }
.rec-row.s-expired { --sc: var(--red); }
.rec-row.s-ended { --sc: var(--text-3); }
.rec-line1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.rec-id { min-width: 0; }
.rec-code { font-size: 17px; font-weight: 650; letter-spacing: .2px; font-variant-numeric: tabular-nums; line-height: 1.35; }
.rec-tags { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.rec-tags .sep { margin: 0 7px; color: var(--line-2); }
.rec-tags .v-ok { color: var(--green); }
.rec-tags .v-no { color: var(--amber); }
.rec-right { display: flex; align-items: baseline; gap: 14px; flex: none; }
.rec-state { font-size: 11.5px; color: var(--sc); font-weight: 600; white-space: nowrap; }
.rec-state i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--sc); margin-right: 6px; vertical-align: 2px; }
.rec-num { font-size: 25px; font-weight: 680; line-height: 1.15; color: var(--sc); font-variant-numeric: tabular-nums; letter-spacing: .3px; min-width: 96px; text-align: right; }
.rec-cap { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.rec-line2 { display: flex; align-items: center; gap: 18px; margin-top: 13px; }
.rec-detail { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; font-variant-numeric: tabular-nums; }
.rec-detail b { color: var(--line-2); margin: 0 7px; font-weight: 400; }
.rec-bar { flex: 1 1 100px; min-width: 60px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.rec-bar > i { display: block; height: 100%; border-radius: 4px; background: var(--sc); transition: width .5s linear; }
.rec-bar.over > i { background: repeating-linear-gradient(45deg, var(--red), var(--red) 5px, var(--red-line) 5px, var(--red-line) 10px); }
.rec-actions { display: flex; gap: 2px; flex: none; }
.act { padding: 5px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-size: 11.5px; white-space: nowrap; }
.act:hover { background: var(--accent-soft); color: var(--accent); }
.act.danger:hover { background: var(--red-soft); color: var(--red); }
.act.primary { color: var(--accent); font-weight: 600; }
/* 「结束」独立于文字操作组，放大便于点击 */
.btn-end { flex: none; margin-left: 12px; padding: 9px 20px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 650; white-space: nowrap; transition: background .16s, color .16s; }
.btn-end:hover { background: var(--accent); color: #fff; }
.btn-end:active { transform: translateY(1px); }
/* 不限时票种 */
.rec-row.is-unlimited { --sc: var(--accent); }
.rec-num.is-text { font-size: 15px; font-weight: 650; letter-spacing: 0; min-width: 0; }
.rec-bar.is-unlimited { opacity: .3; }
.empty { text-align: center; padding: 52px 20px; color: var(--text-3); }
.empty .ic { width: 34px; height: 34px; opacity: .4; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 13px; }
.list-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; padding: 12px 24px; border-top: 1px solid var(--line); font-size: 11px; color: var(--text-3); }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 22px; font-size: 11px; color: var(--text-3); }

/* ---------------- 模态框 ---------------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 20, 30, .42); z-index: 80; display: grid; place-items: center; padding: 18px; }
.modal { width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 13px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.modal-foot:empty { display: none; }
.modal textarea { min-height: 72px; resize: vertical; line-height: 1.7; }
.modal #mMethods { min-height: 210px; }
.modal-note { font-size: 12px; color: var(--text-2); background: var(--surface-2); padding: 10px 13px; border-radius: var(--radius-sm); margin: 0 0 16px; line-height: 1.75; }
.modal-note.warn { color: var(--amber); }
.modal-note.danger { color: var(--red); }
.setting-group { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.setting-group:first-child { border: 0; padding-top: 0; margin-top: 0; }
.setting-group h4 { margin: 0 0 12px; font-size: 12px; font-weight: 650; color: var(--accent); }
.setting-group h4 span { color: var(--text-3); font-weight: 400; margin-left: 6px; }
.quick-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.quick-add .btn { padding: 5px 10px; font-size: 11.5px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.user-table th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 11px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.user-table td { padding: 10px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.user-table td:first-child { color: var(--text); font-weight: 600; }
.user-table .pill { font-size: 10.5px; padding: 2px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.user-table .pill.off { background: var(--surface-2); color: var(--text-3); }
.user-table .act { padding: 4px 7px; }

/* ---------------- Toast ---------------- */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 230px; max-width: 360px; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); box-shadow: var(--shadow-lg); font-size: 12.5px; display: flex; gap: 9px; align-items: flex-start; pointer-events: auto; }
.toast.ok { border-left-color: var(--green); } .toast.err { border-left-color: var(--red); } .toast.warn { border-left-color: var(--amber); }
.toast .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--accent); }
.toast.ok .ic { color: var(--green); } .toast.err .ic { color: var(--red); } .toast.warn .ic { color: var(--amber); }
.toast strong { display: block; font-size: 12.5px; }
.toast span { color: var(--text-2); font-size: 11.5px; }

/* ---------------- 登录页 ---------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 36px 34px 30px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.login-brand .brand-mark { width: 38px; height: 38px; }
.login-card h2 { margin: 0 0 6px; font-size: 20px; font-weight: 650; }
.login-card .sub { margin: 0 0 26px; font-size: 12.5px; color: var(--text-3); }
.login-card .field { margin-bottom: 16px; }
.login-card .field > label { font-size: 12px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 7px; }
.login-card input[type="text"], .login-card input[type="password"] { padding: 10px 12px; }
.login-error { min-height: 18px; font-size: 12px; color: var(--red); margin: 2px 0 12px; }
.login-card .btn-block { margin-top: 4px; }
.login-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--text-3); text-align: center; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .app { padding: 0 24px 30px; }
  .layout { grid-template-columns: 310px minmax(0, 1fr); gap: 16px; }
  .metric { padding: 17px 20px; }
  .rec-line2 { flex-wrap: wrap; gap: 10px; }
  .rec-bar { min-width: 100%; order: 3; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .list-panel { order: 2; }
  .form-panel { order: 1; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .app { padding: 0 14px 24px; }
  .topbar { flex-wrap: wrap; gap: 14px; padding: 18px 0; }
  .brand h1 { font-size: 18px; }
  .topbar-right { gap: 10px; }
  .clock small, .vline { display: none; }
  .user-chip .u-name, .user-chip .u-role { display: none; }
  .user-chip { padding: 4px; }
  .toolbar { padding: 0 16px; }
  .tabs { gap: 14px; overflow-x: auto; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .rec-row { padding: 16px; }
  .rec-line1 { flex-wrap: wrap; gap: 8px; }
  .rec-right { width: 100%; justify-content: space-between; }
  .rec-num { min-width: 0; font-size: 22px; }
  .rec-detail { white-space: normal; }
  .rec-actions { flex-wrap: wrap; }
  .btn-end { margin-left: 0; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .chips { grid-template-columns: repeat(3, 1fr); }
  .footer { flex-direction: column; }
}
