:root {
  color-scheme: dark;
  --bg: #0b0712;
  --surface: #15101f;
  --surface-muted: #100b18;
  --border: rgba(197, 174, 255, 0.12);
  --border-strong: rgba(169, 133, 255, 0.28);
  --text: #f5f1fc;
  --muted: #9d95aa;
  --subtle: #70697c;
  --purple: #9168f4;
  --purple-bright: #ae8aff;
  --purple-soft: rgba(145, 104, 244, 0.13);
  --green: #45d69c;
  --yellow: #f4b950;
  --red: #ef6475;
  --sidebar: 256px;
  --topbar: 82px;
  --radius: 14px;
  --transition: 160ms ease;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--purple-bright); outline-offset: 3px; }

.admin-body {
  color: var(--text);
  background: radial-gradient(circle at 78% -15%, rgba(112, 69, 207, 0.1), transparent 31rem), var(--bg);
}

.skip-link {
  position: fixed;
  z-index: 300;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--bg);
  background: var(--purple-bright);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.admin-sidebar {
  position: fixed;
  z-index: 100;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  padding: 26px 18px 20px;
  border-right: 1px solid var(--border);
  background: rgba(11, 7, 18, 0.96);
  backdrop-filter: blur(18px);
}

.admin-brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-brand { padding: 2px 10px 28px; }

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  color: var(--purple-bright);
  background: var(--purple-soft);
  box-shadow: 0 0 24px rgba(145, 104, 244, 0.12);
  font-weight: 760;
}

.brand-name,
.brand-context { display: block; }
.brand-name { font-size: .78rem; font-weight: 760; letter-spacing: .14em; }
.brand-context { margin-top: 5px; color: var(--muted); font-size: .61rem; font-weight: 650; letter-spacing: .13em; }
.nav-label { margin: 0 11px 9px; color: var(--subtle); font-size: .64rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.admin-nav { display: grid; gap: 4px; }
.admin-nav--footer { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border); }
.admin-nav form { margin: 0; }

.nav-link {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: .86rem;
  font-weight: 560;
  text-align: left;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.nav-link::before { width: 6px; height: 6px; flex: 0 0 6px; border: 1px solid currentColor; border-radius: 2px; content: ""; opacity: .72; }
.nav-link--active { border-color: var(--border-strong); color: var(--text); background: var(--purple-soft); }
.nav-link--active::before { border-color: var(--purple-bright); background: var(--purple-bright); box-shadow: 0 0 12px rgba(169, 133, 255, .65); }
.nav-link--disabled { cursor: not-allowed; opacity: .46; }
.nav-link--button { cursor: pointer; }
.nav-link--button:hover { color: var(--text); background: rgba(255,255,255,.025); }
.nav-link small { margin-left: auto; color: var(--subtle); font-size: .58rem; letter-spacing: .06em; text-transform: uppercase; }

.ticket-badge { display: grid; min-width: 20px; height: 20px; margin-left: auto; padding: 0 6px; place-items: center; border-radius: 999px; color: #fff; background: var(--red); font-size: .67rem; font-weight: 750; }
.admin-main { min-height: 100vh; margin-left: var(--sidebar); }

.admin-topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  min-height: var(--topbar);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(22px, 3vw, 42px);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 7, 18, .84);
  backdrop-filter: blur(18px);
}

