:root {
  --bg: #f4f6f9; --panel: #ffffff; --text: #1d2733; --muted: #66707c; --line: #dfe4ea;
  --brand: #1f4e78; --brand-2: #2b6cb0; --ok: #1e7a46; --ok-bg: #e5f5ec; --warn: #8a5a00; --warn-bg: #fff4d6;
  --bad: #a42828; --bad-bg: #fde8e8; --radius: 8px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--brand-2); }
h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--brand); color: #fff; flex-wrap: wrap; }
.topbar a, .topbar .link { color: #fff; }
.brand { text-decoration: none; font-size: 1.1rem; margin-right: auto; }
.company-switch { display: flex; align-items: center; gap: .4rem; }
.company-switch label { font-size: .85rem; opacity: .85; }
.company-switch select { max-width: 340px; }
.userbox { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: rgba(0,0,0,.08); font-size: .8rem; }
.topbar .pill { background: rgba(255,255,255,.2); }
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar { width: 220px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); padding: 1rem 0; display: flex; flex-direction: column; }
.sidebar a { padding: .55rem 1.2rem; text-decoration: none; color: var(--text); }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: #e8f0fa; color: var(--brand); font-weight: 600; border-left: 3px solid var(--brand); }
.nav-sep { padding: 1rem 1.2rem .3rem; font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.content { flex: 1; padding: 1.5rem; min-width: 0; }
.center { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; }
.login { width: 100%; max-width: 380px; }
.login h1 { font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: .85rem; }
.wrap { word-break: break-all; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
input, select, button, .button { font: inherit; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
input:focus, select:focus, button:focus, .button:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; background: #fff; }
button:hover, .button:hover { background: #f0f3f7; }
button.primary, .button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.primary:hover, .button.primary:hover { background: #173d5e; }
button.danger { color: var(--bad); border-color: #f0c4c4; }
button.big, .button.big { padding: .8rem 1.4rem; font-size: 1.05rem; font-weight: 600; }
button.wide { width: 100%; }
button.small { padding: .25rem .5rem; font-size: .8rem; }
button.link { background: none; border: none; padding: 0; text-decoration: underline; }
button:disabled { opacity: .6; cursor: progress; }
form.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; align-items: end; }
.grid2 > .card { margin-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: .8rem; }
.alert { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cd; }
.alert.error { background: var(--bad-bg); color: var(--bad); border-color: #f2c2c2; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dca0; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; color: var(--muted); font-weight: 600; background: #fafbfc; }
table.compact th { text-transform: none; font-size: .85rem; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.table-wrap table { min-width: 1000px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f5f8fc; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; gap: .3rem; }
.kpi span { font-size: .8rem; color: var(--muted); }
.kpi strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.kpi.wide { grid-column: span 2; }
.kpi.warn strong { color: var(--warn); }
.kpi.bad strong { color: var(--bad); }
.status { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .8rem; background: #eef1f5; white-space: nowrap; }
.s-COMPLETED, .m-MATCHED, .c-ACTIVE { background: var(--ok-bg); color: var(--ok); }
.s-COMPLETED_WITH_ERRORS, .s-warn, .m-DATA_MISMATCH, .m-NOT_IN_TOKEN, .m-DUPLICATE, .c-NEEDS_AUTH { background: var(--warn-bg); color: var(--warn); }
.s-FAILED, .m-MISSING_DOCUMENT, .m-XML_ERROR, .c-ERROR { background: var(--bad-bg); color: var(--bad); }
.sev { font-size: .8rem; font-weight: 600; }
.sev-ERROR { color: var(--bad); } .sev-WARNING { color: var(--warn); } .sev-INFO { color: var(--muted); }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tabs a { padding: .4rem .8rem; border-radius: 6px; text-decoration: none; color: var(--text); border: 1px solid var(--line); background: #fff; font-size: .9rem; }
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
.progress { height: 14px; background: #e6ebf1; border-radius: 999px; overflow: hidden; margin: .8rem 0; }
.progress .bar { height: 100%; width: 0; background: var(--brand-2); transition: width .4s; }
.counters { max-width: 480px; }
.dropzone { border: 2px dashed #9fb3c8; border-radius: var(--radius); padding: 2rem 1rem; text-align: center; background: #fafcff; cursor: pointer; }
.dropzone.over { background: #e8f0fa; border-color: var(--brand); }
.dropzone input[type=file] { margin-top: .5rem; }
.file-list { margin: 0; padding-left: 1.2rem; font-size: .9rem; }
dl.kv { display: grid; grid-template-columns: 180px 1fr; gap: .35rem .8rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .85rem; }
dl.kv dd { margin: 0; }
pre.xml { background: #0f1720; color: #d7e3f0; padding: 1rem; border-radius: var(--radius); overflow: auto; max-height: 75vh; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }
code { background: #fff; padding: .1rem .3rem; border-radius: 4px; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 0; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar a { white-space: nowrap; }
  .sidebar a.active { border-left: none; border-bottom: 3px solid var(--brand); }
  .nav-sep { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .kpi.wide { grid-column: span 1; }
  dl.kv { grid-template-columns: 1fr; }
  .company-switch select { max-width: 200px; }
  .content > table, .card table { display: block; overflow-x: auto; }
  .topbar { gap: .5rem; }
}
