/* Karsana AI Document Processing simulation. */
/* Inter, self-hosted (same files as karsanalabs.com; SIL Open Font License, see fonts/Inter-LICENSE.txt). */
@font-face { font-family: 'Inter Variable'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Inter Variable'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/inter-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* Colour tokens follow karsanalabs.com (src/styles/globals.css); status colours are the app's. */
:root {
  --navy: #071B3A; --ink: #0B1B3D; --accent: #0866F5; --accent-dark: #0652C7; --paper: #FFFFFF; --panel: #F5F9FD;
  --rule: #DFE8F3; --muted: #68758D; --body: #34425B; --viewer: #EAF0F7;
  --valid: #2E7D4F; --review: #A86A12; --mismatch: #B23A3A; --missing: #5F4FA0; --info: #68758D; --edited: #FFF6DD;
  --focus: #0866F5;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Simulation notice */
.sim-banner { background: var(--navy); color: #E6ECF2; font-size: .85rem; padding: .5rem 1rem; text-align: center; }
.sim-banner strong { color: #fff; }

/* Layout */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 2.3rem); }
.sidebar { background: var(--panel); border-right: 1px solid var(--rule); padding: 1.6rem 1.25rem 2rem; }
.sidebar h3 { font-size: 1.05rem; font-weight: 600; margin: 1.6rem 0 .7rem; }
.sidebar h3:first-child { margin-top: .4rem; }
.sidebar-toggle { display: none; }
.main { padding: 2.2rem 5rem 4rem; max-width: 1560px; width: 100%; }
@media (max-width: 1200px) { .main { padding: 2rem 2rem 3rem; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--rule); padding: .7rem 16px; }
  .sidebar-toggle { display: flex; width: 100%; justify-content: space-between; align-items: center;
    background: none; border: 0; font-weight: 600; padding: .4rem 0; cursor: pointer; }
  .sidebar-toggle::after { content: "▾"; color: var(--muted); }
  .sidebar-toggle[aria-expanded="true"]::after { content: "▴"; }
  .sidebar-body { display: none; padding-bottom: .8rem; }
  .sidebar-body.open { display: block; }
  .sidebar-body h3:first-child { display: none; }
  .main { padding: 1.4rem 16px 3rem; }
}

/* Controls */
.select, .input {
  width: 100%; border: 1px solid var(--rule); border-radius: 6px; background: #fff; padding: .5rem .65rem;
  min-height: 2.5rem; font-size: .95rem;
}
.select { appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%230B1B3D' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; }
.select:disabled { background-color: var(--panel); color: var(--muted); cursor: not-allowed; }
.input:focus, .select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 1px var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.5rem;
  padding: .45rem 1rem; border-radius: 6px; border: 1px solid var(--rule); background: #fff; color: var(--ink);
  font-weight: 500; font-size: .95rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); color: #fff; }
.btn:disabled, .btn-disabled { opacity: .5; cursor: not-allowed; }
.btn-wide { width: 100%; }
.btn-hist { width: 100%; justify-content: flex-start; overflow: hidden; text-overflow: ellipsis; }
.btn-hist.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.caption { color: var(--muted); font-size: .86rem; margin: .5rem 0; }
.muted-small { color: var(--muted); font-size: .78rem; font-weight: 400; }
.radio-row { display: flex; gap: 1.2rem; margin-bottom: .8rem; }
.radio-row label { display: inline-flex; gap: .45rem; align-items: center; font-size: .95rem; cursor: pointer; }
.radio-row input { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
.k-sample-info { font-size: .85rem; line-height: 1.4; margin: .45rem 0 .7rem; overflow-wrap: anywhere; }
.k-sample-info span { color: var(--muted); font-size: .78rem; }
.k-hist { font-size: .8rem; color: var(--muted); margin: .25rem 0 .7rem .2rem; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem .8rem; }
.metric .l { font-size: .82rem; color: var(--ink); }
.metric .v { font-size: 1.6rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric.wide { grid-column: 1 / -1; }

/* Header */
.k-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem;
  border-bottom: 2px solid var(--ink); padding-bottom: .7rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.k-brand { font-size: .82rem; font-weight: 600; color: var(--accent); letter-spacing: .01em; }
.k-title { font-size: 1.85rem; font-weight: 700; line-height: 1.15; margin: .1rem 0 .2rem; }
.k-sub { color: var(--muted); font-size: 1rem; margin: 0; }
.k-env { font-size: .8rem; color: var(--muted); text-align: right; line-height: 1.5; }
.k-env b { color: var(--ink); font-weight: 600; }
@media (max-width: 640px) { .k-env { text-align: left; } .k-title { font-size: 1.5rem; } }

/* Upload (disabled in the simulation) */
.uploader { margin-bottom: 1.2rem; }
.uploader-label { font-size: .88rem; margin-bottom: .35rem; }
.uploader-box { display: flex; gap: 1rem; align-items: center; background: var(--panel); border-radius: 8px;
  padding: 1rem; flex-wrap: wrap; }
.uploader-hint { color: var(--muted); font-size: .9rem; }

/* Empty state */
.k-steps { display: flex; margin: .4rem 0 1.2rem; flex-wrap: wrap; }
.k-step { flex: 1 1 140px; border-top: 3px solid var(--rule); padding: .55rem .8rem .2rem 0; }
.k-step .t { font-weight: 600; font-size: .95rem; }
.k-step .d { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.k-empty { border: 1px dashed var(--rule); border-radius: 6px; padding: 1.4rem 1.5rem; color: var(--muted); }
.k-empty b { color: var(--ink); }

/* Two-column workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr); gap: 2rem; align-items: start; }
@media (max-width: 1100px) { .workspace { grid-template-columns: minmax(0, 1fr); gap: 1.6rem; } }

/* Document viewer */
.k-docmeta { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
  border-bottom: 1px solid var(--rule); padding-bottom: .4rem; margin-bottom: .6rem; }
.k-docname { font-weight: 600; font-size: 1.02rem; overflow-wrap: anywhere; }
.k-docinfo { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.viewer-controls { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.ctl-label { font-size: .82rem; margin-bottom: .25rem; }
.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; background: #fff; padding: .35rem .8rem; cursor: pointer; font-size: .88rem; }
.segmented button + button { border-left: 1px solid var(--rule); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.zoom select { width: auto; min-height: 2.1rem; padding: .3rem 2rem .3rem .6rem; font-size: .88rem; }
.k-viewer { background: var(--viewer); border: 1px solid var(--rule); border-radius: 4px; max-height: 760px;
  overflow: auto; padding: 14px; text-align: center; }
.k-viewer img { box-shadow: 0 1px 3px rgba(11,27,61,.22); background: white; max-width: none; display: inline-block; }
.k-synthetic { display: inline-block; margin-top: .4rem; font-size: .78rem; color: var(--mismatch); }

/* Pending panel */
.k-doctype { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.plan { padding-left: 1.2rem; margin: .8rem 0; }
.plan li { margin: .25rem 0; }
.field { margin: .9rem 0; }
.field-label { font-size: .88rem; margin-bottom: .3rem; display: block; }

/* Processing status (replay) */
.status-box { border: 1px solid var(--rule); border-radius: 8px; padding: .8rem 1rem; margin: 1rem 0; }
.status-head { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--rule); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-steps { list-style: none; padding: 0; margin: .6rem 0 0; font-size: .9rem; color: var(--muted); }
.status-steps li { padding: .15rem 0; }
.status-steps li.done { color: var(--ink); }
.status-steps li.done::before { content: "✓ "; color: var(--valid); font-weight: 700; }
.status-steps li.now::before { content: "› "; color: var(--accent); font-weight: 700; }
.status-note { font-size: .8rem; color: var(--muted); margin-top: .5rem; }
.progress { height: 3px; background: var(--rule); border-radius: 2px; margin-top: .7rem; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s linear; }

/* Result header */
.k-resulthead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.k-docref { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.k-stamps { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.stamp { display: inline-block; color: var(--c); border: 2.5px solid var(--c); border-radius: 7px;
  padding: .32rem .8rem .28rem; font-weight: 700; font-size: .9rem; letter-spacing: .07em;
  text-transform: uppercase; transform: rotate(-2.5deg);
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3.5px var(--c);
  background: color-mix(in srgb, var(--c) 6%, white); white-space: nowrap; }
.stamp small { display: block; font-size: .62rem; letter-spacing: .03em; font-weight: 600; text-transform: none; }
.stamp.valid { --c: var(--valid); } .stamp.review { --c: var(--review); }
.stamp.mismatch { --c: var(--mismatch); } .stamp.missing { --c: var(--missing); }
.stamp.approved { --c: var(--accent); transform: rotate(1.5deg); }
.stamp.land { animation: stamp-in .35s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes stamp-in { from { opacity: 0; transform: scale(1.6) rotate(-8deg); } to { opacity: 1; transform: rotate(-2.5deg); } }
@media (prefers-reduced-motion: reduce) {
  .stamp.land { animation: none; } .spinner { animation-duration: 3s; } .progress > div { transition: none; }
}

.k-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .2rem 1rem;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: .55rem 0; margin: .8rem 0 .6rem; }
.k-fact .l { color: var(--muted); font-size: .76rem; }
.k-fact .v { font-weight: 600; font-size: 1rem; font-variant-numeric: tabular-nums; }
.k-fact .v em { font-style: normal; color: var(--muted); font-weight: 400; font-size: .78rem; }

.type-row { display: grid; grid-template-columns: 3fr 2fr; gap: 1rem; align-items: end; margin: .4rem 0 1rem; }
@media (max-width: 640px) { .type-row { grid-template-columns: 1fr; } }

/* Tabs */
.tabs { display: flex; gap: 1.05rem; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: thin; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: .55rem 0; margin-bottom: -1px;
  font-weight: 600; font-size: .92rem; cursor: pointer; white-space: nowrap; color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabpanel { padding-top: 1rem; }

/* Fields */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } }
.fields .field { margin: 0 0 .85rem; min-width: 0; }
.fields .field.edited .input { background: var(--edited); }
.fields .field.flag .input { border-color: var(--mismatch); }
.k-aihint { color: var(--review); font-size: .76rem; margin-top: .2rem; }
.k-err { color: var(--mismatch); font-size: .78rem; margin-top: .2rem; }
.k-note { color: var(--body); font-size: .88rem; padding: .25rem 0 .25rem .7rem; border-left: 3px solid var(--rule); margin: .3rem 0; }
.subhead { font-weight: 600; margin: 1.2rem 0 .4rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; margin: .4rem 0 1rem; }
.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data th { text-align: left; font-weight: 500; color: var(--muted); background: var(--panel); padding: .45rem .6rem;
  border-bottom: 1px solid var(--rule); white-space: nowrap; }
.data td { padding: .4rem .6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.data tr:last-child td { border-bottom: 0; }
.data td.n, .data th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data tr.bad td { background: color-mix(in srgb, var(--mismatch) 7%, white); }
.data td.desc { min-width: 9rem; }
.k-recon { width: 100%; border-collapse: collapse; font-size: .92rem; margin-top: .6rem; }
.k-recon td { padding: .3rem .2rem; border-bottom: 1px solid var(--rule); }
.k-recon td.n { text-align: right; font-variant-numeric: tabular-nums; }
.k-recon tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
.k-recon .ok { color: var(--valid); } .k-recon .bad { color: var(--mismatch); }

/* Checks */
.k-checks { list-style: none; padding: 0; margin: 0; }
.k-checks li { display: grid; grid-template-columns: 1.6rem 1fr; gap: .2rem; padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.k-checks .i { font-weight: 700; color: var(--c); text-align: center; }
.k-checks .lab { font-weight: 600; font-size: .92rem; }
.k-checks .msg { color: var(--body); font-size: .88rem; }
.k-checks .valid { --c: var(--valid); } .k-checks .review { --c: var(--review); }
.k-checks .mismatch { --c: var(--mismatch); } .k-checks .missing { --c: var(--missing); }
.k-checks .info { --c: var(--info); }

/* Raw text and JSON */
.page-head { font-weight: 600; margin: .8rem 0 .3rem; }
.page-head span { color: var(--muted); font-weight: 400; }
pre.code { background: var(--panel); border-radius: 6px; padding: .9rem 1rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 .8rem; max-height: 620px; overflow: auto; }
pre.code .k { color: var(--accent); } pre.code .s { color: #8A4B12; } pre.code .nb { color: #5F4FA0; } pre.code .nl { color: var(--muted); }

/* Alerts */
.alert { border-radius: 6px; padding: .7rem .9rem; font-size: .9rem; margin: .6rem 0; }
.alert.info { background: #EAF2F8; color: #1B4565; }
.alert.warn { background: #FBF3E3; color: #6F4708; }
.alert.error { background: #FBEAEA; color: #7A2222; }

/* Review and export */
.divider { border: 0; border-top: 1px solid var(--rule); margin: 1.6rem 0 1rem; }
.section-title { font-weight: 600; margin-bottom: .5rem; }
.btn-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.btn-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .btn-row, .btn-row.four { grid-template-columns: 1fr 1fr; } }
.export { margin-top: 1.2rem; }

/* Visitor steps: 1 choose, 2 process, 3 review */
.stepno { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 1.45rem; height: 1.45rem;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: .8rem; font-weight: 700; margin-right: .5rem;
  font-variant-numeric: tabular-nums; }
.step-head { display: flex; align-items: center; }
.sidebar-toggle > span { display: inline-flex; align-items: center; }
.stepper { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; padding: 0; margin: 0 0 1.1rem; }
.stepper li { display: flex; align-items: center; gap: .1rem; border: 1px solid var(--rule); border-radius: 8px; padding: .55rem .75rem;
  background: #fff; color: var(--muted); font-size: .92rem; min-width: 0; }
.stepper li .stepno { background: var(--rule); color: var(--ink); }
.stepper li .lbl { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.stepper li .lbl small { font-size: .78rem; color: var(--muted); font-weight: 400; }
.stepper li.now { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--ink); font-weight: 600; }
.stepper li.now .stepno { background: var(--accent); color: #fff; }
.stepper li.done { color: var(--ink); }
.stepper li.done .stepno { background: var(--valid); color: #fff; }
.stepper button { all: unset; cursor: pointer; display: flex; align-items: center; width: 100%; }
.stepper button:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
@media (max-width: 640px) {
  .stepper { gap: .35rem; }
  .stepper li { padding: .45rem .5rem; font-size: .8rem; }
  .stepper li .lbl small { display: none; }
  .stepper li .stepno { margin-right: .35rem; }
}
.process-step { display: flex; align-items: center; font-weight: 600; margin: 1.1rem 0 .5rem; }
.btn-process { min-width: 14rem; min-height: 2.9rem; font-size: 1rem; font-weight: 600; }
.btn-process.attention { animation: nudge 1.6s ease-out 1; }
@keyframes nudge { 0% { box-shadow: 0 0 0 0 rgba(8,102,245,.45); } 100% { box-shadow: 0 0 0 14px rgba(8,102,245,0); } }
@media (prefers-reduced-motion: reduce) { .btn-process.attention { animation: none; } }
