@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #12213B;
  --ink-soft: #445068;
  --bg: #F7F8FA;
  --panel: #FFFFFF;
  --steel: #3D5A80;
  --steel-dark: #2C4260;
  --line: #E4E7EC;
  --line-strong: #D3D8E0;
  --good: #1F9D6B;
  --good-bg: #E9F7F1;
  --alert: #B23A2F;
  --alert-bg: #FBEAE8;
  --new-bg: #FFF6E9;
  --new-dot: #C8791F;
  --radius: 6px;
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

a { color: var(--steel); }

::selection { background: #CFE0F0; }

:focus-visible {
  outline: 2px solid var(--steel);
  outline-offset: 2px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand .mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--steel);
  display: inline-block;
  transform: translateY(-1px);
}

.brand small {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
  color: var(--ink-soft);
}

.topbar-right .who { color: var(--ink); font-weight: 500; }

.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.btn:hover { border-color: var(--steel); background: #FAFBFD; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
}
.btn-primary:hover { background: var(--steel-dark); border-color: var(--steel-dark); }

.btn-danger {
  border-color: #E3BDB8;
  color: var(--alert);
  background: #fff;
}
.btn-danger:hover { background: var(--alert-bg); border-color: var(--alert); }

.btn-quiet {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 6px 10px;
}
.btn-quiet:hover { color: var(--ink); background: var(--bg); }

/* ---------- Page shell ---------- */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 44px 32px 80px;
}

.page-wide { max-width: 1120px; }

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.page-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 40px 36px;
}

.login-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-mark .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--steel);
}

.login-mark span {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.login-card h1 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

.login-card .sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 26px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--sans);
  color: var(--ink);
  background: #fff;
  margin-bottom: 18px;
}
input:focus, select:focus { border-color: var(--steel); }

.login-card .btn-primary { width: 100%; padding: 11px; font-size: 15px; }

.error-banner {
  background: var(--alert-bg);
  color: var(--alert);
  border: 1px solid #E3BDB8;
  border-radius: var(--radius);
  padding: 10px 13px;
  font-size: 13.5px;
  margin-bottom: 18px;
  display: none;
}
.error-banner.show { display: block; }

.success-banner {
  background: var(--good-bg);
  color: var(--good);
  border: 1px solid #B8E4D1;
  border-radius: var(--radius);
  padding: 10px 13px;
  font-size: 13.5px;
  margin-bottom: 18px;
  display: none;
}
.success-banner.show { display: block; }

.footnote {
  margin-top: 22px;
  font-size: 12.5px;
  color: #8A93A6;
  text-align: center;
}

/* ---------- Date divider / report ledger ---------- */
.year-group { margin-bottom: 8px; }

.date-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 34px 0 14px;
}
.date-divider:first-child { margin-top: 0; }

.date-divider .label {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.date-divider .rule {
  flex: 1;
  height: 1px;
  background: var(--line-strong);
}

.report-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  text-decoration: none;
  color: inherit;
}
.report-row:hover {
  border-color: var(--line-strong);
  box-shadow: 0 2px 10px rgba(18, 33, 59, 0.05);
}

.report-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  flex-shrink: 0;
}
.report-row.is-new .report-status-dot { background: var(--new-dot); }

.report-info { flex: 1; min-width: 0; }

.report-title {
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 3px;
  color: var(--ink);
}

.report-meta {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0;
}

.report-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}
.report-tag.new { background: var(--new-bg); color: var(--new-dot); }
.report-tag.viewed { background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line); }

.report-arrow { color: #B7BECC; flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-soft);
}
.empty-state h2 {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--ink);
  margin: 14px 0 6px;
}
.empty-state p { font-size: 14px; margin: 0; }

/* ---------- Report viewer ---------- */
.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.viewer-bar .title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15px;
}
.viewer-bar .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

.viewer-frame {
  width: 100%;
  height: calc(100vh - 62px);
  border: none;
  display: block;
  background: #fff;
}

/* ---------- Admin: tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.tab {
  padding: 11px 4px;
  margin-right: 24px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  position: relative;
  top: 1px;
}
.tab.active { color: var(--ink); border-bottom-color: var(--steel); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Admin: cards / table ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.panel h2 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
}
.panel .panel-sub {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid .full { grid-column: 1 / -1; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .muted { color: var(--ink-soft); font-size: 13px; }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.row-actions .btn { padding: 6px 12px; font-size: 13px; }

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.pill.admin { background: #EAF0FF; color: var(--steel-dark); border-color: #C9D9F5; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 33, 59, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 28px;
  max-width: 400px;
  width: 100%;
}
.modal h3 {
  font-family: var(--serif);
  font-size: 18px;
  margin: 0 0 4px;
}
.modal .sub { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

@media (max-width: 640px) {
  .page { padding: 28px 18px 60px; }
  .topbar { padding: 14px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .report-row { flex-wrap: wrap; }
}
