:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #dce3ec;
  --soft: #f3f6fa;
  --surface: #ffffff;
  --page: #edf2f7;
  --nav: #07111f;
  --nav-soft: #101e30;
  --blue: #0758bb;
  --blue-dark: #073f89;
  --blue-soft: #eaf3ff;
  --green: #087a5b;
  --green-soft: #e8f6f1;
  --amber: #9a5b05;
  --amber-soft: #fff5df;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 18px 50px rgba(13, 30, 53, 0.12);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--page); color: var(--ink); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.62; }
a { color: var(--blue); }
[hidden] { display: none !important; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.1fr) minmax(440px, 0.9fr); background: var(--surface); }
.auth-visual { position: relative; min-height: 100vh; overflow: hidden; background: #030711; }
.auth-visual > img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
.auth-visual::after { content: ""; position: absolute; inset: 55% 0 0; background: linear-gradient(transparent, rgba(2, 7, 17, 0.95)); }
.auth-visual-copy { position: absolute; z-index: 1; left: 44px; right: 44px; bottom: 38px; display: flex; align-items: center; gap: 16px; color: #fff; }
.auth-visual-copy .auth-logo { width: 64px; height: 64px; object-fit: cover; border: 1px solid rgba(255,255,255,.28); border-radius: 8px; }
.auth-visual-copy strong { display: block; font-size: 22px; }
.auth-visual-copy span { display: block; margin-top: 5px; color: #cbd9ed; font-size: 14px; }
.auth-panel { display: grid; place-items: center; min-height: 100vh; padding: 46px max(28px, 8vw); }
.auth-container { width: min(430px, 100%); }
.auth-brand-mobile { display: none; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin-bottom: 34px; }
.auth-tab { border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); padding: 13px 8px; font-weight: 700; }
.auth-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.auth-heading { margin-bottom: 26px; }
.auth-heading h1 { margin: 0; font-size: 30px; line-height: 1.15; }
.auth-heading p { margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.auth-view form, .tool-form { display: grid; gap: 17px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #364152; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; min-height: 46px; padding: 10px 12px; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7, 88, 187, 0.13); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 72px; }
.password-toggle { position: absolute; right: 8px; top: 8px; }
.icon-text-button, .link-button, .back-button, .text-button { border: 0; background: transparent; color: var(--blue); font-weight: 700; padding: 7px 6px; }
.link-button { justify-self: center; }
.back-button { padding-left: 0; margin-bottom: 22px; }
.field-note { margin: -10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.check-row { grid-template-columns: 20px 1fr; align-items: start; font-weight: 500; line-height: 1.5; }
.check-row input { width: 18px; min-height: 18px; margin: 2px 0 0; }
.primary-button, .secondary-button, .logout-button { min-height: 46px; border-radius: 6px; padding: 10px 17px; font-weight: 800; border: 1px solid transparent; }
.primary-button { background: var(--blue); color: #fff; }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { background: #fff; color: var(--blue-dark); border-color: #b9c8db; }
.compact { min-height: 38px; padding: 8px 13px; width: auto; }
.turnstile-slot { min-height: 1px; overflow: hidden; }
.code-input { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: 8px; }

.portal-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); background: var(--page); }
.portal-sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; }
.portal-brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 23px; color: #fff; text-decoration: none; font-weight: 800; }
.portal-brand img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; }
.portal-sidebar nav { display: grid; gap: 5px; }
.nav-button { width: 100%; min-height: 46px; border: 0; border-radius: 6px; background: transparent; color: #b8c5d7; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 9px; padding: 8px 10px; text-align: left; font-size: 14px; font-weight: 700; }
.nav-button:hover, .nav-button.active { background: var(--nav-soft); color: #fff; }
.nav-button.active { box-shadow: inset 3px 0 0 #2a8cff; }
.nav-mark { width: 25px; height: 25px; border: 1px solid #38506d; border-radius: 6px; display: grid; place-items: center; font-size: 11px; color: #9fc8ff; }
.theo-mark { color: #fff; background: var(--blue); border-color: var(--blue); }
.nav-badge { min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; background: #2a8cff; color: #fff; font-size: 11px; padding: 0 5px; }
.sidebar-security { margin-top: auto; border-top: 1px solid #203147; padding: 18px 8px 14px; }
.sidebar-security strong, .sidebar-security span { display: block; }
.sidebar-security strong { color: #a7e4cf; font-size: 12px; }
.sidebar-security span { color: #8495aa; font-size: 11px; line-height: 1.45; margin-top: 4px; }
.logout-button { background: transparent; color: #b8c5d7; border-color: #2a3d55; }
.portal-main { min-width: 0; }
.portal-header { height: 78px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px clamp(22px, 4vw, 54px); position: sticky; top: 0; z-index: 10; }
.header-kicker { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 800; }
.portal-header h1 { margin: 3px 0 0; font-size: 21px; }
.profile-shortcut { border: 0; background: transparent; display: flex; align-items: center; gap: 10px; text-align: left; color: var(--ink); padding: 5px; }
.profile-shortcut strong, .profile-shortcut small { display: block; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-shortcut small { color: var(--muted); margin-top: 2px; }
.profile-avatar, .large-avatar { background: #e6eef9; color: var(--blue-dark); border: 1px solid #c5d5e9; display: grid; place-items: center; font-weight: 900; overflow: hidden; background-size: cover; background-position: center; }
.profile-avatar { width: 40px; height: 40px; border-radius: 50%; }
.large-avatar { width: 96px; height: 96px; border-radius: 50%; font-size: 22px; flex: 0 0 auto; }
.portal-content { padding: 30px clamp(22px, 4vw, 54px) 64px; max-width: 1480px; margin: 0 auto; }
.portal-view { min-width: 0; }
.welcome-band { min-height: 150px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: #0b284a; color: #fff; padding: 29px 32px; border-radius: 8px; border-left: 5px solid #2a8cff; }
.welcome-band span { color: #bcd3ed; }
.welcome-band h2 { margin: 10px 0 0; font-size: 24px; max-width: 610px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin: 18px 0 28px; }
.metric-grid article { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 19px; }
.metric-grid span, .metric-grid small, .metric-grid strong { display: block; }
.metric-grid span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-grid strong { font-size: 25px; margin: 8px 0 4px; }
.metric-grid small { color: var(--muted); }
.section-block { margin-top: 28px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.page-section-heading { margin-bottom: 22px; }
.action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.action-grid button, .product-option { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 19px; text-align: left; color: var(--ink); }
.action-grid button:hover, .product-option:hover { border-color: #8bb8eb; }
.action-grid strong, .action-grid span, .product-option strong, .product-option span { display: block; }
.action-grid span, .product-option span { color: var(--muted); font-size: 12px; margin-top: 7px; line-height: 1.45; }
.product-selector { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.product-option.active { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.tool-form { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form-section-title { padding-top: 4px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.form-section-title:not(:first-child) { margin-top: 8px; }
.simulation-result { margin-top: 16px; background: var(--green-soft); border: 1px solid #a8d9c8; border-radius: 8px; padding: 20px; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.result-grid div { background: #fff; border: 1px solid #c8e4da; padding: 13px; border-radius: 6px; }
.result-grid span, .result-grid strong { display: block; }
.result-grid span { font-size: 11px; color: var(--muted); }
.result-grid strong { margin-top: 5px; }
.proposal-list, .timeline-list { display: grid; gap: 10px; }
.proposal-item, .timeline-item { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 17px; }
.proposal-item { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(140px, .7fr) auto; align-items: center; gap: 16px; }
.proposal-item h3 { margin: 0 0 5px; font-size: 15px; }
.proposal-item p { margin: 0; color: var(--muted); font-size: 12px; }
.proposal-values strong, .proposal-values span { display: block; }
.proposal-values span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.status-pill { display: inline-flex; width: max-content; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 13px; background: var(--blue-soft); color: var(--blue-dark); font-size: 11px; font-weight: 800; }
.status-pill.paid { background: var(--green-soft); color: var(--green); }
.status-pill.pending { background: var(--amber-soft); color: var(--amber); }
.proposal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.proposal-actions a, .proposal-actions button { border: 1px solid #b9c8db; border-radius: 6px; background: #fff; color: var(--blue-dark); padding: 8px 10px; font-size: 12px; font-weight: 800; text-decoration: none; }
.empty-state { background: #fff; border: 1px dashed #bdc9d8; border-radius: 8px; padding: 32px 18px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 6px; }
.timeline-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.timeline-item div strong, .timeline-item div span { display: block; }
.timeline-item div span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.profile-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.profile-photo { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 21px; display: grid; justify-items: center; text-align: center; gap: 14px; }
.profile-photo strong, .profile-photo span { display: block; }
.profile-photo span { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 5px 0 12px; }

.chat-view { height: calc(100vh - 172px); min-height: 520px; }
.chat-shell { height: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; overflow: hidden; }
.chat-header { display: flex; align-items: center; gap: 11px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.chat-header img { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; }
.chat-header strong, .chat-header span { display: block; }
.chat-header span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.chat-header i { display: inline-block; width: 7px; height: 7px; background: #15a476; border-radius: 50%; }
.chat-header-action { margin-left: auto; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--blue-dark); font-size: 20px; cursor: pointer; }
.chat-messages { overflow-y: auto; padding: 20px; background: #eef2f6; display: flex; flex-direction: column; gap: 9px; }
.chat-message { max-width: min(76%, 680px); padding: 10px 12px; border-radius: 8px; background: #fff; border: 1px solid #d8e0ea; align-self: flex-start; line-height: 1.5; font-size: 14px; }
.chat-message.customer { align-self: flex-end; background: #dcecff; border-color: #b4d2f5; }
.chat-message.panel { border-left: 3px solid var(--green); }
.chat-message small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; text-align: right; }
.theo-welcome { width: min(520px, 100%); margin: auto; display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 16px; align-items: center; padding: 22px; background: #fff; border: 1px solid #d8e0ea; border-radius: 8px; }
.theo-welcome img { width: 68px; height: 68px; border-radius: 50%; object-fit: cover; }
.theo-welcome strong, .theo-welcome span { display: block; }
.theo-welcome span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.chat-media-image, .chat-media-video { display: block; width: min(360px, 100%); max-height: 360px; border-radius: 6px; object-fit: contain; background: #08111d; }
.chat-media-audio { display: block; width: min(320px, 100%); }
.chat-document { display: block; color: var(--blue-dark); font-weight: 800; overflow-wrap: anywhere; }
.chat-message-text { margin-top: 7px; overflow-wrap: anywhere; }
.chat-actions { padding: 8px 14px; border-top: 1px solid var(--line); display: flex; gap: 7px; flex-wrap: wrap; }
.chat-actions button, .chat-actions a { border: 1px solid #aabbd0; border-radius: 16px; background: #fff; color: var(--blue-dark); padding: 7px 11px; font-size: 12px; font-weight: 800; text-decoration: none; }
.emoji-panel { padding: 8px 12px; border-top: 1px solid var(--line); background: #fff; display: flex; gap: 4px; flex-wrap: wrap; }
.emoji-panel[hidden] { display: none; }
.emoji-panel button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eef3f8; font-size: 19px; cursor: pointer; }
.chat-composer { padding: 11px 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 40px 40px minmax(0, 1fr) 40px auto; gap: 7px; align-items: stretch; }
.chat-composer textarea { min-height: 44px; max-height: 120px; resize: none; }
.composer-icon-button { width: 40px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--blue-dark); font-size: 19px; cursor: pointer; padding: 0; }
.composer-icon-button.recording { color: #fff; background: var(--red); border-color: var(--red); }
.chat-composer .chat-send-button { border: 0; border-radius: 6px; background: var(--blue); color: #fff; padding: 0 19px; font-weight: 800; }
.mobile-nav { display: none; }

.loading-overlay { position: fixed; z-index: 100; inset: 0; background: rgba(5, 16, 31, .52); display: grid; place-content: center; justify-items: center; color: #fff; }
.loading-overlay span { width: 36px; height: 36px; border: 4px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.loading-overlay p { font-weight: 700; }
.toast-region { position: fixed; z-index: 120; top: 18px; right: 18px; display: grid; gap: 8px; width: min(380px, calc(100% - 36px)); }
.toast { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 6px; padding: 13px 14px; box-shadow: var(--shadow); font-size: 13px; line-height: 1.5; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: minmax(320px, .85fr) minmax(420px, 1.15fr); }
  .auth-panel { padding: 38px; }
  .portal-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .portal-brand span, .nav-button > span:not(.nav-mark):not(.nav-badge), .sidebar-security, .logout-button { display: none; }
  .portal-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .nav-button { grid-template-columns: 1fr; justify-items: center; padding: 8px; }
  .nav-badge { position: absolute; margin: -23px 0 0 24px; }
  .profile-layout { grid-template-columns: 1fr; }
  .profile-photo { grid-template-columns: auto 1fr; justify-items: start; text-align: left; align-items: center; }
}

@media (max-width: 720px) {
  body { background: #fff; }
  .auth-shell { display: block; background: #fff; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; padding: 24px 20px 48px; display: block; }
  .auth-brand-mobile { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; font-weight: 800; }
  .auth-brand-mobile img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; }
  .auth-container { width: 100%; }
  .portal-shell { display: block; padding-bottom: 67px; background: var(--page); }
  .portal-sidebar { display: none; }
  .portal-header { height: 68px; padding: 10px 16px; }
  .portal-header .header-kicker, .profile-shortcut > span:last-child { display: none; }
  .portal-header h1 { margin: 0; font-size: 19px; }
  .portal-content { padding: 18px 14px 36px; }
  .welcome-band { min-height: 0; display: grid; padding: 22px; }
  .welcome-band h2 { font-size: 20px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article:last-child { grid-column: span 2; }
  .action-grid, .product-selector { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .proposal-item { grid-template-columns: 1fr; gap: 11px; }
  .proposal-actions { justify-content: flex-start; }
  .result-grid { grid-template-columns: 1fr; }
  .profile-photo { grid-template-columns: 74px 1fr; }
  .large-avatar { width: 72px; height: 72px; }
  .tool-form { padding: 18px; }
  .chat-view { height: calc(100vh - 120px); min-height: 460px; }
  .chat-shell { border-radius: 0; margin: -18px -14px -36px; border-left: 0; border-right: 0; }
  .chat-message { max-width: 86%; }
  .chat-composer { grid-template-columns: 38px 38px minmax(0, 1fr) 38px 52px; gap: 5px; padding: 8px; }
  .composer-icon-button { width: 38px; height: 42px; }
  .chat-composer .chat-send-button { padding: 0 8px; font-size: 0; }
  .chat-composer .chat-send-button::after { content: ">"; font-size: 18px; }
  .theo-welcome { grid-template-columns: 54px minmax(0, 1fr); padding: 16px; }
  .theo-welcome img { width: 54px; height: 54px; }
  .mobile-nav { position: fixed; z-index: 30; bottom: 0; left: 0; right: 0; height: 64px; padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); }
  .mobile-nav button { border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; }
  .mobile-nav button.active { color: var(--blue); border-top: 2px solid var(--blue); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; } }
