:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d0d5dd;
  --surface: #ffffff;
  --page: #f4f6f8;
  --sidebar: #101828;
  --sidebar-muted: #98a2b3;
  --accent: #1565c0;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

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

.site-auth-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: 0 18px 40px rgb(16 24 40 / 10%);
}

.site-auth-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 12px;
  color: #ffffff;
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 14px;
  font-weight: 700;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: #f79009;
  color: #111827;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: block;
  border-radius: 7px;
  padding: 10px 12px;
  color: #e4e7ec;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: #344054;
}

.nav-item.disabled {
  color: #667085;
  pointer-events: none;
}

.connection-card {
  margin-top: auto;
  display: grid;
  gap: 3px;
  border-top: 1px solid #344054;
  padding: 14px 10px 4px;
  overflow-wrap: anywhere;
}

.connection-card small {
  color: var(--sidebar-muted);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.page-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.auth-panel {
  max-width: 520px;
}

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

.report-header {
  margin-bottom: 12px;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rescan-status {
  margin: 0 0 12px;
  border: 1px solid #b2ddff;
  border-radius: 6px;
  padding: 10px 12px;
  color: #1849a9;
  background: #eff8ff;
  overflow-wrap: anywhere;
}

.rescan-status.error {
  border-color: #fecdca;
  color: #912018;
  background: #fffbfa;
}

.rescan-status.success {
  border-color: #abefc6;
  color: #067647;
  background: #ecfdf3;
}

h1,
h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

h3 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0;
}

.auth-form,
.scan-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.form-hint {
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  min-height: 86px;
  line-height: 1.4;
  resize: vertical;
}

.access-key-field {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  -webkit-text-security: disc;
}

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button.secondary,
.link-button.secondary {
  background: #344054;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.form-error {
  border: 1px solid #fecdca;
  border-radius: 6px;
  padding: 10px 12px;
  color: #912018;
  background: #fffbfa;
}

.connected-state {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

dl div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.report-workspace {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.report-frame {
  width: 100%;
  height: calc(100vh - 112px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.lazy-report {
  min-height: calc(100vh - 112px);
}

.lazy-placeholder,
.page-loading {
  min-height: 180px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  background: #ffffff;
}

.lazy-placeholder strong {
  color: var(--ink);
}

.empty-state,
.empty {
  margin: 0;
  color: var(--muted);
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.cancel-form {
  margin-top: 16px;
}

.report-list {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.report-list ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.report-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
}

.report-list a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.report-list span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.cleanup-actions {
  display: grid;
  gap: 10px;
}

.cleanup-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.cleanup-action summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.restore-button {
  margin-top: 12px;
}

.restore-button.secondary {
  min-height: 32px;
  background: #344054;
  font-size: 13px;
}

.cleanup-items {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.cleanup-items li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.cleanup-items span {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.cleanup-message {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #eef6ff;
}

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

  .sidebar {
    min-height: auto;
  }

  .workspace {
    padding: 16px;
  }

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

  .report-frame {
    height: 70vh;
  }

  .report-list li,
  .cleanup-items li {
    grid-template-columns: 1fr;
  }
}
