:root {
  --bg: #0b1220;
  --bg-soft: #111827;
  --sidebar: #0f172a;
  --sidebar-border: rgba(148,163,184,.12);
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-inv: #e2e8f0;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: rgba(37,99,235,.12);
  --success: #059669;
  --success-soft: rgba(5,150,105,.12);
  --warning: #d97706;
  --warning-soft: rgba(217,119,6,.12);
  --danger: #dc2626;
  --danger-soft: rgba(220,38,38,.12);
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--text); background: #eef2f7; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* Auth / Install */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37,99,235,.35), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(14,165,233,.25), transparent 55%),
    linear-gradient(160deg, #0b1220, #111827 45%, #0f172a);
}
.auth-shell { width: min(440px, 92vw); }
.install-shell { width: min(560px, 94vw); }
.auth-card {
  background: rgba(255,255,255,.96);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  backdrop-filter: blur(12px);
}
.auth-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff; font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 8px 20px rgba(37,99,235,.4);
}
.auth-brand h1 { margin: 0; font-size: 22px; }
.auth-brand p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }

/* Layout */
.app-layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  color: var(--text-inv);
  border-right: 1px solid var(--sidebar-border);
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.side-brand {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 10px 22px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 16px;
}
.side-brand h2 { margin: 0; font-size: 15px; font-weight: 700; color: #fff; }
.side-brand span { font-size: 11px; color: #94a3b8; }
.nav-group { font-size: 11px; color: #64748b; letter-spacing: .08em; text-transform: uppercase; padding: 12px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px;
  color: #cbd5e1; margin-bottom: 4px; transition: .15s ease;
}
.nav-item:hover { background: rgba(148,163,184,.1); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(37,99,235,.35), rgba(37,99,235,.08));
  color: #fff; box-shadow: inset 3px 0 0 #3b82f6;
}
.nav-item .ico {
  width: 20px; text-align: center; opacity: .9;
}
.side-foot {
  margin-top: auto; padding: 14px 10px 6px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 12px; color: #64748b;
}

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 6px 10px 6px 6px; border-radius: 999px; font-size: 13px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg,#2563eb,#06b6d4);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.content { padding: 24px 28px 40px; }

/* Cards / Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 16px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--primary-soft);
}
.stat-card .label { color: var(--text-muted); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat-card .sub { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.stat-card.success::after { background: var(--success-soft); }
.stat-card.warning::after { background: var(--warning-soft); }
.stat-card.danger::after { background: var(--danger-soft); }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.panel-hd h3 { margin: 0; font-size: 15px; }
.panel-bd { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

/* Forms */
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: #fff; color: var(--text);
  transition: border .15s, box-shadow .15s;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.divider {
  margin: 8px 0 0; padding-top: 12px; border-top: 1px dashed var(--border);
  font-size: 12px; color: var(--text-muted); font-weight: 600;
}
.mysql-fields { display: grid; gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 13px;
  transition: .15s ease; background: #fff; color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #0ea5e9); color: #fff; box-shadow: 0 8px 18px rgba(37,99,235,.28); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: #fff; border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Table */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search {
  flex: 1; min-width: 200px; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; background: #fff;
}
.table-wrap { overflow: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle;
}
table.data th { color: var(--text-muted); font-weight: 600; background: #f8fafc; position: sticky; top: 0; }
table.data tr:hover td { background: #f8fafc; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #f1f5f9; color: #64748b; }
.badge-info { background: var(--primary-soft); color: var(--primary); }

/* Progress */
.progress {
  height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden;
}
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #06b6d4); }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  width: min(640px, 100%); background: #fff; border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,.3); max-height: 90vh; overflow: auto;
}
.modal-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-hd h3 { margin: 0; font-size: 16px; }
.modal-bd { padding: 18px; }
.modal-ft {
  padding: 14px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; background: #f8fafc;
}

/* Alerts / Toast */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.alert-danger { background: var(--danger-soft); color: #991b1b; }
.alert-success { background: var(--success-soft); color: #065f46; }
.alert-info { background: var(--primary-soft); color: #1e40af; }
.toast-wrap {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: grid; gap: 8px;
}
.toast {
  background: #0f172a; color: #fff; padding: 12px 14px; border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); font-size: 13px; min-width: 220px;
  animation: slideIn .2s ease;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px);} to { opacity:1; transform:none;} }

.hint { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.mt-16 { margin-top: 16px; }
.empty {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty .big { font-size: 40px; margin-bottom: 8px; opacity: .4; }

.cover-thumb {
  width: 64px; height: 40px; object-fit: cover; border-radius: 6px; background: #e2e8f0;
}
.check-list {
  display: grid; gap: 8px; max-height: 220px; overflow: auto;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.check-list label {
  display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text);
  padding: 6px 8px; border-radius: 8px;
}
.check-list label:hover { background: #f8fafc; }

.chart-bars {
  display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px;
}
.chart-bars .bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%;
}
.chart-bars .bars {
  flex: 1; width: 100%; display: flex; align-items: flex-end; gap: 3px;
}
.chart-bars .b {
  flex: 1; border-radius: 4px 4px 0 0; min-height: 2px;
}
.chart-bars .b.ok { background: #34d399; }
.chart-bars .b.fail { background: #f87171; }
.chart-bars .lbl { font-size: 11px; color: var(--text-muted); }

.upload-box {
  border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 18px;
  text-align: center; background: #f8fafc; cursor: pointer; transition: .15s;
}
.upload-box:hover { border-color: #93c5fd; background: #eff6ff; }
.upload-box strong { display: block; margin-bottom: 4px; }

.timeline { display: grid; gap: 12px; }
.timeline-item {
  display: grid; grid-template-columns: 12px 1fr; gap: 12px;
}
.timeline-item .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--primary); margin-top: 5px;
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.timeline-item .meta { font-size: 12px; color: var(--text-muted); }
.timeline-item .txt { font-size: 13px; margin-top: 2px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -280px; z-index: 50; transition: .2s; width: 260px; }
  .sidebar.open { left: 0; }
  .form-row { grid-template-columns: 1fr; }
}
