:root {
  --ink: #202a35;
  --muted: #77838d;
  --paper: #f4f6f8;
  --surface: #fff;
  --line: #dce2e7;
  --nav: #303a43;
  --nav-deep: #26313a;
  --nav-text: #c7d0d7;
  --accent: #1679d0;
  --accent-dark: #0c63b2;
  --accent-soft: #eaf4fd;
  --green: #22876e;
  --amber: #b97724;
  --red: #b74a4a;
  --shadow: 0 10px 30px rgba(32, 48, 62, .12);
  --font-ui: 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font-family: var(--font-ui); }
body { min-height: 100dvh; font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.app { display: flex; min-height: 100dvh; }
.sidebar { flex: 0 0 214px; width: 214px; background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; min-height: 100dvh; }
.brand { height: 64px; display:flex; align-items:center; gap:10px; padding: 0 18px; background:var(--nav-deep); color:#fff; font:800 17px var(--font-display); letter-spacing:-.04em; }
.brand-mark { width:25px; height:25px; border-radius:7px; background:#1685df; color:#fff; display:grid; place-items:center; font:700 14px var(--font-display); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.brand small { display:block; font:500 9px var(--font-mono); letter-spacing:.12em; color:#9eafbd; margin-top:1px; }
.nav-caption { padding:22px 20px 8px; color:#82919d; font:500 10px var(--font-mono); text-transform:uppercase; letter-spacing:.12em; }
.nav-list { padding:0 9px; display:grid; gap:3px; }
.nav-link { display:flex; align-items:center; gap:11px; text-decoration:none; border-radius:4px; padding:10px 12px; color:#bfccd5; font-size:13px; transition:background .16s,color .16s,transform .16s; }
.nav-link:hover { background:rgba(255,255,255,.07); color:#fff; transform:translateX(2px); }
.nav-link.active { background:#48545e; color:#fff; box-shadow:inset 3px 0 #3d9bea; }
.nav-icon { width:17px; height:17px; display:grid; place-items:center; color:#aab8c2; }
.nav-icon svg { width:16px; height:16px; stroke:currentColor; fill:none; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
.sidebar-foot { margin-top:auto; padding:15px 17px; border-top:1px solid rgba(255,255,255,.08); color:#92a1ad; font-size:11px; line-height:1.55; }
.sidebar-foot strong { display:block; color:#d5dce1; font-weight:600; }
.main-shell { flex:1; min-width:0; }
.topbar { height:64px; display:flex; justify-content:flex-end; align-items:center; gap:15px; padding:0 30px; background:#fff; border-bottom:1px solid var(--line); }
.topbar-user { color:var(--muted); font-size:12px; }
.workspace { max-width:1600px; padding:31px 30px 48px; margin:0 auto; }
.page-head { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-bottom:23px; }
.page-head h1 { margin:0; font:700 26px var(--font-display); letter-spacing:-.045em; color:#25313a; }
.page-head p { margin:5px 0 0; color:var(--muted); font-size:13px; }
.actions { display:flex; align-items:center; flex-wrap:wrap; gap:9px; }
.btn { min-height:34px; border:1px solid #cdd6dd; color:#45525d; background:#fff; border-radius:4px; padding:7px 12px; font-size:12px; font-weight:600; transition:background .16s,border .16s,transform .16s; }
.btn:hover { background:#f5f8fa; border-color:#9fadb8; }
.btn:active { transform:translateY(1px); }
.btn-primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.btn-primary:hover { background:var(--accent-dark); border-color:var(--accent-dark); }
.btn-danger { border-color:#e4c3c3; color:var(--red); }
.btn-danger:hover { background:#fff5f5; border-color:#d8a0a0; }
.btn-small { min-height:28px; padding:5px 9px; font-size:11px; }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.icon-button { border:1px solid var(--line); background:#fff; color:#596772; width:33px; height:33px; border-radius:4px; display:inline-grid; place-items:center; }
.icon-button:hover { background:#f1f6fa; }
.toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; background:#fff; border:1px solid var(--line); border-bottom:0; padding:11px 12px; }
.toolbar-group { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.field, .select, .textarea { border:1px solid #cbd4db; background:#fff; border-radius:3px; min-height:34px; padding:7px 9px; color:var(--ink); outline:none; font-size:12px; width:100%; }
.field:focus, .select:focus, .textarea:focus { border-color:#58a1df; box-shadow:0 0 0 2px rgba(22,121,208,.12); }
.search-field { width:min(290px, 100%); }
.filter-field { width:145px; }
.table-wrap { background:#fff; border:1px solid var(--line); overflow-x:auto; }
table { width:100%; border-collapse:collapse; min-width:1050px; }
thead th { text-align:left; background:#394753; color:#edf2f5; font-size:11px; font-weight:600; padding:10px 11px; white-space:nowrap; border-right:1px solid rgba(255,255,255,.08); }
tbody td { border-bottom:1px solid #e7ebee; padding:10px 11px; font-size:12px; color:#45515b; vertical-align:middle; max-width:250px; }
tbody tr:hover { background:#f7fafc; }
tbody tr:last-child td { border-bottom:0; }
.cell-primary { color:#27343d; font-weight:600; }
.cell-subtle { display:block; color:#89949c; font-size:10px; margin-top:3px; }
.mono { font-family:var(--font-mono); font-size:11px; }
.badge { display:inline-flex; align-items:center; border-radius:12px; padding:4px 8px; font-size:10px; font-weight:700; white-space:nowrap; background:#edf1f4; color:#596772; }
.badge.public { background:#eaf5f0; color:#34745c; }
.badge.unverified { background:#fff4e5; color:#97621d; }
.badge.status-running,.badge.status-queued { background:#e8f3fc; color:#216b9f; }
.badge.status-failed,.badge.status-completed_with_errors { background:#fff0e8; color:#a2592d; }
.badge.status-completed { background:#eaf5f0; color:#34745c; }
.badge.status-cancelled { background:#f1eff4; color:#71677d; }
.table-footer { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 13px; background:#fff; border:1px solid var(--line); border-top:0; color:var(--muted); font-size:11px; }
.pager { display:flex; gap:6px; align-items:center; }
.pager .btn { min-height:27px; padding:4px 8px; }
.surface { border:1px solid var(--line); background:#fff; border-radius:5px; }
.stats-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:13px; margin:20px 0 24px; }
.stat-card { padding:17px 18px; border:1px solid var(--line); border-left:3px solid #388fd0; background:#fff; min-height:105px; }
.stat-label { font-size:11px; color:#75818b; text-transform:uppercase; letter-spacing:.08em; font-weight:600; }
.stat-value { font:700 27px var(--font-display); color:#26353f; letter-spacing:-.05em; margin-top:11px; }
.section-title { font:700 16px var(--font-display); letter-spacing:-.025em; margin:0; }
.section-bar { display:flex; align-items:center; justify-content:space-between; margin:25px 0 11px; gap:12px; }
.empty-state,.error-state,.loading-state { padding:42px 24px; text-align:center; border:1px dashed #cbd5dc; background:#fbfcfd; color:var(--muted); }
.empty-mark { margin:0 auto 12px; width:38px; height:38px; border:1px solid #c9d5dd; border-radius:50%; display:grid; place-items:center; color:#5382a1; font:600 15px var(--font-mono); }
.empty-state h3 { margin:0 0 6px; color:#33424c; font:700 15px var(--font-display); }
.empty-state p { margin:0 auto 16px; max-width:410px; line-height:1.55; font-size:12px; }
.error-state { border-color:#e0bcbc; color:#975050; background:#fffafa; }
.error-state p { margin:0 0 12px; }
.skeleton { height:13px; background:linear-gradient(90deg,#edf1f3 25%,#f6f8f9 50%,#edf1f3 75%); background-size:200% 100%; animation:shimmer 1.5s infinite; border-radius:3px; }
@keyframes shimmer { to { background-position:-200% 0; } }
.notice { padding:12px 14px; border:1px solid #d3e4ef; background:#f2f8fc; color:#48687b; font-size:12px; line-height:1.5; border-radius:4px; }
.notice.warn { background:#fff8eb; border-color:#f0d9ac; color:#805d24; }
.notice.error { background:#fff5f5; border-color:#e6c7c7; color:#984f4f; }
.login-screen { min-height:100dvh; display:grid; place-items:center; padding:24px; background:linear-gradient(115deg,#e8eef2 0%,#f4f6f8 54%,#e4edf2 100%); }
.login-card { width:min(430px,100%); background:#fff; border:1px solid #d8e0e5; border-top:4px solid var(--accent); box-shadow:0 16px 44px rgba(38,54,67,.12); padding:33px 34px 29px; }
.login-card .brand { background:none; color:#25313a; height:auto; padding:0; margin-bottom:27px; }
.login-card .brand-mark { height:31px; width:31px; }
.login-card h1 { margin:0; font:700 25px var(--font-display); letter-spacing:-.04em; }
.login-card .intro { margin:7px 0 23px; color:var(--muted); line-height:1.5; font-size:13px; }
.form-stack { display:grid; gap:14px; }
.form-label { display:grid; gap:6px; color:#4c5963; font-size:11px; font-weight:700; }
.form-label .field,.form-label .select,.form-label .textarea { min-height:38px; font-size:13px; }
.textarea { min-height:78px; resize:vertical; }
.login-card .btn { width:100%; margin-top:5px; min-height:39px; }
.login-foot { margin-top:21px; padding-top:16px; border-top:1px solid #e6eaed; color:#87929a; font-size:11px; line-height:1.55; }
.modal-backdrop { position:fixed; inset:0; z-index:10; background:rgba(30,43,53,.48); display:grid; place-items:center; padding:20px; animation:fade .15s ease-out; }
@keyframes fade { from { opacity:0 } to { opacity:1 } }
.modal { width:min(620px,100%); max-height:min(90dvh,900px); overflow:auto; background:#fff; border-radius:5px; box-shadow:var(--shadow); }
.modal.wide { width:min(850px,100%); }
.modal-head { position:sticky; top:0; z-index:1; display:flex; justify-content:space-between; align-items:center; background:#fff; padding:17px 21px; border-bottom:1px solid var(--line); }
.modal-head h2 { margin:0; font:700 17px var(--font-display); }
.modal-body { padding:20px 21px; }
.modal-foot { display:flex; justify-content:flex-end; gap:8px; border-top:1px solid var(--line); padding:13px 21px; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:13px; }
.form-grid .full { grid-column:1/-1; }
.helper { color:#81909a; font-size:10px; font-weight:400; }
.detail-list { display:grid; gap:7px; }
.detail-row { display:grid; grid-template-columns:145px 1fr; gap:14px; padding:10px 0; border-bottom:1px solid #e9edef; font-size:12px; }
.detail-row:last-child { border-bottom:0; }
.detail-key { color:#82909a; }
.detail-value { color:#37454f; overflow-wrap:anywhere; }
.toast { position:fixed; z-index:20; right:22px; bottom:22px; max-width:390px; padding:12px 16px; color:#fff; background:#354650; border-left:3px solid #3a9be5; box-shadow:var(--shadow); font-size:12px; animation:toast-in .2s ease-out; }
@keyframes toast-in { from { transform:translateY(8px); opacity:0 } to { transform:translateY(0); opacity:1 } }
.job-progress { width:110px; height:6px; background:#e9eef1; border-radius:5px; overflow:hidden; display:inline-block; vertical-align:middle; margin-right:6px; }
.job-progress > i { display:block; height:100%; background:#2a8ccf; }
.rule-card { padding:17px 18px; margin-bottom:12px; }
.rule-card h3 { font:700 13px var(--font-display); margin:0 0 9px; }
.rule-card p { margin:0; color:#67757e; font-size:12px; line-height:1.65; }
.rule-list { margin:0; padding-left:17px; color:#586771; font-size:12px; line-height:1.8; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.mobile-menu { display:none; }
.loading-panel { padding:20px; }
.loading-skeleton-short { width:35%; margin-bottom:16px; }
.loading-skeleton-long { width:100%; height:150px; }
.loading-skeleton-medium { width:31%; margin-bottom:15px; }
.loading-skeleton-tall { height:170px; }
.notice-gap { margin-top:22px; }
.notice-bottom { margin-bottom:14px; }
.notice-top { margin-top:14px; }
.notice-bottom-wide { margin-bottom:16px; }
.page-details-table { min-width:600px; }
.login-error { margin-bottom:12px; }
.retry-button { margin-top:16px; }
.auth-mode { display:block; min-height:100dvh; }
.auth-mode .sidebar,.auth-mode .topbar { display:none; }
.auth-mode .main-shell { min-height:100dvh; }
.auth-mode .workspace { max-width:none; padding:0; }

@media (max-width:900px) {
  .sidebar { flex-basis:184px; width:184px; }
  .workspace { padding:25px 20px 38px; }
  .topbar { padding:0 20px; }
  .stats-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:680px) {
  .app { display:block; }
  .sidebar { min-height:0; width:100%; height:auto; }
  .brand { height:56px; }
  .nav-caption,.sidebar-foot { display:none; }
  .nav-list { padding:0 8px 8px; display:flex; gap:4px; overflow-x:auto; }
  .nav-link { flex:0 0 auto; padding:8px 10px; font-size:11px; }
  .nav-icon { display:none; }
  .topbar { height:45px; padding:0 16px; }
  .workspace { padding:23px 14px 35px; }
  .page-head { display:block; }
  .page-head .actions { margin-top:14px; }
  .page-head h1 { font-size:23px; }
  .stats-grid { gap:8px; }
  .stat-card { min-height:91px; padding:13px; }
  .stat-value { font-size:23px; }
  .toolbar { align-items:stretch; }
  .toolbar-group { width:100%; }
  .search-field { width:100%; }
  .filter-field { flex:1; min-width:130px; }
  .form-grid { grid-template-columns:1fr; }
  .form-grid .full { grid-column:auto; }
  .login-card { padding:27px 23px 24px; }
  .detail-row { grid-template-columns:110px 1fr; }
  .table-footer { align-items:flex-start; flex-direction:column; }
}

.g-stats { grid-template-columns:repeat(3,minmax(0,1fr)); }
.g-form { margin-bottom:18px; }
.g-check { display:flex; gap:9px; align-items:flex-start; font-size:12px; color:#4c5963; }
.g-check input { margin-top:2px; }
.g-actions { margin-top:14px; }
.g-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:12px; }
.g-card { background:#fff; border:1px solid var(--line); border-left:3px solid #388fd0; padding:14px 16px; min-width:0; }
.g-card-head { display:flex; justify-content:space-between; gap:8px; align-items:flex-start; }
.g-card h3 { margin:0 0 6px; font:700 14px var(--font-display); overflow-wrap:anywhere; }
.g-line { margin:4px 0; font-size:12px; color:#52606a; overflow-wrap:anywhere; }
.g-attr { font-size:11px; color:#7a8791; }
.g-skel { height:120px; }
.g-more { margin-top:14px; text-align:center; }
.g-note { margin-top:12px; font-size:11px; }
.g-table { min-width:760px; }
.g-selected { background:var(--accent-soft); }
.g-refs { margin-top:14px; }
.g-ref-list { list-style:none; margin:0; padding:0; display:grid; gap:10px; }
.g-ref-row { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; overflow-wrap:anywhere; }
.g-ref-list .g-card { margin-top:8px; }
.g-setup { border-left:3px solid var(--amber); margin-bottom:16px; }
@media (max-width:680px) { .g-stats { grid-template-columns:1fr; } }
