:root {
  --tna-brand: #0f5c5e;
  --tna-brand-dark: #0a4547;
  --tna-bg: #ffffff;
  --tna-soft: #f4faf9;
  --tna-text: #17324d;
  --tna-muted: #6f7f8f;
  --tna-border: #dce8e6;
}

.tna-root { position: fixed; right: 22px; bottom: 22px; z-index: 999999; font-family: inherit; }
.tna-fab, .tna-send, .tna-inline-submit, .tna-inline-button {
  background: var(--tna-brand); color: #fff; border: 0; border-radius: 12px; cursor: pointer;
  font-weight: 700; text-decoration: none; transition: background .18s ease, transform .18s ease;
}
.tna-fab:hover, .tna-send:hover, .tna-inline-submit:hover, .tna-inline-button:hover { background: var(--tna-brand-dark); color: #fff; }
.tna-fab { padding: 13px 18px; box-shadow: 0 10px 28px rgba(17, 55, 68, .18); }
.tna-panel {
  width: min(540px, calc(100vw - 32px)); height: min(680px, calc(100vh - 90px));
  background: var(--tna-bg); border: 1px solid var(--tna-border); border-radius: 18px;
  box-shadow: 0 18px 55px rgba(19, 50, 77, .22); overflow: hidden; margin-bottom: 10px;
  display: grid; grid-template-rows: auto 1fr auto auto;
}
.tna-panel[hidden] { display: none !important; }
.tna-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; background: var(--tna-brand); color: #fff; }
.tna-close { border: 0; background: transparent; color: #fff; font-size: 25px; cursor: pointer; line-height: 1; }
.tna-messages { overflow-y: auto; overflow-x: hidden; padding: 15px; background: #fbfdfd; }
.tna-msg { margin: 0 0 12px; display: flex; flex-direction: column; min-width: 0; }
.tna-msg-body {
  line-height: 1.55; padding: 11px 13px; border-radius: 14px; max-width: 94%; font-size: 14px;
  overflow-wrap: anywhere; word-break: normal; min-width: 0;
}
.tna-msg-body p { margin: 0 0 8px; }
.tna-msg-body p:last-child { margin-bottom: 0; }
.tna-msg-body h4 { margin: 2px 0 8px; font-size: 14px; color: var(--tna-text); }
.tna-msg-body ul { margin: 4px 0 6px 18px; padding: 0; }
.tna-msg-body li { margin: 3px 0; }
.tna-msg-body code { background: #eef5f4; padding: 1px 4px; border-radius: 4px; font-size: .94em; }
.tna-msg-user { align-items: flex-end; }
.tna-msg-user .tna-msg-body { background: var(--tna-brand); color: #fff; border-bottom-right-radius: 5px; }
.tna-msg-assistant { align-items: flex-start; }
.tna-msg-assistant .tna-msg-body { background: #fff; color: var(--tna-text); border: 1px solid var(--tna-border); border-bottom-left-radius: 5px; }
.tna-msg-error .tna-msg-body { background: #fff8f0; border-color: #f0d8bf; }
.tna-sources { margin-top: 8px; padding: 11px 12px; max-width: 94%; background: var(--tna-soft); border: 1px solid #e4efed; border-radius: 12px; font-size: 12px; color: var(--tna-text); }
.tna-source-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.tna-source-link { display: flex; align-items: center; gap: 8px; color: var(--tna-brand); text-decoration: none; overflow-wrap: anywhere; padding: 7px 8px; background: #fff; border: 1px solid #e2ecea; border-radius: 9px; }
.tna-source-link:hover { border-color: #bcd7d3; background: #fbfefe; }
.tna-source-badge { flex: 0 0 auto; font-size: 9px; font-weight: 800; line-height: 1; letter-spacing: .04em; padding: 5px 6px; border-radius: 999px; background: #e8f3f1; color: var(--tna-brand-dark); }
.tna-source-official .tna-source-badge { background: #dff2ea; color: #17623f; }
.tna-source-open_data .tna-source-badge { background: #e8f1fb; color: #285b8e; }
.tna-source-court .tna-source-badge { background: #f2ecfb; color: #65449a; }
.tna-source-law .tna-source-badge { background: #fff0d8; color: #8b5a12; }
.tna-source-text { min-width: 0; }

.tna-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px; border-top: 1px solid var(--tna-border); background: #fff; }
.tna-input { width: 100%; box-sizing: border-box; resize: none; border: 1px solid var(--tna-border); border-radius: 11px; padding: 10px 11px; min-height: 44px; color: var(--tna-text); background: #fff; }
.tna-input:focus, .tna-inline-input:focus { outline: 2px solid rgba(15, 92, 94, .18); border-color: var(--tna-brand); }
.tna-send { padding: 0 14px; white-space: nowrap; }
.tna-send:disabled, .tna-inline-submit:disabled { opacity: .6; cursor: wait; }
.tna-note { padding: 0 12px 12px; color: var(--tna-muted); background: #fff; font-size: 11px; line-height: 1.4; }

.tna-inline-search { display: flex; width: min(760px, 100%); background: #fff; border: 1px solid var(--tna-border); border-radius: 14px; padding: 5px; box-shadow: 0 7px 24px rgba(17, 55, 68, .08); }
.tna-inline-input { min-width: 0; flex: 1; border: 0; background: #fff; color: var(--tna-text); padding: 12px 14px; font: inherit; }
.tna-inline-input:focus { outline: 0; }
.tna-inline-submit { padding: 10px 18px; white-space: nowrap; }
.tna-inline-button { display: inline-block; padding: 11px 16px; }

@media (max-width: 600px) {
  .tna-root { right: 10px; bottom: 10px; }
  .tna-panel { width: calc(100vw - 20px); height: min(78vh, 620px); }
  .tna-fab { padding: 11px 14px; }
  .tna-form { grid-template-columns: 1fr; }
  .tna-send { min-height: 42px; }
  .tna-inline-search { flex-direction: column; }
}

/* v1.5 structured-answer polish */
.tna-msg-assistant .tna-msg-body strong { color: #102f4b; }
.tna-msg-assistant .tna-msg-body ul { margin-top: 6px; }
.tna-msg-assistant .tna-msg-body li::marker { color: var(--tna-brand); }

/* v1.9 attachments + document analysis */
.tna-file-list {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; background: #fff;
}
.tna-file-list:empty { display: none; }
.tna-file-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--tna-border); background: var(--tna-soft); color: var(--tna-text);
  border-radius: 999px; padding: 5px 8px 5px 10px; font-size: 11px;
}
.tna-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }
.tna-file-remove {
  width: 20px; height: 20px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(15,92,94,.10); color: var(--tna-brand-dark); font-size: 16px; line-height: 18px; padding: 0;
}
.tna-file-remove:hover { background: rgba(15,92,94,.18); }
.tna-form { grid-template-columns: auto 1fr auto; align-items: end; }
.tna-attach {
  width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--tna-border); border-radius: 11px; background: var(--tna-soft);
  color: var(--tna-brand); cursor: pointer; font-size: 18px; box-sizing: border-box;
}
.tna-attach:hover { border-color: #bcd7d3; background: #eef8f6; }
.tna-attach.tna-disabled { opacity: .55; pointer-events: none; }
.tna-source-official_doc .tna-source-badge { background: #e5f5ff; color: #176081; }
.tna-source-official_doc { border-color: #cce7f4; }

@media (max-width: 600px) {
  .tna-form { grid-template-columns: auto 1fr; }
  .tna-send { grid-column: 1 / -1; min-height: 42px; }
  .tna-file-name { max-width: 235px; }
}

/* v1.9.1 adaptive requirement table + consultant handoff */
.tna-table-wrap {
  width: 100%; max-width: 100%; overflow-x: auto; margin: 8px 0 10px;
  border: 1px solid var(--tna-border); border-radius: 10px; background: #fff;
}
.tna-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 12px; line-height: 1.45; }
.tna-table th, .tna-table td { text-align: left; vertical-align: top; padding: 8px 9px; border-bottom: 1px solid #e8efee; border-right: 1px solid #eef3f2; }
.tna-table th:last-child, .tna-table td:last-child { border-right: 0; }
.tna-table tr:last-child td { border-bottom: 0; }
.tna-table th { font-weight: 800; background: var(--tna-soft); color: var(--tna-text); white-space: nowrap; }
.tna-consult {
  margin-top: 8px; padding: 12px; max-width: 94%; box-sizing: border-box;
  background: #fffaf0; border: 1px solid #ead8b6; border-radius: 12px;
}
.tna-consult-text { color: var(--tna-text); font-size: 12px; line-height: 1.5; margin-bottom: 9px; }
.tna-consult-button {
  display: inline-block; padding: 9px 12px; border-radius: 9px; background: var(--tna-brand);
  color: #fff !important; text-decoration: none; font-size: 12px; font-weight: 800;
}
.tna-consult-button:hover { background: var(--tna-brand-dark); color: #fff !important; }

@media (max-width: 600px) {
  .tna-table { min-width: 580px; }
  .tna-consult { max-width: 100%; }
}

/* v1.9.3 mobile-friendly requirement cards + PDF report */
.tna-requirement-cards {
  display: flex; flex-direction: column; gap: 9px; margin: 8px 0 10px; width: 100%;
}
.tna-requirement-card {
  position: relative; border: 1px solid var(--tna-border); border-radius: 11px; background: #fff;
  padding: 10px 11px 10px 42px; break-inside: avoid; page-break-inside: avoid;
}
.tna-requirement-no {
  position: absolute; left: 10px; top: 10px; width: 23px; height: 23px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--tna-soft);
  color: var(--tna-brand-dark); font-size: 11px; font-weight: 800;
}
.tna-requirement-field { margin-bottom: 7px; }
.tna-requirement-field:last-child { margin-bottom: 0; }
.tna-requirement-label {
  color: var(--tna-muted); font-size: 10px; line-height: 1.3; font-weight: 800;
  text-transform: none; margin-bottom: 2px;
}
.tna-requirement-value { color: var(--tna-text); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }

.tna-report-actions { margin: 8px 0 0; max-width: 94%; }
.tna-pdf-button {
  border: 1px solid var(--tna-brand); background: #fff; color: var(--tna-brand); border-radius: 9px;
  padding: 8px 12px; cursor: pointer; font-size: 12px; font-weight: 800;
}
.tna-pdf-button:hover { background: var(--tna-soft); }
.tna-pdf-button:disabled { opacity: .6; cursor: wait; }

/* Off-screen A4 report source used by html2pdf. */
.tna-pdf-stage { position: absolute; left: 0; top: 0; width: 720px; z-index: -1; pointer-events: none; background: #fff; }
.tna-pdf-report {
  width: 720px; box-sizing: border-box; padding: 22px; background: #fff; color: #17324d;
  font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5;
}
.tna-pdf-header { border-bottom: 2px solid #0f5c5e; padding-bottom: 10px; margin-bottom: 10px; }
.tna-pdf-brand { color: #0f5c5e; font-size: 13px; font-weight: 800; margin-bottom: 3px; }
.tna-pdf-header h1 { margin: 0; color: #17324d; font-size: 23px; line-height: 1.25; }
.tna-pdf-meta { display: grid; gap: 3px; margin: 10px 0 18px; color: #536777; font-size: 11px; }
.tna-pdf-content .tna-msg-body { max-width: none; border: 0; padding: 0; font-size: 13px; }
.tna-pdf-content .tna-requirement-card { padding: 10px 11px 10px 42px; margin-bottom: 8px; }
.tna-pdf-content .tna-requirement-label { font-size: 10px; }
.tna-pdf-content .tna-requirement-value { font-size: 12px; }
.tna-pdf-content .tna-sources { max-width: none; margin-top: 16px; }
.tna-pdf-content .tna-source-list { display: block; }
.tna-pdf-content .tna-source-link { display: block; margin: 5px 0; border: 0; padding: 0; background: transparent; }
.tna-pdf-footer { margin-top: 22px; padding-top: 9px; border-top: 1px solid #dce8e6; color: #6f7f8f; font-size: 9px; }

@media (max-width: 600px) {
  .tna-msg-body { max-width: 100%; }
  .tna-requirement-card { padding-left: 39px; }
  .tna-report-actions { max-width: 100%; }
}

/* v1.9.3.2 compact material-session indicator */
.tna-session-chip {
  border-color: #b9d9d3;
  background: #eef8f6;
  color: #0f5c5e;
  font-weight: 700;
}

/* v0.1.9.3.6: predictable report dimensions and page flow */
.tna-pdf-stage .tna-pdf-report { width: 700px; max-width: 700px; margin: 0; }
.tna-pdf-report .tna-msg-body,
.tna-pdf-report .tna-requirement-table { overflow: visible !important; max-height: none !important; height: auto !important; }
.tna-pdf-report .tna-requirement-card { break-inside: avoid; page-break-inside: avoid; }
.tna-pdf-report .tna-pdf-header { break-after: avoid; page-break-after: avoid; }

/* 0.1.9.3.8: render the report in the page painting layer for capture. */
.tna-pdf-stage { position: fixed; left: 0; top: 0; width: 700px; height: auto; max-height: none; overflow: visible; z-index: 2147483646; background: white; pointer-events: none; }
.tna-pdf-stage .tna-pdf-report { box-shadow: none; }
.tna-pdf-report .tna-requirement-card, .tna-pdf-report .tna-requirement-field { break-inside: avoid; page-break-inside: avoid; }

/* Additional footer text in the PDF report. In native print mode it repeats on each page. */

/* v0.1.9.3.13: the canvas source must have a real painted layout. */
.tna-pdf-stage { position:fixed; left:0; top:0; z-index:2147483640; width:760px; max-height:100vh; overflow:auto; background:#fff; pointer-events:none; }
.tna-checklist-table {table-layout:fixed;width:100%;border-collapse:collapse;font-size:11px;}
.tna-checklist-table th,.tna-checklist-table td{border:1px solid #cad6db;padding:6px;overflow-wrap:anywhere;vertical-align:top;}
.tna-checklist-table th:nth-child(1),.tna-checklist-table td:nth-child(1){width:6%;text-align:center;}
.tna-checklist-table th:nth-child(2),.tna-checklist-table td:nth-child(2){width:14%;}
.tna-checklist-table th:nth-child(4),.tna-checklist-table td:nth-child(4){width:11%;}
.tna-checklist-table th:nth-child(5),.tna-checklist-table td:nth-child(5){width:8%;text-align:center;}
