:root {
  color-scheme: light;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color: #0f172a;
  background-color: #f1f5f9;
  --sidebar-width: 264px;
  --border-color: #e2e8f0;
  --card-background: #ffffff;
  --primary-gradient: linear-gradient(135deg, #6366f1, #3b82f6);
  --primary-color: #3b82f6;
  --primary-dark: #1d4ed8;
  --text-muted: #64748b;
  --shadow-lg: 0 24px 60px -32px rgba(15, 23, 42, 0.45);
  --shadow-md: 0 12px 40px -24px rgba(15, 23, 42, 0.4);
  --transition-base: 0.18s ease;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: #f1f5f9;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-weight: 600;
  color: #0f172a;
}

p {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

.label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background-color: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 24px;
  transition: transform var(--transition-base);
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
  color: #f8fafc;
}

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  color: rgba(226, 232, 240, 0.85);
  font-size: 14px;
  transition: background-color var(--transition-base), color var(--transition-base);
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--primary-gradient);
  color: #f8fafc;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.6);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
  display: none;
}

body.drawer-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

.content-area {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #f1f5f9;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
  padding: 18px 32px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 20;
}

.menu-trigger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background-color: #f8fafc;
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.menu-trigger:hover {
  background-color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.6);
}

.menu-trigger span {
  display: block;
  width: 18px;
  height: 2px;
  background-color: #1e293b;
  border-radius: 999px;
  transition: transform 0.2s ease;
}

.menu-trigger span + span {
  margin-top: 4px;
}

body.drawer-open .menu-trigger span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

body.drawer-open .menu-trigger span:nth-child(2) {
  opacity: 0;
}

body.drawer-open .menu-trigger span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.top-bar-context {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.top-bar-title {
  font-size: 20px;
  font-weight: 600;
  color: #1e293b;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.top-bar-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 140px;
}

.top-bar-user-name {
  font-size: 14px;
  color: #0f172a;
}

.top-bar-user-email,
.top-bar-user-role {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.top-bar-user-role {
  text-transform: capitalize;
}

.top-bar-avatar {
  width: 40px;
  height: 40px;
  font-size: 16px;
  flex-shrink: 0;
}

.top-bar-logout {
  white-space: nowrap;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.main-content {
  flex: 1;
  padding: 32px 36px 48px;
  width: min(1100px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 26px;
  font-weight: 600;
  color: #0f172a;
}

.page-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 24px;
  align-items: start;
}

.card {
  background-color: var(--card-background);
  border-radius: 18px;
  padding: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 18px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  font-weight: 500;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color var(--transition-base), border-color var(--transition-base);
  padding: 0 16px;
}

.btn-sm {
  height: 36px;
  font-size: 13px;
}

.btn-md {
  height: 42px;
  font-size: 14px;
}

.btn-lg {
  height: 48px;
  font-size: 15px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #f8fafc;
  box-shadow: 0 8px 18px -10px rgba(99, 102, 241, 0.6);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -12px rgba(59, 130, 246, 0.7);
}

.btn-secondary {
  background-color: #e2e8f0;
  color: #1e293b;
}

.btn-secondary:hover {
  background-color: #cbd5f5;
}

.btn-ghost {
  background-color: transparent;
  color: #475569;
}

.btn-ghost:hover {
  background-color: rgba(148, 163, 184, 0.14);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  height: 28px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  background-color: rgba(99, 102, 241, 0.12);
  color: #3730a3;
}

.badge-muted {
  background-color: rgba(148, 163, 184, 0.18);
  color: #475569;
}

.badge-outline {
  border: 1px solid rgba(99, 102, 241, 0.3);
  background-color: transparent;
  color: #4338ca;
}

.badge-positive {
  background-color: rgba(34, 197, 94, 0.18);
  color: #047857;
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.18);
  color: #b45309;
}

.list {
  display: grid;
  gap: 14px;
}

.list-item {
  background-color: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  padding: 18px 20px;
  display: grid;
  gap: 12px;
}

.list-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.list-item-title {
  font-size: 16px;
  font-weight: 600;
}

.list-item-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.list-item-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background-color: rgba(14, 165, 233, 0.18);
  color: #0ea5e9;
  font-size: 12px;
}

.chip-danger {
  background-color: rgba(248, 113, 113, 0.2);
  color: #b91c1c;
}

.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.metric-value {
  font-size: 28px;
  font-weight: 600;
}

.metric-trend {
  font-size: 12px;
  color: #0f766e;
}

.metric-trend-negative {
  color: #b91c1c;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 26px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-pill-idle {
  background-color: rgba(148, 163, 184, 0.2);
  color: #475569;
}

.status-pill-tested {
  background-color: rgba(34, 197, 94, 0.2);
  color: #047857;
}

.status-pill-error {
  background-color: rgba(248, 113, 113, 0.2);
  color: #b91c1c;
}

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.form-field input,
.form-field select,
.form-field textarea {
  border-radius: 10px;
  border: 1px solid #cbd5f5;
  padding: 10px 12px;
  font: inherit;
  background-color: #ffffff;
  color: #0f172a;
}

.form-field textarea {
  min-height: 110px;
  resize: vertical;
}

.form-helper {
  font-size: 12px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.search-input {
  height: 36px;
  border-radius: 999px;
  border: 1px solid #cbd5f5;
  padding: 0 14px;
  font-size: 14px;
  background-color: #ffffff;
}

.banner {
  border-radius: 16px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(129, 140, 248, 0.12));
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.banner strong {
  color: #1e293b;
}

.banner-content {
  display: grid;
  gap: 4px;
}

.banner-actions {
  margin-left: auto;
}

.code-block {
  font-family: "JetBrains Mono", "Fira Mono", "Courier New", monospace;
  font-size: 13px;
  background-color: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 12px;
  overflow: auto;
  line-height: 1.45;
}

.code-block-light {
  background-color: #f8fafc;
  color: #0f172a;
  border: 1px solid var(--border-color);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.table thead {
  background-color: #f8fafc;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
}

.table th,
.table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
  background-color: rgba(148, 163, 184, 0.12);
}

.timeline {
  display: grid;
  gap: 18px;
}

.timeline-item {
  padding-left: 20px;
  border-left: 2px solid rgba(148, 163, 184, 0.3);
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--primary-color);
}

.timeline-meta {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

.info-list {
  display: grid;
  gap: 10px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  gap: 12px;
}

.info-item span:first-child {
  color: var(--text-muted);
}

.info-item span:last-child {
  font-weight: 500;
  color: #0f172a;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.stat-card {
  background-color: #f8fafc;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  padding: 16px;
}

.stat-label {
  font-size: 12px;
  color: #475569;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  margin-top: 4px;
}

.footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.footer-actions-start {
  justify-content: flex-start;
}

.section {
  display: grid;
  gap: 12px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 16px 0;
  border: none;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #0f172a;
}

.toggle input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  background-color: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
  position: relative;
  transition: background-color 0.2s ease;
}

.toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #ffffff;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px -2px rgba(15, 23, 42, 0.35);
}

