:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: #101622;
  --surface-2: #151d2b;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #f5f7fb;
  --muted: #98a3b7;
  --muted-2: #66728a;
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --blue: #60a5fa;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #fb7185;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -8%, rgba(99, 102, 241, 0.2), transparent 33rem),
    radial-gradient(circle at 92% 8%, rgba(14, 165, 233, 0.09), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }

[hidden] { display: none !important; }

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

.auth-card {
  width: min(100%, 430px);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(16, 22, 34, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
  font-weight: 850;
  letter-spacing: -0.08em;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

.brand-mark.small { width: 36px; height: 36px; border-radius: 11px; font-size: 12px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--violet-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(33px, 5vw, 56px); line-height: 1.03; letter-spacing: -0.055em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -0.03em; }

.auth-card h1 { margin-top: 22px; font-size: 36px; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.tiny-note { margin: 25px 0 0; color: var(--muted-2); font-size: 11px; }

.stack-form { display: grid; gap: 9px; margin-top: 30px; }
.stack-form label, .field > span { color: #d9deea; font-size: 12px; font-weight: 700; }

input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  background: rgba(7, 10, 17, 0.58);
  color: var(--text);
  padding: 12px 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input::placeholder { color: #5f6b81; }
input:focus { border-color: rgba(139, 92, 246, 0.9); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.14); background: rgba(7, 10, 17, 0.84); }
code { padding: 2px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); color: #ddd6fe; font-size: 0.92em; }

.form-error { min-height: 18px; margin: 2px 0 0; color: var(--red); font-size: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 18, 0.76);
  backdrop-filter: blur(18px);
}

.topbar-inner, .content, .footer { width: min(100% - 40px, 1240px); margin: 0 auto; }
.topbar-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand-lockup, .topbar-actions, .button-row, .selection-tools, .check-label { display: flex; align-items: center; }
.brand-lockup { gap: 11px; }
.brand-title { font-size: 14px; font-weight: 800; letter-spacing: -0.02em; }
.brand-subtitle { margin-top: 2px; color: var(--muted-2); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar-actions { gap: 14px; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.status-chip::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.status-chip.good { border-color: rgba(52, 211, 153, 0.24); color: var(--green); }
.status-chip.warn { border-color: rgba(251, 191, 36, 0.24); color: var(--amber); }
.status-chip.bad { border-color: rgba(251, 113, 133, 0.24); color: var(--red); }

.content { padding: 34px 0 30px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card { min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; padding: 17px 18px; border: 1px solid var(--line); border-radius: 17px; background: rgba(16, 22, 34, 0.7); }
.metric-label { color: var(--muted); font-size: 11px; }
.metric-card strong { font-size: 34px; font-weight: 700; letter-spacing: -0.06em; }

.card { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 21px; background: rgba(16, 22, 34, 0.72); box-shadow: 0 10px 35px rgba(0, 0, 0, 0.12); }
.controls-card { padding: 24px; }
.projects-card, .activity-card { overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 24px; }
.controls-grid { display: grid; grid-template-columns: 1.1fr 1fr 0.75fr; gap: 13px; }
.field { display: grid; gap: 8px; }
.field em { color: var(--muted-2); font-style: normal; font-weight: 500; }
.control-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; }
.control-foot p { max-width: 650px; margin-bottom: 0; }
.button-row { gap: 9px; justify-content: end; flex-wrap: wrap; }

.primary-button, .secondary-button, .ghost-button {
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 800;
  transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.primary-button { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; box-shadow: 0 8px 22px rgba(99, 102, 241, 0.2); }
.secondary-button { border-color: rgba(139, 92, 246, 0.35); background: rgba(139, 92, 246, 0.11); color: #ddd6fe; }
.ghost-button { border-color: var(--line); background: transparent; color: var(--muted); }
.primary-button:hover:not(:disabled), .secondary-button:hover:not(:disabled), .ghost-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.1); }
.ghost-button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); background: rgba(255, 255, 255, 0.04); }

.projects-heading { padding: 24px 24px 0; margin-bottom: 18px; }
.selection-tools { gap: 16px; }
.check-label { gap: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.check-label input, .row-check { width: 15px; height: 15px; margin: 0; accent-color: var(--violet); }
.empty-state { padding: 34px 24px; color: var(--muted); font-size: 13px; text-align: center; }
.empty-state.compact { padding: 28px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 14px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted-2); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
td { color: #dce2ef; font-size: 12px; }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
.check-col { width: 42px; }
.project-name { color: var(--text); font-weight: 750; }
.project-link { display: block; margin-top: 4px; color: var(--muted-2); font-size: 10px; text-decoration: none; }
.project-link:hover { color: var(--blue); }
.source-badge, .result-badge { display: inline-flex; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.source-badge.direct { border-color: rgba(96, 165, 250, 0.24); color: var(--blue); }
.source-badge.git { color: var(--muted-2); }
.result-badge.ready { border-color: rgba(52, 211, 153, 0.23); color: var(--green); }
.result-badge.already_patched { border-color: rgba(96, 165, 250, 0.23); color: var(--blue); }
.result-badge.no_anchor, .result-badge.not_found { border-color: rgba(251, 191, 36, 0.23); color: var(--amber); }
.result-badge.error, .result-badge.stale { border-color: rgba(251, 113, 133, 0.23); color: var(--red); }
.result-badge.applying { border-color: rgba(167, 139, 250, 0.24); color: var(--violet-2); }
.file-path { max-width: 245px; overflow: hidden; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.row-action { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }
.row-action:hover { border-color: var(--line-strong); color: var(--text); }
.row-action.rollback { border-color: rgba(251, 191, 36, 0.25); color: var(--amber); }

.activity-card { padding-bottom: 4px; }
.activity-card .section-heading { padding: 24px 24px 0; }
.activity-log { display: grid; }
.activity-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: start; padding: 13px 24px; border-top: 1px solid var(--line); }
.activity-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--muted-2); }
.activity-dot.good { background: var(--green); }
.activity-dot.warn { background: var(--amber); }
.activity-dot.bad { background: var(--red); }
.activity-message { color: #dce2ef; font-size: 12px; }
.activity-detail { margin-top: 3px; color: var(--muted-2); font-size: 11px; }
.activity-time { color: var(--muted-2); font-size: 10px; white-space: nowrap; }

.footer { display: flex; justify-content: space-between; gap: 15px; padding: 5px 0 35px; color: var(--muted-2); font-size: 10px; }

@media (max-width: 900px) {
  .controls-grid { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .control-foot { align-items: start; flex-direction: column; }
  .button-row { justify-content: start; }
}

@media (max-width: 640px) {
  .topbar-inner, .content, .footer { width: min(100% - 24px, 1240px); }
  .topbar-inner { min-height: 62px; }
  .topbar-actions .status-chip { display: none; }
  .content { padding-top: 44px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 92px; }
  .metric-card strong { font-size: 28px; }
  .controls-card { padding: 18px; }
  .controls-grid { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .projects-heading, .activity-card .section-heading { align-items: start; flex-direction: column; padding: 18px 18px 0; }
  .selection-tools { width: 100%; justify-content: space-between; }
  .footer { flex-direction: column; padding-bottom: 24px; }
  .auth-card { padding: 28px 22px; }
}
