/* TaxPilot by Ionity — UI on the Ionity design tokens (Ionity-Global/ionity-css-and-theme, theme/variables.css).
   © 2018–2026 Antwerp Designs | Ionity (Pty) Ltd — All Rights Reserved — TM · Policy 986 AED. */
:root {
  --ionity-purple: #5746e3; --ionity-purple-light: #7b6ef0; --ionity-purple-dark: #3d30c4;
  --ionity-teal: #00d4b8; --ionity-teal-dark: #00a892; --ionity-cyan: #00d2ff; --ionity-blue: #1a58a6;
  --ionity-bg: #0b0d12; --ionity-surface-1: #151922; --ionity-surface-2: #1a2030; --ionity-surface-3: #0e1117;
  --ionity-border: #232936; --ionity-border-light: #2e3848;
  --ionity-text: #e7ebf2; --ionity-text-muted: #8b93a4; --ionity-text-dim: #5a6275;
  --ok: #3fbf7f; --ok-bg: rgba(31, 111, 74, .22); --warn: #e0a83a; --warn-bg: rgba(138, 90, 0, .22); --danger: #ffb4b4; --danger-bg: #2a1416;
  --grad: linear-gradient(135deg, var(--ionity-purple), var(--ionity-teal));
  --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'Roboto Mono', 'Cascadia Code', Consolas, monospace;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ionity-bg); color: var(--ionity-text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--ionity-teal); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--ionity-surface-3); border: 1px solid var(--ionity-border); border-radius: var(--r-sm); padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ionity-purple-light); outline-offset: 0; border-color: transparent; }
:focus-visible { outline: 2px solid var(--ionity-teal); outline-offset: 2px; }

.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--r-sm); padding: 8px 14px; cursor: pointer; font-weight: 500; transition: background .15s, border-color .15s, opacity .15s; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-primary { background: var(--ionity-purple); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ionity-purple-light); }
.btn-secondary { background: transparent; border-color: var(--ionity-teal-dark); color: var(--ionity-teal); }
.btn-secondary:hover { background: rgba(0, 212, 184, .08); }
.btn-ghost { background: transparent; border-color: var(--ionity-border-light); color: var(--ionity-text); }
.btn-ghost:hover { background: var(--ionity-surface-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 1px solid var(--ionity-border); border-radius: var(--r-sm); width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--grad); color: #fff; font-weight: 700; letter-spacing: .3px; }
.fine { color: var(--ionity-text-dim); font-size: 11px; }
.hint { color: var(--ionity-text-muted); font-size: 12.5px; margin: 0 0 10px; }

/* Gate */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 70% -10%, rgba(87, 70, 227, .25), transparent), radial-gradient(900px 500px at -10% 110%, rgba(0, 212, 184, .14), transparent), var(--ionity-bg); }
.gate-card { display: grid; grid-template-columns: 300px minmax(0, 460px); background: var(--ionity-surface-1); border: 1px solid var(--ionity-border); border-radius: 20px; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }
.gate-hero { width: 100%; height: 100%; object-fit: cover; display: block; }
.gate-body { padding: 32px 30px; display: flex; flex-direction: column; gap: 14px; }
.gate h1 { margin: 6px 0 0; font-size: 30px; line-height: 1.15; }
.gate .by { font-weight: 400; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--ionity-text-muted); margin: 0; }
.gate-msg { min-height: 1.4em; margin: 0; color: var(--warn); }
.gate-points { margin: 0; padding-left: 18px; color: var(--ionity-text-muted); font-size: 13px; }
.wordmark { display: block; width: auto; flex: none; }
.gate-body .wordmark { align-self: flex-start; height: 30px; }
.topbar .wordmark { height: 22px; }
@media (max-width: 760px) {
  .gate-card { grid-template-columns: 1fr; }
  .gate-hero { height: 220px; object-position: center 35%; }
  .gate-body { padding: 22px 18px; }
}

