/* ── Reset & variables ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --border:    #e2e5ea;
  --text:      #1a1d23;
  --muted:     #6b7280;
  --primary:   #1a56db;
  --primary-h: #1245b8;
  --danger:    #c81e1e;
  --danger-bg: #fff5f5;
  --warn:      #92400e;
  --warn-bg:   #fffbeb;
  --success:   #065f46;
  --success-bg:#ecfdf5;
  --flag-bg:   #fef2f2;
  --flag-bdr:  #fca5a5;
  --ok-bg:     #f0fdf4;
  --ok-bdr:    #86efac;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
}
.brand-icon { font-size: 22px; }
.brand-icon.large { font-size: 48px; }
.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}
.header-nav a { color: var(--muted); font-weight: 500; }
.header-nav a:hover { color: var(--text); text-decoration: none; }
.officer-pill {
  background: #eff6ff;
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 13px;
  font-weight: 600;
}
.logout-link { color: var(--muted) !important; }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}
.page-narrow { max-width: 640px; margin: 0 auto; }
.page-wide   { width: 100%; }
.centered    { text-align: center; padding-top: 60px; }

.page-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-heading h2 { font-size: 22px; }

.page-intro {
  color: var(--muted);
  margin-bottom: 24px;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px 24px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); text-decoration: none; color:#fff; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-full  { width: 100%; }
.btn-large { padding: 12px 28px; font-size: 16px; }
.btn-sm    { padding: 4px 12px; font-size: 13px; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fca5a5; }
.alert-warn  { background: var(--warn-bg); color: var(--warn); border: 1px solid #fcd34d; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}
.action-card { border-color: #93c5fd; }

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
}
.form-row { margin-bottom: 20px; }
.form-row label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="number"],
.form-row input {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  transition: border-color .15s;
}
.form-row input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}
.field-hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.optional { font-weight: 400; color: var(--muted); }
.form-actions { margin-top: 8px; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand h1 { font-size: 26px; margin-top: 8px; }
.login-tagline { color: var(--muted); font-size: 14px; }
.login-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
  margin-bottom: 8px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--primary);
}
.login-form .btn { margin-top: 12px; }
.login-note {
  margin-top: 20px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
  padding: 20px 0;
}
.hero-text h2 { font-size: 32px; margin-bottom: 14px; line-height: 1.2; }
.hero-text p  { color: var(--muted); margin-bottom: 24px; font-size: 16px; }
.hero-text .btn { margin-right: 12px; }
.hero-steps { display: flex; flex-direction: column; gap: 20px; padding-top: 8px; }
.step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.step-num {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step p { margin-top: 2px; color: var(--muted); font-size: 14px; }

@media (max-width: 700px) {
  .hero { grid-template-columns: 1fr; gap: 32px; }
}

/* ── Verdict banner ──────────────────────────────────────────────────────── */
.verdict-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  border: 1px solid;
}
.verdict-flag { background: var(--flag-bg); border-color: var(--flag-bdr); color: #991b1b; }
.verdict-ok   { background: var(--ok-bg);   border-color: var(--ok-bdr);   color: var(--success); }
.verdict-warn { background: var(--warn-bg); border-color: #fcd34d; color: var(--warn); }
.verdict-icon { font-size: 28px; line-height: 1; }
.verdict-body { font-size: 15px; }
.verdict-body strong { margin-right: 10px; }

/* ── Note layout ─────────────────────────────────────────────────────────── */
.note-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .note-layout { grid-template-columns: 1fr; }
}

/* ── Detail list ─────────────────────────────────────────────────────────── */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 14px;
}
.detail-list dt { color: var(--muted); font-weight: 600; white-space: nowrap; }
.detail-list dd { word-break: break-word; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.status-approved { background: var(--success-bg); color: var(--success); }
.status-filed    { background: #eff6ff; color: var(--primary); }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  margin: 2px 2px 2px 0;
}
.tag-flag         { background: var(--flag-bg); color: #991b1b; font-weight: 700; }
.tag-ok           { background: var(--ok-bg);   color: var(--success); font-weight: 700; }
.tag-same-supplier{ background: #fff7ed; color: #c2410c; }

/* ── Sources ─────────────────────────────────────────────────────────────── */
.source-list { display: flex; flex-direction: column; gap: 12px; }
.source-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg);
}
.source-same-supplier { border-color: #fdba74; background: #fff7ed; }
.source-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.source-link { font-size: 13px; font-weight: 600; font-family: monospace; }
.source-amount { margin-left: auto; font-weight: 700; font-size: 14px; }
.source-meta { font-size: 13px; color: var(--muted); }
.sep { margin: 0 4px; color: #d1d5db; }
.matched-words { margin-top: 6px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table-full {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.num   { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap{ white-space: nowrap; }
.mono  { font-family: ui-monospace, monospace; }
.small-text { font-size: 13px; color: var(--muted); }

/* ── Full note text ──────────────────────────────────────────────────────── */
.note-text {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: #f8fafc;
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
}

/* ── Meta bar ────────────────────────────────────────────────────────────── */
.meta-bar {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty-state { color: var(--muted); font-style: italic; font-size: 14px; }
.empty-state-block {
  text-align: center;
  padding: 60px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.empty-state-block p { color: var(--muted); margin-bottom: 16px; }

/* ── Tool history badges ─────────────────────────────────────────────────── */
.tool-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tool-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  font-weight: 500;
}
.tool-badge-ok {
  background: var(--ok-bg);
  color: var(--success);
  border-left: 3px solid var(--success);
}
.tool-badge-fail {
  background: var(--danger-bg);
  color: var(--danger);
  border-left: 3px solid var(--danger);
}
.tool-icon {
  font-weight: 700;
  font-size: 14px;
}
