* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1c2330; background: #f5f6f8; font-size: 15px;
}
nav {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #1c2330; color: #fff; padding: 10px 16px;
}
nav a { color: #d7dce5; text-decoration: none; }
nav a:hover { color: #fff; }
nav .brand { font-weight: 700; color: #ffd166; }
nav .right { margin-left: auto; }
main { padding: 16px 24px; max-width: none; margin: 0 auto; }
footer { padding: 12px 16px; color: #8b93a3; font-size: 12px; }
h1 { font-size: 20px; } h2 { font-size: 15px; margin-top: 22px; }

.flash { background: #fff7d6; border: 1px solid #e5d98a; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
.flash.warn { background: #fdeaea; border-color: #e3b1b1; }

.badge { display: inline-block; background: #e4e7ee; border-radius: 10px; padding: 1px 8px; font-size: 11px; }
.badge.dry { background: #ffd166; color: #40340a; font-weight: 700; }
.badge.fail { background: #f3c1c1; }

.cards { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.card {
  background: #fff; border: 1px solid #e1e4ea; border-radius: 8px; padding: 14px 18px;
  text-decoration: none; color: inherit; min-width: 150px;
}
.card strong { font-size: 22px; display: block; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: #fff; border: 1px solid #e1e4ea; border-radius: 8px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #edeff3; vertical-align: top; }
table.lines th { padding: 7px 3px; }
th { background: #f0f2f6; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.num, input.num { text-align: right; }
td.detail { font-size: 12px; color: #5a6274; max-width: 420px; word-break: break-all; }

.state { padding: 2px 8px; border-radius: 10px; font-size: 11px; background: #e4e7ee; white-space: nowrap; }
.s-PENDING_REVIEW { background: #ffe9b8; }
.s-APPROVED, .s-POSTED { background: #cdeec9; }
.s-EXTRACTION_FAILED, .s-POST_FAILED, .s-GUARD_FAILED { background: #f3c1c1; }
.s-IGNORED, .s-DUPLICATE { background: #e0e0e0; }
.s-NEEDS_DOCUMENT { background: #d8e4ff; }

.split { display: grid; grid-template-columns: minmax(320px, 30%) 1fr; gap: 20px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.pane { min-width: 0; }
iframe.pdf { width: 100%; height: 82vh; border: 1px solid #e1e4ea; border-radius: 8px; background: #fff; }

table.kv th { width: 180px; background: none; text-transform: none; }
ul.guards { list-style: none; padding: 0; }
ul.guards li { padding: 5px 10px; border-radius: 6px; margin: 4px 0; background: #edf7ec; }
ul.guards li.bad { background: #fdeaea; }
ul.history { font-size: 12px; color: #5a6274; padding-left: 16px; }

pre.json {
  background: #10141c; color: #cfe3ff; padding: 12px; border-radius: 8px;
  font-size: 12px; overflow-x: auto;
}

input, select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid #c9cfda; border-radius: 6px; width: 100%;
  background: #fff;
}
table.lines { width: 100%; }
table.lines td { padding: 5px 3px; }
table.lines th.col-desc, table.lines td.col-desc { width: 30%; }
table.lines input.desc { width: 100%; min-width: 200px; }
table.lines input.qty { width: 52px; }
table.lines input.amt { width: 88px; }
table.lines input.pct { width: 52px; }
table.lines .combo input.combo-text { width: 190px; }

.combo { position: relative; display: inline-block; }
.combo input.combo-text { width: 230px; }
.combo-list {
  position: absolute; z-index: 40; top: 100%; left: 0; margin-top: 2px;
  background: #fff; border: 1px solid #c9cfda; border-radius: 6px;
  max-height: 280px; overflow-y: auto; width: 340px;
  box-shadow: 0 6px 18px rgba(20, 27, 45, .18); display: none;
}
.combo-list div { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.combo-list div:hover, .combo-list div.active { background: #eef2fa; }

.import-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: #fff; border: 1px solid #e1e4ea; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.import-form input[type=file] { width: auto; }
.import-form button { margin: 0; }
.import-form .hint { flex-basis: 100%; }

.supplier-assign { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: #fff; border: 1px solid #e1e4ea; border-radius: 8px; padding: 8px 12px; }
.supplier-assign select { width: auto; min-width: 220px; }
.supplier-assign label.check { margin: 0; white-space: nowrap; }
.supplier-assign button { margin: 0; }
table.lines select.tax { width: 140px; }
table.lines select.use { width: 100px; }
input.sm, select.sm { width: 110px; min-width: 0; }
input.xs { width: 64px; min-width: 0; }
button {
  font: inherit; background: #1c2330; color: #fff; border: 0; border-radius: 6px;
  padding: 7px 14px; cursor: pointer; margin: 6px 0;
}
button:hover { background: #33405c; }
button.danger { background: #a33; }
button.primary { background: #2e7d32; }
button.primary:hover { background: #3d9142; }
button.secondary { background: #5a6274; }
button.link { background: none; color: #d7dce5; padding: 0; margin: 0; }
form.inline { display: inline; }
form.inline input[type="text"], form.inline input:not([type]) { width: auto; }
.actions form { margin-right: 6px; }

form.settings { max-width: 720px; }
form.settings label { display: block; margin: 12px 0; font-weight: 600; }
form.settings label input, form.settings label textarea, form.settings label select { font-weight: 400; margin-top: 4px; }
label.check { font-weight: 400 !important; }
label.check input { width: auto; }

fieldset.loan-box { border: 1px solid #c9cfda; border-radius: 8px; margin: 14px 0; padding: 4px 14px 12px; background: #fff; }
fieldset.loan-box legend { font-weight: 700; padding: 0 6px; }
.hint { color: #5a6274; font-size: 13px; }

.rule-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; background: #fff; padding: 10px; border-radius: 8px; border: 1px solid #e1e4ea; }
.rule-form input, .rule-form select { width: auto; }

.login-box { max-width: 340px; margin: 12vh auto; background: #fff; padding: 24px; border-radius: 10px; border: 1px solid #e1e4ea; }
.login-box label { display: block; margin: 12px 0; }
