/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-900: #0a1628;
  --blue-800: #0f2044;
  --blue-700: #1a3a6e;
  --blue-600: #1e4d9b;
  --blue-500: #2563eb;
  --blue-400: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  --green-500: #16a34a;
  --green-100: #dcfce7;
  --orange-500: #ea580c;
  --orange-100: #ffedd5;
  --red-500: #dc2626;
  --red-100: #fee2e2;

  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white: #ffffff;

  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --shadow-md: 0 4px 20px rgba(0,0,0,.10);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
}

/* ===== LAYOUT ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--blue-900);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== SIDEBAR ===== */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--blue-500);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.logo-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: white;
  display: block;
}
.logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  display: block;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  position: relative;
  cursor: pointer;
}
.nav-item svg {
  width: 17px; height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  flex-shrink: 0;
}
.nav-item:hover {
  color: white;
  background: rgba(255,255,255,.07);
}
.nav-item.active {
  color: white;
  background: var(--blue-600);
}

.badge {
  margin-left: auto;
  background: var(--orange-500);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--blue-600);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 11px; color: rgba(255,255,255,.4); }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--gray-700);
}
.menu-toggle svg {
  width: 22px; height: 22px;
  stroke: currentColor; fill: none; stroke-width: 2;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  flex: 1;
}

.date-display {
  font-size: 12.5px;
  color: var(--gray-500);
  font-weight: 500;
}

/* ===== SECTIONS ===== */
.section { display: none; padding: 28px 28px 40px; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.section-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-900);
}
.section-header p {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg {
  width: 22px; height: 22px;
  stroke: currentColor; fill: none; stroke-width: 2;
}

.stat-blue .stat-icon { background: var(--blue-100); color: var(--blue-600); }
.stat-green .stat-icon { background: var(--green-100); color: var(--green-500); }
.stat-orange .stat-icon { background: var(--orange-100); color: var(--orange-500); }
.stat-red .stat-icon { background: var(--red-100); color: var(--red-500); }

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 3px;
  font-weight: 500;
}

/* ===== CARD ===== */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}
.card-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
}

.card-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
}
.card-search svg {
  width: 16px; height: 16px;
  stroke: var(--gray-400); fill: none; stroke-width: 2;
  flex-shrink: 0;
}
.card-search input {
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--gray-900);
  font-family: inherit;
  width: 100%;
}

.card-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.filter-select {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-700);
  outline: none;
  background: white;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--blue-400); }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  padding: 11px 20px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.table td {
  padding: 13px 20px;
  font-size: 13.5px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--gray-50); }

.empty-row {
  text-align: center;
  color: var(--gray-400);
  font-style: italic;
  padding: 32px 20px !important;
}

/* STATUS PILLS */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-100); color: var(--green-500); }
.pill-orange { background: var(--orange-100); color: var(--orange-500); }
.pill-red { background: var(--red-100); color: var(--red-500); }
.pill-blue { background: var(--blue-100); color: var(--blue-600); }

/* TYPE BADGES */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-100);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  border: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--blue-500);
  color: white;
}
.btn-primary:hover { background: var(--blue-600); }

.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger {
  background: var(--red-100);
  color: var(--red-500);
}
.btn-danger:hover { background: var(--red-500); color: white; }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); }

/* ===== ACTION BUTTONS IN TABLE ===== */
.action-btns { display: flex; gap: 6px; align-items: center; }
.action-btn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.action-btn:hover { background: var(--gray-100); }
.action-btn.delete:hover { background: var(--red-100); border-color: var(--red-200); }
.action-btn svg { width: 13px; height: 13px; stroke: var(--gray-500); fill: none; stroke-width: 2; }
.action-btn.delete:hover svg { stroke: var(--red-500); }

/* ===== ALERTS ===== */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--orange-100);
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  color: #9a3412;
  font-size: 13.5px;
  font-weight: 500;
}
.alert-banner svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none; stroke-width: 2;
  flex-shrink: 0;
}

.days-badge {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
}
.days-urgent { background: var(--red-100); color: var(--red-500); }
.days-warning { background: var(--orange-100); color: var(--orange-500); }
.days-ok { background: var(--green-100); color: var(--green-500); }

/* ===== CONFIG ===== */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.config-card { padding: 24px; }
.config-card h2 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.config-desc { font-size: 13px; color: var(--gray-500); margin-bottom: 20px; }
.full-width { grid-column: 1 / -1; }

.config-status { margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.status-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-600); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gray-300);
  flex-shrink: 0;
}
.status-dot.green { background: var(--green-500); }
.status-dot.orange { background: var(--orange-500); }

.deploy-steps { display: flex; flex-direction: column; gap: 0; }
.deploy-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--gray-100);
}
.deploy-step:last-child { border-bottom: none; }
.step-num {
  width: 28px; height: 28px;
  background: var(--blue-500);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-content { flex: 1; }
.step-content strong { display: block; font-size: 13.5px; color: var(--gray-900); margin-bottom: 4px; }
.step-content code {
  font-size: 12px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: 'Courier New', monospace;
  color: var(--blue-700);
  display: inline-block;
  word-break: break-all;
}

/* ===== FORM ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--gray-700); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--gray-900);
  background: white;
  outline: none;
  transition: border .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--gray-200);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s;
  z-index: 999;
  pointer-events: none;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green-500); }
.toast.error { background: var(--red-500); }

/* ===== UTILS ===== */
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .section { padding: 20px 16px 32px; }
  .config-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: flex-start; }
}