.page-identity { min-width: 0; }
.page-identity h1 { margin: 0; font-size: clamp(1.15rem, 2vw, 1.4rem); font-weight: 680; letter-spacing: -.025em; }
.page-identity p { margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip { display: flex; min-height: 42px; align-items: center; gap: 10px; padding: 5px 12px 5px 6px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface-muted); font-size: .74rem; }
.profile-avatar { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; color: var(--purple-bright); background: var(--purple-soft); font-weight: 750; }
.menu-button { display: none; width: 42px; height: 42px; padding: 0; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); cursor: pointer; }
.menu-button span, .menu-button span::before, .menu-button span::after { display: block; width: 17px; height: 1px; background: currentColor; content: ""; }
.menu-button span { position: relative; }
.menu-button span::before { position: absolute; top: -5px; }
.menu-button span::after { position: absolute; top: 5px; }
.sidebar-backdrop { display: none; }
.admin-content { width: min(100%, 1580px); margin: 0 auto; padding: clamp(22px, 3vw, 42px); }
.section-heading { margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 1rem; font-weight: 650; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: .75rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.kpi-card, .panel { border: 1px solid var(--border); background: linear-gradient(145deg, rgba(21,16,31,.96), rgba(15,11,23,.96)); box-shadow: 0 0 32px rgba(126,82,225,.06); }
.kpi-card { min-height: 124px; padding: 20px; border-radius: 12px; transition: transform var(--transition), border-color var(--transition); }
.kpi-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.kpi-card p { margin: 0; color: var(--muted); font-size: .75rem; font-weight: 600; }
.kpi-card strong { display: block; margin-top: 17px; font-size: 1.75rem; font-weight: 690; letter-spacing: -.045em; }
.kpi-card span { display: block; margin-top: 5px; color: var(--subtle); font-size: .68rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.panel { min-width: 0; border-radius: var(--radius); }
.panel--wide { grid-column: 1 / -1; }
.panel-header { display: flex; min-height: 67px; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: .9rem; font-weight: 650; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: .7rem; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot--warning { background: var(--yellow); }
.legend-dot--critical { background: var(--red); }
.empty-state { display: grid; min-height: 188px; padding: 28px; place-content: center; text-align: center; }
.empty-state--large { min-height: 300px; }
.empty-icon { display: grid; width: 42px; height: 42px; margin: 0 auto 13px; place-items: center; border: 1px solid var(--border); border-radius: 12px; color: var(--subtle); background: rgba(255,255,255,.018); }
.empty-state h3 { margin: 0; color: var(--muted); font-size: .82rem; font-weight: 620; }
.empty-state p { max-width: 340px; margin: 7px auto 0; color: var(--subtle); font-size: .72rem; line-height: 1.55; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .77rem; text-align: left; }
.data-table th { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--subtle); font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 0; }
.data-table--records td { padding: 15px 16px; border-bottom: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.data-table--records tbody tr:last-child td { border-bottom: 0; }
.data-table--records tbody tr:hover { background: rgba(255,255,255,.015); }
.cell-primary { color: var(--text) !important; font-weight: 600; }
.cell-actions { text-align: right; }
.action-group { display: inline-flex; justify-content: flex-end; gap: 8px; }
.badge { display: inline-flex; min-height: 24px; align-items: center; padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; font-size: .65rem; font-weight: 680; white-space: nowrap; }
.badge--role { border-color: var(--border-strong); color: var(--purple-bright); background: var(--purple-soft); }
.badge--success { color: var(--green); background: rgba(69,214,156,.08); }
.badge--muted { color: var(--subtle); background: rgba(255,255,255,.02); }
.alert { margin: 18px 20px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: .75rem; }
.alert--success { border-color: rgba(69,214,156,.25); color: var(--green); background: rgba(69,214,156,.07); }
.alert--danger { border-color: rgba(239,100,117,.3); color: #ff9eaa; background: rgba(239,100,117,.08); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.admin-body--auth { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-shell { width: min(100%, 440px); }
.auth-card { padding: clamp(26px, 5vw, 38px); border: 1px solid var(--border); border-radius: 18px; background: rgba(16,11,24,.96); box-shadow: 0 24px 80px rgba(0,0,0,.28), 0 0 36px rgba(145,104,244,.08); }
.auth-card--message { text-align: center; }
.auth-card--message .auth-brand { justify-content: center; }
.auth-heading { margin: 40px 0 28px; }
.auth-heading .eyebrow { margin-bottom: 9px; color: var(--purple-bright); font-size: .67rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.auth-heading h1 { margin: 0; font-size: clamp(1.45rem, 5vw, 1.8rem); font-weight: 680; letter-spacing: -.035em; }
.auth-heading p { margin: 10px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.auth-form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field label { color: var(--muted); font-size: .72rem; font-weight: 620; }
.field input, .field select { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--border); border-radius: 10px; outline: none; color: var(--text); background: var(--bg); transition: border-color var(--transition), box-shadow var(--transition), opacity var(--transition); }
.field input::placeholder { color: var(--subtle); }
.field input:focus, .field select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(145,104,244,.1); }
.field input:disabled, .field select:disabled { cursor: not-allowed; opacity: .55; }
.field small { color: var(--subtle); font-size: .67rem; line-height: 1.5; }
.field--inactive { opacity: .65; }
.checkbox-field { display: flex; width: fit-content; align-items: center; gap: 9px; color: var(--muted); cursor: pointer; font-size: .73rem; }
.checkbox-field input { width: 15px; height: 15px; accent-color: var(--purple); }
.field-error, .validation-summary { color: var(--red); font-size: .7rem; }
.field-error:empty, .validation-summary:empty { display: none; }
.validation-summary ul { margin: 0; padding-left: 18px; }
.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 0 18px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: .78rem; font-weight: 680; transition: transform var(--transition), border-color var(--transition), background var(--transition); }
.button:hover { transform: translateY(-1px); }
.button--full { width: 100%; }
.button--primary { color: #fff; background: var(--purple); box-shadow: 0 10px 28px rgba(145,104,244,.16); }
.button--primary:hover { background: var(--purple-bright); }
.button--secondary { border-color: var(--border-strong); background: var(--purple-soft); }
.button--danger { border-color: rgba(239,100,117,.32); color: #fff; background: rgba(190,54,72,.72); }
.button--danger:hover { background: rgba(219,67,87,.9); }
.button--compact { min-height: 34px; padding: 0 12px; font-size: .7rem; }
.panel-header--actions { flex-wrap: wrap; }
.form-panel { max-width: 900px; }
.management-form { padding: clamp(20px, 3vw, 30px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.confirmation-body { padding: clamp(20px, 3vw, 30px); }
.confirmation-body .alert { margin: 24px 0 0; }
.confirmation-list { display: grid; gap: 0; margin: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.confirmation-list div { display: grid; grid-template-columns: minmax(120px, .35fr) 1fr; gap: 20px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.confirmation-list div:last-child { border-bottom: 0; }
.confirmation-list dt { color: var(--subtle); font-size: .67rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.confirmation-list dd { margin: 0; color: var(--text); font-size: .78rem; overflow-wrap: anywhere; }

@media (max-width: 1040px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .admin-sidebar { transform: translateX(-102%); transition: transform 220ms ease; }
  .admin-sidebar.is-open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .menu-button { display: grid; }
  .admin-topbar { justify-content: flex-start; }
  .profile-chip { margin-left: auto; }
  .sidebar-backdrop { position: fixed; z-index: 90; inset: 0; display: block; border: 0; background: rgba(5,3,8,.66); backdrop-filter: blur(3px); }
  .has-open-navigation { overflow: hidden; }
}

@media (max-width: 600px) {
  .admin-content { padding: 18px 14px 30px; }
  .admin-topbar { min-height: 72px; padding: 12px 14px; }
  .page-identity p, .profile-chip span:last-child { display: none; }
  .profile-chip { padding-right: 5px; }
  .kpi-grid { gap: 10px; }
  .kpi-card { min-height: 108px; padding: 16px; }
  .kpi-card strong { margin-top: 12px; font-size: 1.45rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel--wide { grid-column: auto; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .confirmation-list div { grid-template-columns: 1fr; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
