:root {
  --ink: #0d1526;
  --ink-2: #111c33;
  --panel: #ffffff;
  --bg: #f4f6fa;
  --line: #e5eaf1;
  --text: #1e2738;
  --muted: #6b7791;
  --accent: #2563eb;
  --accent-dark: #1d4fd7;
  --teal: #0ea5a0;
  --teal-dark: #0b8b87;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
  --mono: "JetBrains Mono","SFMono-Regular",Consolas,"Courier New",monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter","Segoe UI",system-ui,-apple-system,Roboto,sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #c8d4e6; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand .logo { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.brand .logo span { color: #2dd4bf; }
.brand .tag { font-size: 10.5px; color: #7f8ca3; margin-top: 4px; font-family: var(--mono); letter-spacing: .4px; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 2px 0; border-radius: 8px;
  color: #9fb0c9; font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(45,212,191,.13); color: #fff; box-shadow: inset 3px 0 0 #2dd4bf; }
.nav .section { font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px; color: #566481; padding: 16px 12px 5px; font-weight: 600; }

.side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .role { font-family: var(--mono); font-size: 10.5px; color: #2dd4bf; letter-spacing: .6px; }
.side-foot form { margin-top: 10px; }
.side-foot button {
  width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.18);
  color: #c8d4e6; padding: 7px; border-radius: 7px; cursor: pointer; font-size: 12.5px;
}
.side-foot button:hover { background: rgba(255,255,255,.08); }

.main { flex: 1; padding: 26px 32px 40px; min-width: 0; animation: fadein .25s ease; }
.main.narrow { max-width: 780px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 5px; }

/* ---------- Cards / stats ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 14.5px; margin: 0 0 14px; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display:flex; align-items:center; gap:14px; }
.stat .ic { width: 40px; height: 40px; border-radius: 10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.stat .ic svg { width: 20px; height: 20px; }
.stat .ic.blue { background:#e7eefc; color: var(--accent); }
.stat .ic.teal { background:#e0f5f4; color: var(--teal); }
.stat .ic.gray { background:#eef1f6; color: var(--muted); }
.stat .num { font-size: 23px; font-weight: 700; font-family: var(--mono); line-height: 1.1; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover td { background: #f8fafd; }
tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
.trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num-col { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items:center; gap:4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; font-family: var(--mono); white-space: nowrap; }
.badge.ok     { background: #e5f5ec; color: var(--ok); }
.badge.warn   { background: #fdf1e0; color: var(--warn); }
.badge.danger { background: #fde8e8; color: var(--danger); }
.badge.info   { background: #e7eefc; color: var(--accent); }
.badge.gray   { background: #eef1f6; color: var(--muted); }
.badge.running::before { content:""; width:7px; height:7px; border-radius:50%; background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity:.35 } 50% { opacity:1 } }

.result-badges { display:flex; gap:5px; flex-wrap:wrap; }

/* ---------- Forms / buttons ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; margin: 15px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], select {
  width: 100%; padding: 9px 12px; border: 1px solid #d3dbe7; border-radius: 8px;
  font-size: 13.5px; background: #fff; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 13px 0; font-size: 13.5px; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check .d { color: var(--muted); font-size: 12px; margin-top: 1px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 18px; border-radius: 8px; border: none;
  font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s, box-shadow .15s; position: relative;
}
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.teal:hover { background: var(--teal-dark); }
.btn.ghost { background: #fff; border: 1px solid #d3dbe7; color: var(--text); }
.btn.ghost:hover { background: #f4f6fa; }
.btn.sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.btn.danger { background: #fde8e8; color: var(--danger); }
.btn.danger:hover { background: #fbd5d5; }
.btn:disabled { opacity: .65; cursor: default; pointer-events: none; }
.actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }

/* button spinner (added by app.js on submit) */
.btn.loading { color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.ghost.loading::after, .btn.danger.loading::after { border-color: rgba(0,0,0,.2); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Page loading overlay ---------- */
#pageLoader {
  position: fixed; inset: 0; background: rgba(244,246,250,.72);
  backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
#pageLoader.show { display: flex; }
#pageLoader .spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid #d3dbe7; border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

/* inline loader (job page first poll) */
.inline-loader { display:flex; align-items:center; gap:10px; color: var(--muted); font-size: 13px; padding: 8px 0; }
.inline-loader .spinner { width: 18px; height: 18px; border-radius:50%; border: 2px solid #d3dbe7; border-top-color: var(--accent); animation: spin .8s linear infinite; }

/* ---------- Flash ---------- */
.flash { padding: 11px 15px; border-radius: 9px; margin-bottom: 16px; font-size: 13.5px; display:flex; gap:9px; align-items:center; }
.flash.success { background: #e5f5ec; color: var(--ok); border: 1px solid #c4e8d3; }
.flash.error   { background: #fde8e8; color: var(--danger); border: 1px solid #f6c8c8; }

/* ---------- Sync progress ---------- */
.progress-wrap { background: #e9edf4; border-radius: 20px; height: 12px; overflow: hidden; margin: 14px 0 10px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), #2dd4bf); width: 0%; transition: width .4s; border-radius: 20px; }
.console {
  background: var(--ink); color: #b9e6dd; border-radius: var(--radius);
  padding: 14px 16px; font-family: var(--mono); font-size: 12px; line-height: 1.8;
  max-height: 380px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

/* ---------- Pagination ---------- */
.pager { display:flex; gap:6px; margin-top:16px; align-items:center; flex-wrap: wrap; }
.pager a, .pager span.cur, .pager span.dots {
  min-width: 32px; height: 32px; padding: 0 9px; display:inline-flex; align-items:center; justify-content:center;
  border-radius: 7px; font-size: 12.5px; font-weight: 600; font-family: var(--mono);
}
.pager a { border: 1px solid #d3dbe7; background:#fff; color: var(--text); }
.pager a:hover { background: #f4f6fa; }
.pager span.cur { background: var(--accent); color: #fff; }
.pager span.dots { color: var(--muted); }
.pager .info { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 520px at 72% -12%, #1b3a63 0%, var(--ink) 58%);
}
.login-card { width: 384px; background: var(--panel); border-radius: 16px; padding: 34px 32px; box-shadow: 0 24px 60px rgba(0,0,0,.42); }
.login-card .logo { font-size: 21px; font-weight: 800; }
.login-card .logo span { color: var(--teal); }
.login-card .tag { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }

.empty { color: var(--muted); padding: 30px 10px; text-align: center; font-size: 13.5px; }

/* ---------- Upload dropzone ---------- */
.dropzone {
  border: 1.5px dashed #ccd5e3; border-radius: 12px; padding: 28px 20px;
  text-align: center; background: #f9fafc; transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: #eef3fb; }
.dropzone .dz-text { font-size: 13px; color: var(--muted); margin: 10px 0 12px; }
.dropzone .dz-selected { margin-top: 12px; font-size: 12.5px; color: var(--text); font-weight: 600; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .main { padding: 18px 16px 32px; }
  .trunc { max-width: 180px; }
}
