:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f7f9ff;
  --border: #e5e9f3;
  --text: #1f2433;
  --muted: #7a8399;
  --primary: #4f6bff;
  --primary-dark: #3f57db;
  --sidebar: #141b2d;
  --sidebar-hover: #1e2740;
  --success: #26a269;
  --warning: #d9871f;
  --danger: #d24a5a;
  --radius: 14px;
  --header-h: 72px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #1a2555 0%, #3a48a1 45%, #7f92fb 100%);
}

.auth-wrapper { width: 100%; max-width: 420px; }
.login-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 20px;
  box-shadow: 0 22px 48px rgba(18, 26, 57, 0.24);
  padding: 32px;
}
.login-card h1 { margin: 0 0 8px; font-size: 30px; }
.subtitle { margin: 0 0 24px; color: var(--muted); }

.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 30;
}

.brand { font-size: 22px; font-weight: 700; color: #2d3d8e; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  background: #eef2ff;
  color: #30408d;
}

.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  padding: 18px 14px;
  overflow-y: auto;
}
.sidebar-nav { display: grid; gap: 6px; }
.nav-item {
  display: block;
  padding: 11px 13px;
  border-radius: 10px;
  color: #e3e8ff;
  font-size: 14px;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: #2a3660; font-weight: 600; }
.nav-item.muted { opacity: 0.8; }

.main-content {
  margin-top: var(--header-h);
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--header-h));
  padding: 24px;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.panel-header h1 { margin: 0; font-size: 30px; }
.panel-actions { display: flex; gap: 10px; }

.card, .table-card, .form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(20, 31, 63, 0.05);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card { padding: 20px; }
.stat-card h3 { margin: 0 0 10px; color: var(--muted); font-size: 14px; font-weight: 600; }
.stat-card p { margin: 0; font-size: 34px; font-weight: 700; color: #212d66; }

.table-card, .form-card { padding: 18px; }
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.table-header h2 { margin: 0; font-size: 20px; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.empty-cell { color: var(--muted); text-align: center; padding: 22px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}
.status-badge.is-success { background: #e6f7ef; color: var(--success); }
.status-badge.is-warning { background: #fff4de; color: var(--warning); }
.status-badge.is-danger { background: #fce8eb; color: var(--danger); }
.status-badge.is-neutral { background: #edf1f7; color: #526179; }

.search-form { display: flex; gap: 10px; margin-bottom: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.single-col { grid-template-columns: 1fr; }
.form-row { display: grid; gap: 6px; }
.form-row span { font-size: 13px; color: #47526d; }
.form-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 10px; }

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-soft);
  font-size: 14px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.btn-lg { width: 100%; padding: 12px 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #ebefff; color: #2d3f92; }
.btn-ghost { background: #eff3ff; color: #304190; }
.text-link { color: #3e57d6; font-weight: 600; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.auth-flashes { margin-bottom: 14px; }
.flash {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
}
.flash.success { background: #e6f7ef; border-color: #cdeedc; }
.flash.info { background: #edf2ff; border-color: #d8e2ff; }
.flash.error, .flash.danger { background: #fce8eb; border-color: #f8cfd5; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}
.modal.is-open { display: block; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 14, 34, 0.55);
}
.modal__dialog {
  position: relative;
  width: min(420px, 92vw);
  margin: 15vh auto 0;
  background: #fff;
  border-radius: 14px;
  padding: 20px;
}

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 78px; }
  .brand { font-size: 18px; }
  .nav-item { font-size: 0; padding: 12px; text-align: center; }
  .nav-item::first-letter { font-size: 14px; }
  .main-content { padding: 16px; }
  .panel-header h1 { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
}