/* App shell */
.app { height: 100dvh; display: grid; grid-template-columns: 260px minmax(0, 1fr) 380px; grid-template-rows: 54px minmax(0, 1fr); grid-template-areas: 'top top top' 'cases chat panel'; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--ionity-border); background: rgba(21, 25, 34, .92); backdrop-filter: blur(8px); }
.product { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 8px; }
.user-photo { border-radius: 50%; background: var(--ionity-surface-2); }
.user-name { color: var(--ionity-text-muted); font-size: 13px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.only-mobile { display: none; }

.cases { grid-area: cases; border-right: 1px solid var(--ionity-border); padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; overflow: auto; background: var(--ionity-surface-3); }
.cases-head { display: flex; align-items: center; justify-content: space-between; }
.cases h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--ionity-text-muted); }
.case-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.case-list button { width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 8px 10px; cursor: pointer; display: grid; gap: 2px; }
.case-list button:hover { background: var(--ionity-surface-2); }
.case-list button.active { background: var(--ionity-surface-2); border-color: var(--ionity-purple); }
.case-list .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-list .s { color: var(--ionity-text-dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-fine { margin: 0; }

/* Chat */
.chat { grid-area: chat; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.case-bar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--ionity-border); }
.case-title { flex: 1; background: transparent; border-color: transparent; font-weight: 700; font-size: 15px; }
.case-title:hover { border-color: var(--ionity-border); }
.case-status { width: auto; }
.messages { flex: 1; overflow: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.empty { position: absolute; inset: 120px 24px auto; text-align: center; color: var(--ionity-text-muted); max-width: 560px; margin: 0 auto; pointer-events: none; }
.empty img { border-radius: 50%; border: 2px solid var(--ionity-purple); }
.empty h2 { color: var(--ionity-text); margin: 10px 0 6px; }
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; max-width: 900px; width: 100%; margin: 0 auto; }
.msg .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--ionity-surface-2); overflow: hidden; }
.msg .av img { width: 100%; height: 100%; object-fit: cover; }
.msg .bubble { background: var(--ionity-surface-1); border: 1px solid var(--ionity-border); border-radius: var(--r-lg); padding: 10px 14px; overflow-wrap: anywhere; }
.msg.user .bubble { background: rgba(87, 70, 227, .14); border-color: rgba(123, 110, 240, .35); }
.msg.error .bubble { background: var(--danger-bg); border-color: #5a2126; color: var(--danger); }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3 { margin: 10px 0 6px; font-size: 15px; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; max-width: 100%; }
.bubble th, .bubble td { border: 1px solid var(--ionity-border-light); padding: 4px 8px; text-align: left; white-space: nowrap; }
.bubble th { background: var(--ionity-surface-2); }
.bubble td.num { text-align: right; font-family: var(--mono); }
.bubble code { font-family: var(--mono); background: var(--ionity-surface-3); padding: 1px 4px; border-radius: 4px; font-size: 12.5px; }
.bubble pre { position: relative; padding-top: 30px !important; background: var(--ionity-surface-3); border: 1px solid var(--ionity-border); border-radius: var(--r-sm); padding: 10px 12px; overflow: auto; white-space: pre-wrap; }
.bubble pre code { background: none; padding: 0; }
.copy { position: absolute; top: 6px; right: 6px; font-size: 11px; padding: 2px 8px; }
.trace { margin-top: 8px; font-size: 12px; color: var(--ionity-text-muted); }
.trace summary { cursor: pointer; }
.trace ol { margin: 6px 0 0; padding-left: 18px; }
.trace .bad { color: var(--warn); }
.out-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--ionity-teal-dark); color: var(--ionity-teal); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; background: none; cursor: pointer; text-decoration: none; }
.working { color: var(--ionity-text-muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.working .live::after { content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--ionity-teal); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.quick { display: flex; gap: 6px; padding: 6px 16px; overflow-x: auto; scrollbar-width: thin; }
.quick button { flex: none; background: var(--ionity-surface-1); border: 1px solid var(--ionity-border-light); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--ionity-text-muted); }
.quick button:hover { color: var(--ionity-text); border-color: var(--ionity-purple-light); }
.composer { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--ionity-border); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 200px; line-height: 1.45; }
.attach { cursor: pointer; }

