:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-sunken: #f9fafb;
  --border: #e3e5ea;
  --border-strong: #cdd0d8;
  --text: #16181d;
  --text-muted: #6b7080;
  --text-faint: #9297a6;
  --accent: #4338ca;
  --accent-hover: #362cb0;
  --accent-soft: #eeecfd;
  --accent-contrast: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --success: #0f7a4d;
  --success-bg: #e2f6ec;

  --shadow-sm: 0 1px 2px rgba(20, 21, 26, 0.05);
  --shadow-md: 0 4px 16px rgba(20, 21, 26, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --surface: #1a1b1f;
    --surface-sunken: #16171b;
    --border: #2b2d33;
    --border-strong: #3c3f47;
    --text: #f1f2f4;
    --text-muted: #9a9da8;
    --text-faint: #6d7078;
    --accent: #8b85f5;
    --accent-hover: #a29cf9;
    --accent-soft: #262247;
    --accent-contrast: #14131f;
    --danger: #ff8a80;
    --danger-bg: #3a1f1d;
    --success: #4fd6a0;
    --success-bg: #103526;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--accent);
}
.logout-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}
.logout-link:hover { color: var(--text); }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 64px 24px 96px;
}

h1 { font-size: 1.5rem; margin: 0 0 6px; font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: 1.1rem; margin: 48px 0 4px; font-weight: 700; letter-spacing: -0.01em; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; margin: 0 0 30px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }

.file-drop {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  padding: 16px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.file-drop input[type="file"] { margin-top: 8px; font-size: 0.85rem; }

.submit-btn {
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 650;
  font-size: 0.92rem;
  padding: 11px 22px;
  cursor: pointer;
  margin-top: 14px;
  width: 100%;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.submit-btn:hover:not(:disabled) { background: var(--accent-hover); }
.submit-btn:disabled { opacity: 0.6; cursor: wait; }

.status-line {
  display: flex; align-items: center; gap: 10px; margin-top: 16px;
  font-size: 0.9rem; font-weight: 500; color: var(--text-muted); min-height: 22px;
}
.status-line.success { color: var(--success); }

.spinner {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  margin-top: 16px; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 0.87rem; font-weight: 500; background: var(--danger-bg); color: var(--danger);
}
.alert.warn { background: var(--accent-soft); color: var(--accent); }

.about {
  margin-top: 12px; font-size: 0.83rem; color: var(--text-muted); line-height: 1.6;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.login-card img { height: 32px; margin-bottom: 16px; }
