:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --bg-2: #eef2ff;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --border: rgba(148, 163, 184, 0.28);
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --sidebar: 286px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-2: #111827;
  --surface: rgba(15, 23, 42, 0.82);
  --surface-solid: #111827;
  --surface-2: #172033;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --primary: #60a5fa;
  --primary-2: #93c5fd;
  --primary-soft: rgba(96, 165, 250, 0.16);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--primary-soft), transparent 34rem),
    radial-gradient(circle at 80% 10%, rgba(14, 165, 233, 0.10), transparent 28rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

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

.login-card,
.hero-card,
.entry-card,
.toolbar,
.sidebar,
.topbar {
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border-radius: var(--radius-xl);
  text-align: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 18px;
  color: white;
  font-weight: 900;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 16px 36px rgba(37, 99, 235, 0.28);
}

.brand-mark.small {
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 14px;
  font-size: 0.85rem;
}

.login-card h1,
.topbar h1 {
  margin: 0;
  letter-spacing: -0.045em;
}

.login-card p,
.subtitle {
  color: var(--muted);
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 18px;
}

.password-row input,
.filter-row input,
.filter-row select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-solid);
  outline: none;
}

.password-row input:focus,
.filter-row input:focus,
.filter-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.primary,
.ghost,
.link-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.primary:hover,
.ghost:hover,
.link-button:hover {
  transform: translateY(-1px);
}

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

.ghost.small,
.link-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 0.86rem;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  border-radius: 0;
  border-right: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header strong,
.sidebar-header span {
  display: block;
}

.sidebar-header span {
  color: var(--muted);
  font-size: 0.85rem;
}

.section-nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 18px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item strong,
.nav-item small {
  display: block;
}

.nav-item small {
  margin-top: 2px;
  font-size: 0.78rem;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--primary-soft);
}

.nav-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  color: white;
  font-size: 0.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(5, 150, 105, 0.12);
}

.main {
  padding: 30px;
}

.topbar,
.hero-card,
.toolbar {
  border-radius: var(--radius-xl);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.subtitle {
  max-width: 680px;
  margin: 8px 0 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto;
  gap: 16px;
  align-items: center;
  margin-top: 22px;
  padding: 20px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
}

.metric span {
  display: block;
  font-size: 2rem;
  font-weight: 950;
  letter-spacing: -0.06em;
}

.metric small {
  color: var(--muted);
  font-weight: 800;
}

.approve-button {
  min-height: 68px;
  padding: 0 24px;
  border-radius: 20px;
  white-space: nowrap;
}

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

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.checkbox-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px;
  gap: 10px;
}

.parse-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  min-width: min(520px, 100%);
}

.parse-form input {
  min-width: 0;
}

.entries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.entry-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 430px;
  padding: 18px;
  border-radius: var(--radius-xl);
}

.entry-card.selected {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 18px 48px rgba(37, 99, 235, 0.14);
}

.entry-card.duplicate {
  opacity: 0.72;
}

.entry-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.check-wrap {
  position: relative;
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  cursor: pointer;
}

.check-wrap input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.custom-checkbox {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
  transition: background 160ms ease, border-color 160ms ease;
}

.custom-checkbox::after {
  content: "✓";
  color: white;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.7);
}

.check-wrap input:checked + .custom-checkbox {
  border-color: var(--primary);
  background: var(--primary);
}

.check-wrap input:checked + .custom-checkbox::after {
  opacity: 1;
  transform: scale(1);
}

.entry-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 0.78rem;
  font-weight: 900;
}

.pill.muted {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.14);
}

.pill.warning {
  color: var(--warning);
  background: rgba(217, 119, 6, 0.14);
}

.entry-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.entry-snippet {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
}

.target-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.target-name {
  text-align: right;
}

.markdown-preview {
  flex: 1;
  overflow: auto;
  max-height: 160px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 0.9rem;
}

.markdown-preview h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.markdown-preview blockquote {
  margin: 0 0 10px;
  padding-left: 12px;
  color: var(--muted);
  border-left: 3px solid var(--primary);
}

.markdown-preview p {
  margin: 0;
  color: var(--muted);
}

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

.tag {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.12);
  font-size: 0.76rem;
  font-weight: 800;
}

.entry-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.empty-state {
  margin-top: 24px;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-xl);
  text-align: center;
  color: var(--muted);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 36px));
}

.toast {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  animation: slideIn 180ms ease-out;
}

.toast.success {
  border-color: rgba(5, 150, 105, 0.35);
}

.toast.error {
  border-color: rgba(220, 38, 38, 0.35);
}

.toast.warning {
  border-color: rgba(217, 119, 6, 0.35);
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-radius: 0 0 28px 28px;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .toolbar,
  .hero-card {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .filter-row,
  .parse-form {
    grid-template-columns: 1fr;
  }

  .entries-grid {
    grid-template-columns: 1fr;
  }
}
