:root {
  --sa-bg: #0b1220;
  --sa-sidebar: #000;
  --sa-surface: #ffffff;
  --sa-surface-2: #f8fafc;
  --sa-border: #e2e8f0;
  --sa-ink: #0f172a;
  --sa-muted: #64748b;
  --sa-accent: #eab308;
  --sa-accent-hover: #ca8a04;
  --sa-accent-soft: rgba(234, 179, 8, 0.14);
  --sa-accent-ink: #a16207;
  --sa-danger: #ef4444;
  --sa-warn: #f59e0b;
  --sa-radius: 14px;
  --sa-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
  --sa-font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body.sa-body {
  margin: 0;
  font-family: var(--sa-font);
  color: var(--sa-ink);
  background: #f1f5f9;
}

.sa-app {
  min-height: 100vh;
}

/* Sidebar */
.sa-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  height: 100vh;
  background: var(--sa-sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 200;
}
.sa-sidebar-backdrop {
  display: none;
}

.sa-sidebar__brand {
  display: block;
  padding: 1.35rem 1.25rem 1.1rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sa-sidebar__logo {
  display: block;
  width: min(200px, calc(100% - 0.5rem));
  height: auto;
  margin: 0 auto;
}

.sa-nav {
  display: grid;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.85rem 0.85rem 0.75rem;
  align-content: start;
  overflow-y: auto;
}
.sa-nav__item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: #a1a1aa;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  transition: background 0.15s, color 0.15s;
  border: 0;
  background: transparent;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.sa-nav__item i { font-size: 1rem; width: 1.1rem; flex-shrink: 0; }
.sa-nav__item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sa-nav__item.is-active {
  background: var(--sa-accent-soft);
  color: var(--sa-accent);
}
.sa-sidebar__foot {
  flex-shrink: 0;
  margin-top: auto;
  padding: 0.75rem 0.85rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sa-sidebar__foot form { margin: 0; }

/* Main */
.sa-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  margin-left: 260px;
}
.sa-topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  padding: 1.5rem 2rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--sa-border);
}
.sa-topbar__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.sa-topbar__head { flex: 1; min-width: 0; }
.sa-topbar__title { margin: 0; font-size: 1.5rem; font-weight: 700; }
.sa-topbar__sub { margin: 0.25rem 0 0; color: var(--sa-muted); font-size: 0.88rem; }
.sa-topbar__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--sa-border);
  border-radius: 10px;
  background: #fff;
  color: var(--sa-ink);
  font-size: 1.35rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.sa-topbar__toggle:hover {
  background: var(--sa-accent-soft);
  border-color: var(--sa-accent);
  color: var(--sa-accent-ink);
}
.sa-topbar__actions { display: flex; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap; }
body.sa-body--nav-open { overflow: hidden; }
.sa-content { padding: 1.25rem 2rem 2rem; flex: 1; }

