:root {
  --bg: #0b1018;
  --bg-2: #111826;
  --sidebar: #0a0f16;
  --card: #151c28;
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #ff8a3d;
  --accent-2: #ffb37a;
  --ok: #62d392;
  --warn: #f0c14a;
  --danger: #f07178;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, system-ui, sans-serif;
}

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

button,
input,
textarea {
  font: inherit;
}

#app {
  min-height: 100dvh;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(255, 138, 61, 0.18), transparent 50%),
    radial-gradient(800px 400px at 100% 0%, rgba(61, 214, 198, 0.08), transparent 45%),
    linear-gradient(180deg, #0b1018, #0e1622);
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #0c1017;
}

.brand h1,
.brand .name {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-card p.lead {
  color: var(--muted);
  margin: 10px 0 24px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 6px;
  background: #0e1520;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

dl,
dt,
dd {
  margin: 0;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(255, 138, 61, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, #ff9a55, var(--accent));
  color: #1a0d04;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-small {
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
}

.btn-secondary {
  background: #1c2738;
  color: var(--text);
  border: 1px solid var(--line);
  width: auto;
}

.company-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 640px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-head h3 {
  margin: 0;
  font-size: 18px;
}

.info-grid {
  display: grid;
  gap: 16px;
}

.info-grid dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 4px;
}

.info-grid dd {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.total-value {
  color: var(--accent);
  font-size: 22px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.error {
  background: rgba(240, 113, 120, 0.12);
  border: 1px solid rgba(240, 113, 120, 0.35);
  color: #ffc2c5;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 14px;
}

.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav a,
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  width: 100%;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.nav a.active,
.nav a:hover,
.nav-group-toggle:hover,
.nav-group.has-active > .nav-group-toggle {
  background: rgba(255, 138, 61, 0.1);
  color: var(--text);
}

.nav a.active,
.nav-group.has-active > .nav-group-toggle {
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-group-toggle .chevron {
  margin-left: auto;
  transition: transform 0.15s ease;
}

.nav-group.open .nav-group-toggle .chevron {
  transform: rotate(90deg);
}

.nav-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 12px;
}

.nav-group.open .nav-sub {
  display: flex;
}

.nav-sub-link {
  padding: 8px 12px 8px 28px !important;
  font-size: 14px;
  font-weight: 600;
}

.nav-empty {
  padding: 8px 12px 8px 28px;
  color: var(--muted);
  font-size: 13px;
}

.lead-page {
  color: var(--muted);
  margin: 0 0 16px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 10px 16px;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.code-editor {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
  resize: vertical;
}

.badge-err {
  background: rgba(240, 113, 120, 0.14);
  color: var(--danger);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.user-name {
  font-weight: 700;
}

.user-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 10px;
}

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 20px 28px 8px;
}

.topbar h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.menu-btn {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 42px;
  height: 42px;
}

.page {
  padding: 12px 28px 32px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok {
  background: rgba(98, 211, 146, 0.14);
  color: var(--ok);
}

.badge-off {
  background: rgba(139, 155, 180, 0.14);
  color: var(--muted);
}

.badge-warn {
  background: rgba(240, 193, 74, 0.14);
  color: var(--warn);
}

.switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 0;
  background: #2a3548;
  position: relative;
  cursor: pointer;
}

.switch.on {
  background: var(--accent);
}

.switch::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.15s ease;
}

.switch.on::after {
  transform: translateX(18px);
}

.cards {
  display: grid;
  gap: 16px;
}

.log-card,
.settings-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  font-size: 14px;
}

.kv dt {
  color: var(--muted);
}

pre.json {
  margin: 0;
  background: #0e1520;
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.45;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1c2738;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.overlay {
  display: none;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    z-index: 10;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: none;
  }

  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9;
  }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .page,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
