:root {
  --bg: #0a0e17;
  --bg-grad: linear-gradient(180deg, #0a0e17 0%, #0d1220 100%);
  --surface: #121826;
  --surface-2: #1a2030;
  --surface-3: #232b3e;
  --surface-hover: #28324a;
  --border: #2a3346;
  --border-light: #34405c;
  --border-muted: #1e2638;
  --text: #e8ecf6;
  --text-secondary: #b4bccf;
  --text-muted: #7a8499;
  --text-subtle: #5c6577;
  --accent: #5b8def;
  --accent-light: #7ba5f5;
  --accent-dark: #4170d4;
  --accent-bg: rgba(91,141,239,0.10);
  --accent-bg-hover: rgba(91,141,239,0.16);
  --accent-grad: linear-gradient(135deg, #5b8def 0%, #7c6cf0 100%);
  --success: #2dd4a7;
  --success-bg: rgba(45,212,167,0.10);
  --danger: #f05a6e;
  --danger-bg: rgba(240,90,110,0.10);
  --warning: #f5b945;
  --warning-bg: rgba(245,185,69,0.10);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-xs: 5px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 24px rgba(91,141,239,0.15);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

::selection { background: var(--accent-bg); color: var(--accent-light); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

body {
  font-family: var(--font);
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; cursor: pointer; }
[v-cloak] { display: none; }

/* ===== Loading ===== */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; color: var(--text-muted); gap: 14px; }
.spinner { width: 34px; height: 34px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Login ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg-grad); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 44px 36px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent-grad); }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.02em; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 32px; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 244px; background: var(--surface); 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: 22px 20px; font-size: 16px; font-weight: 800; border-bottom: 1px solid var(--border-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 10px; letter-spacing: -0.02em; }
.sidebar-brand::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-grad); flex-shrink: 0; box-shadow: 0 0 12px rgba(91,141,239,0.5); }
.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 14px; font-weight: 500; margin-bottom: 2px; transition: var(--transition); position: relative; }
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text-secondary); }
.sidebar-nav a.active { background: var(--accent-bg); color: var(--accent-light); font-weight: 600; }
.sidebar-nav a.active::before { content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sidebar-nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border-muted); display: flex; align-items: center; justify-content: space-between; }
.user-info { color: var(--text-muted); font-size: 13px; }
.main { flex: 1; margin-left: 244px; padding: 28px 32px; min-height: 100vh; }

/* ===== Page header ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow-sm); transition: var(--transition); }
.card-header { padding: 16px 22px; border-bottom: 1px solid var(--border-muted); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }
.card-body.no-pad { padding: 0; }

/* ===== Stat cards ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; position: relative; overflow: hidden; transition: var(--transition); box-shadow: var(--shadow-sm); }
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::before { content: ""; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--accent-grad); opacity: 0.7; }
.stat-label { color: var(--text-muted); font-size: 11px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.stat-sub { color: var(--text-muted); font-size: 12px; margin-top: 6px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 12px 18px; font-size: 11px; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.8px; background: var(--surface-2); }
.table td { padding: 14px 18px; border-bottom: 1px solid var(--border-muted); font-size: 14px; transition: var(--transition); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.table tbody tr { transition: var(--transition); }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 7px; font-weight: 600; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-family: inherit; transition: var(--transition); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-subtle); }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--border-light); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-bg); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { color: var(--text-subtle); font-size: 12px; margin-top: 6px; }
.form-row { display: flex; gap: 14px; }
.form-row > .form-group { flex: 1; }
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237a8499' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition); font-family: inherit; white-space: nowrap; }
.btn:hover { background: var(--surface-3); border-color: var(--border-light); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: 0 2px 8px rgba(91,141,239,0.3); }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(91,141,239,0.4); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-success { background: var(--success); border-color: var(--success); color: #0a0e17; }
.btn-success:hover { filter: brightness(1.1); }
.btn-text { background: none; border: none; color: var(--text-muted); padding: 5px 10px; }
.btn-text:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; letter-spacing: 0.2px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: var(--surface-3); color: var(--text-muted); }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(5,8,15,0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; animation: fadeIn 0.18s ease; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border-muted); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border-muted); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Alert ===== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(240,90,110,0.3); }

/* ===== Toast ===== */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-md); backdrop-filter: blur(10px); animation: slideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); display: flex; align-items: center; gap: 8px; }
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.toast-success { border-color: rgba(45,212,167,0.3); }
.toast-success::before { background: var(--success); }
.toast-error { border-color: rgba(240,90,110,0.3); }
.toast-error::before { background: var(--danger); }
.toast-info::before { background: var(--accent); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.pagination-info { color: var(--text-muted); font-size: 13px; }
.pagination-btns { display: flex; gap: 6px; }

/* ===== Empty state ===== */
.empty { text-align: center; padding: 56px 20px; color: var(--text-muted); font-size: 14px; }
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }

