:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #d7e1ed;
  --text: #10243a;
  --muted: #5b7188;
  --primary: #0e7490;
  --primary-strong: #0c6279;
  --success: #1e9f5f;
  --danger: #d65454;
  --warning: #e8a838;
  --radius: 8px;
  --radius-lg: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #0f2e45;
  color: #d8ecff;
  padding: 24px 18px;
}
.brand {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 700;
}
.nav { display: grid; gap: 8px; }
.nav a {
  text-decoration: none;
  color: #d8ecff;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
}
.nav a.active,
.nav a:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
}
.main { padding: 24px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.title { margin: 0; font-size: 26px; }
.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.logout-form { margin: 0; }
.button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
}
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.button.primary:hover { background: var(--primary-strong); }
.button.small { padding: 6px 10px; font-size: 13px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 4px 0; }
.muted { color: var(--muted); }
.metric {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
}
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f6f9fc;
  color: #35546f;
}
.auth-badge::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 999px;
  background: #9aaec2;
}
.auth-badge.connected {
  border-color: #b8e4c9;
  background: #ecf9f1;
  color: #0f6f3c;
}
.auth-badge.connected::before { background: var(--success); }
.auth-badge.disconnected {
  border-color: #f0c7c7;
  background: #fff2f2;
  color: #9a2f2f;
}
.auth-badge.disconnected::before { background: var(--danger); }
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  text-align: left;
  vertical-align: top;
}
th {
  background: #eef4fb;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #33506b;
}
tr:last-child td { border-bottom: none; }
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.pager-info { color: var(--muted); font-size: 13px; }
.pager-controls { display: flex; align-items: center; gap: 8px; }
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.completed { background: #ecf9f1; color: #0f6f3c; }
.status-badge.failed { background: #fff2f2; color: #9a2f2f; }
.status-badge.running { background: #e8f0fe; color: #1a5bbf; }
.deadline.expired { color:var(--danger); font-weight:600; }
.deadline.upcoming { color:#b36b00; font-weight:600; }
.confidence { font-weight:600; }
.confidence.high { color:var(--success); }
.confidence.medium { color:#b36b00; }
.confidence.low { color:var(--danger); }
.error-box {
  background: #fff2f2;
  border: 1px solid #f0c7c7;
  border-radius: var(--radius);
  padding: 12px;
  color: #9a2f2f;
  margin: 8px 0;
}
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}
.empty-state p { font-size: 16px; margin: 8px 0; }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 12px; }
}
