*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Dark theme (default) */
:root, [data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222633;
  --border: #2a2e3b;
  --text: #e4e5ea;
  --text-muted: #8b8fa3;
  --accent: #6c5ce7;
  --accent-hover: #7e70ea;
  --green: #00d68f;
  --red: #ff4757;
  --orange: #ffa502;
  --radius: 12px;
  --radius-sm: 8px;
}

/* Light theme */
[data-theme="light"] {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-hover: #f0f1f5;
  --border: #e2e4ea;
  --text: #1a1d27;
  --text-muted: #6b7084;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd1;
  --green: #059669;
  --red: #dc2626;
  --orange: #d97706;
}

/* Auto: follow system preference */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-hover: #f0f1f5;
    --border: #e2e4ea;
    --text: #1a1d27;
    --text-muted: #6b7084;
    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --green: #059669;
    --red: #dc2626;
    --orange: #d97706;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 640px;
}

/* Login */
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

input[type="text"], input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

input:focus {
  border-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input { width: auto; accent-color: var(--accent); cursor: pointer; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.2rem;
}

/* Dashboard */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.header h1 {
  font-size: 1.3rem;
  font-weight: 600;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: auto;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-logout:hover { border-color: var(--red); color: var(--red); background: transparent; }

.site-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}

.site-card:hover { border-color: var(--accent); }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.site-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.status {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.status.online { background: rgba(0,214,143,0.15); color: var(--green); }
.status.offline { background: rgba(255,71,87,0.15); color: var(--red); }
.status.unknown { background: rgba(139,143,163,0.15); color: var(--text-muted); }

[data-theme="light"] .status.online { background: rgba(5,150,105,0.15); }
[data-theme="light"] .status.offline { background: rgba(220,38,38,0.15); }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .status.online { background: rgba(5,150,105,0.15); }
  :root:not([data-theme="dark"]) .status.offline { background: rgba(220,38,38,0.15); }
}

.site-domain {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.site-favicon {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  object-fit: contain;
  flex-shrink: 0;
}

.site-domain a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.site-domain a:hover {
  color: var(--accent);
}

.disk-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.disk-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.disk-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.disk-label svg {
  flex-shrink: 0;
}

.disk-type {
  font-weight: 500;
  color: var(--text);
  font-size: 0.75rem;
}

.disk-pct {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.75rem;
}

.disk-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.disk-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.last-check {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-wp {
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
}

/* Admin section */
.admin-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.admin-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.collab-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
}

.collab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.collab-info { font-size: 0.9rem; }
.collab-info span { color: var(--text-muted); font-size: 0.8rem; }

.btn-reset {
  background: transparent;
  border: 1px solid var(--orange);
  color: var(--orange);
  width: auto;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.btn-reset:hover { background: rgba(255,165,2,0.1); }

.new-token-display {
  background: var(--bg);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  margin-top: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.new-token-display:hover { border-color: var(--accent); }

.token-value {
  font-family: monospace;
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--green);
}

.token-copy-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 0.8rem;
}

.theme-switcher {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.theme-track {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 3px;
  position: relative;
  gap: 0;
}

.theme-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 28px;
  padding: 0;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s;
  border-radius: 50px;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn:hover { color: var(--text); }
.theme-btn.active { color: #fff; }

.theme-indicator {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 36px;
  height: 28px;
  background: var(--accent);
  border-radius: 50px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

.theme-indicator[data-pos="0"] { transform: translateX(0); }
.theme-indicator[data-pos="1"] { transform: translateX(36px); }
.theme-indicator[data-pos="2"] { transform: translateX(72px); }

.powered-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.powered-logo {
  height: 48px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.powered-logo:hover {
  opacity: 1;
}

/* Default (dark): show dark logo (light text), hide light logo */
.powered-logo-light { display: none; }
.powered-logo-dark { display: block; }

/* Forced light: show light logo (dark text) */
[data-theme="light"] .powered-logo-light { display: block; }
[data-theme="light"] .powered-logo-dark { display: none; }

/* Auto + system light: show light logo */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .powered-logo-light { display: block; }
  :root:not([data-theme="dark"]) .powered-logo-dark { display: none; }
}

.powered-footer span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.powered-footer span a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.powered-footer span a:hover {
  color: var(--accent);
}

.loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.modal-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.2rem;
}

.modal-body p { margin: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.modal-btn-cancel:hover { border-color: var(--text-muted); }

.modal-btn-confirm {
  background: var(--accent);
  border: none;
  color: #fff;
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.modal-btn-confirm:hover { background: var(--accent-hover); }

.modal-btn-danger {
  background: var(--red);
  border: none;
  color: #fff;
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.modal-btn-danger:hover { opacity: 0.9; }

.hidden { display: none; }

@media (max-width: 480px) {
  body { padding: 1rem 0.5rem; }
  .login-card { padding: 1.5rem 1.2rem; }
  .site-meta { flex-direction: column; gap: 0.3rem; }
}