/* ===== Filter bar ===== */
.filter-bar { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 18px; flex-wrap: wrap; }
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-input, .filter-bar .form-select { min-width: 140px; }

/* ===== Key display ===== */
.key-display { font-family: var(--font-mono); font-size: 13px; background: var(--surface-3); padding: 3px 9px; border-radius: var(--radius-xs); border: 1px solid var(--border-muted); }
.copy-btn { cursor: pointer; color: var(--text-muted); font-size: 12px; font-weight: 600; transition: var(--transition); }
.copy-btn:hover { color: var(--accent); }

/* ===== Chart ===== */
.chart-container { position: relative; height: 240px; }

/* ===== Tags ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 3px 9px; background: var(--surface-3); border-radius: var(--radius-xs); font-size: 12px; color: var(--text-muted); font-weight: 500; border: 1px solid var(--border-muted); transition: var(--transition); }
.tag-more { cursor: pointer; background: var(--accent-bg); color: var(--accent-light); border-color: transparent; }
.tag-more:hover { background: var(--accent); color: #fff; }

/* ===== Model management ===== */
.model-list { max-height: 400px; overflow-y: auto; }
.model-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border-muted); font-size: 13px; transition: var(--transition); }
.model-item:last-child { border-bottom: none; }
.model-item:hover { background: var(--surface-2); }

.model-mode-row { display: flex; gap: 24px; margin-bottom: 12px; }
.radio-label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 14px; color: var(--text-secondary); font-weight: 500; transition: var(--transition); }
.radio-label:hover { color: var(--text); }
.radio-label input { accent-color: var(--accent); width: 15px; height: 15px; }
.model-picker-wrap { display: flex; flex-direction: column; gap: 8px; }
.model-picker { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; display: flex; flex-direction: column; gap: 2px; background: var(--surface-2); }
.model-pick-item { padding: 7px 12px; border-radius: var(--radius-xs); cursor: pointer; font-size: 13px; transition: var(--transition); display: flex; align-items: center; gap: 8px; }
.model-pick-item:hover { background: var(--surface-3); }
.model-pick-item.active { background: var(--accent-grad); color: #fff; box-shadow: 0 2px 6px rgba(91,141,239,0.25); }
.model-pick-item.active .mono { color: #fff; }

/* ===== Misc ===== */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: var(--font-mono); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-16 { margin-top: 16px; }
.section-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

/* ===== Utility classes ===== */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cell-truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .grid-2col { grid-template-columns: 1fr; } }

/* ===== View transition ===== */
.main > * { animation: viewFade 0.22s ease; }
@keyframes viewFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Sidebar depth ===== */
.sidebar { background: linear-gradient(180deg, var(--surface) 0%, #0f1521 100%); }

/* ===== Stat value numbers ===== */
.stat-value { font-variant-numeric: tabular-nums; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .main { margin-left: 0; padding: 16px; }
}

/* ===== Model picker action bar ===== */
.model-picker-actions { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.model-picker-actions .form-hint { margin-left: auto; }
