:root {
  color-scheme: dark;
  --admin-bg: #080b10;
  --admin-panel: #111722;
  --admin-panel-raised: #171f2c;
  --admin-text: #f7f8fb;
  --admin-muted: #9da7b8;
  --admin-accent: #ff9f43;
  --admin-danger: #ff647c;
  --admin-border: rgba(255, 255, 255, .1);
  --bg: var(--admin-bg);
  --bg-soft: #0d121a;
  --panel: var(--admin-panel);
  --panel-strong: var(--admin-panel-raised);
  --text: var(--admin-text);
  --muted: var(--admin-muted);
  --blue: var(--admin-accent);
  --blue-bright: #ffc078;
  --red: var(--admin-danger);
  --green: #5bd99a;
  --yellow: #ffd166;
  --line: var(--admin-border);
  --line-soft: rgba(255, 255, 255, .07);
  --shadow: 0 30px 90px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px),
    var(--bg);
  background-size: 72px 72px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { color: #03101c; background: var(--blue-bright); }
:focus-visible { outline: 3px solid var(--blue-bright); outline-offset: 3px; }

.page-glow {
  position: fixed;
  z-index: -1;
  width: 650px;
  height: 650px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(45px);
  opacity: .13;
  background: radial-gradient(circle, var(--blue) 0, transparent 68%);
}
.page-glow--one { top: -350px; right: -170px; }
.page-glow--two { bottom: -420px; left: -380px; opacity: .07; }

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand__mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #05101a;
  background: var(--blue);
  font-weight: 900;
  font-size: 18px;
  clip-path: polygon(0 0, 100% 0, 100% 72%, 73% 100%, 0 100%);
}
.brand__name { font-size: 20px; font-weight: 800; letter-spacing: -.045em; }
.brand__name span { color: var(--blue); }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--blue-bright); font-size: 10px; font-weight: 850; letter-spacing: .19em; }
.eyebrow span { width: 28px; height: 1px; background: var(--blue); }

.login-screen { min-height: 100vh; padding: 28px; display: grid; place-items: center; }
.login-card {
  width: min(100%, 510px);
  padding: 48px;
  border: 1px solid rgba(255, 192, 120, .3);
  background: linear-gradient(145deg, rgba(14, 25, 39, .98), rgba(6, 12, 19, .99));
  box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 58px; }
