:root{--bg:#f5f6f8;--ink:#121820;--muted:#6d7682;--line:#e3e7ec;--card:#fff;--accent:#111827;font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Arial,sans-serif}
*{box-sizing:border-box}html,body{margin:0;background:var(--bg);color:var(--ink)}a{color:inherit}
.topbar{height:68px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 30px;position:sticky;top:0;z-index:20}
.brand{text-decoration:none;font-size:21px;letter-spacing:-.6px}.brand-mark{font-weight:900}.brand-light{font-weight:400}
nav{display:flex;align-items:center;gap:20px}nav a,.nav-button{font-size:14px;text-decoration:none;color:#222b35;background:none;border:0;padding:0;cursor:pointer}.logout-form{margin:0}
.page{max-width:1220px;margin:0 auto;padding:38px 24px 80px}.page-head,.section-head{display:flex;justify-content:space-between;align-items:center;gap:20px}.page-head{margin-bottom:26px}
h1{font-size:34px;letter-spacing:-1.2px;margin:3px 0 0}h2{font-size:20px;margin:0 0 16px}.eyebrow{font-size:11px;font-weight:800;letter-spacing:.11em;color:#697482}.muted{color:var(--muted)}
.primary{display:inline-flex;align-items:center;justify-content:center;background:var(--accent);color:#fff;text-decoration:none;border:0;border-radius:10px;padding:12px 17px;font-weight:750;cursor:pointer}.wide{width:100%;margin-top:16px}
.cards{display:grid;grid-template-columns:repeat(5,1fr);gap:14px;margin-bottom:26px}.metric{background:#fff;border:1px solid var(--line);border-radius:15px;padding:19px;min-height:100px}.metric span{font-size:10px;font-weight:800;color:#707a86;display:block;margin-bottom:13px}.metric strong{font-size:25px;letter-spacing:-.7px}.metric.vat{border:2px solid #171c23}
.review-note{display:inline-block;margin:0 0 30px;background:#fff2c9;border-radius:999px;padding:8px 12px;font-size:13px;text-decoration:none}
.table-wrap{background:#fff;border:1px solid var(--line);border-radius:14px;overflow:auto}table{border-collapse:collapse;width:100%;min-width:820px}th,td{padding:13px 14px;text-align:left;border-bottom:1px solid #edf0f3;font-size:13px;white-space:nowrap}th{font-size:10px;color:#707985;letter-spacing:.03em}.empty{text-align:center;color:var(--muted);padding:28px}
.status{display:inline-block;font-size:10px;padding:5px 8px;border-radius:999px;background:#eceff2}.status.ok{background:#dff5e6}.status.review{background:#fff0c7}.status.needs_ocr{background:#ffdede}
.panel{background:#fff;border:1px solid var(--line);border-radius:15px;padding:24px}.narrow{max-width:620px}.two{display:grid;grid-template-columns:1fr 1fr;gap:18px}.three{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
label{font-size:12px;font-weight:750;display:block;margin:14px 0 6px}input,select,textarea{width:100%;border:1px solid #cfd5dc;border-radius:9px;background:#fff;padding:11px 12px;font:inherit}textarea{min-height:90px}pre{white-space:pre-wrap;max-height:600px;overflow:auto;background:#f7f8fa;border-radius:10px;padding:14px;font-size:12px}
.auth-shell{min-height:calc(100vh - 145px);display:grid;place-items:center}.auth-card{width:min(430px,100%);background:#fff;border:1px solid var(--line);border-radius:18px;padding:30px}.auth-card h1{margin-bottom:4px}.auth-foot{text-align:center;font-size:13px;color:var(--muted);margin-top:20px}.error{color:#b42318;font-size:12px}
.upload-grid{display:grid;grid-template-columns:1.35fr .65fr;gap:18px}.upload-zone{margin:0;border:1px dashed #aeb6c0;border-radius:14px;min-height:220px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:8px;cursor:pointer;padding:24px}.upload-zone input,.camera-button input{display:none}.upload-zone span{color:var(--muted);font-weight:400}.upload-icon{font-size:34px}.camera-button{margin:10px 0 0;display:flex;background:#f1f3f5;border-radius:12px;min-height:72px;align-items:center;justify-content:center;font-size:16px}
.camera-fab{display:none}
@media(max-width:900px){
 .topbar{padding:0 16px}.topbar nav a:nth-child(3),.topbar nav a:nth-child(4){display:none}nav{gap:14px}
 .page{padding:24px 15px 92px}.page-head{align-items:flex-start}h1{font-size:29px}
 .cards{grid-template-columns:1fr 1fr}.metric.vat{grid-column:1/-1}.metric{min-height:92px}.metric strong{font-size:22px}
 .two,.upload-grid{grid-template-columns:1fr}.three{grid-template-columns:1fr 1fr 1fr}
 .camera-fab{display:flex;position:fixed;left:15px;right:15px;bottom:14px;background:#111827;color:white;text-decoration:none;border-radius:14px;min-height:58px;align-items:center;justify-content:center;gap:8px;font-weight:800;box-shadow:0 12px 30px #0003;z-index:40}
}
@media(max-width:560px){.cards{grid-template-columns:1fr 1fr}.metric{padding:16px}.three{grid-template-columns:1fr}.page-head .primary{display:none}}

.doc-actions{display:flex;align-items:center;gap:10px}.doc-actions form{margin:0}
.danger{background:#b42318;color:#fff;border:0;border-radius:9px;padding:8px 12px;font-weight:750;cursor:pointer}
.trash{width:30px;height:30px;border:1px solid #ead0ce;background:#fff6f5;color:#b42318;border-radius:8px;font-size:20px;line-height:20px;cursor:pointer}
.trash:hover,.danger:hover{filter:brightness(.95)}

.ai-note{margin-top:8px;padding:9px 11px;border-radius:9px;background:#fff7df;border:1px solid #f0dda1;font-size:12px;color:#6b5312}

.ai-ok{margin:0 0 14px;padding:9px 11px;border-radius:9px;background:#e6f7eb;border:1px solid #bfe6ca;font-size:12px;color:#206a36}
.ai-error{margin:0 0 14px;padding:9px 11px;border-radius:9px;background:#fff0ef;border:1px solid #f0c1bd;font-size:12px;color:#9b2c21}

.foreign-warning{margin:0 0 16px;padding:12px 14px;border-radius:10px;background:#fff0ef;border:1px solid #efb3ad;color:#8d2118;font-size:13px;line-height:1.45}

.foreign-actions{margin:0 0 14px;padding:10px 12px;border-radius:9px;background:#fafafa;border:1px solid #ddd;color:#555;font-size:12px}
.foreign-actions p{margin:0}
.ghost-data{margin-top:18px;background:#fff;border:1px solid var(--line);border-radius:12px;padding:12px 14px}.ghost-data summary{cursor:pointer;font-weight:800;font-size:13px}.ghost-data table{margin-top:10px}


/* v0.17 — document comparison workspace */
.document-workspace{
  display:grid;
  grid-template-columns:minmax(320px,1.08fr) minmax(360px,1fr) minmax(300px,.78fr);
  gap:18px;
  align-items:start;
}
.document-workspace .panel{min-width:0}
.panel-title-row{display:flex;align-items:center;justify-content:space-between;gap:12px}
.panel-title-row h2{margin-bottom:0}
.preview-open{font-size:12px;color:var(--muted);text-decoration:none}
.preview-open:hover{text-decoration:underline}
.preview-panel{position:sticky;top:86px}
.image-preview-button{
  display:block;width:100%;margin:16px 0 0;padding:0;border:0;background:#eef1f4;
  border-radius:10px;overflow:hidden;cursor:zoom-in;
}
.document-preview-image{
  display:block;width:100%;height:auto;max-height:690px;object-fit:contain;background:#eef1f4;
}
.document-preview-pdf{
  display:block;width:100%;height:690px;margin-top:16px;border:0;border-radius:10px;background:#eef1f4;
}
.preview-help{margin:8px 0 0;text-align:center;font-size:11px;color:var(--muted)}
.preview-fallback{min-height:300px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px}
.ocr-panel pre{max-height:690px;margin-bottom:0}
.preview-modal{
  display:none;position:fixed;inset:0;z-index:1000;background:rgba(9,13,18,.88);
  padding:28px;align-items:center;justify-content:center;cursor:zoom-out;
}
.preview-modal.open{display:flex}
.preview-modal img{
  display:block;max-width:96vw;max-height:94vh;width:auto;height:auto;object-fit:contain;
  background:#fff;box-shadow:0 20px 70px rgba(0,0,0,.45);cursor:default;
}
.preview-modal-close{
  position:fixed;top:18px;right:22px;width:44px;height:44px;border:0;border-radius:999px;
  background:#fff;color:#111827;font-size:30px;line-height:40px;cursor:pointer;z-index:1001;
}
.preview-open-body{overflow:hidden}

@media(min-width:1250px){
  .page:has(.document-workspace){max-width:1580px}
}
@media(max-width:1180px){
  .document-workspace{grid-template-columns:minmax(300px,1fr) minmax(360px,1fr)}
  .ocr-panel{grid-column:1/-1}
  .ocr-panel pre{max-height:380px}
}
@media(max-width:800px){
  .document-workspace{grid-template-columns:1fr}
  .preview-panel{position:static}
  .ocr-panel{grid-column:auto}
  .document-preview-image,.document-preview-pdf{max-height:70vh;height:auto}
}


/* v0.18 — manual preview rotation */
.preview-actions{display:flex;align-items:center;gap:7px}
.rotate-btn{
  width:30px;height:30px;padding:0;border:1px solid var(--line);
  border-radius:7px;background:#fff;color:#111827;font-size:19px;
  line-height:27px;cursor:pointer;
}
.rotate-btn:hover{background:#f3f4f6}
.image-preview-button{
  min-height:330px;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.document-preview-image,
.preview-modal img{
  transform-origin:center center;
  transition:transform .16s ease;
}


/* v0.19 — always-visible delete action in archive */
table th.actions-col,
table td.actions-col{
  position:sticky;
  right:0;
  z-index:2;
  background:#fff;
  min-width:88px;
  text-align:center;
  box-shadow:-8px 0 12px -12px rgba(17,24,39,.55);
}
table th.actions-col{z-index:3}
.actions-col form{margin:0}
.list-delete{
  border:1px solid #ead0ce;
  background:#fff6f5;
  color:#b42318;
  border-radius:8px;
  padding:6px 9px;
  font-size:11px;
  font-weight:700;
  cursor:pointer;
}
.list-delete:hover{background:#fde8e6}


/* v0.27 — smart camera + rotation-safe preview */
.smart-camera-open{width:100%;border:0;cursor:pointer}
.camera-batch{margin:12px 0;padding:12px 14px;border-radius:10px;background:#f7f8fa;display:flex;flex-direction:column;gap:3px}
.camera-fallback{margin-top:12px;font-size:12px;color:var(--muted)}
.camera-fallback input{display:block;margin-top:5px;max-width:100%}
.smart-camera-modal{display:none;position:fixed;inset:0;z-index:2000;background:#05070a}
.smart-camera-modal.open{display:block}
.smart-camera-stage{position:absolute;inset:0;overflow:hidden;background:#05070a}
.smart-camera-stage video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.smart-camera-stage:after{content:"";position:absolute;inset:0;pointer-events:none;background:rgba(0,0,0,.16)}
.document-guide{position:absolute;z-index:2;left:50%;top:50%;height:min(70vh,720px);aspect-ratio:1/1.4142;transform:translate(-50%,-50%);border:2px solid rgba(255,255,255,.72);box-shadow:0 0 0 200vmax rgba(0,0,0,.46);border-radius:5px}
.document-guide .corner{position:absolute;width:34px;height:34px;border-color:#fff;border-style:solid}
.document-guide .tl{left:-3px;top:-3px;border-width:4px 0 0 4px}.document-guide .tr{right:-3px;top:-3px;border-width:4px 4px 0 0}.document-guide .bl{left:-3px;bottom:-3px;border-width:0 0 4px 4px}.document-guide .br{right:-3px;bottom:-3px;border-width:0 4px 4px 0}
.camera-topbar{position:absolute;z-index:4;left:0;right:0;top:0;padding:calc(env(safe-area-inset-top,0px) + 14px) 18px 12px;display:flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(rgba(0,0,0,.65),transparent)}
.camera-title{font-weight:700;text-shadow:0 1px 4px #000}
.camera-close{position:absolute;left:16px;top:calc(env(safe-area-inset-top,0px) + 10px);width:42px;height:42px;border-radius:50%;border:0;background:rgba(0,0,0,.45);color:#fff;font-size:29px;line-height:38px}
.camera-quality{position:absolute;z-index:4;left:50%;bottom:126px;transform:translateX(-50%);max-width:88vw;padding:8px 13px;border-radius:999px;background:rgba(0,0,0,.68);color:#fff;font-size:13px;white-space:nowrap;display:flex;gap:8px;align-items:center}
.quality-dot{width:10px;height:10px;border-radius:50%;background:#f0ad4e}.camera-quality[data-state="good"] .quality-dot{background:#39d98a}.camera-quality[data-state="bad"] .quality-dot{background:#ff5c5c}
.camera-controls{position:absolute;z-index:4;left:0;right:0;bottom:0;padding:12px 16px calc(env(safe-area-inset-bottom,0px) + 16px);display:flex;flex-direction:column;align-items:center;gap:8px;background:linear-gradient(transparent,rgba(0,0,0,.68))}
.camera-shutter{width:72px;height:72px;border-radius:50%;border:4px solid #fff;background:rgba(255,255,255,.15);padding:6px}.camera-shutter span{display:block;width:100%;height:100%;border-radius:50%;background:#fff}.camera-shutter:disabled{opacity:.35}.camera-hint{color:#fff;font-size:12px;text-align:center;text-shadow:0 1px 4px #000}

/* JS sets the exact height/scale after 90-degree rotations so the inline preview is never clipped. */
.image-preview-button{position:relative}
.document-preview-image{transform-origin:center center;will-change:transform}
@media(max-width:650px){.document-guide{height:min(66vh,640px);max-width:86vw}.camera-quality{bottom:122px;font-size:12px}}

/* ===== v0.30 product UI / subscription / processing states ===== */
.brand-logo{display:flex;align-items:center;min-width:150px}
.brand-logo img{display:block;width:172px;max-height:42px;object-fit:contain;object-position:left center}
.site-footer{display:flex;align-items:center;justify-content:center;gap:8px;padding:28px 20px 36px;color:#98a2b3;font-size:12px}
.site-footer img{width:20px;height:20px}
.plan-chip{padding:6px 10px!important;border-radius:999px;background:#fff7d6!important;color:#7a5a00!important;font-size:12px!important;font-weight:700;white-space:nowrap}
.plan-chip.active{background:#ecfdf3!important;color:#027a48!important}.plan-chip.expired{background:#fef3f2!important;color:#b42318!important}
.messages{margin:0 0 16px}.alert.success{background:#ecfdf3;color:#027a48;border:1px solid #abefc6}.alert.warning{background:#fffaeb;color:#b54708;border:1px solid #fedf89}.alert.info{background:#eff8ff;color:#175cd3;border:1px solid #b2ddff}
.workflow-status{display:inline-flex;align-items:center;gap:7px;padding:8px 12px;border-radius:999px;font-weight:700;font-size:13px;white-space:nowrap}
.workflow-status.mini{padding:5px 9px;font-size:12px}
.workflow-status.confirmed{background:#ecfdf3;color:#027a48}.workflow-status.ready{background:#eef4ff;color:#3538cd}.workflow-status.waiting{background:#fff7d6;color:#7a5a00}.workflow-status.processing{background:#eff8ff;color:#175cd3}.workflow-status.error,.workflow-status.foreign{background:#fef3f2;color:#b42318}
.spinner{display:inline-block;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:pkspin .75s linear infinite;vertical-align:-2px}.spinner.big{width:22px;height:22px;border-width:3px;flex:0 0 auto}
@keyframes pkspin{to{transform:rotate(360deg)}}
.pulse-dot{display:inline-block;width:9px;height:9px;border-radius:50%;background:currentColor;animation:pkpulse 1.3s ease-in-out infinite}
@keyframes pkpulse{0%,100%{opacity:.35;transform:scale(.85)}50%{opacity:1;transform:scale(1.15)}}
.processing-note{display:flex;align-items:center;gap:12px;padding:13px 16px;margin:0 0 18px;border:1px solid #b2ddff;background:#eff8ff;color:#175cd3;border-radius:12px}.processing-note span:not(.spinner):not(.pulse-dot){color:#475467}.processing-note.compact{padding:10px 13px}
.trial-badge{display:inline-block;background:#fff7d6;color:#7a5a00;padding:7px 11px;border-radius:999px;font-size:12px;font-weight:800;margin-bottom:10px}
.subscription-summary{border-radius:16px;padding:18px 20px;margin:0 0 18px;border:1px solid #eaecf0}.subscription-summary div{display:flex;flex-direction:column;gap:5px}.subscription-summary strong{font-size:18px}.subscription-summary span{color:#667085}.subscription-summary.trial{background:#fffaeb;border-color:#fedf89}.subscription-summary.active{background:#ecfdf3;border-color:#abefc6}.subscription-summary.expired{background:#fef3f2;border-color:#fecdca}
.price-hero{display:flex;align-items:stretch;gap:14px;margin:0 0 22px}.price-main,.price-total{border:1px solid #eaecf0;background:white;border-radius:16px;padding:18px 22px;display:flex;flex-direction:column;justify-content:center}.price-main{flex:1}.price-main>span{font-size:36px;font-weight:800;letter-spacing:-1px}.price-main small,.price-total small{color:#667085}.price-total{min-width:250px;background:#111827;color:white}.price-total>span{font-size:12px;text-transform:uppercase;letter-spacing:.08em;color:#d0d5dd}.price-total strong{font-size:30px;margin:3px 0}.price-total small{color:#d0d5dd}
.billing-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin-bottom:18px}.billing-card{display:flex;flex-direction:column;gap:10px}.billing-card h2{margin:0}.billing-card p{color:#667085;line-height:1.5}.payment-icon{font-size:30px}.billing-card .wide{margin-top:auto}.bank-box{display:grid;gap:9px;background:#f9fafb;border:1px solid #eaecf0;border-radius:12px;padding:13px}.bank-box>div{display:flex;justify-content:space-between;gap:18px}.bank-box span{color:#667085}.bank-box strong{text-align:right;overflow-wrap:anywhere}.copyable{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.small{font-size:12px}.billing-note{max-width:none}.billing-note p{margin-bottom:0;color:#667085}
.settings-grid{display:grid;grid-template-columns:minmax(0,560px) minmax(260px,360px);gap:18px;align-items:start}.subscription-mini strong{font-size:18px}.subscription-mini p{color:#667085;margin:8px 0 18px}.subscription-mini.trial{border-color:#fedf89}.subscription-mini.active{border-color:#abefc6}.subscription-mini.expired{border-color:#fecdca}
.success-mark{width:58px;height:58px;border-radius:50%;display:grid;place-items:center;background:#ecfdf3;color:#027a48;font-size:32px;font-weight:800;margin:0 auto 14px}.payment-result{text-align:center}
button[disabled]{opacity:.55;cursor:not-allowed}

@media(max-width:900px){.billing-grid,.settings-grid{grid-template-columns:1fr}.price-hero{flex-direction:column}.price-total{min-width:0}.topbar{align-items:flex-start}.topbar nav{gap:6px}.plan-chip{display:none!important}.brand-logo img{width:150px}}
@media(max-width:640px){.brand-logo img{width:132px}.price-main>span{font-size:31px}.bank-box>div{flex-direction:column;gap:2px}.bank-box strong{text-align:left}.site-footer{padding-bottom:90px}}


/* ===== v0.31 real brand + client polish ===== */
:root{--brand-yellow:#ffc400}
.brand-logo{min-width:118px;height:58px;overflow:hidden}
.brand-logo img{width:118px!important;height:58px!important;object-fit:contain;object-position:left center}
.auth-card{width:min(470px,100%)}
.auth-logo{display:block;width:min(330px,92%);height:auto;margin:0 auto 20px}
.site-footer{display:flex;align-items:center;justify-content:center;gap:8px;color:#667085;font-size:12px}
.site-footer img{width:28px;height:28px;object-fit:contain}
.archive-summary{display:flex;gap:8px;flex-wrap:wrap;margin:-8px 0 18px}
.summary-chip{display:inline-flex;align-items:center;padding:7px 10px;border-radius:999px;font-size:12px;font-weight:750;border:1px solid #eaecf0;background:#fff}
.summary-chip.ready{background:#eef4ff;color:#3538cd;border-color:#c7d7fe}
.summary-chip.processing{background:#eff8ff;color:#175cd3;border-color:#b2ddff}
.summary-chip.waiting{background:#fffaeb;color:#7a5a00;border-color:#fedf89}
.summary-chip.confirmed{background:#ecfdf3;color:#027a48;border-color:#abefc6}
@media(max-width:900px){.brand-logo{min-width:100px;height:54px}.brand-logo img{width:100px!important;height:54px!important}.topbar{height:62px}.auth-logo{width:min(300px,90%)}}
@media(max-width:640px){.brand-logo{min-width:84px;height:48px}.brand-logo img{width:84px!important;height:48px!important}.topbar{height:58px}.archive-summary{gap:6px}.summary-chip{font-size:11px;padding:6px 8px}}

/* ===== v0.36 installable PWA ===== */
.pwa-install-button{display:none!important;padding:7px 11px!important;border:1px solid #e6b500!important;border-radius:9px!important;background:#ffc400!important;color:#171717!important;font-weight:800!important;white-space:nowrap}
.pwa-install-button.show{display:inline-flex!important}
.pwa-install-modal{display:none;position:fixed;inset:0;z-index:3000;background:rgba(17,24,39,.55);padding:20px;align-items:center;justify-content:center}
.pwa-install-modal.open{display:flex}
.pwa-install-card{position:relative;width:min(430px,100%);background:#fff;border-radius:20px;padding:30px 28px;text-align:center;box-shadow:0 24px 70px rgba(0,0,0,.25)}
.pwa-install-card h2{margin:8px 0 10px;font-size:22px}.pwa-install-card p{margin:0;color:#667085;line-height:1.55}
.pwa-install-icon{width:92px;height:92px;object-fit:contain}.pwa-install-close{position:absolute;right:12px;top:10px;border:0;background:transparent;font-size:30px;line-height:1;color:#667085;cursor:pointer}
@media(max-width:900px){.pwa-install-button.show{display:inline-flex!important}.topbar nav{flex-wrap:nowrap}.pwa-install-button{font-size:12px!important}}
@media(max-width:640px){.pwa-install-button.show{position:fixed;right:15px;bottom:82px;z-index:39;box-shadow:0 10px 24px #0002;padding:10px 13px!important}.pwa-install-card{padding:28px 22px}.pwa-install-icon{width:82px;height:82px}}


/* ===== v0.38 monthly periods + history ===== */
.reports-table td,.reports-table th{white-space:nowrap}.positive{color:#027a48;font-weight:750}.negative{color:#b42318;font-weight:750}.report-note{margin-top:18px;padding:14px 16px;border:1px solid #eaecf0;border-radius:12px;background:#f9fafb;color:#667085;line-height:1.5}.report-note strong{color:#344054}
