/* ── Variables ── */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Login ── */
#login-screen {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #064e3b 0%, #10b981 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: 0.5rem; }
.login-card h1 { font-size: 1.4rem; color: var(--text); }
.login-card .subtitle { color: var(--text-secondary); margin-bottom: 2rem; }

.form-group { text-align: left; margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; color: var(--text); font-size: 13px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row .form-group { margin-bottom: 0; }

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: background .2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
}
.btn-secondary:hover { background: var(--bg); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; border: none; padding: 5px 10px; border-radius: var(--radius); font-size: 12px; cursor: pointer; }
.btn-icon { background: transparent; border: none; padding: 4px 6px; cursor: pointer; font-size: 14px; border-radius: 4px; }
.btn-icon:hover { background: var(--bg); }

.error-msg { color: var(--danger); font-size: 13px; margin: 4px 0 8px; }
.hidden { display: none !important; }

/* ── Topbar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-left .logo { font-size: 1.4rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-secondary); font-size: 13px; }
.role-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
}

/* ── Layout ── */
.layout { display: flex; flex: 1; }

/* ── Sidebar ── */
.sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  flex-shrink: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 1.25rem;
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all .15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; border-right: 3px solid var(--primary); }

/* ── Content ── */
.content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }
.view { display: none; }
.view.active { display: block; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; }
h3 { font-size: 1rem; font-weight: 600; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.75rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.flex-row { display: flex; align-items: center; }
.flex-row.space-between { justify-content: space-between; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .loading { text-align: center; color: var(--text-secondary); padding: 24px; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.status-active { background: var(--primary-light); color: var(--primary-dark); }
.status-inactive { background: #f1f5f9; color: var(--text-secondary); }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-content {
  background: var(--surface);
  border-radius: 12px;
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: transparent; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-secondary); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 1rem; }
#site-form, #eng-form { padding: 1.25rem 1.5rem; }
#site-assigned { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--bg); }
.form-group small { display: block; color: var(--text-secondary); font-size: 11px; margin-top: 3px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  z-index: 200;
  transition: opacity .3s, transform .3s;
}
.toast.success { background: var(--primary); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--text); }

/* ── Report summary ── */
.report-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.report-stat { background: var(--bg); border-radius: var(--radius); padding: 0.75rem; text-align: center; }
.report-stat .val { font-size: 1.4rem; font-weight: 700; }
.report-stat .lbl { font-size: 11px; color: var(--text-secondary); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .sidebar { width: 56px; }
  .nav-item span:not(:first-child) { display: none; }
  .nav-item { justify-content: center; padding: 10px; font-size: 18px; }
  .content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