.toggle input[type="checkbox"]:checked {
  background: var(--primary-gradient);
}

.toggle input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

.pill-group {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background-color: rgba(148, 163, 184, 0.2);
  gap: 4px;
}

.pill-group button {
  border-radius: 999px;
  background-color: transparent;
  padding: 6px 14px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}

.pill-group button.active {
  background-color: #ffffff;
  color: #0f172a;
  box-shadow: 0 3px 8px -6px rgba(15, 23, 42, 0.35);
}

.login-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef2ff 0%, #e0f2fe 100%);
  padding: 32px;
}

.login-card {
  background-color: #ffffff;
  border-radius: 24px;
  padding: 40px;
  width: min(520px, 100%);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(99, 102, 241, 0.15);
  display: grid;
  gap: 24px;
}

.hero-title {
  font-size: 32px;
  font-weight: 700;
  color: #0f172a;
}

.hero-subtitle {
  font-size: 18px;
  color: #475569;
}

.hero-badge {
  width: fit-content;
}

.table-actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.table-actions button {
  padding: 0;
  color: var(--primary-color);
  font-size: 13px;
}

.table-card {
  overflow: hidden;
}

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

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #0f172a;
}

@media (max-width: 1280px) {
  .main-content {
    width: min(960px, 100%);
  }

  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), 82vw);
    transform: translateX(-110%);
    box-shadow: var(--shadow-lg);
  }

  body.drawer-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
  }

  .top-bar {
    padding: 16px 20px;
    gap: 16px;
  }

  .menu-trigger {
    display: inline-flex;
  }

  .top-bar-context {
    flex: 1 1 auto;
  }

  .top-bar-actions {
    flex: 0 0 auto;
    gap: 12px;
    flex-wrap: nowrap;
  }

  .main-content {
    width: min(900px, 100%);
    padding: 28px 20px 40px;
  }

  .page-header {
    align-items: flex-start;
  }

  .overview-cards {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .table {
    min-width: 520px;
  }
}

@media (max-width: 768px) {
  .top-bar {
    gap: 12px;
    align-items: center;
  }

  .top-bar-context {
    flex: 1 1 auto;
  }

  .top-bar-actions {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .top-bar-user {
    display: none;
  }

  .top-bar-logout {
    padding: 0 14px;
    height: 36px;
  }

  .page-header {
    flex-direction: column;
    gap: 16px;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .grid-2,
  .grid-3,
  .overview-cards {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 20px;
    gap: 16px;
  }

  .banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .banner-actions {
    margin-left: 0;
  }

  .list-item {
    padding: 16px 18px;
  }

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

  .toolbar {
    gap: 10px;
  }

  .toolbar-group {
    width: 100%;
  }

  .table {
    min-width: 480px;
  }
}

@media (max-width: 640px) {
  body {
    background-color: #ffffff;
  }

  .main-content {
    padding: 24px 18px 36px;
    gap: 18px;
  }

  .page-title {
    font-size: 22px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .top-bar-logout {
    padding: 0 12px;
  }

  .page-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-group select,
  .search-input {
    width: 100%;
  }

  .footer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .footer-actions .btn {
    width: 100%;
  }

  .login-card {
    padding: 28px;
  }
}
