:root {
  --blue: #2563eb; --green: #16a34a; --orange: #f59e0b;
  --bg: #f8fafc; --card: #ffffff; --text: #0f172a; --muted: #64748b;
  --border: #e2e8f0; --warn-bg: #fef3c7;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
nav {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 22px;
}
nav .brand { font-weight: 700; margin-right: 8px; }
nav a { color: var(--muted); text-decoration: none; padding: 4px 2px; }
nav a.active, nav a:hover { color: var(--blue); }
nav form.inline { margin-left: auto; }
.linklike {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; padding: 0;
}
.linklike:hover { color: var(--blue); }
main { max-width: 1060px; margin: 0 auto; padding: 22px 16px 60px; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.12rem; margin-top: 2em; }
section { margin-bottom: 1rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
}
.tile-warn { background: var(--warn-bg); }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }

table {
  border-collapse: collapse; width: 100%; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  font-size: .92rem;
}
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f1f5f9; font-weight: 600; }
tr:last-child td { border-bottom: none; }
td:nth-child(n+3), th:nth-child(n+3) { text-align: right; }
table a { text-decoration: none; }

.chart { width: 100%; height: auto; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.chart-value { font-size: 10px; fill: var(--muted); }
.chart-label { font-size: 10px; fill: var(--muted); }
.legend { color: var(--muted); font-size: .85rem; }

.flags { background: var(--warn-bg); border-radius: 8px; padding: 12px 12px 12px 30px; }
.flags li { margin: 4px 0; }

.filters a {
  display: inline-block; margin: 0 6px 6px 0; padding: 3px 10px;
  border: 1px solid var(--border); border-radius: 14px;
  color: var(--muted); text-decoration: none; font-size: .85rem;
}
.filters a.active { background: var(--blue); color: white; border-color: var(--blue); }

form label { display: block; margin: 10px 0 4px; }
input[type=text], input[type=password], input[name=username], input[name=current],
input[name=new], input[name=confirm] {
  width: 100%; max-width: 360px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
button[type=submit] {
  margin-top: 14px; background: var(--blue); color: white; border: none;
  padding: 8px 18px; border-radius: 6px; font: inherit; cursor: pointer;
}
button[type=submit]:hover { filter: brightness(1.1); }

.login-box {
  max-width: 380px; margin: 10vh auto; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 28px;
}
.error { color: #b91c1c; background: #fee2e2; padding: 8px 12px; border-radius: 6px; }
.notice { color: #166534; background: #dcfce7; padding: 8px 12px; border-radius: 6px; }
.muted { color: var(--muted); }

.chart-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; height: 320px;
}
.table-view { margin-top: 8px; }
.table-view summary { color: var(--muted); cursor: pointer; font-size: .85rem; }
.table-view table { margin-top: 8px; font-size: .82rem; }

.upload-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
}
.upload-box summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.upload-box select, .upload-box input[type=file], .upload-box input[type=date] {
  display: block; margin-top: 4px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; background: white;
}

.badge {
  background: var(--blue); color: white; border-radius: 10px;
  padding: 0 7px; font-size: .75rem; font-weight: 700;
}
.chip {
  display: inline-block; padding: 1px 9px; border-radius: 12px;
  font-size: .78rem; border: 1px solid var(--border); margin: 0 3px 3px 0;
}
.chip-review { background: #fef3c7; }
.chip-manual { background: #fde68a; }
.chip-approved, .chip-ok { background: #dcfce7; }
.chip-rejected, .chip-fail { background: #fee2e2; }
.chip-archived { background: #e2e8f0; }
.chip-error { background: #fecaca; }
.chip-ai { background: #ede9fe; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 900px) { .review-grid { grid-template-columns: 1fr; } }
.doc-frame { width: 100%; height: 540px; border: 1px solid var(--border); border-radius: 8px; background: white; }
.muted-row td { color: var(--muted); }
textarea { width: 100%; max-width: 420px; font: 12px/1.4 monospace;
  border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.reject-form { margin-top: 22px; display: flex; gap: 8px; align-items: center; }
.reject-form input { max-width: 240px; }
button.danger { background: #dc2626; }
.inline-label { display: flex; gap: 6px; align-items: center; }
.pack-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.pack-form label { margin: 0; }
.pack-form input { width: 110px; }
