:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --danger: #f85149;
  --ok: #3fb950;
  --warn: #d29922;
  --font: "Segoe UI", "IBM Plex Sans", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  padding: 24px;
}

body.auth-checking {
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

body.login-mode,
body:has(#login-view:not(.hidden)) {
  padding: 0;
  overflow: hidden;
}

h1,
h2,
p {
  margin: 0;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

#login-view {
  display: flex;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: var(--bg);
}

.login-panel {
  flex: 0 0 min(420px, 100%);
  width: min(420px, 100%);
  height: 100%;
  display: flex;
  align-items: stretch;
  background: rgba(22, 27, 34, 0.96);
  border-right: 1px solid var(--border);
  z-index: 1;
}

.login-panel-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 32px;
}

#login-view h1 {
  font-size: 1.75rem;
  letter-spacing: 0.02em;
}

#login-view .sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 28ch;
}

.login-hero {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0e14;
}

.login-hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(13, 17, 23, 0.55) 0%, rgba(13, 17, 23, 0.15) 40%, rgba(13, 17, 23, 0.35) 100%),
    linear-gradient(180deg, transparent 45%, rgba(13, 17, 23, 0.72) 100%);
  pointer-events: none;
}

.login-hero-copy {
  position: absolute;
  left: 48px;
  right: 48px;
  bottom: 48px;
  z-index: 1;
  max-width: 34rem;
}

.login-hero-kicker {
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.login-hero-title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.login-hero-text {
  margin-top: 12px;
  color: rgba(230, 237, 243, 0.82);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 36ch;
}

.form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.form button,
.toolbar button,
.actions button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(88, 166, 255, 0.14);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 14px;
}

.form button:hover,
.toolbar button:hover,
.actions button:hover {
  border-color: var(--accent);
}

.form button.primary {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
  font-weight: 600;
}

.error {
  margin-top: 12px;
  color: var(--danger);
  min-height: 1.2em;
  font-size: 0.9rem;
}

#app-view {
  max-width: 1100px;
  margin: 0 auto;
}

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

.brand {
  font-size: 1.35rem;
  font-weight: 650;
}

.user-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.tabs button.active {
  color: var(--text);
  border-color: var(--border);
  background: rgba(22, 27, 34, 0.8);
}

.panel {
  background: rgba(22, 27, 34, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
}

.panel h2 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.panel .hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

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

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.8);
  vertical-align: middle;
}

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

.mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

input[type="number"] {
  width: 72px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  color: var(--muted);
}

.badge.on {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.45);
}

.badge.off {
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.4);
}

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

.actions button.danger {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.08);
}

.status-line {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.status-line.error {
  color: var(--danger);
}

.status-line.ok {
  color: var(--ok);
}

@media (max-width: 720px) {
  body {
    padding: 14px;
  }

  body:has(#login-view:not(.hidden)) {
    padding: 0;
    overflow: auto;
  }

  #login-view {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .login-panel {
    flex: none;
    width: 100%;
    height: auto;
    min-height: 100vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .login-hero {
    min-height: 42vh;
  }

  .login-hero-copy {
    left: 24px;
    right: 24px;
    bottom: 24px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
