:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-soft: #475569;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --border: #e2e8f0;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, Arial, sans-serif; background: var(--surface-2); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.layout { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #e5e7eb;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; flex-direction: column; gap: 4px; margin-bottom: 28px; }
.brand h1 { font-size: 22px; margin: 0; }
.brand p { margin: 0; color: #94a3b8; font-size: 13px; }
.nav-group { margin-top: 20px; }
.nav-title { font-size: 12px; text-transform: uppercase; color: #64748b; margin: 14px 12px 10px; letter-spacing: .08em; }
.nav-link {
  display: block;
  padding: 12px 14px;
  border-radius: 14px;
  color: #e2e8f0;
  margin-bottom: 6px;
}
.nav-link:hover { background: rgba(255,255,255,.06); }
.nav-link.active { background: rgba(37,99,235,.24); border: 1px solid rgba(96,165,250,.25); }

.sidebar-footer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 24px;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 14px;
}
.sidebar-footer p { margin: 0 0 10px; color: #cbd5e1; font-size: 14px; }
.sidebar-footer form { margin: 0; }

.content { padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h2 { margin: 0; font-size: 28px; }
.topbar p { margin: 6px 0 0; color: var(--text-soft); }
.top-actions { display: flex; gap: 10px; align-items: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 18px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stat-card h3 { margin: 0 0 8px; font-size: 14px; color: var(--text-soft); font-weight: 600; }
.stat-card .value { font-size: 34px; font-weight: 700; }

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.table th, .table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th { font-size: 13px; color: var(--text-soft); font-weight: 700; }
.table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}
.badge.admin { background: #dbeafe; color: #1d4ed8; }
.badge.worker { background: #dcfce7; color: #15803d; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.off { background: #fee2e2; color: #b91c1c; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.btn-ghost {
  background: #f8fafc;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 12px 14px;
  background: white;
}
.field textarea { min-height: 140px; resize: vertical; }
.field.checkbox { flex-direction: row; align-items: center; gap: 10px; }
.field small { color: var(--text-soft); }

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.muted { color: var(--text-soft); }
.codebox {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}
pre.codebox { overflow-x: auto; }

.flash {
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-weight: 600;
}
.flash.success { background: #dcfce7; color: #166534; }
.flash.danger { background: #fee2e2; color: #991b1b; }
.flash.warning { background: #fef3c7; color: #92400e; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #dbeafe 0%, #f8fafc 40%, #eef2ff 100%);
}
.login-card {
  width: 100%;
  max-width: 460px;
  background: white;
  padding: 28px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.login-card h1 { margin: 0 0 10px; font-size: 30px; }
.login-card p { margin: 0 0 24px; color: var(--text-soft); }

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px;
}
.kv div { padding: 6px 0; border-bottom: 1px solid var(--border); }

.text-truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar-footer { position: static; margin-top: 20px; }
}
