@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --success: #15803d;
  --danger: #dc2626;
  --dark: #0f172a;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top right, #eaf1ff, var(--bg) 35%);
  color: var(--text);
  line-height: 1.45;
}

h1, h2, h3, h4, h5 { margin: 0 0 8px; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 10px; color: var(--muted); }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 270px;
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  color: #fff;
  padding: 24px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand { padding: 8px 10px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); margin-bottom: 14px; }
.sidebar h2 { font-size: 22px; margin-bottom: 6px; }
.sidebar p { color: #cbd5e1; margin-bottom: 8px; }

.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar a {
  color: #dbeafe;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  transition: background .2s ease, transform .2s ease;
}
.sidebar a:hover { background: rgba(59, 130, 246, 0.2); transform: translateX(2px); }

.content { flex: 1; padding: 20px 24px 28px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(37, 99, 235, 0.1);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.topbar-subtitle { margin: 2px 0 0; font-size: 12px; color: #64748b; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.network-status {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.network-online {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}
.network-offline {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.phase-table tbody tr.phase-row-active {
  background: rgba(34, 197, 94, 0.12);
}

.page-body { padding: 2px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid #e6edf7;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}
.card p { font-size: 30px; font-weight: 700; color: #0f172a; margin: 6px 0 0; }

.panel {
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid #e8eef8;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 14px;
}

th, td {
  border-bottom: 1px solid #edf2f7;
  padding: 10px 12px;
  font-size: 14px;
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
th {
  background: #f8fbff;
  text-align: left;
  font-weight: 600;
  color: #334155;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  margin: 6px 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

button, .menu-toggle {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s ease, opacity .2s ease, background .2s ease;
}
button:active, .menu-toggle:active { transform: translateY(1px); }
button:hover, .menu-toggle:hover { opacity: .95; }
button { background: var(--brand); color: #fff; width: 100%; }
button.secondary, .menu-toggle { background: #334155; color: #fff; }
button.danger { background: var(--danger); color: #fff; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  margin: 8px 0;
  border: 1px solid transparent;
  font-size: 14px;
}
.alert.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

.login-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #dbeafe, #f1f5f9 50%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.14);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 600;
}
.role-badge { background: rgba(59,130,246,.18); color: #bfdbfe; }
.disabled-link { color: #94a3b8; pointer-events: none; text-decoration: line-through; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { width: auto; padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.row-actions a { text-decoration: none; color: #1d4ed8; font-weight: 600; font-size: 13px; padding: 7px 0; }

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    z-index: 1000;
    transition: left .2s ease;
  }
  .sidebar.open { left: 0; }
  .content { width: 100%; padding: 14px; }
  .topbar { margin-top: 2px; }
  .menu-toggle { display: inline-block; width: auto; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (min-width: 981px) {
  .menu-toggle { display: none; }
}

.dark-mode {
  --bg: #020617;
  --panel: #020617;
  --line: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --brand: #38bdf8;
  --danger: #f97373;
}

.dark-mode body {
  background: radial-gradient(circle at top right, #020617, #020617 35%);
}

.dark-mode .sidebar {
  background: linear-gradient(180deg, #020617 0%, #020617 100%);
  border-right-color: #1e293b;
}

.dark-mode .topbar {
  background: rgba(15,23,42,0.96);
  border-color: #1e293b;
}

.dark-mode .panel,
.dark-mode .modal-dialog {
  background: #020617;
  border-color: #1e293b;
}

.dark-mode table {
  background: #020617;
  border-color: #1e293b;
}

.dark-mode th {
  background: #020617;
  color: #e5e7eb;
}

.dark-mode td { border-bottom-color: #1f2937; }

.dark-mode input,
.dark-mode select,
.dark-mode textarea {
  background: #020617;
  border-color: #374151;
  color: #e5e7eb;
}

.dark-mode .badge { background: #0f172a; color: #e5e7eb; }

.dark-mode .network-online {
  background: rgba(34, 197, 94, 0.2);
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.35);
}
.dark-mode .network-offline {
  background: rgba(248, 113, 113, 0.15);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
}

/* Global Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 18px;
}
.modal-overlay.open { display: flex; }
.modal-dialog {
  width: min(920px, 96vw);
  max-height: 86vh;
  overflow: auto;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #e6edf7;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  position: sticky;
  top: 0;
  z-index: 1;
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
}
.modal-close {
  background: #334155;
  color: #fff;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  font-size: 22px;
  line-height: 38px;
}
.modal-body {
  padding: 16px;
}

.table-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 14px;
}
.table-toolbar .toolbar-left {
  display: flex;
  gap: 10px;
  align-items: center;
}
.table-toolbar input[type="search"] {
  width: 320px;
}
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
}
.table-wrap table {
  margin: 0;
  min-width: 720px;
}
.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
