:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --text: #102033;
  --muted: #66758a;
  --line: #d8e0eb;
  --brand: #10243f;
  --brand-2: #1d4f7a;
  --good: #0f7a4f;
  --warn: #9b5c00;
  --bad: #a12828;
  --shadow: 0 16px 40px rgba(20, 36, 58, .12);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 44px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #dcecfb 0, transparent 34rem), var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.app-shell { width: min(1180px, calc(100% - 28px)); margin: 18px auto 34px; }
.loading-card, .empty-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.topbar {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  position: sticky;
  top: 12px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; display: grid; place-items: center; font-weight: 800; letter-spacing: .05em; }
.brand-title { font-size: 1.08rem; font-weight: 800; line-height: 1.15; }
.brand-subtitle { color: var(--muted); font-size: .88rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58vw; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { text-decoration: none; color: var(--text); min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; border-radius: 999px; border: 1px solid transparent; }
.nav a.active, .nav a:hover { background: var(--brand); color: white; }
.nav a.setup-link { color: var(--muted); }
.nav a.setup-link.active { color: white; }

.main { margin-top: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 20px 4px 14px; }
h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.05; margin: 0; letter-spacing: -.04em; }
h2 { margin: 0 0 14px; font-size: 1.2rem; letter-spacing: -.02em; }
h3 { margin: 0 0 10px; font-size: 1rem; }
p { color: var(--muted); line-height: 1.55; }
.small { font-size: .9rem; color: var(--muted); }
.kicker { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .09em; font-size: .74rem; margin-bottom: 7px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card.soft { background: var(--panel-soft); box-shadow: none; }
.card.clickable { transition: transform .15s ease, border-color .15s ease; }
.card.clickable:hover { transform: translateY(-1px); border-color: #b5c6da; }
.big-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.action-card { min-height: 148px; display: flex; flex-direction: column; justify-content: space-between; text-decoration: none; color: var(--text); }
.action-card strong { font-size: 1.25rem; }
.action-card span { color: var(--muted); margin-top: 8px; display: block; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn, .ghost, .danger, .success {
  border: 0;
  border-radius: 12px;
  min-height: var(--tap);
  padding: 10px 14px;
  font-weight: 750;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn { background: var(--brand); color: #fff; }
.ghost { background: #edf2f8; color: var(--text); border: 1px solid var(--line); }
.success { background: var(--good); color: #fff; }
.danger { background: #fff0f0; color: var(--bad); border: 1px solid #f0c6c6; }
.btn.full, .ghost.full, .success.full, .danger.full { width: 100%; }
.link-button { background: transparent; border: 0; color: var(--brand-2); padding: 0; min-height: 0; font-weight: 750; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.one { grid-template-columns: 1fr; }
.field { display: grid; gap: 6px; }
label { font-weight: 750; font-size: .92rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  min-height: var(--tap);
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29,79,122,.14); }
.help { color: var(--muted); font-size: .86rem; line-height: 1.35; }
.inline-help { font-size: .86rem; color: var(--muted); margin-top: 4px; }

.search-line { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.list { display: grid; gap: 10px; }
.row-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.row-main { min-width: 0; }
.row-title { font-weight: 800; }
.row-meta { color: var(--muted); font-size: .9rem; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 4px 9px; font-size: .78rem; font-weight: 800; background: #eef3f8; color: var(--muted); white-space: nowrap; }
.badge.good { background: #e5f6ee; color: var(--good); }
.badge.warn { background: #fff5de; color: var(--warn); }
.badge.bad { background: #ffecec; color: var(--bad); }
.badge.info { background: #e5f0fb; color: var(--brand-2); }

.notice { border-radius: 14px; border: 1px solid var(--line); padding: 12px 14px; background: #f7f9fc; color: var(--text); }
.notice.warn { background: #fff7e8; border-color: #e8c884; }
.notice.bad { background: #fff1f1; border-color: #efbbbb; }
.notice.good { background: #eaf8f1; border-color: #aedec8; }
.notice strong { color: var(--text); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: #f7f9fc; }
tr:last-child td { border-bottom: 0; }

.checklist { display: grid; gap: 10px; }
.check-item { display: grid; grid-template-columns: 1fr 180px; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: #fff; }
.check-item .item-name { font-weight: 750; }
.check-item textarea { grid-column: 1 / -1; min-height: 64px; display: none; }
.check-item.flagged textarea, .check-item.could_not_check textarea { display: block; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 999px; padding: 9px 12px; font-weight: 750; min-height: 40px; }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.details-list details { border: 1px solid var(--line); border-radius: 14px; background: #fff; margin-bottom: 10px; overflow: hidden; }
.details-list summary { cursor: pointer; font-weight: 800; padding: 12px 14px; }
.details-body { padding: 0 14px 14px; }
.file-tree { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; background: #fbfcfe; border: 1px solid var(--line); border-radius: 12px; padding: 10px; overflow: auto; max-height: 420px; }
.file-line { padding: 3px 0; white-space: nowrap; }
.file-folder { font-weight: 800; color: var(--brand-2); margin-top: 8px; }

.setup-section { margin-bottom: 14px; }
.setup-section details { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.setup-section summary { list-style: none; cursor: pointer; padding: 16px 18px; font-weight: 850; display: flex; justify-content: space-between; gap: 12px; }
.setup-section summary::-webkit-details-marker { display: none; }
.setup-content { border-top: 1px solid var(--line); padding: 18px; }

.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 50; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--brand); color: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }
.toast.good { background: var(--good); }

.print-only { display: none; }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 20px, 1180px); margin-top: 10px; }
  .topbar { grid-template-columns: 1fr; position: static; border-radius: 18px; }
  .nav { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .nav a { white-space: nowrap; }
  .brand-subtitle { max-width: 78vw; }
  .big-actions, .grid.two, .grid.three, .form-grid { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; flex-direction: column; }
  .search-line { grid-template-columns: 1fr; }
  .row-card { grid-template-columns: 1fr; }
  .row-card .btn-row { justify-content: stretch; }
  .row-card .btn-row .ghost, .row-card .btn-row .btn { flex: 1; }
  .check-item { grid-template-columns: 1fr; }
  .card { padding: 15px; border-radius: 16px; }
  .action-card { min-height: 126px; }
}

@media print {
  body { background: #fff; }
  .topbar, .btn-row, .nav, .no-print, .setup-section { display: none !important; }
  .app-shell { width: 100%; margin: 0; }
  .card { box-shadow: none; border-color: #aaa; }
  .print-only { display: block; }
}
.top-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.small-btn { min-height: 36px; padding: 8px 10px; border-radius: 10px; }
.small-select { width: auto; min-width: 150px; min-height: 36px; padding: 7px 10px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 820px) {
  .top-actions { justify-content: flex-start; }
  .small-select { width: 100%; }
}
