:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg0: #050807;
  --bg1: #0c1210;
  --ink: #e8f2ec;
  --muted: #9bb0a5;
  --line: #2c3d35;
  --accent: #3ecf8e;
  --accent-ink: #04140c;
  --danger: #e57373;
  --panel: rgba(12, 18, 16, 0.92);
  --field: rgba(255, 255, 255, 0.04);
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, monospace;
  --sans: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  --bg-grad: radial-gradient(120% 80% at 10% -10%, #143528 0%, transparent 55%),
    radial-gradient(90% 60% at 100% 0%, #0a1f18 0%, transparent 50%), var(--bg0);
}

[data-theme="light"] {
  color-scheme: light;
  --bg0: #f4f7f5;
  --bg1: #ffffff;
  --ink: #122018;
  --muted: #5a6f64;
  --line: #d5e0da;
  --accent: #0f9f63;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --panel: rgba(255, 255, 255, 0.94);
  --field: #ffffff;
  --bg-grad: radial-gradient(100% 70% at 0% 0%, #d9efe4 0%, transparent 55%),
    radial-gradient(80% 50% at 100% 0%, #e8f5ef 0%, transparent 45%), var(--bg0);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg-grad);
  background-attachment: fixed;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent);
}

#app {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px;
  backdrop-filter: blur(10px);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
}

.brand,
.nav-brand {
  font: 600 13px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

[data-theme="dark"] .theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun,
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
}

.lede {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 12px;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.err {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.ok {
  color: var(--accent);
  font-size: 0.9rem;
}

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

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

.nav {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.nav-links button {
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 500;
}

.nav-links button.active,
.nav-links button:hover {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.nav-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-user {
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-all;
}

.main {
  padding: 28px 26px 48px;
  max-width: 960px;
}

.main h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}

.main .sub {
  margin: 0 0 22px;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.row .field {
  flex: 1 1 160px;
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

code.key-once {
  display: block;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 12px;
  background: var(--field);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  word-break: break-all;
  margin: 10px 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.meta-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-grid dd {
  margin: 2px 0 0;
  font-weight: 600;
}