/* Panel */
.panel { grid-area: panel; border-left: 1px solid var(--ionity-border); display: flex; flex-direction: column; min-height: 0; background: var(--ionity-surface-3); }
.tabs { display: flex; border-bottom: 1px solid var(--ionity-border); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 11px 12px; cursor: pointer; color: var(--ionity-text-muted); font-weight: 500; white-space: nowrap; }
.tab.active { color: var(--ionity-text); border-bottom-color: var(--ionity-teal); }
.tabpane { display: none; padding: 14px; overflow: auto; flex: 1; }
.tabpane.active { display: block; }
.drop { display: grid; gap: 4px; place-items: center; text-align: center; border: 1.5px dashed var(--ionity-border-light); border-radius: var(--r-md); padding: 22px 12px; cursor: pointer; color: var(--ionity-text-muted); margin-bottom: 12px; transition: border-color .15s, background .15s; }
.drop strong { color: var(--ionity-text); }
.drop.over { border-color: var(--ionity-teal); background: rgba(0, 212, 184, .06); }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li { background: var(--ionity-surface-1); border: 1px solid var(--ionity-border); border-radius: var(--r-md); padding: 9px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; }
.file-list .n { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .m { grid-column: 1 / -1; color: var(--ionity-text-dim); font-size: 12px; }
.badge { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(0, 212, 184, .14); color: var(--ionity-teal); letter-spacing: .3px; }
.badge.vision { background: rgba(123, 110, 240, .18); color: var(--ionity-purple-light); }
.badge.wait { background: var(--warn-bg); color: var(--warn); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
.row label { display: grid; gap: 3px; font-size: 12px; color: var(--ionity-text-muted); }
.row input, .row select { width: 110px; }
.row select#calc-year { width: 170px; }
table.codes { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.codes th { text-align: left; font-size: 12px; color: var(--ionity-text-muted); font-weight: 500; padding: 2px 4px; }
table.codes td { padding: 2px 4px; }
table.codes input { width: 100%; }
.calc-out table, #dl-out table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.calc-out td, #dl-out td, #dl-out th { border-bottom: 1px solid var(--ionity-border); padding: 4px 4px; }
.calc-out td:last-child { text-align: right; font-family: var(--mono); white-space: nowrap; }
.verdict { margin-top: 10px; padding: 10px 12px; border-radius: var(--r-md); font-weight: 700; }
.verdict.pay { background: var(--warn-bg); color: var(--warn); }
.verdict.refund { background: var(--ok-bg); color: var(--ok); }
.verdict.nil { background: var(--ionity-surface-2); }
.guide-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.guide h3 { margin: 6px 0; font-size: 15px; }
.guide ol { padding-left: 18px; }
.guide li { margin-bottom: 6px; }
.guide .pit { background: var(--warn-bg); border-radius: var(--r-sm); padding: 8px 10px; color: #f3d9a4; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ionity-surface-2); border: 1px solid var(--ionity-border-light); padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--shadow); z-index: 9999; max-width: calc(100vw - 32px); }

@media (max-width: 1180px) { .app { grid-template-columns: 220px minmax(0, 1fr) 330px; } }
@media (max-width: 920px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'top' 'chat'; }
  .only-mobile { display: inline-flex; }
  .user-name, .pill { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  #btn-signout { white-space: nowrap; }
  .product { font-size: 15px; }
  .cases, .panel { position: fixed; top: 54px; bottom: 0; z-index: 50; width: min(88vw, 360px); box-shadow: var(--shadow); transition: transform .2s; }
  .cases { left: 0; transform: translateX(-105%); }
  .panel { right: 0; transform: translateX(105%); }
  .cases.open, .panel.open { transform: none; }
  .msg { grid-template-columns: 28px minmax(0, 1fr); }
  .msg .av { width: 28px; height: 28px; }
  .empty { inset: 100px 16px auto; }
}
.guide-list button { white-space: normal; text-align: left; max-width: 100%; }
