:root {
  --bg: #0b1020;
  --bg-soft: #121935;
  --panel: #161e3c;
  --panel-2: #1b2547;
  --line: #26315a;
  --text: #e8ecff;
  --muted: #93a0c9;
  --brand: #6d8cff;
  --brand-2: #9a6dff;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  background: radial-gradient(1200px 600px at 20% -10%, #1a2452 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 15px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }

.muted { color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card { width: min(400px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 16px; }

.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 18px; margin: 0; }
.brand p { margin: 2px 0 0; font-size: 13px; }

.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 12px; font-weight: 800; letter-spacing: 0.5px; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.brand.small .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }
.brand.small strong { display: block; font-size: 14px; }
.brand.small .muted { font-size: 12px; }

.version {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--brand); background: rgba(109, 140, 255, .12); border: 1px solid rgba(109, 140, 255, .35);
  vertical-align: middle;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }

input, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109, 140, 255, .18); }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform .05s, border-color .15s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: rgba(12, 17, 38, .85);
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--muted);
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }

.content { padding: 22px 28px 48px; min-width: 0; }

.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 20px; flex: 1; }
.search { max-width: 320px; }

.view { display: flex; flex-direction: column; gap: 16px; }

/* ---------- table ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(109, 140, 255, .05); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }
td.wrap-none { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2);
}
.badge.ok { color: var(--ok); border-color: rgba(52, 211, 153, .4); }
.badge.warn { color: var(--warn); border-color: rgba(251, 191, 36, .4); }
.badge.err { color: var(--err); border-color: rgba(248, 113, 113, .4); }
.badge.brand { color: var(--brand); border-color: rgba(109, 140, 255, .4); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }

.alert { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; }
.alert.error { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .4); color: #ffd7d7; }
.alert.ok { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .4); color: #cdfff0; }
.alert.info { background: rgba(109, 140, 255, .1); border-color: rgba(109, 140, 255, .35); }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- pager ---------- */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-info { color: var(--muted); font-size: 13px; padding: 0 6px; }
.pager-size { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-left: 10px; }
.pager-size select { width: auto; padding: 5px 8px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 8, 20, .68); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px; z-index: 50; animation: fade .12s ease;
}
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 4px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.checkline { display: flex; align-items: center; gap: 9px; color: var(--muted); }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 34px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: rgba(109, 140, 255, .07); }
.dropzone strong { display: block; margin-bottom: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---------- toast ---------- */
.toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); animation: fade .15s ease;
  max-width: 360px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
  display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 16px; }
  .modal .row { grid-template-columns: 1fr; }
}