.login-card h1 { margin: 20px 0 14px; font-size: clamp(38px, 7vw, 54px); line-height: 1; letter-spacing: -.055em; }
.login-card > p { margin: 0 0 30px; color: var(--muted); font-size: 14px; line-height: 1.7; }
code { color: #ffe0bd; }
label { display: grid; gap: 9px; color: #9eabba; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
input, select {
  width: 100%;
  min-height: 47px;
  padding: 0 14px;
  color: #eef6ff;
  border: 1px solid var(--line);
  outline: 0;
  background: #090f17;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(255, 159, 67, .11); }
input::placeholder { color: #566273; }
.password-field { position: relative; }
.password-field input { padding-right: 95px; }
.icon-button {
  position: absolute;
  top: 0;
  right: 0;
  min-height: 47px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--blue-bright);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}
.primary-button {
  min-height: 49px;
  padding: 0 20px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #03111e;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
  transition: transform .2s, background .2s;
}
.primary-button:hover { transform: translateY(-1px); background: var(--blue-bright); }
.primary-button:disabled { cursor: wait; opacity: .55; transform: none; }
#login-form { display: grid; gap: 17px; }
#login-form .primary-button { margin-top: 5px; }
.back-link { display: inline-block; margin-top: 26px; color: #7f8b9c; text-decoration: none; font-size: 12px; }
.back-link:hover { color: #fff; }
.message { margin-bottom: 20px; padding: 13px 15px; border: 1px solid rgba(91, 217, 154, .25); background: rgba(91, 217, 154, .08); color: #a9eccb; font-size: 13px; line-height: 1.5; }
.message--error { border-color: rgba(255, 107, 120, .3); background: rgba(255, 107, 120, .08); color: #ffb3ba; }
.login-card .message { margin: 17px 0 0; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 78px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 15, .88);
  backdrop-filter: blur(18px);
}
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.connection-state { padding-right: 17px; color: #9eabba; font-size: 11px; }
.connection-state i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(91, 217, 154, .7); }
.connection-state.is-error i { background: var(--red); box-shadow: 0 0 12px rgba(255, 107, 120, .7); }
.text-button, .panel-link {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #aab5c4;
  font-size: 12px;
}
.text-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); }
.text-button:hover, .panel-link:hover { color: #fff; border-color: rgba(255, 159, 67, .55); }
.text-button--danger:hover { color: #ffabb3; border-color: rgba(255, 107, 120, .5); }

.admin-layout { min-height: calc(100vh - 78px); display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 78px;
  height: calc(100vh - 78px);
  padding: 34px 18px 24px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(8, 13, 20, .68);
}
.sidebar__caption { padding: 0 15px 17px; color: #526073; font-size: 9px; font-weight: 850; letter-spacing: .17em; }
.admin-nav { display: grid; gap: 5px; }
.nav-item {
  width: 100%;
  min-height: 47px;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: #8794a6;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}
.nav-item span { color: #4e5b6c; font-size: 9px; font-weight: 850; }
.nav-item b { min-width: 24px; padding: 3px 6px; color: #718094; border: 1px solid var(--line-soft); font-size: 9px; font-weight: 750; text-align: center; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .025); }
.nav-item.is-active { color: #fff; border-color: rgba(255, 159, 67, .24); background: rgba(255, 159, 67, .08); }
.nav-item.is-active span { color: var(--blue); }
.nav-item.is-active b { color: #ffe0bd; border-color: rgba(255, 159, 67, .25); }
.sidebar__footer { margin-top: auto; padding: 20px 14px 0; display: grid; gap: 12px; border-top: 1px solid var(--line-soft); }
.sidebar__footer small { color: #566274; font-size: 10px; line-height: 1.5; }
.sidebar__footer a { color: #8795a7; text-decoration: none; font-size: 11px; }
.sidebar__footer a:hover { color: var(--blue-bright); }

.content { width: 100%; max-width: 1700px; padding: 48px clamp(22px, 4vw, 64px) 80px; overflow: hidden; }
.content__header { margin-bottom: 35px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.content__header h1 { margin: 16px 0 7px; font-size: clamp(38px, 5vw, 62px); line-height: 1; letter-spacing: -.055em; }
.content__header p { margin: 0; color: #647184; font-size: 11px; }
.mobile-menu { display: none; }
.view { animation: fade-in .22s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(7px); } }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.metric-card { min-height: 174px; padding: 26px; display: flex; flex-direction: column; background: linear-gradient(145deg, #101824, #0b111a); }
.metric-card span { color: #788698; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.metric-card strong { margin-top: 24px; color: var(--blue-bright); font-size: 46px; line-height: 1; letter-spacing: -.055em; }
.metric-card small { margin-top: auto; color: #586576; font-size: 10px; }
.overview-grid { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.panel { border: 1px solid var(--line); background: rgba(12, 19, 29, .88); box-shadow: 0 14px 45px rgba(0, 0, 0, .12); }
.panel + .panel { margin-top: 22px; }
.overview-grid .panel + .panel { margin-top: 0; }
.panel__head { min-height: 85px; padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel__head span { color: var(--blue-bright); font-size: 9px; font-weight: 850; letter-spacing: .14em; }
.panel__head h2 { margin: 7px 0 0; font-size: 21px; letter-spacing: -.035em; }
.panel-link { padding: 8px 0; color: #8190a3; }
.compact-list { min-height: 260px; }
.compact-item { min-height: 65px; padding: 14px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; border-bottom: 1px solid var(--line-soft); }
.compact-item:last-child { border-bottom: 0; }
.compact-item strong, .compact-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-item strong { font-size: 12px; }
.compact-item small { margin-top: 6px; color: #687689; font-size: 10px; }
.empty-state { min-height: 220px; padding: 30px; display: grid; place-items: center; color: #637084; text-align: center; font-size: 12px; }

.form-panel { overflow: hidden; }
.admin-form { padding: 23px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.admin-form label { align-content: start; }
.admin-form .field-wide { grid-column: span 2; }
.form-action { display: flex; align-items: end; }
.form-action .primary-button { width: 100%; }
.search-input { width: min(240px, 40vw); min-height: 38px; }
.table-panel { overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 950px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: #637184; background: rgba(255, 255, 255, .018); font-size: 9px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
td { color: #b5c0ce; font-size: 11px; line-height: 1.45; }
tbody tr:hover { background: rgba(255, 159, 67, .025); }
tbody tr:last-child td { border-bottom: 0; }
.cell-main { display: block; color: #eef5fd; font-weight: 700; }
.cell-sub { display: block; margin-top: 4px; color: #5e6b7e; font-size: 9px; }
.mono { max-width: 260px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; word-break: break-all; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border: 1px solid var(--line); color: #94a2b5; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.badge--on { color: #9ee8c4; border-color: rgba(91, 217, 154, .28); background: rgba(91, 217, 154, .07); }
.badge--off, .badge--error { color: #ffabb3; border-color: rgba(255, 107, 120, .28); background: rgba(255, 107, 120, .07); }
.badge--warn { color: #ffe29a; border-color: rgba(255, 209, 102, .3); background: rgba(255, 209, 102, .07); }
.table-actions { display: flex; justify-content: flex-end; gap: 7px; }
.action-button { min-height: 31px; padding: 0 10px; border: 1px solid var(--line); background: transparent; color: #9eabba; cursor: pointer; font-size: 10px; white-space: nowrap; }
.action-button:hover { color: #fff; border-color: rgba(255, 159, 67, .55); }
.action-button--danger:hover { color: #ffabb3; border-color: rgba(255, 107, 120, .5); }
.inline-select { min-height: 30px; width: auto; padding: 0 28px 0 9px; font-size: 10px; }
.json-data { max-width: 410px; color: #718094; font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; word-break: break-word; }

.modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(2, 5, 9, .82); backdrop-filter: blur(8px); }
.modal__card { position: relative; z-index: 1; width: min(100%, 620px); padding: 42px; border: 1px solid rgba(255, 192, 120, .35); background: #0c131d; box-shadow: var(--shadow); }
.modal__card h2 { margin: 19px 0 10px; font-size: 34px; letter-spacing: -.045em; }
.modal__card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.modal__close { position: absolute; top: 13px; right: 13px; width: 36px; height: 36px; border: 1px solid var(--line); background: transparent; color: #8290a2; cursor: pointer; font-size: 21px; }
.license-key { margin: 25px 0 16px; padding: 17px; border: 1px dashed rgba(255, 192, 120, .42); background: #070c12; color: #ffe0bd; font-family: "SFMono-Regular", Consolas, monospace; font-size: 14px; line-height: 1.6; word-break: break-all; }

label,
.eyebrow,
.icon-button,
.primary-button,
.back-link,
.message,
.connection-state,
.text-button,
.panel-link,
.sidebar__caption,
.nav-item,
.nav-item span,
.nav-item b,
.sidebar__footer small,
.sidebar__footer a,
.content__header p,
.metric-card span,
.metric-card small,
.panel__head span,
.compact-item strong,
.compact-item small,
.empty-state,
th,
td,
.cell-sub,
.badge,
.action-button,
.inline-select,
.json-data,
.modal__card p {
  font-size: .875rem;
}

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .overview-grid { grid-template-columns: 1fr; }
  .overview-grid .panel + .panel { margin-top: 0; }
  .admin-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  body.sidebar-open { overflow: hidden; }
  .login-screen { padding: 16px; }
  .login-card { padding: 32px 24px; }
  .login-card .brand { margin-bottom: 45px; }
  .topbar { height: 68px; padding: 0 16px; }
  .topbar .brand__name { display: none; }
  .connection-state { display: none; }
  .text-button { padding: 0 10px; }
  .admin-layout { min-height: calc(100vh - 68px); grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 30;
    top: 68px;
    bottom: 0;
    left: 0;
    width: min(82vw, 300px);
    height: auto;
    transform: translateX(-102%);
    transition: transform .25s ease;
    box-shadow: 25px 0 70px rgba(0, 0, 0, .5);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .content { padding: 34px 16px 60px; }
  .content__header { align-items: center; }
  .content__header h1 { font-size: 39px; }
  .mobile-menu { display: block; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); background: transparent; color: #aab5c4; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 145px; }
  .panel__head { align-items: flex-start; flex-direction: column; }
  .search-input { width: 100%; }
  .admin-form { grid-template-columns: 1fr; }
  .admin-form .field-wide { grid-column: auto; }
  .modal__card { padding: 36px 23px 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
