:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --log-bg: #0b1020;
  --log-text: #e5e7eb;
}

[data-theme="dark"] {
  --bg: #0b0f1a;
  --card: #121826;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
  --primary: #3b82f6;
  --primary-dark: #1d4ed8;
  --log-bg: #0b1020;
  --log-text: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

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

.brand {
  font-size: 20px;
  font-weight: 700;
}

.controls label {
  display: block;
  font-size: 12px;
  margin: 10px 0 6px;
  color: var(--muted);
}

.controls input,
.controls select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}

.controls .row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

button {
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 10px;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover { background: var(--primary-dark); }

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.ghost.danger {
  color: #dc2626;
  border-color: #fca5a5;
}

[data-theme="dark"] .ghost.danger {
  color: #f87171;
  border-color: #7f1d1d;
}

.ghost.danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

.ghost.danger {
  color: #dc2626;
  border-color: #fca5a5;
}

[data-theme="dark"] .ghost.danger {
  color: #f87171;
  border-color: #7f1d1d;
}

.ghost.danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: auto;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input { display: none; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .2s;
  border-radius: 99px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.content {
  padding: 24px;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.top-exit-btn {
  margin-top: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.logs {
  background: var(--log-bg);
  color: var(--log-text);
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  height: calc(100vh - 120px);
  overflow: auto;
  line-height: 1.6;
}

.log-line {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 6px 0;
  white-space: pre-wrap;
}

.log-level-info { color: #93c5fd; }
.log-level-warn { color: #fbbf24; }
.log-level-error { color: #f87171; }
.log-level-debug { color: #34d399; }

.login {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.card h2 { margin: 0 0 8px; }

.card p { color: var(--muted); margin: 0 0 16px; }

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

.error {
  color: #ef4444;
  font-size: 12px;
  margin-top: 6px;
}

.login-links {
  margin-top: 16px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}

.login-links a {
  color: var(--accent, #2563eb);
  text-decoration: none;
}

.login-links a:hover {
  text-decoration: underline;
}

.status-footer-simple {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: var(--card);
}

.footer-link {
  color: var(--primary);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-divider {
  margin: 0 8px;
  opacity: 0.5;
}

.password-hash-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.password-hash-modal.hidden {
  display: none;
}

.password-hash-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.password-hash-dialog {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.password-hash-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.password-hash-title {
  font-size: 16px;
  font-weight: 700;
}

.password-hash-sub,
.cell-muted {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.password-hash-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.password-hash-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.password-hash-input,
.password-hash-output {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.password-hash-output {
  resize: vertical;
  min-height: 140px;
}

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

.password-hash-primary {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.password-hash-ghost {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.password-hash-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.password-hash-error {
  font-size: 12px;
  color: var(--muted);
}

.password-hash-error.hidden {
  display: none;
}

.password-hash-error.password-hash-error-active {
  color: #dc2626;
}

.password-hash-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.password-hash-hint code {
  font-size: 10px;
  word-break: break-all;
}

.bet-history-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 14px;
  }

  .content {
    padding: 12px;
  }

  .logs {
    height: calc(100vh - 280px);
    min-height: 240px;
  }

  .card {
    width: min(360px, calc(100vw - 32px));
    margin: 16px;
    padding: 18px;
  }

  .header {
    flex-wrap: wrap;
    gap: 8px;
  }
}
