:root {
  --brand: #16558f; --brand-600: #124a7d; --brand-50: #eef4fb; --brand-100: #dbe8f6;
  --bg: #f4f6fa; --surface: #ffffff; --line: #e6eaf0; --line-2: #eef1f5;
  --text: #0f1b2d; --text-2: #475467; --muted: #8a94a6;
  --green: #12b76a; --green-50: #ecfdf3; --red: #f04438; --red-50: #fef3f2; --amber: #f79009; --amber-50: #fffaeb;
  --indigo: #6172f3; --indigo-50: #eef4ff; --slate-50: #f2f4f7;
  --radius: 14px; --shadow-xs: 0 1px 2px rgba(16,24,40,.05); --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 20px 40px -12px rgba(16,24,40,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "JetBrains Mono", Consolas, monospace; }
.w-full { width: 100%; justify-content: center; }
a { color: var(--brand); cursor: pointer; text-decoration: none; }
.link { font-size: 13px; font-weight: 600; }
.link:hover { text-decoration: underline; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head p { margin: 2px 0 0; font-size: 13px; }

/* ---------- Sidebar ---------- */
.side { width: 256px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; padding: 0 14px; }
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 8px 20px; border-bottom: 1px solid var(--line-2); margin-bottom: 10px; }
.brand-logo { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.brand b { font-size: 17px; letter-spacing: -.2px; color: var(--brand); display: block; }
.brand small { color: var(--muted); font-size: 12px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 14px 10px 6px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--text-2); padding: 9px 12px; border-radius: 10px; display: flex; align-items: center; gap: 11px; font-weight: 500; transition: background .15s, color .15s; }
nav a:hover { background: var(--slate-50); color: var(--text); }
nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
nav a.active .i { stroke: var(--brand); }
nav a .i.ext { width: 14px; height: 14px; margin-left: auto; opacity: .5; }
.nav-count { margin-left: auto; background: var(--brand); color: #fff; border-radius: 20px; padding: 0 8px; font-size: 11px; font-weight: 600; line-height: 19px; }
.nav-count:empty, .nav-count[data-zero] { display: none; }
.nav-count.green { background: var(--green); }
.side-foot { margin-top: auto; padding: 16px 8px; border-top: 1px solid var(--line-2); font-size: 13px; }
.conn { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(18,183,106,.18); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 18px 32px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; gap: 16px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.status-chip { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--slate-50); color: var(--text-2); border: 1px solid var(--line); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-chip.working { background: var(--green-50); color: #067647; border-color: #abefc6; }
.status-chip.working .status-dot { background: var(--green); animation: pulse 1.4s infinite; }
.status-chip.schedule, .status-chip.idle { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }
.status-chip.schedule .status-dot, .status-chip.idle .status-dot { background: var(--brand); }
.status-chip.login, .status-chip.limit, .status-chip.error { background: var(--amber-50); color: #b54708; border-color: #fedf89; }
.status-chip.login .status-dot, .status-chip.limit .status-dot, .status-chip.error .status-dot { background: var(--amber); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18,183,106,.5); } 100% { box-shadow: 0 0 0 8px rgba(18,183,106,0); } }
main { padding: 26px 32px 48px; }
.page { display: none; animation: fade .25s; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow-xs); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2-1 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2-1 > .card, .grid-3 > .card { margin-bottom: 20px; }
.notice { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-radius: 12px; margin-bottom: 20px; font-weight: 500; background: var(--amber-50); color: #b54708; border: 1px solid #fedf89; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 14px; transition: box-shadow .2s, transform .2s; }
.kpi:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.kpi-ic .i { width: 20px; height: 20px; }
.kpi-ic.blue { background: var(--brand-50); color: var(--brand); }
.kpi-ic.indigo { background: var(--indigo-50); color: var(--indigo); }
.kpi-ic.red { background: var(--red-50); color: var(--red); }
.kpi-ic.green { background: var(--green-50); color: var(--green); }
.kpi-ic.amber { background: var(--amber-50); color: var(--amber); }
.kpi-ic.slate { background: var(--slate-50); color: var(--text-2); }
.kpi-body small { color: var(--text-2); font-weight: 500; font-size: 13px; display: block; }
.kpi-body b { font-size: 28px; font-weight: 700; letter-spacing: -.8px; display: block; line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpi-body span { font-size: 12px; color: var(--muted); }
.t-red { color: var(--red); } .t-green { color: var(--green); } .t-amber { color: var(--amber); }

.big-pct { font-size: 26px; font-weight: 700; color: var(--brand); letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.bar { height: 12px; background: var(--slate-50); border-radius: 99px; overflow: hidden; display: flex; margin: 4px 0 12px; }
.bar i { display: block; height: 100%; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar.thin { height: 6px; margin: 14px 0 12px; }
.g { background: var(--green); } .r { background: var(--red); } .a { background: var(--amber); }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--line); vertical-align: -1px; }
.legend i.g { background: var(--green); } .legend i.r { background: var(--red); } .legend i.a { background: var(--amber); }
.stat-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--brand); background: var(--brand-50); padding: 6px 12px; border-radius: 99px; }
.stat-inline .i { width: 15px; height: 15px; }
.chart-box { position: relative; height: 240px; }
.chart-box.donut { height: 190px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center b { font-size: 26px; letter-spacing: -.6px; }
.donut-center small { color: var(--muted); font-size: 12px; }
.pie-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 16px; }
.pie-legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.pie-legend i { width: 10px; height: 10px; border-radius: 3px; }
.pie-legend b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }

.current { font-size: 13px; color: var(--text-2); }
.current .q { font-size: 20px; font-weight: 700; color: var(--text); font-family: "JetBrains Mono", Consolas, monospace; margin: 4px 0; letter-spacing: -.3px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: #067647; background: var(--green-50); padding: 3px 10px; border-radius: 99px; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 1.4s infinite; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mini-stats small { color: var(--muted); display: block; font-size: 12px; }
.mini-stats b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.4px; }

.log { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; max-height: 240px; overflow: auto; }
.log.tall { max-height: calc(100vh - 190px); }
.log div { padding: 7px 4px; border-bottom: 1px solid var(--line-2); display: flex; gap: 12px; }
.log .t { color: var(--muted); flex-shrink: 0; }
.log .error { color: var(--red); } .log .warn { color: #b54708; } .log .ok { color: #067647; } .log .found { color: var(--red); font-weight: 600; }
.log .info { color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; font: 600 13.5px/1 Inter, system-ui, sans-serif; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--text-2); border: 1px solid #d0d5dd; box-shadow: var(--shadow-xs); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; }
.btn .i { width: 16px; height: 16px; }
.btn:hover { background: #f9fafb; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-100); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #079455; border-color: #079455; color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #d92d20; border-color: #d92d20; color: #fff; }
.btn-danger-soft { color: var(--red); border-color: #fecdca; }
.btn-danger-soft:hover { background: var(--red-50); color: #b42318; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--slate-50); }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.actions.end { justify-content: flex-end; }

/* ---------- Forms ---------- */
input, select { width: 100%; height: 42px; background: var(--surface); color: var(--text); border: 1px solid #d0d5dd; border-radius: 10px; padding: 0 12px; font: inherit; margin-top: 6px; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-100); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 4px 0 18px; }
.form-grid.four { grid-template-columns: repeat(4, 1fr); }
.form-grid label, .lbl { font-size: 13px; color: var(--text-2); font-weight: 500; display: block; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: var(--text-2); font-size: 13.5px; }
.switch input { display: none; }
.switch span { width: 40px; height: 22px; background: #d0d5dd; border-radius: 20px; position: relative; flex-shrink: 0; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(16,24,40,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { left: 20px; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 48px 20px; border: 1.5px dashed #c5cdd8; border-radius: 12px; cursor: pointer; text-align: center; transition: .2s; background: #fbfcfe; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-50); }
.drop u { color: var(--brand); font-weight: 600; text-decoration: none; }
.drop-ic { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; margin-bottom: 8px; box-shadow: 0 0 0 8px #f5f9fd; }
.drop-ic .i { width: 22px; height: 22px; }
.file-chip { display: flex; gap: 12px; align-items: center; }
.file-chip > .i { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--green-50); color: var(--green); }
.file-chip small { display: block; }

.table-wrap { overflow: auto; max-height: 440px; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
th { background: #f9fafb; position: sticky; top: 0; font-weight: 600; color: var(--text-2); font-size: 12px; }
tr:hover td { background: #fafbfc; }
th.sel { background: var(--brand-50); color: var(--brand); }
td.sel { background: rgba(22,85,143,.04); font-weight: 600; color: var(--brand); }
td.wrap { white-space: normal; min-width: 260px; color: var(--text-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--slate-50); color: var(--text-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.found { background: var(--red-50); color: #b42318; } .pill.clean { background: var(--green-50); color: #067647; }
.pill.error { background: var(--amber-50); color: #b54708; } .pill.pending, .pill.skip { color: var(--muted); }
.pill.running { background: var(--green-50); color: #067647; } .pill.done { background: var(--brand-50); color: var(--brand); } .pill.paused { background: var(--amber-50); color: #b54708; } .pill.queued { background: var(--indigo-50); color: #3538cd; }

/* ---------- Jobs ---------- */
.job-list { display: flex; flex-direction: column; gap: 16px; }
.job { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-xs); transition: box-shadow .2s; }
.job:hover { box-shadow: var(--shadow); }
.job-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.job-title { display: flex; gap: 14px; align-items: flex-start; }
.job-title > .i { width: 42px; height: 42px; padding: 10px; border-radius: 10px; background: var(--brand-50); color: var(--brand); }
.job-title h3 { font-size: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.job-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.job-meta b { color: var(--text-2); font-weight: 600; }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.job-nums { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.job-nums div { background: #f9fafb; border-radius: 10px; padding: 10px 14px; }
.job-nums small { display: block; font-size: 12px; color: var(--muted); }
.job-nums b { font-size: 18px; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 64px 20px; }
.empty .drop-ic { margin: 0 auto 14px; }
.empty h3 { margin-bottom: 4px; }

.days { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 18px; }
.days label { min-width: 58px; text-align: center; padding: 9px 12px; border: 1px solid #d0d5dd; border-radius: 10px; cursor: pointer; user-select: none; font-weight: 600; color: var(--text-2); font-size: 13px; transition: .15s; }
.days input { display: none; }
.days label.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.timeline { position: relative; height: 40px; background: repeating-linear-gradient(90deg, var(--slate-50) 0 calc(100%/24 - 1px), var(--line) calc(100%/24 - 1px) calc(100%/24)); border-radius: 10px; margin: 8px 0 28px; }
.timeline .win { position: absolute; top: 4px; bottom: 4px; background: linear-gradient(180deg, #4b8ac4, var(--brand)); border-radius: 7px; opacity: .9; }
.timeline .now { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--red); border-radius: 2px; }
.timeline .now::before { content: ""; position: absolute; top: -4px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.timeline .h { position: absolute; bottom: -22px; font-size: 11px; color: var(--muted); transform: translateX(-50%); }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,27,45,.45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 24px; animation: fade .15s; }
.modal-box { background: var(--surface); border-radius: 16px; width: min(1200px, 100%); max-height: 90vh; display: flex; flex-direction: column; padding: 22px 24px; box-shadow: var(--shadow-lg); }
.modal-box.sm { width: min(460px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 17px; }
.modal-body { overflow: auto; margin-top: 16px; }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-list .btn { justify-content: flex-start; height: 44px; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; background: var(--slate-50); padding: 3px; border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font: 600 13px Inter, sans-serif; color: var(--text-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.search { position: relative; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; }
.search input { margin: 0; padding-left: 36px; width: 260px; height: 38px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }

#toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 99; }
.toast { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px; max-width: 400px; box-shadow: var(--shadow-lg); animation: tin .25s; font-weight: 500; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex-shrink: 0; }
.toast.err::before { background: var(--red); } .toast.ok::before { background: var(--green); }
@keyframes tin { from { transform: translateY(12px); opacity: 0; } }

.login { position: fixed; inset: 0; background: radial-gradient(circle at 30% 20%, var(--brand-50), var(--bg) 60%); display: grid; place-items: center; z-index: 100; }
.login-card { width: 360px; background: #fff; padding: 36px 32px; border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; text-align: center; border: 1px solid var(--line); }
.login-logo { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto; }
.login-card h2 { margin: 6px 0 0; color: var(--brand); }
.login-card p { margin: 0 0 8px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(3, 1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } .job-nums { grid-template-columns: repeat(3, 1fr); } .form-grid.four { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  body { flex-direction: column; } .side { width: 100%; height: auto; position: static; padding: 0 12px; }
  nav { flex-direction: row; overflow-x: auto; } .nav-label, .side-foot { display: none; } .brand { padding: 14px 8px; }
  main, .topbar { padding-left: 16px; padding-right: 16px; } .grid-2-1, .grid-3, .form-grid, .form-grid.four { grid-template-columns: 1fr; } .kpis { grid-template-columns: 1fr 1fr; }
}
