:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #101828;
  --muted: #667085;
  --line: #dfe7f1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #079455;
  --success-soft: #ecfdf3;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warning: #dc6803;
  --warning-soft: #fffaeb;
  --sidebar: #0b1220;
  --sidebar-soft: #111c31;
  --shadow: 0 20px 55px rgba(16, 24, 40, .08);
  --radius: 8px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #f9fbff 0%, var(--bg) 42%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 260px;
  display: flex;
  flex-direction: column;
  color: #cbd5e1;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, .12), transparent 34%),
    var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 82px;
  padding: 20px;
}

.sidebar-brand strong {
  color: #ffffff;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: .01em;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #38bdf8, var(--primary));
  font-weight: 800;
  box-shadow: 0 16px 32px rgba(37, 99, 235, .28);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 12px;
}

.sidebar-section {
  display: block;
  padding: 10px 10px 12px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.nav-item,
.logout-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 13px;
  border-radius: var(--radius);
  color: #9fb0c8;
  font-weight: 650;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.nav-item:hover,
.logout-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, .07);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  box-shadow: 0 12px 28px rgba(37, 99, 235, .32);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: inherit;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}

.nav-item.active .nav-icon {
  background: transparent;
}

.sidebar-footer {
  padding: 16px 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 6px 12px;
  color: #8da2c0;
  font-size: 12px;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, .12);
}

.main-content {
  width: calc(100% - 260px);
  margin-left: 260px;
  padding: 34px clamp(24px, 3vw, 48px) 48px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
  color: #0f172a;
  font-size: clamp(25px, 2vw, 34px);
  line-height: 1.15;
  letter-spacing: 0;
}

.page-header p {
  margin: 8px 0 0;
  max-width: 780px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card,
.card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(223, 231, 241, .96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 142px;
  padding: 18px;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto 16px 14px auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--primary-soft);
}

.stat-card.success::after {
  background: var(--success-soft);
}

.stat-card.danger::after {
  background: var(--danger-soft);
}

.stat-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 12px;
  color: #0f172a;
  font-size: 34px;
  font-weight: 850;
  line-height: 1;
}

.stat-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .9fr);
  gap: 20px;
}

.card {
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.card-header h2 {
  margin: 0;
  color: #0f172a;
  font-size: 16px;
  line-height: 1.2;
}

.card-body {
  padding: 20px;
}

.panel-list {
  display: grid;
  gap: 12px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  flex: 0 0 auto;
}

.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(7, 148, 85, .1);
}

.status-dot.warn {
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(220, 104, 3, .12);
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #1f2937;
  background: #ffffff;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.15;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .24);
}

.btn-primary:hover {
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(37, 99, 235, .3);
}

.btn-outline {
  color: #344054;
  border-color: var(--line);
  background: #ffffff;
}

.btn-outline:hover {
  color: #111827;
  border-color: #b8c5d8;
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
}

.btn-ghost:hover {
  color: #111827;
  background: var(--surface-soft);
}

.btn-danger {
  color: #ffffff;
  background: var(--danger);
}

.btn-sm {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
}

.btn-xs {
  min-width: 32px;
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(255, 255, 255, .18);
}

.btn-outline .btn-icon,
.btn-ghost .btn-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 650;
}

.alert-success {
  color: #067647;
  border: 1px solid #abefc6;
  background: var(--success-soft);
}

.alert-error {
  color: #b42318;
  border: 1px solid #fecdca;
  background: var(--danger-soft);
}

.alert-warning {
  color: #b54708;
  border: 1px solid #fedf89;
  background: var(--warning-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 0;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.badge-success {
  color: #067647;
  background: var(--success-soft);
}

.badge-muted {
  color: #475467;
  background: #eef2f6;
}

.badge-primary {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}

.form-control {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #cfd8e6;
  border-radius: var(--radius);
  color: #101828;
  background: #ffffff;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.form-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.inline-panel {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
}

.toggle input {
  width: 0;
  height: 0;
  opacity: 0;
}

.toggle .slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c8d2df;
  cursor: pointer;
  transition: background .16s ease;
}

.toggle .slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(16, 24, 40, .22);
  transition: transform .16s ease;
}

.toggle input:checked + .slider {
  background: var(--success);
}

.toggle input:checked + .slider::before {
  transform: translateX(18px);
}

.job-row {
  border-left: 3px solid transparent;
}

.job-row.is-editing {
  border-color: var(--primary);
}

.job-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.job-title strong {
  display: block;
}

.job-meta {
  color: var(--muted);
  font-size: 13px;
}

.job-properties {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 236px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #cfd8e6;
  border-radius: var(--radius);
  background: #ffffff;
}

.checkbox-grid label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 8px;
  border-radius: var(--radius);
  color: #344054;
  cursor: pointer;
}

.checkbox-grid label:hover {
  background: var(--surface-soft);
}

.checkbox-grid input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

thead th {
  padding: 12px 14px;
  color: #475467;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfdff;
}

code {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  color: #1d4ed8;
  background: var(--primary-soft);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.empty-state {
  padding: 48px 22px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 850;
}

.text-sm {
  font-size: 13px;
}

.text-muted {
  color: var(--muted);
}

.text-xs {
  font-size: 12px;
}

.font-semibold {
  font-weight: 750;
}

.mt-2 {
  margin-top: 12px;
}

.mt-3 {
  margin-top: 20px;
}

.w-full {
  width: 100%;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #08111f 0%, #0f2442 56%, #133b55 100%);
}

.login-card {
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: var(--radius);
  color: #ffffff;
  background: rgba(15, 23, 42, .78);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .32);
  backdrop-filter: blur(18px);
}

.login-card h1 {
  margin: 0;
  font-size: 30px;
}

.login-card .subtitle {
  margin: 6px 0 24px;
  color: #a9bad2;
}

.login-card label {
  display: block;
  margin: 14px 0 7px;
  color: #dbe7f5;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--radius);
  color: #ffffff;
  background: rgba(255, 255, 255, .08);
  outline: none;
}

.login-card input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .16);
}

.login-card button {
  width: 100%;
  min-height: 44px;
  margin-top: 22px;
  border: 0;
  border-radius: var(--radius);
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  font-weight: 800;
  cursor: pointer;
}

.login-error {
  margin-bottom: 18px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: #fecaca;
  background: rgba(217, 45, 32, .14);
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .sidebar {
    width: 82px;
  }

  .sidebar-brand {
    justify-content: center;
    padding-inline: 12px;
  }

  .sidebar-brand strong,
  .sidebar-section,
  .nav-item span:last-child,
  .logout-link span:last-child,
  .sidebar-status {
    display: none;
  }

  .nav-item,
  .logout-link {
    justify-content: center;
  }

  .main-content {
    width: calc(100% - 82px);
    margin-left: 82px;
    padding: 24px 16px 36px;
  }

  .page-header,
  .card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

@media (max-width: 560px) {
  .sidebar {
    position: fixed;
    top: auto;
    right: 0;
    width: auto;
    height: 72px;
    flex-direction: row;
    border-right: 0;
    border-top: 1px solid rgba(255, 255, 255, .08);
  }

  .sidebar-brand,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    padding: 10px;
  }

  .nav-item {
    min-height: 50px;
    margin: 0;
    padding: 8px;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding-bottom: 94px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
