:root {
  color-scheme: light;
  --bg: #f7f7f9;
  --panel: #ffffff;
  --text: #4a4a4a;
  --muted: #666666;
  --border: #d9dfe7;
  --accent: #08b7f4;
  --accent-dark: #459cff;
  --danger: #ff556a;
  --soft: #f0f5f8;
  --sidebar: #ffffff;
  --row-hover: #f1f5f8;
  --shadow: rgba(10, 10, 10, 0.12);
  --radius: 4px;
  --control-bg: rgba(255, 255, 255, 0.92);
  --control-shadow: rgba(10, 10, 10, 0.1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151a23;
  --panel: #202733;
  --text: #e8edf5;
  --muted: #aeb7c5;
  --border: #384252;
  --accent: #43b6ff;
  --accent-dark: #7bc9ff;
  --danger: #ff6b7c;
  --soft: #2a3342;
  --sidebar: #1b222d;
  --row-hover: #253040;
  --shadow: rgba(0, 0, 0, 0.34);
  --control-bg: rgba(32, 39, 51, 0.94);
  --control-shadow: rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #151a23;
    --panel: #202733;
    --text: #e8edf5;
    --muted: #aeb7c5;
    --border: #384252;
    --accent: #43b6ff;
    --accent-dark: #7bc9ff;
    --danger: #ff6b7c;
    --soft: #2a3342;
    --sidebar: #1b222d;
    --row-hover: #253040;
    --shadow: rgba(0, 0, 0, 0.34);
    --control-bg: rgba(32, 39, 51, 0.94);
    --control-shadow: rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", Arial, Helvetica, sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
.button-link {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 13px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.secondary {
  background: var(--soft);
  color: var(--text);
}

button.danger {
  background: var(--danger);
}

button.full {
  width: 100%;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.hidden {
  display: none !important;
}

.console-controls {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: flex-end;
}

.controls-slot {
  display: flex;
  justify-content: flex-end;
  min-width: max-content;
}

.login-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.language-control,
.theme-control {
  position: relative;
}

.language-toggle,
.theme-toggle,
.language-options button,
.theme-options button {
  min-height: 38px;
  border: 1px solid var(--border);
  background: var(--control-bg);
  color: var(--text);
  box-shadow: 0 8px 28px var(--control-shadow);
}

.language-toggle {
  min-width: 92px;
  gap: 7px;
  justify-content: center;
}

.language-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}

.language-control.open .language-toggle::after {
  transform: rotate(225deg) translateY(-1px);
}

.language-options,
.theme-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--control-bg);
  box-shadow: 0 14px 42px var(--control-shadow);
}

.language-control.open .language-options,
.theme-control.open .theme-options {
  display: grid;
}

.language-options button {
  min-width: 92px;
  justify-content: flex-start;
  box-shadow: none;
}

.theme-control {
  width: 38px;
  transition: width 180ms ease;
}

.theme-control.open {
  width: 148px;
}

.theme-toggle {
  width: 38px;
  min-width: 38px;
  border-radius: 999px;
  padding: 0;
  box-shadow: 0 8px 28px var(--control-shadow);
}

.theme-options {
  top: 0;
  right: 0;
  grid-auto-flow: column;
  box-shadow: none;
  background: transparent;
  border: 0;
  padding: 0;
}

.theme-options button {
  width: 38px;
  min-width: 38px;
  border-radius: 999px;
  padding: 0;
  box-shadow: 0 8px 28px var(--control-shadow);
}

.theme-control:not(.open) .theme-options {
  display: none;
}

.theme-control.open .theme-toggle {
  display: none;
}

.language-options button:hover,
.language-options button.active,
.theme-options button:hover,
.theme-options button.active {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.login-view {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 70px var(--shadow);
}

.login-card form,
.form-grid {
  display: grid;
  gap: 12px;
}

.mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
}

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

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

.brand small,
.muted {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  justify-content: flex-start;
  background: transparent;
  color: var(--text);
}

.nav button.active,
.nav button:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--accent-dark);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar,
.section-head,
.inline-form,
.filters,
.user-menu {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 30px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.panel,
.metric {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(10, 10, 10, 0.05);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  display: grid;
  gap: 5px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  font-size: 20px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
}

tr:hover {
  background: var(--row-hover);
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, #21a67a 16%, var(--panel));
  color: #168761;
  font-size: 12px;
  font-weight: 700;
}

.badge.off {
  background: color-mix(in srgb, var(--danger) 14%, var(--panel));
  color: var(--danger);
}

.empty,
.secret-row {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

.secret-row {
  margin: 14px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-style: solid;
  background: color-mix(in srgb, #f0b429 16%, var(--panel));
  color: var(--text);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 30px var(--shadow);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 900px) {
  .console-controls {
    justify-content: flex-start;
  }

  .app-view,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: 0;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .topbar,
  .section-head,
  .inline-form,
  .filters,
  .user-menu {
    flex-direction: column;
    align-items: stretch;
  }

  .user-menu .controls-slot,
  .user-menu .console-controls {
    justify-content: flex-start;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav button {
    justify-content: center;
    min-width: 0;
    padding-inline: 8px;
    text-align: center;
  }

  .main {
    padding: 18px;
  }

  .panel,
  .metric {
    padding: 16px;
  }

  .secret-row {
    grid-template-columns: 1fr;
  }

  .toast {
    right: 14px;
    bottom: 14px;
    left: 14px;
    max-width: none;
  }
}

@media (max-width: 460px) {
  body {
    overflow-x: hidden;
  }

  .login-view {
    align-items: start;
    padding: 12px;
  }

  .login-card {
    width: 100%;
    padding: 18px;
  }

  .login-card-head {
    align-items: center;
  }

  .controls-slot,
  .console-controls {
    width: auto;
    min-width: 0;
  }

  .language-toggle {
    width: 42px;
    min-width: 42px;
    padding-inline: 0;
  }

  .language-toggle::after,
  #languageCurrentCode {
    display: none;
  }

  .theme-control.open {
    width: 130px;
  }

  .app-view {
    min-height: 100svh;
  }

  .sidebar {
    padding: 12px;
  }

  .brand {
    align-items: flex-start;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav button {
    flex: 0 0 auto;
    min-height: 38px;
    white-space: nowrap;
  }

  .main {
    padding: 12px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .topbar p,
  .brand small {
    font-size: 12px;
  }

  .panel,
  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 18px;
  }

  .table-wrap {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 8px;
  }

  .section-head h2 {
    font-size: 20px;
  }
}
}
