:root {
  --ink: #172033;
  --ink-soft: #5e687c;
  --navy: #111a2f;
  --navy-2: #18243e;
  --blue: #3366e8;
  --blue-2: #eaf0ff;
  --cyan: #38bdf8;
  --green: #138a61;
  --green-bg: #e8f7f0;
  --amber: #b46b08;
  --amber-bg: #fff6df;
  --red: #c83b47;
  --red-bg: #ffebed;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --line: #dfe4ed;
  --shadow: 0 16px 42px rgba(28, 42, 70, .09);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 26px 20px 22px; color: #edf2ff;
  background: linear-gradient(180deg, var(--navy) 0%, #0d1528 100%);
  border-right: 1px solid rgba(255,255,255,.04);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 26px; }
.brand strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand small { display: block; margin-top: 3px; color: #8794ad; font-size: 11px; }
.brand-mark { width: 34px; height: 38px; position: relative; display: block; }
.brand-mark i { position: absolute; width: 19px; height: 24px; border: 2px solid #eef4ff; border-radius: 4px; background: var(--navy); }
.brand-mark i:nth-child(1) { left: 0; top: 8px; opacity: .45; }
.brand-mark i:nth-child(2) { left: 7px; top: 4px; opacity: .7; }
.brand-mark i:nth-child(3) { left: 14px; top: 0; border-color: var(--cyan); }
.nav { display: grid; gap: 7px; }
.nav-item { width: 100%; border: 0; color: #aeb9cd; background: transparent; border-radius: 10px; padding: 11px 12px; display: flex; align-items: center; gap: 11px; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { color: #fff; background: rgba(70, 112, 238, .18); box-shadow: inset 3px 0 0 #5681ff; }
.nav-icon { width: 20px; text-align: center; font-size: 19px; }
.sidebar-spacer { flex: 1; }
.engine-card { padding: 15px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.035); }
.engine-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; margin-bottom: 13px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #40d39c; box-shadow: 0 0 0 5px rgba(64,211,156,.1); }
.engine-row { display: flex; justify-content: space-between; color: #93a0b7; font-size: 12px; padding: 5px 0; }
.engine-row strong { color: #dfe8f9; font-weight: 600; }
.engine-row strong.ok { color: #63ddb0; }
.engine-row strong.bad { color: #ff8f98; }
.sidebar-note { margin: 14px 3px 0; color: #68758e; font-size: 10px; line-height: 1.5; }

.main { min-width: 0; padding: 0 36px 56px; }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 2px 0 0; font-size: 27px; letter-spacing: -.03em; }
.eyebrow { margin: 0; color: var(--blue); font-weight: 800; font-size: 10px; letter-spacing: .16em; }
.topbar-meta { display: flex; align-items: center; gap: 15px; }
.mode-badge { color: var(--amber); background: var(--amber-bg); border: 1px solid #f4dda1; border-radius: 999px; padding: 6px 10px; font-size: 10px; font-weight: 800; letter-spacing: .07em; }
.clock { color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
.view { display: none; max-width: 1460px; margin: 0 auto; }
.view.active { display: block; }

.upload-panel { padding: 36px 0 26px; }
.dropzone { min-height: 245px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1.5px dashed #aebbd7; border-radius: var(--radius); background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(248,250,255,.98)); box-shadow: 0 8px 28px rgba(28,42,70,.04); transition: .2s ease; }
.dropzone:hover, .dropzone.dragging, .dropzone:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 5px rgba(51,102,232,.08), var(--shadow); transform: translateY(-1px); }
.upload-symbol { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 13px; color: var(--blue); background: var(--blue-2); border-radius: 14px; font-size: 27px; font-weight: 600; }
.dropzone h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.dropzone p { margin: 7px 0 17px; color: var(--ink-soft); }
.dropzone small { margin-top: 13px; color: #8b94a5; font-size: 11px; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; font-weight: 700; font-size: 12px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--blue); box-shadow: 0 7px 17px rgba(51,102,232,.22); }
.button.secondary { color: var(--blue); background: var(--blue-2); border-color: #cfdaff; }
.button.ghost { color: var(--ink-soft); background: #fff; border-color: var(--line); }
.button.danger { color: var(--red); }
.button.small { padding: 6px 10px; font-size: 11px; }
.processing { min-height: 245px; align-items: center; justify-content: center; gap: 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.processing:not([hidden]) { display: flex; }
.processing strong { font-size: 16px; }
.processing p { color: var(--ink-soft); margin: 4px 0 0; }
.spinner { width: 38px; height: 38px; border: 3px solid #dce5ff; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-panel { display: flex; align-items: flex-start; gap: 12px; margin: 24px 0; padding: 15px; background: var(--red-bg); color: #7d2630; border: 1px solid #ffcdd2; border-radius: 12px; }
.error-icon { width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; color: white; background: var(--red); border-radius: 50%; font-weight: 800; }
.error-panel p { margin: 3px 0 0; color: #98545c; }
.icon-button { margin-left: auto; border: 0; background: transparent; color: currentColor; font-size: 21px; }

.result-panel { padding: 28px 0; }
.result-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.file-heading { min-width: 0; display: flex; align-items: center; gap: 14px; }
.file-badge { width: 46px; height: 48px; display: grid; place-items: center; color: var(--blue); background: var(--blue-2); border: 1px solid #d3deff; border-radius: 11px; font-weight: 900; font-size: 11px; }
.title-row { display: flex; align-items: center; gap: 9px; }
.title-row h2 { max-width: 670px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; font-size: 20px; letter-spacing: -.02em; }
.file-heading p { margin: 5px 0 0; color: var(--ink-soft); font-size: 11px; }
.status-badge { border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; }
.status-badge.valid { color: var(--green); background: var(--green-bg); }
.status-badge.invalid { color: var(--red); background: var(--red-bg); }
.status-badge.error { color: var(--amber); background: var(--amber-bg); }
.result-actions { display: flex; gap: 8px; }
.status-grid { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 12px; margin-bottom: 19px; }
.status-card { min-width: 0; min-height: 105px; padding: 17px; display: flex; flex-direction: column; justify-content: center; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 4px 13px rgba(32,47,78,.04); }
.status-card small { display: block; color: #8a93a4; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.status-card strong { display: block; margin-top: 5px; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-card p { margin: 4px 0 0; color: var(--ink-soft); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.primary-status { flex-direction: row; align-items: center; justify-content: flex-start; gap: 13px; }
.status-icon { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-bg); font-size: 20px; font-weight: 800; }
.primary-status.invalid .status-icon { color: var(--red); background: var(--red-bg); }
.primary-status.error .status-icon { color: var(--amber); background: var(--amber-bg); }

.tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { position: relative; border: 0; background: transparent; color: var(--ink-soft); padding: 12px 15px; white-space: nowrap; font-size: 12px; font-weight: 700; }
.tab::after { content: ""; position: absolute; height: 2px; left: 15px; right: 15px; bottom: -1px; background: transparent; }
.tab.active { color: var(--blue); }
.tab.active::after { background: var(--blue); }
.count { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; margin-left: 3px; border-radius: 999px; background: #e9edf4; color: #687287; font-size: 9px; }
.tab.active .count { color: var(--blue); background: var(--blue-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.content-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 13px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 5px 16px rgba(32,47,78,.035); }
.panel-heading { min-height: 50px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #edf0f5; }
.panel-heading h3 { margin: 0; font-size: 13px; }
.pill { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--blue); background: var(--blue-2); border-radius: 999px; padding: 4px 8px; font-size: 9px; font-weight: 800; }
.pill.subtle { color: var(--ink-soft); background: #f0f2f6; }
.data-list { display: grid; grid-template-columns: 1fr 1fr; margin: 0; padding: 7px 16px 13px; }
.data-list div { padding: 10px 8px 9px 0; border-bottom: 1px solid #f0f2f6; }
.data-list div:nth-last-child(-n+2) { border-bottom: 0; }
.data-list dt { color: #8992a3; font-size: 10px; }
.data-list dd { margin: 4px 0 0; font-weight: 650; font-size: 12px; word-break: break-word; }
.totals { padding: 10px 16px 14px; }
.totals div { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; color: var(--ink-soft); font-size: 11px; }
.totals strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.totals .grand-total { margin: 7px -7px 3px; padding: 11px 7px; border-top: 1px solid #dfe4ed; border-bottom: 1px solid #dfe4ed; color: var(--ink); font-weight: 700; }
.totals .grand-total strong { color: var(--blue); font-size: 17px; }
.party-dot { width: 9px; height: 9px; border-radius: 50%; }
.party-dot.seller { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-2); }
.party-dot.buyer { background: #8b5cf6; box-shadow: 0 0 0 4px #f0eaff; }
.party-data { padding: 15px 16px 17px; min-height: 130px; }
.party-data strong { display: block; margin-bottom: 7px; font-size: 14px; }
.party-data p { margin: 3px 0; color: var(--ink-soft); font-size: 11px; }
.party-data .id-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 11px; }
.party-data .id-tag { color: #536079; background: #f1f3f7; border-radius: 6px; padding: 4px 7px; font-size: 9px; }
.full-width { grid-column: 1 / -1; }
.payment-data { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px 16px 17px; }
.payment-field small { display: block; color: #8992a3; font-size: 9px; }
.payment-field strong { display: block; margin-top: 4px; font-size: 11px; word-break: break-all; }
.empty-state { color: #8a94a6; text-align: center; padding: 30px; font-size: 12px; }

.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 11px 13px; background: #f8f9fc; color: #778197; text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 13px; border-top: 1px solid #edf0f5; vertical-align: top; }
td strong { display: block; }
td small { display: block; margin-top: 3px; color: #8791a4; max-width: 480px; }
th.number, td.number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.validator-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; margin-bottom: 13px; }
.validator-card { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 13px; }
.validator-card-top { display: flex; align-items: center; justify-content: space-between; }
.validator-card strong { font-size: 14px; }
.validator-card p { margin: 7px 0 0; color: var(--ink-soft); font-size: 11px; }
.engine-status { padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.engine-status.valid { color: var(--green); background: var(--green-bg); }
.engine-status.invalid { color: var(--red); background: var(--red-bg); }
.engine-status.error { color: var(--amber); background: var(--amber-bg); }
.messages-panel { overflow: hidden; }
.filter-buttons { display: flex; gap: 4px; }
.mini-filter { border: 0; border-radius: 7px; padding: 5px 8px; color: #798398; background: #f1f3f7; font-size: 9px; }
.mini-filter.active { color: #fff; background: var(--blue); }
.message-list { padding: 5px 0; }
.message { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; gap: 10px; padding: 13px 16px; border-top: 1px solid #eef1f5; }
.message:first-child { border-top: 0; }
.message-mark { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; font-size: 10px; font-weight: 900; }
.message.error .message-mark { color: var(--red); background: var(--red-bg); }
.message.warning .message-mark { color: var(--amber); background: var(--amber-bg); }
.message.notice .message-mark { color: var(--blue); background: var(--blue-2); }
.message p { margin: 0; font-size: 11px; line-height: 1.45; word-break: break-word; }
.message code { display: block; margin-top: 5px; color: #7e889a; font-size: 9px; white-space: pre-wrap; word-break: break-word; }
.message-engine { color: #8b95a7; font-size: 9px; }

.document-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.document-action { border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; color: var(--ink-soft); background: #fff; font-size: 10px; font-weight: 700; }
.document-action.active { color: var(--blue); border-color: #bfcfff; background: var(--blue-2); }
.document-viewer { overflow: hidden; min-height: 540px; background: #fff; border: 1px solid var(--line); border-radius: 13px; }
.viewer-toolbar { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); }
.viewer-toolbar strong { font-size: 11px; }
#pdfViewer { width: 100%; height: 650px; border: 0; }
.code-view { margin: 0; padding: 18px; overflow: auto; min-height: 500px; max-height: 680px; background: #111827; color: #d8e2f3; font: 11px/1.55 "Cascadia Code", "SFMono-Regular", Consolas, monospace; tab-size: 2; white-space: pre; }
.code-panel { overflow: hidden; }
.code-panel .code-view { border-radius: 0 0 12px 12px; }

.history-heading { display: flex; align-items: center; justify-content: space-between; padding: 34px 0 20px; }
.history-heading h2 { margin: 4px 0 0; font-size: 23px; }
.history-panel { overflow: hidden; }
.history-item { display: grid; grid-template-columns: 44px minmax(180px, 1.5fr) minmax(140px, .8fr) minmax(120px, .7fr) auto; align-items: center; gap: 13px; padding: 13px 16px; border-top: 1px solid #edf0f5; cursor: pointer; }
.history-item:first-child { border-top: 0; }
.history-item:hover { background: #fafbfe; }
.history-file { width: 39px; height: 39px; display: grid; place-items: center; color: var(--blue); background: var(--blue-2); border-radius: 9px; font-size: 9px; font-weight: 900; }
.history-name { min-width: 0; }
.history-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.history-name small, .history-cell small { display: block; margin-top: 3px; color: #8993a5; font-size: 9px; }
.history-cell strong { font-size: 11px; }
.history-status { padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.history-status.valid { color: var(--green); background: var(--green-bg); }
.history-status.invalid { color: var(--red); background: var(--red-bg); }
.history-status.error { color: var(--amber); background: var(--amber-bg); }
.history-empty { display: flex; min-height: 300px; flex-direction: column; align-items: center; justify-content: center; color: #8b95a6; }
.history-empty span { font-size: 31px; color: #b3bed3; }
.history-empty strong { color: var(--ink); margin-top: 10px; }
.history-empty p { margin: 5px 0 0; font-size: 11px; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .main { padding-inline: 24px; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 14px 16px; flex-direction: row; align-items: center; gap: 12px; }
  .brand { padding: 0; }
  .brand small, .engine-card, .sidebar-note, .sidebar-spacer { display: none; }
  .nav { display: flex; margin-left: auto; }
  .nav-item { width: auto; font-size: 0; padding: 8px 10px; }
  .nav-icon { font-size: 19px; }
  .main { padding: 0 14px 35px; }
  .topbar { min-height: 82px; }
  .clock { display: none; }
  .topbar h1 { font-size: 22px; }
  .upload-panel { padding-top: 20px; }
  .result-heading { align-items: flex-start; }
  .result-actions .danger { display: none; }
  .status-grid, .content-grid, .validator-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .payment-data { grid-template-columns: 1fr 1fr; }
  .history-item { grid-template-columns: 40px minmax(0,1fr) auto; }
  .history-item .history-cell:nth-of-type(2), .history-item .history-cell:nth-of-type(3) { display: none; }
}

