:root {
  --bg: #0b0f14;
  --bg-elevated: #121820;
  --bg-card: #161d27;
  --border: #243041;
  --text: #e8eef7;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --success: #22c55e;
  --warn: #fbbf24;
  --danger: #f87171;
  --sidebar-w: 240px;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(59, 130, 246, 0.18), transparent),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #fff 30%, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; }

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 20px;
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h2 { font-size: 1rem; font-weight: 700; }
.sidebar-brand span { font-size: 0.75rem; color: var(--text-muted); }

.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
}

.nav-item:hover { background: var(--accent-soft); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #93c5fd; font-weight: 600; }
.nav-item.nav-admin-only { display: none; }
.nav-item.nav-admin-only.is-visible { display: flex; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); flex-shrink: 0; }

.sidebar-clocks-panel {
  padding: 0 12px 14px;
  flex-shrink: 0;
}

.sidebar-clocks-panel.is-empty {
  display: none;
}

.sidebar-clocks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-clock-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  transition: background 0.8s ease, box-shadow 0.3s ease;
}

.sidebar-clock-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.14), transparent 55%);
  pointer-events: none;
}

.sidebar-clock-left {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sidebar-clock-icon {
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-clock-name {
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-clock-time {
  position: relative;
  z-index: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.sidebar-clock-item.clock-phase-day {
  background: linear-gradient(135deg, #0c4a6e 0%, #2563eb 48%, #7dd3fc 100%);
}

.sidebar-clock-item.clock-phase-dawn {
  background: linear-gradient(135deg, #7c2d12 0%, #ea580c 42%, #fde047 100%);
}

.sidebar-clock-item.clock-phase-dusk {
  background: linear-gradient(135deg, #4c1d95 0%, #db2777 45%, #fb923c 100%);
}

.sidebar-clock-item.clock-phase-night {
  background: linear-gradient(135deg, #020617 0%, #1e1b4b 52%, #4338ca 100%);
}

.clock-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clock-setting-row label {
  margin-top: 0;
  margin-bottom: 6px;
}

.user-badge { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.user-badge strong { color: var(--text); display: block; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px 40px;
  width: calc(100vw - var(--sidebar-w));
  max-width: none;
  box-sizing: border-box;
  min-height: 100vh;
}

.view { display: none; }
.view.active {
  display: block;
  width: 100%;
  max-width: none;
}

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; margin-bottom: 6px; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; }

label { display: block; margin: 14px 0 6px; font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }

input, textarea, select, button {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.15s;
  width: auto;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #334155; color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #7f1d1d; color: #fecaca; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 14px; color: #c5d4e8; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; padding: 20px 16px; }
  .row { grid-template-columns: 1fr; }
}

.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}

.drop:hover, .drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.file-item button { width: auto; padding: 4px 12px; font-size: 0.75rem; }

.meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }
.ok { color: var(--success); }
.error { color: var(--danger); }

.preview {
  margin-top: 12px;
  max-height: 180px;
  overflow: auto;
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border);
}

.id-mode { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0; }
.id-mode label { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
.id-mode input { width: auto; }
.id-fields.hidden { display: none; }

.data-table, .detail-inline table, .result table, .detail-box table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0;
}

.table-scroll {
  overflow-x: auto;
  margin: 12px 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}

.table-scroll table { min-width: 100%; }

.data-table { margin: 10px 0 16px; }

.data-table th, .data-table td,
.detail-inline th, .detail-inline td,
.result th, .result td,
.detail-box th, .detail-box td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  vertical-align: middle;
}

.data-table th,
.detail-inline th,
.result th,
.detail-box th {
  background: var(--bg-elevated);
  color: #c5d4e8;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.detail-inline td,
.result td,
.detail-box td {
  text-align: left;
  word-break: break-word;
}

.data-table td { text-align: left; }

.lucky-files-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3),
.data-table th:nth-child(4),
.data-table td:nth-child(4),
.data-table th:nth-child(5),
.data-table td:nth-child(5),
.data-table th:nth-child(6),
.data-table td:nth-child(6),
.data-table th:nth-child(7),
.data-table td:nth-child(7) {
  text-align: center;
}

.detail-inline tr:nth-child(even) td,
.result tr:nth-child(even) td,
.detail-box tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.12);
}

.data-table tbody tr:nth-child(4n+1):not(.lucky-detail-row) td,
.data-table tbody tr:nth-child(4n+3):not(.lucky-detail-row) td {
  background: rgba(0, 0, 0, 0.08);
}

.lucky-detail-row td {
  padding: 0;
  background: var(--bg-elevated) !important;
  border-top: none;
}

.result, .detail-box {
  margin-top: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.65;
}

.result h3, .detail-box h3, .detail-inline h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  color: #aab8cc;
  font-weight: 600;
}
.result h3:first-child, .detail-box h3:first-child, .detail-inline h3:first-child { margin-top: 0; }
.result p, .detail-box p, .detail-inline p { margin: 0 0 8px; white-space: pre-wrap; }
.result code, .detail-box code, .detail-inline code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-new { background: #1e3a5f; color: #93c5fd; }
.badge-update { background: #3b2f1a; color: #fbbf24; }
.badge-admin { background: #3b1a4a; color: #e9a3ff; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; cursor: pointer; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 999;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal h3 { margin-bottom: 12px; font-size: 1.1rem; }
.modal p { color: var(--text-muted); line-height: 1.6; margin-bottom: 20px; white-space: pre-wrap; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { margin: 0; min-width: 88px; }

.lucky-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.btn-table {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 8px 14px;
  font-size: 0.82rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  width: auto;
  margin: 0;
  white-space: nowrap;
}

.btn-table-view {
  background: #334155;
  color: var(--text);
  border-color: #475569;
}
.btn-table-view:hover { background: #475569; }

.status-btn {
  min-width: 72px;
  padding: 8px 14px;
  font-size: 0.82rem;
  border-radius: 8px;
  border: 1px solid #3d4f66;
  cursor: pointer;
  font-weight: 600;
  background: #2a3544;
  color: #8b9cb3;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.status-btn:hover:not(.active) {
  background: #334155;
  color: #c5d4e8;
  border-color: #4b5f78;
}

.status-killed.active {
  background: #7c3aed;
  color: #f3e8ff;
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.35);
}

.status-waiting.active {
  background: #22c55e;
  color: #052e16;
  border-color: #4ade80;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}

.status-lost.active {
  background: #7f1d1d;
  color: #000;
  border-color: #991b1b;
  box-shadow: 0 0 0 2px rgba(127, 29, 29, 0.5);
  font-weight: 700;
}

.btn-table-delete {
  background: #991b1b;
  color: #fecaca;
  border-color: #b91c1b;
}
.btn-table-delete:hover { background: #b91c1c; }

.detail-inline {
  padding: 16px 20px;
  line-height: 1.65;
  background: var(--bg-card);
}

.detail-inline > .meta:first-child {
  margin-bottom: 8px;
}

.detail-history {
  padding-left: 20px;
  margin: 8px 0;
}

.detail-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* 滑动模拟 */
.slide-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .slide-panels { grid-template-columns: 1fr; }
}

.slide-panel .meta { margin-bottom: 12px; }

.slide-error {
  color: var(--danger);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 24px;
  text-align: center;
  border: 1px dashed #7f1d1d;
  border-radius: var(--radius);
  background: rgba(127, 29, 29, 0.15);
}

.slide-board-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.slide-board {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 0 auto;
}

.slide-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: #60a5fa;
  pointer-events: none;
  z-index: 2;
}

.slide-path {
  filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.6));
}

/* 圆点九宫格 */
.pattern-board {
  background: radial-gradient(circle at center, #1a2332 0%, #0f1419 100%);
  border: 2px solid var(--border);
  border-radius: 16px;
}

.pattern-dots {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 14px;
  z-index: 3;
}

.pattern-dot {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pattern-dot span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #334155;
  border: 2px solid #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  transition: all 0.25s ease;
}

.pattern-dot.active span,
.pattern-dot.done span {
  background: #3b82f6;
  border-color: #93c5fd;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.8);
  transform: scale(1.15);
}

.pattern-dot.current span {
  background: #22c55e;
  border-color: #bbf7d0;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.9);
  transform: scale(1.35);
}

/* 黑屏滑动模拟 */
.black-screen-board {
  background: #000;
  border: 2px solid #1e293b;
  border-radius: 12px;
  overflow: hidden;
}

.black-screen-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 600;
  color: #334155;
  letter-spacing: 0.08em;
  pointer-events: none;
  z-index: 1;
  user-select: none;
}

.black-screen-board .slide-svg {
  z-index: 2;
}

.black-screen-board .slide-path {
  color: #60a5fa;
}

/* UPI 支付检查 */
.upi-handle-list {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}

.upi-select-table {
  width: 100%;
  table-layout: auto;
  margin: 0;
}

.upi-select-table th,
.upi-select-table td {
  vertical-align: top;
  padding: 10px 12px;
  text-align: left !important;
}

.upi-select-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-elevated);
}

.upi-select-table .upi-col-cat {
  width: 160px;
  min-width: 120px;
  white-space: nowrap;
  font-weight: 600;
  color: #c5d4e8;
}

.upi-select-table .upi-col-actions {
  width: 110px;
  min-width: 90px;
  white-space: nowrap;
  text-align: center !important;
}

.upi-select-table .upi-col-handles {
  min-width: 280px;
}

.upi-select-table .btn-link {
  width: auto;
  padding: 0;
  border: none;
  background: none;
  font-weight: 500;
}

.upi-select-table .btn-link + .btn-link {
  margin-left: 10px;
}

.upi-handle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upi-handle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 5px 10px 5px 8px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.upi-handle-chip:hover {
  border-color: #475569;
}

.upi-handle-chip input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
  margin: 0;
  flex: 0 0 16px;
  border-radius: 4px;
  box-shadow: none;
  cursor: pointer;
  accent-color: var(--accent);
}

.upi-handle-chip span {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.2;
}

.upi-result-table code {
  font-size: 0.85rem;
}

.upi-result-table tr.upi-ok td:nth-child(4) {
  color: #4ade80;
  font-weight: 600;
}

.upi-result-table tr.upi-miss td:nth-child(4) {
  color: #94a3b8;
}

.upi-result-table tr.upi-err td:nth-child(4) {
  color: var(--danger);
  font-weight: 600;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  width: auto;
}

.btn-link:hover {
  text-decoration: underline;
}

.yiduan-token-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.yiduan-token-row input {
  flex: 1;
  min-width: 200px;
}

.yiduan-folder-list {
  margin-top: 12px;
  overflow-x: auto;
}

.yiduan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.yiduan-table th,
.yiduan-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.yiduan-table th {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.yiduan-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.yiduan-col-check {
  width: 44px;
  text-align: center;
}

.yiduan-col-id {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.yiduan-col-path {
  color: var(--text-muted);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
}

.yiduan-col-time {
  color: var(--text-muted);
  white-space: nowrap;
}

.compress-card {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(96, 165, 250, 0.06);
}

.compress-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(96, 165, 250, 0.45);
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.compress-toggle input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.compress-note {
  margin-top: 0;
  line-height: 1.6;
}
