* { box-sizing: border-box; }
:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #102044;
  background: #f4f7fd;
  font-synthesis: none;
  --ink: #102044;
  --muted: #566584;
  --line: #dce5f4;
  --blue: #174bd2;
  --blue-deep: #103ba4;
  --pale: #eaf1ff;
  --round: 16px;
}
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 2.9rem); letter-spacing: -.045em; line-height: 1.12; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.22rem, 2.4vw, 1.5rem); letter-spacing: -.022em; line-height: 1.22; }
h3 { font-size: 1.05rem; margin-bottom: .7rem; }
p { line-height: 1.55; }
a { color: var(--blue-deep); text-underline-offset: .15em; }
button, input, textarea, select { font: inherit; }
button, .file-button {
  min-height: 44px; border: 1px solid #b8cae8; border-radius: 11px; background: white;
  color: var(--ink); padding: .54rem .9rem; font-weight: 650; cursor: pointer; line-height: 1.35;
}
button:hover, .file-button:hover { background: #eff5ff; border-color: #8daae1; }
button:disabled { opacity: .55; cursor: default; }
.primary {
  justify-self: start; background: var(--blue); color: white; border-color: var(--blue);
  box-shadow: 0 3px 8px #123fac1d;
}
.primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
:focus-visible { outline: 3px solid #467cef; outline-offset: 3px; }
label { display: grid; gap: .42rem; font-size: .94rem; font-weight: 650; min-width: 0; }
input, textarea, select {
  width: 100%; min-height: 44px; border: 1px solid #b8cae8; border-radius: 10px;
  background: white; color: var(--ink); padding: .57rem .75rem;
}
input::placeholder, textarea::placeholder { color: #586a88; }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
form { display: grid; gap: .9rem; min-width: 0; }
.top { background: #fff; border-bottom: 1px solid var(--line); }
.bar, .shell { max-width: 1480px; margin: auto; padding-inline: clamp(1rem, 4vw, 3.5rem); }
.bar, .workspace, .section-head, .top-actions, .file-pickers, .pagination, .settings-grid, .mode, .connection-actions {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.bar, .workspace, .section-head { justify-content: space-between; }
.bar { min-height: 76px; padding-block: .75rem; }
.brand { color: var(--ink); text-decoration: none; font-weight: 760; font-size: 1.2rem; display: flex; align-items: center; gap: .65rem; }
.brand-mark {
  display: inline-grid; place-items: center; flex: none; width: 42px; height: 42px;
  background: var(--blue); color: #fff; border-radius: 11px; font-size: 1.05rem; font-weight: 800; letter-spacing: -.065em;
}
.login-name { color: var(--muted); font-size: .93rem; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; }
#logout { min-height: 40px; border-color: var(--line); }
.shell {
  display: grid; grid-template-columns: 214px minmax(0, 1fr); gap: clamp(1.4rem, 3.5vw, 3.5rem);
  padding-block: clamp(1.25rem, 4vw, 3rem);
}
.sidebar { min-width: 0; }
.workspace-nav { display: grid; gap: .42rem; }
.workspace-nav a {
  display: flex; align-items: center; gap: .65rem; min-height: 48px; padding: .6rem .78rem;
  border-radius: 11px; color: #394c73; font-weight: 650; text-decoration: none;
}
.workspace-nav a:hover { background: #edf2fc; color: var(--blue-deep); }
.workspace-nav a[aria-current="page"] { background: #e6eeff; color: #143eae; box-shadow: inset 3px 0 #2f67e6; }
.nav-icon { width: 1.05rem; height: 1.05rem; display: inline-grid; place-items: center; flex: none; font-size: 1.12rem; line-height: 1; }
.nav-documents::before { content: ""; width: .66rem; height: .84rem; border: 1.5px solid currentColor; border-radius: 2px; background: linear-gradient(currentColor, currentColor) 50% 39% / .3rem 1px no-repeat, linear-gradient(currentColor, currentColor) 50% 67% / .3rem 1px no-repeat; }
.nav-profiles::before { content: ""; width: .79rem; height: .4rem; border: 1.5px solid currentColor; border-radius: 2px; box-shadow: 0 .28rem 0 -.1rem currentColor; }
.nav-ttn::before { content: ""; width: .85rem; height: .6rem; border: 1.5px solid currentColor; border-radius: 1px 3px 2px 2px; }
.organization { margin-top: 1.75rem; padding: 1rem .75rem 0; border-top: 1px solid var(--line); }
.organization-name { margin-top: .2rem; font-weight: 700; overflow-wrap: anywhere; }
.main-content, .view { min-width: 0; }
.view { display: grid; gap: 1.2rem; }
.workspace { align-items: flex-end; margin-bottom: .25rem; }
.workspace p { margin-top: .4rem; }
.workspace-organization { margin-top: .47rem; font-size: 1rem; line-height: 1.4; letter-spacing: 0; color: var(--muted); }
.mode { align-items: center; gap: .4rem; }
.muted { color: var(--muted); font-size: .9rem; }
.badge {
  display: inline-block; border-radius: 80px; background: #e9f0ff; color: #214b9d;
  padding: .31rem .66rem; font-size: .82rem; line-height: 1.35; font-weight: 680; max-width: 100%;
}
.warning, [data-status="NEEDS_REVIEW"], [data-status="PARTIALLY_IMPORTED"], [data-status="RECONCILING"] { background: #fff0d3; color: #785004; }
[data-status="FAILED"], [data-status="REJECTED"] { background: #ffebe7; color: #8f3429; }
[data-status="IMPORTED"], [data-status="SIMULATED"], [data-status="LINKED"] { background: #dff5ec; color: #105c45; }
.panel, .login-card { padding: clamp(1.15rem, 3vw, 1.9rem); background: #fff; border: 1px solid var(--line); border-radius: var(--round); }
.panel { display: grid; gap: 1.15rem; min-width: 0; box-shadow: 0 8px 30px #12235906; }
.upload-panel {
  position: relative; color: white; border: none; border-radius: 22px; overflow: hidden;
  background: radial-gradient(ellipse at 91% 4%, #557ff5, transparent 50%), linear-gradient(120deg, #153ea8, #2150cb);
  box-shadow: 0 11px 25px #244eac26; padding: clamp(1.35rem, 4vw, 2.5rem);
}
.upload-panel::after {
  content: ""; position: absolute; pointer-events: none; inset: 0 0 0 auto; width: 44%;
  background: linear-gradient(90deg, #2554c700, #2554c700), url("/static/ls-documents.webp") 50% 52% / cover no-repeat;
  opacity: .95; mask-image: linear-gradient(90deg, transparent, #000 23%);
}
.upload-panel > * { position: relative; z-index: 1; }
.upload-intro h2 { font-size: clamp(1.55rem, 3.2vw, 2.1rem); }
.upload-intro p { color: #eff4ff; margin-top: .45rem; }
#upload, .upload-intro, #upload-results { max-width: min(100%, 490px); }
.upload-panel label, .upload-panel .muted { color: white; }
.upload-panel select { color: var(--ink); border-color: transparent; }
.upload-panel .primary { background: #f7faff; color: #163eaa; border-color: #f7faff; }
.upload-panel .primary:hover { background: #d9e7ff; border-color: #d9e7ff; }
.upload-panel :focus-visible, .upload-panel .file-button:focus-within { outline-color: #ffc96e; }
.upload-area { border: 1px dashed #9bb5fc; background: #10317c42; border-radius: 12px; padding: .72rem; }
.upload-area.is-dragging { background: #112b65; border-color: #fff; }
.file-button { position: relative; overflow: hidden; width: fit-content; place-content: center; }
.upload-panel .file-button { color: white; border-color: #afc5ff; background: #ffffff10; }
.upload-panel .file-button:hover { background: #ffffff30; }
.file-button:focus-within { outline: 3px solid #467cef; outline-offset: 3px; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-hint { font-size: .85rem; color: #eef3ff; margin-top: .55rem; }
#chosen, #upload-results { list-style: none; padding: 0; margin: 0; overflow-wrap: anywhere; }
#chosen:empty, #upload-results:empty { display: none; }
#chosen { margin-top: .6rem; font-size: .92rem; }
#chosen li { display: flex; gap: .5rem; justify-content: space-between; align-items: center; }
#chosen li + li { margin-top: .3rem; }
#chosen button { min-height: 34px; padding: .31rem .48rem; color: #fff; background: #ffffff15; border-color: #a2bcff; white-space: nowrap; font-size: .83rem; }
#chosen button:hover { background: #ffffff30; }
#upload-results li + li { margin-top: .25rem; }
.filters { grid-template-columns: minmax(135px, 1.4fr) repeat(2, minmax(130px, 1fr)) auto; align-items: end; }
.filters button { white-space: nowrap; }
.rows { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(7rem, auto) minmax(4rem, auto);
  align-items: center; column-gap: .95rem; min-height: 66px; border-bottom: 1px solid var(--line); padding: .65rem .2rem;
}
.row > :first-child { overflow-wrap: anywhere; }
.row button:first-child { text-align: left; padding: .35rem .45rem; border: 0; background: transparent; margin-left: -.45rem; }
.row button:first-child:hover { background: var(--pale); }
.row .badge { width: fit-content; }
.row small { display: block; margin-top: .2rem; }
.row .amount { text-align: right; font-weight: 640; white-space: nowrap; }
.empty-list { border-radius: 12px; background: #f3f7ff; padding: 1rem; display: grid; gap: .25rem; }
.pagination { justify-content: flex-end; }
.settings-grid { align-items: end; }
.settings-grid label { flex: 1 1 215px; max-width: 460px; }
details { margin-block: .35rem; border: 1px solid var(--line); border-radius: 12px; padding: .8rem .9rem; }
details form, details pre { margin-top: .75rem; }
summary { cursor: pointer; font-weight: 680; overflow-wrap: anywhere; }
pre { overflow: auto; max-width: 100%; padding: .8rem; background: #f1f6ff; border-radius: 8px; white-space: pre-wrap; word-break: break-word; color: #213965; }
.check { display: flex; align-items: center; gap: .58rem; }
.check input { min-height: auto; width: auto; height: 17px; accent-color: var(--blue); }
#settings-feedback:empty, #connection-feedback:empty, .form-feedback:empty { display: none; }
.connection-form { gap: 1rem; }
.connection-form fieldset { border: 1px solid var(--line); border-radius: 13px; padding: 1rem; display: grid; gap: .68rem; min-width: 0; }
.connection-form legend { padding-inline: .35rem; font-weight: 730; }
.connection-form small { margin-top: -.48rem; }
.connection-form input[aria-invalid="true"] { border-color: #aa3830; }
.ttn-fields, .ttn-line { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; align-items: end; }
#ttn-lines { display: grid; gap: .65rem; margin-bottom: .75rem; }
.ttn-line { grid-template-columns: minmax(0, 1fr) minmax(9rem, .55fr) auto; }
.ttn-summary { display: grid; gap: .7rem; margin: 0; }
.ttn-summary div { display: grid; gap: .2rem; }
.ttn-summary dt { font-size: .9rem; color: var(--muted); }
.ttn-summary dd { margin: 0; overflow-wrap: anywhere; }
.ttn-table-wrap { overflow-x: auto; }
.ttn-table { border-collapse: collapse; width: 100%; }
.ttn-table th, .ttn-table td { border-bottom: 1px solid var(--line); padding: .55rem .45rem; text-align: left; }
.ttn-table th { color: var(--muted); font-size: .9rem; }
.ttn-table .numeric { text-align: right; white-space: nowrap; }
.ttn-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; }
.ttn-totals div { background: #eef4ff; padding: .75rem .85rem; border-radius: 11px; }
.ttn-totals small { display: block; color: var(--muted); margin-bottom: .2rem; }
.ttn-totals strong { overflow-wrap: anywhere; }
dialog {
  width: min(100% - 30px, 965px); max-height: calc(100dvh - 35px); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; padding: clamp(1rem, 3vw, 1.7rem);
  box-shadow: 0 25px 65px #12234b52;
}
dialog::backdrop { background: #12234488; }
.dialog-head { margin-bottom: .9rem; }
.dialog-head h2 { overflow-wrap: anywhere; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1.2rem; margin-block: .9rem; }
.card-grid section { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 13px; overflow-wrap: anywhere; }
.card-grid img { display: block; max-width: 100%; margin-top: .6rem; }
.card-grid p, .issues li { margin-block: .25rem; }
.fact-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.card-error { margin-block: .65rem; }
.issues { padding: .65rem 1rem .65rem 1.8rem; background: #fff6df; border-radius: 10px; color: #74500c; }
.card-actions { margin: .85rem 0; display: flex; flex-wrap: wrap; align-items: center; gap: .72rem; }
.card-actions p { flex-basis: 100%; }
#feedback { z-index: 10; position: fixed; inset: auto 1rem 1rem auto; max-width: min(450px, 100% - 2rem); padding: .8rem 1rem; border: 1px solid #f0b9ae; border-radius: 10px; color: #752e21; background: #fff1ee; }
.error { color: #972b2c; }
.upload-panel .error { color: #fff; }
.login-page { display: grid; min-height: 100dvh; align-items: center; padding: 1rem; }
.login-layout { width: min(100%, 900px); min-height: 500px; margin: auto; display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; box-shadow: 0 16px 50px #162c6618; border-radius: 20px; overflow: hidden; background: white; }
.login-visual { background: url("/static/ls-documents.webp") center / cover no-repeat, radial-gradient(ellipse at 70% 20%, #5877ec, transparent 60%), #173faa; }
.login-card { display: grid; align-content: center; gap: 1.35rem; border: 0; border-radius: 0; padding: clamp(1.3rem, 5vw, 3.6rem); }
.login-card h1 { font-size: 2.5rem; margin-bottom: .3rem; }
.login-card form { gap: 1rem; }
.login-card .primary { width: 100%; margin-top: .2rem; }
@media (max-width: 1000px) {
  .shell { grid-template-columns: 170px minmax(0, 1fr); gap: 1.4rem; }
  .upload-panel::after { width: 34%; opacity: .62; }
}
@media (max-width: 860px) {
  .bar { min-height: 64px; }
  .shell { grid-template-columns: minmax(0, 1fr); padding-top: .85rem; gap: 1.2rem; }
  .workspace-nav { display: flex; flex-wrap: wrap; gap: .3rem; }
  .workspace-nav a { min-height: 44px; padding-inline: .63rem; }
  .workspace-nav a[aria-current="page"] { box-shadow: inset 0 -2px #2f67e6; }
  .organization { display: none; }
  .upload-panel::after { display: none; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label:first-child { grid-column: span 2; }
  .filters button { justify-self: start; }
}
@media (max-width: 540px) {
  .view { gap: .95rem; }
  .workspace-nav a { gap: .35rem; font-size: .92rem; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .fact-fields { grid-template-columns: minmax(0, 1fr); }
  .row { grid-template-columns: minmax(0, 1fr) auto; row-gap: .25rem; }
  .row .badge { grid-column: 1 / -1; grid-row: 2; }
  .login-layout { min-height: auto; grid-template-columns: minmax(0, 1fr); max-width: 420px; }
  .login-visual { min-height: 130px; background-position: 50% 49%; }
  .login-card { padding: 1.4rem; }
  .ttn-line { grid-template-columns: minmax(0, 1fr) auto; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
  .ttn-line label:first-child { grid-column: span 2; }
  .ttn-totals { gap: .3rem; }
  .ttn-totals div { padding: .55rem .43rem; }
}
@media (max-width: 340px) {
  .login-name { display: none; }
  .workspace-nav .nav-icon { display: none; }
}