/* Buttons */
.sa-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.sa-btn:hover { transform: translateY(-1px); }
.sa-btn--primary {
  background: linear-gradient(135deg, #fde047, #eab308);
  color: #171717;
  box-shadow: 0 8px 20px rgba(234, 179, 8, 0.28);
}
.sa-btn--primary:hover {
  background: linear-gradient(135deg, #fef08a, #ca8a04);
  color: #0a0a0a;
}
.sa-btn--ghost {
  background: #fff;
  color: var(--sa-ink);
  border-color: var(--sa-border);
}
.sa-btn--ghost:hover { background: var(--sa-surface-2); }
.sa-btn--sm { padding: 0.45rem 0.7rem; font-size: 0.82rem; }

/* Cards & table */
.sa-card {
  background: #fff;
  border: 1px solid var(--sa-border);
  border-radius: var(--sa-radius);
  box-shadow: var(--sa-shadow);
  overflow: hidden;
}
.sa-card__head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--sa-border);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sa-card__body { padding: 1.25rem; }

.sa-table-wrap { overflow-x: auto; }
.sa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.sa-table th,
.sa-table td {
  padding: 0.85rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--sa-border);
}
.sa-table th {
  background: var(--sa-surface-2);
  color: var(--sa-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.sa-table tr:last-child td { border-bottom: 0; }
.sa-table tr:hover td { background: #fafbfc; }
.sa-table code {
  background: #f1f5f9;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  font-size: 0.82rem;
}

.sa-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.sa-badge--ok { background: #dcfce7; color: #15803d; }
.sa-badge--off { background: #fee2e2; color: #b91c1c; }
.sa-badge--warn { background: #fef3c7; color: #b45309; }

.sa-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* Form */
.sa-form { display: grid; gap: 1rem; max-width: 720px; }
.sa-form--wide { max-width: none; }
.sa-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.sa-field { display: grid; gap: 0.35rem; }
.sa-field span { font-size: 0.82rem; font-weight: 600; color: var(--sa-muted); }
.sa-field small { color: var(--sa-muted); font-size: 0.75rem; }
.sa-field input,
.sa-field select,
.sa-field textarea {
  width: 100%;
  border: 1px solid var(--sa-border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sa-field input:focus,
.sa-field select:focus,
.sa-field textarea:focus {
  outline: none;
  border-color: var(--sa-accent);
  box-shadow: 0 0 0 3px var(--sa-accent-soft);
}
.sa-field--check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-direction: row;
}
.sa-form__actions {
  display: flex;
  gap: 0.65rem;
  padding-top: 0.5rem;
}

/* Alerts */
.sa-alert {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.sa-alert--ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.sa-alert--err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* Stats row */
.sa-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.sa-stat {
  background: #fff;
  border: 1px solid var(--sa-border);
  border-radius: var(--sa-radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--sa-shadow);
}
.sa-stat__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--sa-muted); }
.sa-stat__value { font-size: 1.75rem; font-weight: 800; margin-top: 0.25rem; }

/* Auth */
.sa-body--auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #000;
}
.sa-auth {
  width: min(440px, calc(100% - 2rem));
  display: grid;
  gap: 0.85rem;
}
.sa-auth__shell {
  border-radius: var(--sa-radius);
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
}
.sa-auth__logo-bar {
  background: #000;
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
}
.sa-auth__logo {
  display: block;
  width: min(240px, 78vw);
  height: auto;
  margin: 0 auto;
}
.sa-auth__card {
  background: #fff;
  padding: 1.5rem;
}
.sa-auth__footer {
  margin: 0.15rem 0 0;
  text-align: center;
}
.sa-auth__footer a {
  color: #71717a;
  font-size: 0.85rem;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
}
.sa-auth__footer a:hover {
  color: #eab308;
}
.sa-body--auth .sa-btn--primary {
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, #fde047, #eab308);
  color: #171717;
  box-shadow: 0 8px 22px rgba(234, 179, 8, 0.35);
}
.sa-body--auth .sa-btn--primary:hover {
  background: linear-gradient(135deg, #fef08a, #ca8a04);
  color: #0a0a0a;
}
.sa-body--auth .sa-tab.is-active {
  background: rgba(234, 179, 8, 0.14);
  border-color: #eab308;
  color: #a16207;
}

.sa-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.sa-tab {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.35rem;
  border: 1px solid var(--sa-border);
  border-radius: 10px;
  background: var(--sa-surface-2);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  text-align: center;
  white-space: nowrap;
}
.sa-tab.is-active {
  background: var(--sa-accent-soft);
  border-color: var(--sa-accent);
  color: var(--sa-accent-ink);
}
.sa-tab-panel { display: none; }
.sa-tab-panel.is-active { display: grid; gap: 0.85rem; }

@media (max-width: 900px) {
  .sa-main { margin-left: 0; }
  .sa-sidebar {
    width: min(280px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  .sa-app.is-nav-open .sa-sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  }
  .sa-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
  }
  .sa-app.is-nav-open .sa-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .sa-topbar__toggle { display: inline-flex; }
  .sa-content { padding: 1rem; }
  .sa-topbar { padding: 1rem; }
}
