:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f172a;
  --muted: #5f6f86;
  --line: #d8e1ee;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-soft: #dbeafe;
  --success-soft: #dcfce7;
  --success-text: #166534;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 18px 40px rgba(15, 23, 42, .08);
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f6f9fc 0%, #edf2f7 100%);
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.portal-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(216,225,238,.9);
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #e8f1ff 0%, #dbeafe 60%, #d7fff1 100%);
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  font-size: 24px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.12);
}
.brand h1 { margin: 0; font-size: 1.55rem; line-height: 1.1; }
.brand .sub { margin: 4px 0 0; color: var(--muted); font-size: .96rem; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.nav-links a, .nav-links button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}
.nav-links a.active,
.nav-links a:hover,
.nav-links button:hover {
  background: #f1f5f9;
  border-color: var(--line);
  text-decoration: none;
}
.user-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: #f8fbff;
  border: 1px solid var(--line);
  color: var(--muted);
}
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 30px 22px 40px;
}
.page-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}
.page-hero h2 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.08;
}
.page-hero p { margin: 0; color: var(--muted); max-width: 760px; }
.hero-badge {
  padding: 12px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #eef5ff, #f2fbff);
  border: 1px solid var(--line);
  color: var(--primary-dark);
  box-shadow: var(--shadow);
}
.alert {
  padding: 13px 16px;
  border-radius: 16px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: #bbf7d0; }
.card {
  background: var(--surface);
  border: 1px solid rgba(216,225,238,.95);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.card.soft { background: var(--surface-soft); }
.card h3, .card h2 { margin-top: 0; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -30px auto;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(59,130,246,.13), transparent 70%);
}
.stat-label { color: var(--muted); font-size: .95rem; margin-bottom: 10px; }
.stat-value { font-size: 2.3rem; font-weight: 700; margin: 0 0 8px; }
.stat-foot { color: var(--muted); font-size: .92rem; }
.actions, .stack-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stack-actions { flex-direction: column; align-items: stretch; }
.button-link, button, .btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .18);
}
.button-link:hover, button:hover, .btn:hover { text-decoration: none; filter: brightness(.98); }
.button-link.secondary, .btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.button-link.light {
  background: linear-gradient(180deg, #edf4ff 0%, #dbeafe 100%);
  color: var(--primary-dark);
  box-shadow: none;
}
button.danger, .danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}
th, td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #eaf0f7;
  vertical-align: top;
}
th { font-size: .92rem; color: var(--muted); background: #fbfdff; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fcfdff; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #1d4ed8;
  font-size: .84rem;
  font-weight: 600;
  text-transform: capitalize;
}
.role-badge { background: #ede9fe; color: #6d28d9; }
.status-disabled { background: #f1f5f9; color: #475569; }
.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 22px;
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 16px;
}
.grid-form.narrow { grid-template-columns: 1fr; }
.grid-form label, .checkbox-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: .95rem;
  color: #17253c;
}
.grid-form .full { grid-column: 1 / -1; }
input, textarea, select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  outline: none;
  transition: .15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(59,130,246,.12);
}
textarea { min-height: 120px; resize: vertical; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.checkbox-field { flex-direction: row; align-items: center; }
.checkbox-field input { width: auto; }
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}
.muted { color: var(--muted); }
.notes {
  white-space: pre-wrap;
  background: linear-gradient(180deg, #fcfdff 0%, #f7faff 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 0;
}
.kv-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}
.kv {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdff;
}
.kv .label { display: block; color: var(--muted); font-size: .88rem; margin-bottom: 6px; }
.doc-list, .ref-list, .bullet-list { margin: 0; padding-left: 18px; }
.doc-list li, .ref-list li, .bullet-list li { margin-bottom: 10px; }
.ref-list a { font-weight: 600; }
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 1.05fr);
}
.auth-panel {
  padding: 60px 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}
.auth-card {
  width: min(100%, 540px);
  background: white;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-card h2 { font-size: 2rem; margin: 0 0 8px; }
.auth-card p { margin: 0 0 18px; color: var(--muted); }
.auth-side {
  position: relative;
  overflow: hidden;
  color: white;
  background: linear-gradient(145deg, #4e8df7 0%, #4f86ee 48%, #1fb981 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px;
}
.auth-side::before,
.auth-side::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(8px);
}
.auth-side::before {
  width: 320px; height: 320px; right: -80px; top: -60px;
  background: rgba(255,255,255,.08);
}
.auth-side::after {
  width: 260px; height: 260px; left: -70px; bottom: -60px;
  background: rgba(255,255,255,.06);
}
.auth-copy { position: relative; z-index: 1; max-width: 540px; }
.auth-kicker { font-size: 1rem; opacity: .92; margin-bottom: 8px; }
.auth-title { font-size: 3.25rem; line-height: 1; margin: 0 0 20px; }
.auth-copy p { font-size: 1.15rem; line-height: 1.55; margin: 0 0 28px; opacity: .98; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  font-size: 1.1rem;
}
.check-list span {
  width: 38px; height: 38px; border-radius: 999px; display: inline-grid; place-items: center;
  background: rgba(255,255,255,.14); font-weight: 700;
}
.footer {
  text-align: center;
  color: var(--muted);
  padding: 24px 16px 36px;
}
.empty-state {
  padding: 28px;
  border: 1px dashed #c7d6ea;
  border-radius: 18px;
  background: #fbfdff;
  color: var(--muted);
}
@media (max-width: 1080px) {
  .stats, .grid-2, .grid-form, .auth-page { grid-template-columns: 1fr; }
  .auth-side { min-height: 360px; }
}
@media (max-width: 780px) {
  .topbar-inner, .page-hero, .row-between { flex-direction: column; align-items: stretch; }
  .container, .topbar-inner, .auth-panel, .auth-side { padding-left: 16px; padding-right: 16px; }
  .card, .auth-card { padding: 18px; }
  .auth-title { font-size: 2.35rem; }
  .brand h1 { font-size: 1.28rem; }
  .kv-list { grid-template-columns: 1fr; }
}
