/* DigiTax back office - used on desktop screens by accountants, so it is denser than the customer
   application, but it still works on a tablet. */

:root {
  --brand: #d6202a;
  --primary: #1b4dd1;
  --primary-dark: #153ea8;
  --primary-soft: #e8eefc;
  --ink: #101828;
  --ink-soft: #5b6676;
  --line: #d5dae3;
  --line-soft: #e7eaf0;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ok: #157f3c;
  --ok-soft: #e4f5ea;
  --warn: #a15c00;
  --warn-soft: #fdf1dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ai: #6d28d9;
  --ai-soft: #efe8fd;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { font-size: 24px; margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14.5px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.muted { color: var(--ink-soft); }
.strong { font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--ink-soft); text-align: center; padding: 28px 12px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ------------------------------------------------------------------ chrome */

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px; height: 54px; padding: 0 20px; background: #101828; color: #fff; }
.brand { font-size: 19px; font-weight: 750; color: #fff; text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.brand span { color: #ff5a63; }
.brand small { font-size: 12px; font-weight: 500; opacity: .7; margin-left: 4px; letter-spacing: 0; }
.brand.big { font-size: 28px; color: var(--ink); margin-bottom: 14px; }
.brand.big span { color: var(--brand); }
.mainnav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.mainnav a { color: #cdd5e1; text-decoration: none; padding: 8px 12px; border-radius: 7px; font-weight: 550; white-space: nowrap; }
.mainnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.mainnav a.active { background: rgba(255, 255, 255, .14); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right form { margin: 0; }
.lang-switch a { color: #9aa6b8; text-decoration: none; font-size: 12.5px; font-weight: 650; padding: 4px 5px; }
.lang-switch a.active { color: #fff; }
.user-link { color: #fff; text-decoration: none; font-weight: 550; white-space: nowrap; }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }
.topbar .btn:hover { background: rgba(255, 255, 255, .1); }

.content { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.content.narrow { max-width: 620px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.back-link { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 550; }

body.guest { display: grid; place-items: center; min-height: 100vh; }
body.guest .content { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: var(--surface); border-radius: 14px; padding: 30px 28px; box-shadow: 0 6px 30px rgba(16, 24, 40, .1); }
.login-card h1 { font-size: 20px; margin-bottom: 2px; }
.login-card label { display: block; font-weight: 600; margin: 14px 0 5px; }
.login-card .btn { margin-top: 20px; }

/* ------------------------------------------------------------------ building blocks */

.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ai { background: var(--ai); border-color: var(--ai); color: #fff; }
.btn-ai:hover { background: #5b21b6; }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { display: flex; width: 100%; min-height: 42px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--primary); }
.btn-quiet.danger { color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27, 77, 209, .15); }
.stack label { display: block; font-weight: 600; margin: 12px 0 4px; }
.stack label.check { font-weight: 400; }
.hint { color: var(--ink-soft); font-size: 13px; margin: 4px 0 0; }
.field-error { color: var(--danger); font-size: 13px; font-weight: 550; margin: 4px 0 0; }
.field-error:empty { display: none; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.check.small { font-size: 13px; margin-top: 4px; color: var(--ink-soft); }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--primary-soft); color: #1d3a8a; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--bg); color: var(--ink-soft); text-decoration: none; }
.badge-ok, .pay-Paid, .ai-Completed, .status-ApprovedByCustomer, .status-Submitted, .status-Closed { background: var(--ok-soft); color: var(--ok); }
.badge-warn, .pay-Pending, .status-QuestionsInProgress { background: var(--warn-soft); color: var(--warn); }
.badge-danger, .pay-Failed, .ai-Failed, .status-WaitingForCustomer { background: var(--danger-soft); color: var(--danger); }
.badge-primary, .status-QuestionsCompleted, .status-InReview, .status-SentForApproval { background: var(--primary-soft); color: var(--primary-dark); }
.ai-Queued, .ai-Processing, .kind-TaxPackage, .kind-TaxFormPdf { background: var(--ai-soft); color: var(--ai); }

.table-wrap { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table-compact td { padding: 6px 10px; font-size: 13px; }
.row-actions { white-space: nowrap; text-align: right; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar input[type="search"] { flex: 1; min-width: 220px; }
.filter-bar select { width: auto; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; }
.tile-value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; }
.tile-label { color: var(--ink-soft); }

.facts { margin: 0; display: grid; gap: 10px; }
.facts-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.facts dt { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 550; }

/* ------------------------------------------------------------------ customer details */

.customer-head { display: grid; gap: 14px; }
.customer-main h1 { margin-bottom: 4px; }
.customer-main p { margin-bottom: 4px; }
.logins summary { cursor: pointer; color: var(--primary); font-weight: 550; }
.logins table { margin-top: 8px; }

.app-bar-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.year-switch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.year { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 650; }
.year.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.status-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 650; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.status-form label.grow { flex: 1; min-width: 200px; }
.status-form select { width: auto; min-width: 170px; font-weight: 600; text-transform: none; letter-spacing: 0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--ink-soft); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--line-soft); font-size: 12px; text-align: center; }
.count-new { background: var(--brand); color: #fff; }

.form-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.legend { color: var(--ink-soft); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid; }

/* ------------------------------------------------------------------ tax form */

.tf-head, .tf-row { display: grid; grid-template-columns: minmax(180px, 1.15fr) minmax(120px, 1fr) minmax(120px, 1fr); gap: 10px; align-items: center; }
.tf-head { position: sticky; top: 54px; z-index: 5; background: var(--bg); padding: 8px 18px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.tf-section { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); margin-bottom: 12px; }
.tf-section > summary { padding: 12px 18px; font-size: 16px; font-weight: 700; cursor: pointer; list-style-position: inside; }
.tf-group { padding: 14px 18px; border-top: 1px solid var(--line-soft); }
.tf-group h3 { color: var(--primary-dark); }
.tf-row { padding: 3px 0; }
.tf-row label { color: var(--ink); }
.tf-row[data-field-type="textarea"] { align-items: start; }
.tf-input.old { background: #f6f7f9; color: var(--ink-soft); }
.tf-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.tf-input.changed { border-color: var(--primary); }
.conf-high { background: var(--ok-soft) !important; border-color: #8fcfa3 !important; }
.conf-mid { background: #fff4cc !important; border-color: #e5c558 !important; }
.conf-low { background: var(--danger-soft) !important; border-color: #f0a8a1 !important; }

.person-tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg); border-radius: 8px; margin-bottom: 10px; }
.person-tabs button { border: 0; background: none; padding: 5px 14px; border-radius: 6px; font: inherit; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.person-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }

.tg-docs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.doc-chip { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; font-size: 12.5px; font-weight: 550; vertical-align: middle; }
.doc-chip:hover { background: #d7e2fb; }
.tg-entry { border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 12px 10px; margin: 0 0 10px; }
.tg-entry legend { display: flex; align-items: center; gap: 8px; padding: 0 6px; font-size: 12.5px; font-weight: 650; color: var(--ink-soft); }

.save-bar { position: sticky; bottom: 0; z-index: 6; display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 12px 18px; background: rgba(244, 246, 250, .95); border-top: 1px solid var(--line); backdrop-filter: blur(6px); }
.save-bar .btn { min-height: 40px; padding: 0 22px; }
.unsaved { color: var(--warn); font-weight: 600; }

/* ------------------------------------------------------------------ answers, messages, parameters */

.answers td.q { width: 48%; }
.answers td.d { width: 150px; white-space: nowrap; text-align: right; }
.answers .doc-chip { margin: 2px 4px 2px 0; }

.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.bubble { max-width: 70%; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-soft); }
.bubble.mine { align-self: flex-end; background: var(--primary-soft); border-color: #cddcfa; }
.bubble.theirs { align-self: flex-start; }
.bubble header { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; margin-bottom: 4px; }
.bubble time { color: var(--ink-soft); }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 4px; }
.composer textarea { margin-bottom: 10px; }
.composer-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.composer-row .btn { margin-left: auto; }
.file-pick { font-weight: 600; }
.file-pick input { font-weight: 400; margin-left: 6px; }
.upload-inline { display: inline-flex; align-items: center; gap: 8px; }

.param-row { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr); gap: 16px; padding: 10px 0; border-top: 1px solid var(--line-soft); align-items: start; }
.param-row label code { display: block; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.param-row label span { font-size: 13px; }

.param-test { margin-top: 6px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--bg); }
.param-test h3 { margin-bottom: 4px; }
.param-test-row { display: flex; gap: 10px; flex-wrap: wrap; }
.param-test-row input { flex: 1; min-width: 220px; max-width: 420px; }
.param-test-result { margin: 10px 0 0; padding: 9px 12px; border-radius: 7px; font-weight: 550; overflow-wrap: anywhere; }
.param-test-result:empty { display: none; }
.param-test-result.pending { color: var(--ink-soft); padding-left: 0; }
.param-test-result.sent { background: var(--ok-soft); color: var(--ok); }
.param-test-result.outbox { background: var(--warn-soft); color: var(--warn); }
.param-test-result.error { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 14px; gap: 8px; }
  .tf-head { display: none; }
  .tf-row { grid-template-columns: 1fr 1fr; }
  .tf-row label { grid-column: 1 / -1; font-weight: 600; margin-top: 6px; }
  .param-row { grid-template-columns: 1fr; gap: 6px; }
  .bubble { max-width: 92%; }
}

/* ---------- log and jobs ---------- */
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }
.danger-text { color: #b42318; }
.log-fields { margin-top: 16px; }
.log-fields > summary { cursor: pointer; font-weight: 600; }
.log-fields .table-wrap { margin-top: 12px; }
.job-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.badge.job-Succeeded { background: #e6f4ea; color: #1e6b3a; }
.badge.job-Failed { background: #fde8e6; color: #b42318; }
.badge.job-Running { background: #e5efff; color: #1d4ed8; }
.badge.job-Queued, .badge.job-Cancelled { background: #eef0f3; color: #475467; }

/* ---------- OCR ---------- */
.ocr-cell { white-space: nowrap; }
.ocr-cell .ocr-error { display: block; max-width: 280px; white-space: normal; font-size: 12px; color: #b42318; overflow-wrap: anywhere; }
.badge.ocr-Succeeded { background: #e6f4ea; color: #1e6b3a; text-decoration: none; }
a.badge.ocr-Succeeded:hover { text-decoration: underline; }
.badge.ocr-Failed { background: #fde8e6; color: #b42318; }
.badge.ocr-Running { background: #e5efff; color: #1d4ed8; }
.badge.ocr-Queued { background: #eef0f3; color: #475467; }
.ocr-pending { margin: 0 0 10px; }
.ocr-text { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 ui-monospace, Consolas, monospace; background: #f7f8fa; border: 1px solid #e4e7ec; border-radius: 6px; padding: 16px; margin: 0; max-height: 75vh; overflow: auto; }

/* ---------- AI result per document ---------- */
.ai-cell .ai-note { display: block; max-width: 260px; font-size: 12px; color: #667085; overflow-wrap: anywhere; }
.badge.ai-doc-Succeeded { background: #e6f4ea; color: #1e6b3a; }
.badge.ai-doc-Skipped { background: #eef0f3; color: #475467; }
.badge.ai-doc-Failed { background: #fde8e6; color: #b42318; }
.badge.ai-doc-Running { background: #e5efff; color: #1d4ed8; }

/* ---------- checking AI values ---------- */
.tf-meta { grid-column: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: -2px 0 4px; font-size: 12px; color: var(--ink-soft); }
.tf-sources { display: inline-flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; min-width: 0; }
.tf-conf { font-variant-numeric: tabular-nums; }
.tf-source { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-review { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 1px 10px; font-size: 12px; color: var(--ink-soft); cursor: pointer; }
.tf-review:hover { border-color: var(--primary); color: var(--primary); }
.tf-review.on { background: var(--ok-soft); border-color: #8fcfa3; color: var(--ok); }
.tf-review.on::before { content: "\2713\00a0"; }
.tf-input.reviewed { border-color: #8fcfa3; }
.tf-suggestion { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 5px 8px; border: 1px solid #e5c558; background: #fffbea; border-radius: 6px; color: var(--ink); }
.tf-suggestion a { overflow-wrap: anywhere; }
.review-bar { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.review-bar[hidden] { display: none; }
@media (max-width: 760px) { .tf-meta { grid-column: 1 / -1; } }

/* ---------- quality ---------- */
.quality-tiles { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 18px; }
.quality-tiles .tile { min-width: 150px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: flex; flex-direction: column; gap: 2px; }
.quality-tiles .tile span { font-size: 12px; color: var(--ink-soft); }
.quality-tiles .tile strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.quality-tiles .tile small { font-size: 12px; color: var(--ink-soft); }

/* ---------- price and payments ---------- */
.price-panel { display: flex; flex-wrap: wrap; gap: 20px 40px; align-items: flex-start; }
.price-now { font-size: 24px; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; font-variant-numeric: tabular-nums; }
.price-now .badge { font-size: 12px; }
.price-edit { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.price-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); }
.price-edit input[type=text] { width: 120px; text-align: right; }
.price-edit p { flex-basis: 100%; margin: 0; max-width: 520px; }
.payment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 8px; }
.payment-head .push-right { margin-left: auto; }
.badge.payattempt-Paid, .badge.paytx-confirmed { background: var(--ok-soft); color: var(--ok); }
.badge.payattempt-Error, .badge.paytx-declined, .badge.paytx-error, .badge.paytx-cancelled, .badge.paytx-expired { background: var(--danger-soft); color: var(--danger); }
.badge.payattempt-Created, .badge.paytx-waiting { background: #e5efff; color: #1d4ed8; }
.badge.payattempt-Cancelled { background: #eef0f3; color: #475467; }
.badge.pay-Waived { background: #eef0f3; color: #475467; }
