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

:root {
  --paper: #F6F4EE;
  --surface: #FFFFFF;
  --ink: #1E2233;
  --ink-muted: #676B7C;
  --navy: #1B2A4A;
  --navy-deep: #131D33;
  --seal: #B8862E;
  --seal-light: #EFE0BE;
  --valid: #2F6B4F;
  --valid-bg: #E4F0E8;
  --suspect: #A63D3D;
  --suspect-bg: #F6E4E1;
  --pending-bg: #F1EEE4;
  --border: #E3DFD3;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, .display {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  color: var(--navy-deep);
  letter-spacing: -0.01em;
}

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

code, .mono, .ip, .timestamp {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.85em;
}

/* ---------- Shell ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}

.topbar {
  background: var(--navy-deep);
  color: #EDEFF5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 64px;
  border-bottom: 3px solid var(--seal);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Source Serif 4', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.brand .seal-mark {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--seal);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  font-family: 'Roboto Mono', monospace;
  color: var(--seal);
  letter-spacing: 0.5px;
}

.topbar nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.topbar nav a {
  color: #C7CBDB;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover, .topbar nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.topbar .who {
  display: flex; align-items: center; gap: 12px;
}
.topbar .who .role-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--seal);
  color: #2B1E05;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.topbar form { margin: 0; }
.topbar .logout-btn {
  background: none;
  border: 1px solid #3B4560;
  color: #C7CBDB;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
}
.topbar .logout-btn:hover { border-color: var(--seal); color: #fff; }

main.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 28px 80px;
  width: 100%;
}

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { margin: 0; font-size: 1.6rem; }
.page-header p.sub { margin: 4px 0 0; color: var(--ink-muted); font-size: 0.92rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--navy-deep); }
.btn.secondary { background: transparent; color: var(--navy); }
.btn.secondary:hover { background: #EEF0F4; }
.btn.valid { background: var(--valid); border-color: var(--valid); }
.btn.suspect { background: var(--suspect); border-color: var(--suspect); }
.btn.outline-valid { background: transparent; color: var(--valid); border-color: var(--valid); }
.btn.outline-suspect { background: transparent; color: var(--suspect); border-color: var(--suspect); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Stat strip ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
}
.stat {
  background: var(--surface);
  padding: 16px 18px;
}
.stat .n { font-family: 'Source Serif 4', serif; font-size: 1.6rem; font-weight: 700; color: var(--navy-deep); display: block; }
.stat .l { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); }

/* ---------- Table ---------- */
table.doclist {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.doclist th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--border);
  padding: 10px 12px;
}
table.doclist td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.doclist tr:hover td { background: #FBFAF6; }
table.doclist a.doc-link { color: var(--navy-deep); font-weight: 600; text-decoration: none; }
table.doclist a.doc-link:hover { text-decoration: underline; }

/* ---------- Seal / status badge (signature element) ---------- */
.seal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.1;
  position: relative;
  flex-shrink: 0;
}
.seal-badge::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px dashed currentColor;
  border-radius: 50%;
  opacity: 0.5;
}
.seal-badge.pending { color: var(--ink-muted); }
.seal-badge.valid   { color: var(--valid); }
.seal-badge.suspect { color: var(--suspect); }
.seal-badge.approved{ color: var(--valid); }
.seal-badge.rejected{ color: var(--suspect); }

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill.pending  { background: var(--pending-bg); color: #8A7B4E; }
.pill.valid, .pill.approved { background: var(--valid-bg); color: var(--valid); }
.pill.suspect, .pill.rejected { background: var(--suspect-bg); color: var(--suspect); }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy-deep);
  margin-bottom: 6px;
}
.field input[type=text], .field input[type=email], .field input[type=password],
.field textarea, .field select, .field input[type=file] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #C9C4B4;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 80px; }
.field .hint { color: var(--ink-muted); font-size: 0.78rem; margin-top: 4px; }

.error-box {
  background: var(--suspect-bg);
  color: var(--suspect);
  border: 1px solid #E5B9B2;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.success-box {
  background: var(--valid-bg);
  color: var(--valid);
  border: 1px solid #BEDFCB;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 18px;
}

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-deep);
  background-image: radial-gradient(circle at 20% 20%, #1F2E4F 0%, var(--navy-deep) 60%);
  padding: 20px;
}
.login-card {
  background: var(--paper);
  border-radius: 4px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card .seal-mark-lg {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 2px solid var(--seal);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.68rem;
  color: var(--seal);
}
.login-card h1 { text-align: center; font-size: 1.3rem; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--ink-muted); font-size: 0.85rem; margin: 0 0 26px; }
.login-card .btn { width: 100%; justify-content: center; }

/* ---------- Document detail ---------- */
.doc-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin: 20px 0 28px;
}
.doc-meta-grid .item .l { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); display: block; margin-bottom: 3px; }
.doc-meta-grid .item .v { font-size: 0.94rem; color: var(--ink); font-weight: 500; }

.trace-box {
  background: #FBFAF6;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 20px 0;
}
.trace-box h3 { font-size: 0.85rem; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--navy); font-family: 'Inter'; }
.trace-row { display: flex; gap: 18px; font-size: 0.85rem; flex-wrap: wrap; }
.trace-row .k { color: var(--ink-muted); margin-right: 6px; }

.decision-panel {
  border-top: 1px solid var(--border);
  margin-top: 28px;
  padding-top: 22px;
}
.decision-panel h3 { font-size: 1rem; margin: 0 0 12px; }
.decision-panel .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 10px 0 10px 18px;
  border-left: 2px solid var(--border);
  position: relative;
  font-size: 0.85rem;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -5px; top: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--seal);
}
.timeline .action { font-weight: 600; color: var(--navy-deep); }
.timeline .meta { color: var(--ink-muted); }

/* ---------- Activity log ---------- */
table.activity { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
table.activity th { text-align: left; font-size: 0.68rem; text-transform: uppercase; color: var(--ink-muted); border-bottom: 2px solid var(--border); padding: 8px 10px; }
table.activity td { padding: 9px 10px; border-bottom: 1px solid var(--border); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-muted);
}
.empty-state .glyph { font-size: 2rem; margin-bottom: 10px; color: var(--seal); }

@media (max-width: 720px) {
  .topbar { padding: 0 14px; }
  .topbar nav { display: none; }
  main.content { padding: 24px 16px 60px; }
}
