:root {
  --brand: #2857d9;
  --brand-dark: #163fac;
  --brand-soft: #edf2ff;
  --ink: #172036;
  --muted: #6c7487;
  --line: #e5e9f2;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --success: #20a56a;
  --danger: #cf3f4e;
  --shadow: 0 18px 55px rgba(25, 42, 89, .11);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }
body { font-family: "Segoe UI", Inter, Arial, sans-serif; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.toast { position: fixed; z-index: 1000; left: 50%; bottom: 26px; transform: translate(-50%, 25px); background: #172036; color: #fff; padding: 13px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s ease; box-shadow: var(--shadow); max-width: min(90vw, 520px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a92f3d; }

.auth-screen { min-height: 100vh; padding: 28px; display: grid; place-items: center; background: radial-gradient(circle at 8% 12%, #dfe8ff 0, transparent 34%), linear-gradient(145deg, #f8faff 0%, #edf2fb 100%); }
.auth-shell { width: min(1120px, 100%); min-height: 680px; display: grid; grid-template-columns: 1.08fr .92fr; border-radius: 30px; overflow: hidden; background: var(--surface); box-shadow: 0 28px 90px rgba(20, 45, 112, .17); }
.auth-brand { position: relative; padding: 48px 56px; color: #fff; background: linear-gradient(145deg, #122b76 0%, #2456d8 58%, #3974ed 100%); display: flex; flex-direction: column; overflow: hidden; }
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.12); }
.auth-brand::before { width: 520px; height: 520px; right: -310px; top: 50px; }
.auth-brand::after { width: 360px; height: 360px; left: -220px; bottom: -190px; }
.brand { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #3767eb, #1b43bd); font-weight: 800; font-size: 24px; box-shadow: 0 10px 24px rgba(6, 25, 80, .22); }
.brand-mark img { width: 92%; height: 92%; object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; letter-spacing: -.3px; }
.brand small { margin-top: 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; opacity: .64; }
.brand-light .brand-mark { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2); backdrop-filter: blur(8px); }
.brand-copy { position: relative; z-index: 1; margin: auto 0; max-width: 510px; }
.eyebrow, .section-kicker, .step { text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: 1.8px; }
.eyebrow { color: #b9cdff; }
.brand-copy h1 { margin: 18px 0; font-size: clamp(40px, 5vw, 62px); line-height: 1.02; letter-spacing: -2.5px; }
.brand-copy p { margin: 0; max-width: 470px; font-size: 17px; line-height: 1.7; color: rgba(255,255,255,.76); }
.secure-note, .prompt-preview { position: relative; z-index: 1; display: flex; gap: 13px; align-items: center; padding: 16px 18px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.08); border-radius: 16px; backdrop-filter: blur(8px); }
.secure-note strong, .secure-note small { display: block; }
.secure-note small { color: rgba(255,255,255,.65); margin-top: 3px; line-height: 1.4; }
.secure-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(54, 221, 149, .18); color: #69efb0; font-weight: 800; }
.prompt-preview { max-width: 420px; }
.prompt-preview p { margin: 0; color: rgba(255,255,255,.88); font-weight: 600; }
.mini-avatar { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; background: #fff; color: var(--brand); font-size: 12px; font-weight: 900; }

.auth-card { padding: 58px 60px; display: flex; flex-direction: column; justify-content: center; }
.auth-card-head { margin-bottom: 34px; }
.step { color: var(--brand); }
.auth-card-head h2 { margin: 10px 0 7px; font-size: 34px; letter-spacing: -1.3px; }
.auth-card-head p { margin: 0; color: var(--muted); }
.form-stack { display: grid; gap: 20px; }
.field-grid { display: grid; gap: 12px; }
.api-grid { grid-template-columns: 112px 1fr 98px; }
.field > span { display: block; margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #394159; }
.field small { display: block; color: #9096a7; margin-top: 7px; line-height: 1.35; }
.field input, .field select, .field textarea { width: 100%; min-height: 49px; border: 1px solid #dfe3ed; border-radius: 12px; background: #fbfcff; color: var(--ink); outline: none; padding: 0 14px; transition: .18s ease; }
.field input:focus, .field select:focus, .chat-composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(40, 87, 217, .1); background: #fff; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.icon-button { position: absolute; right: 7px; top: 7px; width: 36px; height: 36px; border: 0; background: transparent; color: #778097; cursor: pointer; border-radius: 9px; }
.icon-button:hover { background: var(--brand-soft); color: var(--brand); }
.connection-preview { display: flex; gap: 12px; align-items: center; padding: 13px 15px; border-radius: 12px; background: #f6f8fc; border: 1px solid #edf0f6; }
.connection-preview small, .connection-preview strong { display: block; }
.connection-preview small { color: var(--muted); margin-bottom: 2px; }
.connection-preview strong { font-size: 13px; overflow-wrap: anywhere; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(32,165,106,.11); }
.primary-button, .secondary-button, .danger-button { min-height: 49px; padding: 0 18px; border-radius: 12px; cursor: pointer; font-weight: 750; transition: .18s ease; }
.primary-button { border: 0; color: #fff; background: linear-gradient(135deg, var(--brand), #1741b9); display: flex; justify-content: space-between; align-items: center; box-shadow: 0 12px 24px rgba(40,87,217,.22); text-decoration: none; }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 15px 30px rgba(40,87,217,.28); }
.primary-button:disabled { opacity: .6; cursor: wait; transform: none; }
.setup-help { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; }
.secondary-button { border: 1px solid #dce1ec; background: #fff; color: #475069; }
.secondary-button:hover { border-color: #b9c6eb; color: var(--brand); background: #f9faff; }
.secondary-button.compact { min-height: 38px; padding: 0 13px; font-size: 13px; }
.text-link { color: var(--brand); text-align: center; font-size: 13px; font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.danger-button { color: var(--danger); background: #fff; border: 1px solid #f0cfd3; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 100; width: 264px; padding: 24px 18px 18px; background: #121b31; color: #fff; display: flex; flex-direction: column; box-shadow: 8px 0 30px rgba(18,27,49,.08); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 28px; }
.sidebar-brand .brand-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; }
.sidebar-brand .brand-mark img { width: 98%; height: 98%; }
.sidebar-brand small { color: #8995b2; opacity: 1; }
.mobile-close { display: none; border: 0; background: transparent; color: #fff; font-size: 28px; }
.side-nav { display: flex; flex-direction: column; gap: 5px; }
.nav-label { padding: 0 13px 8px; color: #6f7b98; text-transform: uppercase; letter-spacing: 1.4px; font-size: 10px; font-weight: 800; }
.nav-label-spaced { margin-top: 22px; }
.nav-item { width: 100%; min-height: 46px; padding: 0 13px; display: flex; gap: 12px; align-items: center; border: 0; border-radius: 11px; background: transparent; color: #aeb8d0; cursor: pointer; text-decoration: none; text-align: left; font-weight: 650; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, #2c5ce1, #214ab9); color: #fff; box-shadow: 0 9px 20px rgba(22,58,157,.32); }
.nav-icon { width: 22px; text-align: center; font-size: 18px; }
.nav-icon.sparkle { color: #9eb7ff; }
.nav-item em { margin-left: auto; padding: 3px 7px; border-radius: 20px; background: #335ed0; color: #dfe7ff; font-size: 9px; font-style: normal; text-transform: uppercase; letter-spacing: .6px; }
.sidebar-user { margin-top: auto; display: grid; grid-template-columns: 38px 1fr 32px; gap: 10px; align-items: center; padding: 15px 10px 2px; border-top: 1px solid rgba(255,255,255,.08); }
.user-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: #2b4ca5; color: #fff; font-weight: 800; }
.user-meta { min-width: 0; }
.user-meta strong, .user-meta small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-meta strong { font-size: 13px; }
.user-meta small { margin-top: 2px; color: #7785a5; font-size: 10px; }
.logout-button { width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent; color: #7d89a7; cursor: pointer; font-size: 19px; }
.logout-button:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-backdrop { display: none; }

.app-main { margin-left: 264px; min-height: 100vh; }
.topbar { height: 86px; padding: 0 34px; display: flex; align-items: center; gap: 18px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px); }
.topbar h1 { margin: 1px 0 0; font-size: 24px; letter-spacing: -.6px; }
.topbar-eyebrow { color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 800; letter-spacing: 1.3px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.api-pill { display: flex; gap: 8px; align-items: center; border: 1px solid #dceae4; background: #f5fbf8; color: #39735b; padding: 8px 12px; border-radius: 25px; font-size: 11px; }
.api-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(32,165,106,.1); }
.round-button, .menu-button { width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 11px; color: #616b82; cursor: pointer; }
.round-button:hover, .menu-button:hover { color: var(--brand); border-color: #bcc9eb; }
.menu-button { display: none; }

.view { display: none; padding: 34px; }
.active-view { display: block; }
.welcome-row { display: flex; justify-content: space-between; gap: 30px; align-items: center; margin-bottom: 28px; }
.welcome-actions { display: flex; align-items: center; gap: 10px; }
.dashboard-customize-button { white-space: nowrap; }
.section-kicker { color: var(--brand); }
.welcome-row h2, .content-heading h2 { margin: 7px 0 5px; font-size: 28px; letter-spacing: -1px; }
.welcome-row p, .content-heading p { color: var(--muted); margin: 0; }
.ask-button { min-width: 310px; padding: 13px 16px; border: 1px solid #dbe3fb; border-radius: 15px; background: #fff; color: var(--ink); display: grid; grid-template-columns: 36px 1fr 18px; gap: 11px; align-items: center; cursor: pointer; text-align: left; box-shadow: 0 7px 20px rgba(31,63,139,.06); }
.ask-button > span:first-child { width: 36px; height: 36px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 11px; }
.ask-button small, .ask-button strong { display: block; }
.ask-button small { color: var(--muted); margin-bottom: 2px; }
.ask-button:hover { border-color: #aebfed; transform: translateY(-1px); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 17px; }
.metric-card { min-height: 184px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 9px 30px rgba(27,45,96,.055); display: flex; flex-direction: column; }
.metric-card.metric-primary { color: #fff; border: 0; background: linear-gradient(145deg, #214cc9 0%, #3267e7 100%); box-shadow: 0 18px 35px rgba(40,87,217,.25); }
.metric-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: auto; }
.metric-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.17); font-weight: 900; }
.metric-icon.blue { background: #edf3ff; color: #3766dd; }
.metric-icon.violet { background: #f4efff; color: #835bd2; }
.metric-icon.green { background: #ebf8f2; color: #2d9c70; }
.metric-badge { padding: 4px 8px; background: rgba(255,255,255,.14); border-radius: 20px; font-size: 10px; }
.metric-label { margin-top: 17px; font-size: 12px; color: var(--muted); }
.metric-primary .metric-label, .metric-primary small { color: rgba(255,255,255,.7); }
.metric-card > strong { margin: 6px 0 4px; font-size: clamp(25px, 2.4vw, 34px); letter-spacing: -1.2px; }
.metric-card > small { color: #9299aa; }
.status-value { color: var(--success); }
.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 17px; margin-top: 17px; }
.dashboard-grid.dashboard-grid-single { grid-template-columns: 1fr; }
.dashboard-widget-tray { margin: -8px 0 18px; padding: 18px; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 2fr) auto; gap: 18px; align-items: center; border: 1px dashed #9eb4ef; border-radius: 16px; background: #f6f8ff; }
.dashboard-widget-tray h3 { margin: 4px 0; font-size: 18px; }
.dashboard-widget-tray p { margin: 0; color: var(--muted); font-size: 12px; }
.dashboard-hidden-widgets { display: flex; flex-wrap: wrap; gap: 8px; }
.dashboard-hidden-widgets button { border: 1px solid #ccd7f5; border-radius: 10px; padding: 9px 12px; background: #fff; color: var(--brand); font-weight: 700; cursor: pointer; }
.dashboard-hidden-widgets button:hover { background: var(--brand-soft); }
.dashboard-hidden-empty { color: var(--muted); font-size: 12px; }
.dashboard-customizing [data-dashboard-widget] { position: relative; outline: 2px dashed rgba(36,84,214,.35); outline-offset: -3px; cursor: pointer; transition: transform .15s ease, outline-color .15s ease; }
.dashboard-customizing [data-dashboard-widget]::after { content: "Clique para ocultar"; position: absolute; top: 10px; right: 10px; z-index: 3; padding: 5px 8px; border-radius: 20px; background: #b4233c; color: #fff; font-size: 10px; font-weight: 800; box-shadow: 0 5px 14px rgba(180,35,60,.25); }
.dashboard-customizing [data-dashboard-widget]:hover { transform: translateY(-2px); outline-color: #b4233c; }
.dashboard-widget-hidden { display: none !important; }
.dashboard-pinned-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; margin-top: 17px; }
.dashboard-pinned-card { min-height: 150px; padding: 20px; position: relative; overflow: hidden; }
.dashboard-pinned-card .pinned-source { color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.dashboard-pinned-card h3 { margin: 7px 0 10px; font-size: 18px; }
.dashboard-pinned-card p { margin: 0; color: #536078; white-space: pre-line; line-height: 1.55; }
.dashboard-pinned-card small { display: block; margin-top: 12px; color: var(--muted); }
.dashboard-pin-button { margin-left: auto; white-space: nowrap; }
.management-card { position: relative; }
.dashboard-card-pin-button { position: absolute; top: 11px; right: 11px; width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid #dbe4f6; border-radius: 10px; color: #2454d6; background: #fff; opacity: .7; transition: .2s ease; }
.dashboard-card-pin-button:hover { opacity: 1; border-color: #2454d6; box-shadow: 0 5px 14px rgba(36,84,214,.14); }
.hour-chart { min-height: 250px; display: block; padding: 8px 0 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.hour-line-legend { min-height: 30px; padding: 0 4px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #65718a; font-size: 11px; }
.hour-line-legend span { display: inline-flex; align-items: center; gap: 7px; }
.hour-line-legend i { width: 24px; height: 3px; display: inline-block; border-radius: 20px; background: #2f61de; }
.hour-line-legend strong { color: #e26724; font-size: 11px; }
.hour-line-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; }
.hour-line-svg { width: 100%; min-width: 780px; height: 220px; display: block; overflow: visible; }
.hour-line-grid { stroke: #e8edf7; stroke-width: 1; vector-effect: non-scaling-stroke; }
.hour-line-y-label, .hour-line-x-label { fill: #8993a8; font-family: inherit; font-size: 9px; }
.hour-line-area { fill: url(#peakHoursAreaGradient); }
.hour-line-path { fill: none; stroke: #2f61de; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 4px 5px rgba(47,97,222,.16)); }
.hour-line-point circle { fill: #fff; stroke: #2f61de; stroke-width: 3; vector-effect: non-scaling-stroke; cursor: help; }
.hour-line-point.peak circle { fill: #fb9b45; stroke: #e26724; filter: drop-shadow(0 4px 5px rgba(226,103,36,.25)); }
.hour-line-point text { fill: #d45f20; font-family: inherit; font-size: 10px; font-weight: 800; }
.hour-bar { min-width: 24px; flex: 1 0 24px; display: grid; grid-template-rows: 22px 1fr 18px; gap: 5px; align-items: end; text-align: center; }
.hour-bar b { font-size: 9px; color: #65718a; white-space: nowrap; }
.hour-bar span { height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 7px 7px 3px 3px; background: #f1f4fb; }
.hour-bar i { width: 100%; min-height: 2px; display: block; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #3b70ef, #214cc9); }
.hour-bar.peak i { background: linear-gradient(180deg, #fb9b45, #e26724); box-shadow: 0 5px 12px rgba(226,103,36,.25); }
.hour-bar small { color: var(--muted); font-size: 9px; }
.indicator-expandable { cursor: zoom-in; }
.indicator-fullscreen-popup { width: min(96vw, 1500px) !important; }
.indicator-fullscreen-popup .swal2-html-container { margin: 0; padding: 18px 24px 28px; text-align: left; overflow: auto; max-height: 78vh; }
.indicator-fullscreen-content .management-panel, .indicator-fullscreen-content .management-card, .indicator-fullscreen-content .metric-card, .indicator-fullscreen-content .panel { box-shadow: none; border: 0; }
.indicator-fullscreen-content .dashboard-pin-button, .indicator-fullscreen-content .dashboard-card-pin-button { display: none; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 9px 30px rgba(27,45,96,.045); }
.getting-started, .roadmap-panel { padding: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.panel-head h3 { margin: 5px 0 0; font-size: 20px; }
.panel-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.quick-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-list button { min-height: 52px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; text-align: left; border: 1px solid #e7eaf2; border-radius: 12px; background: #fafbfe; color: #3d465e; cursor: pointer; }
.quick-list button:hover { background: var(--brand-soft); border-color: #cbd7f8; color: var(--brand); }
.quick-list b { color: var(--brand); }
.roadmap-items { display: grid; gap: 10px; }
.roadmap-items > div { min-height: 58px; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 11px; padding: 8px 0; }
.roadmap-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; font-weight: 800; }
.roadmap-icon.stock { color: #315fd5; background: #edf2ff; }
.roadmap-icon.finance { color: #268a65; background: #eaf8f1; }
.roadmap-icon.clients { color: #8b5ac8; background: #f5effc; }
.roadmap-items strong, .roadmap-items small { display: block; }
.roadmap-items small { color: var(--muted); margin-top: 2px; }
.roadmap-items em { color: #9aa1b2; font-size: 10px; font-style: normal; background: #f2f4f8; padding: 4px 7px; border-radius: 20px; }

.assistant-view { height: calc(100vh - 86px); padding: 24px 34px; }
.chat-card { height: 100%; max-width: 1060px; margin: 0 auto; display: grid; grid-template-rows: auto 1fr auto auto auto; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 12px 38px rgba(27,45,96,.07); }
.chat-head { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.assistant-identity { display: flex; align-items: center; gap: 11px; }
.assistant-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #2f62e3, #1e46b7); box-shadow: 0 9px 18px rgba(40,87,217,.22); }
.assistant-avatar img { width: 92%; height: 92%; object-fit: contain; }
.assistant-identity strong, .assistant-identity small { display: block; }
.assistant-identity small { color: var(--muted); margin-top: 3px; }
.assistant-identity small i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.chat-messages { overflow: auto; padding: 28px max(22px, 7%); display: flex; flex-direction: column; gap: 18px; background: linear-gradient(#fbfcff, #fff); scroll-behavior: smooth; }
.message { display: flex; gap: 10px; max-width: 82%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; font-size: 10px; font-weight: 900; background: #eaf0ff; color: var(--brand); }
.message.user .message-avatar { background: #ebedf2; color: #596176; }
.message-body { padding: 13px 15px; border: 1px solid #e4e8f1; border-radius: 5px 16px 16px 16px; background: #fff; color: #343d54; line-height: 1.55; box-shadow: 0 5px 15px rgba(30,48,96,.04); white-space: pre-wrap; }
.message.user .message-body { border: 0; border-radius: 16px 5px 16px 16px; color: #fff; background: var(--brand); box-shadow: 0 8px 18px rgba(40,87,217,.17); }
.message-time { display: block; margin-top: 5px; color: #9ca3b2; font-size: 9px; }
.message.user .message-time { color: rgba(255,255,255,.66); }
.message.typing .message-body { color: #8890a1; }
.suggestion-row { padding: 0 22px 10px; display: flex; gap: 7px; overflow-x: auto; }
.suggestion-row button { white-space: nowrap; padding: 8px 11px; border: 1px solid #dce3f5; background: #f8faff; color: #4a5e91; border-radius: 20px; font-size: 11px; cursor: pointer; }
.suggestion-row button:hover { color: var(--brand); border-color: #b6c7f1; }
.chat-composer { margin: 0 20px; min-height: 58px; padding: 8px 8px 8px 16px; display: flex; align-items: flex-end; gap: 10px; border: 1px solid #dce1ec; border-radius: 15px; background: #fff; transition: .18s ease; }
.chat-composer textarea { width: 100%; max-height: 130px; min-height: 39px; padding: 9px 0 7px; resize: none; border: 0; outline: 0; color: var(--ink); background: transparent; line-height: 1.4; }
.voice-button { flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid #dfe5f0; border-radius: 12px; color: #2d58cf; background: #f3f6ff; cursor: pointer; font-size: 14px; transition: .18s ease; }
.voice-button:hover { background: #e9efff; }
.voice-button.listening { color: #fff; background: #d43c55; border-color: #d43c55; box-shadow: 0 0 0 6px rgba(212,60,85,.12); animation: voice-pulse 1.2s infinite; }
.voice-button:disabled { opacity: .5; cursor: not-allowed; }
.voice-status { display: block; min-height: 18px; margin: 5px 28px 0; color: #69758d; font-size: 11px; }
.voice-status.error { color: #b33145; }
@keyframes voice-pulse { 50% { transform: scale(.94); box-shadow: 0 0 0 10px rgba(212,60,85,.06); } }
.similar-history { margin: 0 20px 10px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid #cdd9f8; border-radius: 12px; color: #29437f; background: #f3f6ff; }
.similar-history strong,.similar-history small { display: block; }.similar-history small { margin-top: 3px; color: #687694; }
.similar-history button { flex: 0 0 auto; padding: 8px 11px; border: 1px solid #b8c8f2; border-radius: 9px; color: #234bb8; background: #fff; cursor: pointer; }
.send-button { width: 42px; height: 42px; flex: 0 0 auto; border: 0; border-radius: 12px; color: #fff; background: var(--brand); cursor: pointer; font-size: 21px; }
.send-button:hover { background: var(--brand-dark); }
.send-button:disabled { opacity: .5; cursor: wait; }
.chat-disclaimer { padding: 9px 20px 14px; text-align: center; color: #9ba2b1; font-size: 9px; }

.content-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.history-list { display: grid; gap: 12px; max-width: 900px; }
.history-search { max-width: 900px; margin-bottom: 16px; display: grid; grid-template-columns: 1fr auto auto; gap: 9px; }
.history-search input { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; outline: none; }
.history-search button { border: 1px solid #ccd7f3; border-radius: 11px; padding: 10px 14px; color: #2857d9; background: #f5f7ff; cursor: pointer; }
.history-item { padding: 18px 20px; display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 15px; background: #fff; cursor: pointer; }
.history-item:hover { border-color: #bcc9eb; box-shadow: 0 8px 22px rgba(31,58,125,.07); }
.history-item-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.history-item-content { min-width: 0; flex: 1; }
.history-item strong, .history-item small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-item p { margin: 6px 0; color: #566078; font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-item small { color: var(--muted); margin-top: 4px; }
.history-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.history-pin, .history-delete { padding: 8px 10px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.history-pin { border: 1px solid #cbd8fb; color: #2857d9; background: #f4f7ff; }
.history-pin:hover { background: #eaf0ff; }
.history-delete { border: 1px solid #f0d8dc; color: #b33145; background: #fff7f8; }
.history-delete:hover { background: #fdecef; }
.history-empty { padding: 40px; border: 1px dashed #d7dce7; border-radius: 18px; color: var(--muted); text-align: center; background: rgba(255,255,255,.55); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 900px; margin-bottom: 20px; }
.settings-card { padding: 22px; display: flex; gap: 15px; }
.setting-icon { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; color: var(--brand); background: var(--brand-soft); font-size: 19px; }
.setting-icon.key { color: #278861; background: #eaf8f1; }
.settings-card small, .settings-card strong { display: block; }
.settings-card small { color: var(--muted); }
.settings-card strong { margin: 5px 0; overflow-wrap: anywhere; }
.settings-card p { margin: 0; color: #9097a7; font-size: 12px; }

.management-view { background: #f7f9fd; }
.management-heading { gap: 22px; flex-wrap: wrap; }
.period-filter { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 6px 20px rgba(27,45,96,.04); }
.period-filter label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.period-filter .form-control { min-width: 142px; min-height: 39px; border-color: #dfe4ef; font-size: 13px; }
.period-filter .btn, .management-heading > .btn { min-height: 39px; border: 0; border-radius: 10px; background: var(--brand); }
.management-card { height: 100%; min-height: 142px; padding: 21px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: 0 8px 26px rgba(27,45,96,.05); }
.management-card > span { color: var(--muted); font-size: 12px; }
.management-card > strong { margin: auto 0 5px; color: var(--ink); font-size: clamp(22px, 2.4vw, 31px); letter-spacing: -1px; }
.management-card > small { color: #99a1b2; }
.management-card.success { border-top: 3px solid #34a87b; }
.management-card.danger { border-top: 3px solid #d95668; }
.management-card.warning { border-top: 3px solid #e8a235; }
.management-card.danger > strong { color: #bd3f52; }
.management-card.success > strong { color: #218260; }
.management-panel { height: 100%; min-height: 250px; padding: 21px; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: 0 8px 26px rgba(27,45,96,.045); }
.management-panel-head { min-height: 46px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.management-panel h3 { margin: 5px 0 0; font-size: 19px; }
.management-panel .table { font-size: 12px; }
.management-panel .table > :not(caption) > * > * { padding: 11px 8px; border-bottom-color: #edf0f6; }
.bar-chart { height: 245px; min-width: 0; display: flex; align-items: stretch; gap: 9px; overflow-x: auto; padding: 16px 4px 4px; }
.bar-chart.empty-state { display: grid; place-items: center; color: var(--muted); }
.bar-column { min-width: 54px; flex: 1 0 54px; display: grid; grid-template-rows: 28px 1fr 20px; gap: 5px; text-align: center; }
.bar-column > b { overflow: hidden; color: #59647d; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.bar-column > span { min-height: 130px; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid #dfe4ef; }
.bar-column i { width: 58%; min-height: 5px; display: block; border-radius: 7px 7px 2px 2px; background: linear-gradient(#4d7af0, #2454d6); box-shadow: 0 5px 12px rgba(36,84,214,.15); }
.bar-column > small { color: #8a93a7; font-size: 9px; }
.monthly-chart { height: 270px; }
.monthly-chart .bar-column { min-width: 78px; flex-basis: 78px; grid-template-rows: 28px 1fr 20px 18px; }
.monthly-chart .bar-column > em { color: #6d7891; font-size: 9px; font-style: normal; white-space: nowrap; }
.sales-list-table { min-width: 1040px; }
.document-action { white-space: nowrap; }
.commission-value { color: #1f8b68; }
.rank-list { display: grid; gap: 5px; }
.rank-row { min-height: 51px; display: grid; grid-template-columns: 30px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid #eef1f6; }
.rank-position { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--brand); background: var(--brand-soft); font-size: 10px; font-weight: 900; }
.rank-row strong, .rank-row small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row strong { font-size: 12px; }.rank-row small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.rank-row > b { color: #33415e; font-size: 12px; white-space: nowrap; }
.empty-state.compact { min-height: 120px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.stock-highlight { min-height: 170px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: linear-gradient(135deg, #1944bd, #3971ed); }
.stock-highlight .section-kicker, .stock-highlight p { color: rgba(255,255,255,.72); }
.stock-highlight h3 { margin: 7px 0; font-size: clamp(30px, 5vw, 48px); }
.stock-highlight > i { margin-right: 4%; font-size: clamp(54px, 9vw, 100px); opacity: .18; }
.action-module { width: 100%; min-height: 82px; display: grid; grid-template-columns: 46px 1fr 20px; align-items: center; gap: 13px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #fff; text-align: left; box-shadow: 0 7px 22px rgba(27,45,96,.04); }
.action-module > i { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; color: var(--brand); background: var(--brand-soft); font-size: 20px; }
.action-module strong, .action-module small { display: block; }.action-module small { margin-top: 4px; color: var(--muted); }
.action-module > b { color: var(--brand); font-size: 18px; }.action-module:hover { border-color: #bdccef; transform: translateY(-1px); }

.dre-table thead th, .dre-table .dre-total td { background: #111827; color: #fff; font-weight: 800; }
.dre-table .dre-expense td:first-child { padding-left: 2rem; }
.plan-summary { min-height: 0; }
.plan-summary > div { display: flex; gap: 2rem; justify-content: flex-end; flex-wrap: wrap; }
.plan-summary span { color: #64748b; }.plan-summary strong { color: #0f172a; margin-left: .5rem; }
.person-search { min-height: 0; padding: 1rem; }
.person-results { display: grid; gap: 1rem; }
.person-card .person-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.25rem; }
.person-card h3 { margin: .15rem 0; }.person-card p { margin: 0; color: #64748b; }
.credit-limit { text-align: right; border-radius: 14px; background: #eef4ff; padding: .8rem 1rem; }
.credit-limit span { display: block; color: #64748b; font-size: .78rem; }.credit-limit strong { color: #2454d6; font-size: 1.2rem; }
.person-finance { border: 1px solid #e5eaf3; border-radius: 14px; overflow: hidden; }
.person-finance .management-panel-head { padding: .8rem 1rem; margin: 0; background: #f8fafc; }
.person-finance h4 { margin: 0; font-size: .95rem; }
.product-search-form { padding: 18px; }
.product-search-form label > span { display: block; margin-bottom: 6px; color: #4c5870; font-size: 12px; font-weight: 700; }
.product-results { display: grid; gap: 16px; }
.product-detail-card { padding: 20px; }
.product-detail-card .management-panel-head small { color: var(--muted); }
.product-stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.product-stat-grid > div { padding: 13px; border: 1px solid #e6eaf3; border-radius: 12px; background: #fafbfe; }
.product-stat-grid span, .product-stat-grid strong { display: block; }
.product-stat-grid span { color: var(--muted); font-size: 11px; }
.product-stat-grid strong { margin-top: 5px; color: #253047; font-size: 16px; }
.product-stat-grid .success strong { color: var(--success); }
.product-stat-grid .danger strong { color: var(--danger); }
.last-purchase-box { margin-top: 14px; padding: 15px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; border-radius: 13px; background: #f3f6ff; }
.last-purchase-box strong, .last-purchase-box span { display: block; }
.last-purchase-box span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.last-purchase-box p { margin: 0; color: var(--muted); }
.danfe-preview { padding: 8px; color: #111827; text-align: left; font-family: Arial, sans-serif; }
.danfe-preview > header { display: flex; justify-content: space-between; gap: 20px; padding: 15px; border: 2px solid #111827; }
.danfe-preview header h2 { margin: 3px 0; font-size: 25px; }.danfe-preview header p { margin: 0; overflow-wrap: anywhere; }
.danfe-preview header > div:last-child { min-width: 180px; padding-left: 18px; border-left: 1px solid #111827; text-align: center; }
.danfe-preview header > div:last-child strong, .danfe-preview header > div:last-child span { display: block; }
.danfe-preview > section { margin: 6px 0; padding: 11px 15px; display: flex; flex-wrap: wrap; gap: 8px 25px; border: 1px solid #111827; }
.danfe-preview > section strong { width: 100%; }.danfe-preview > small { color: #64748b; }
.sale-document-preview .document-grand-total > * { border-top: 2px solid #111827; font-size: 15px; }
.sale-document-preview .document-payments span { min-width: 180px; }
.sale-document-preview .document-commission { border-color: #d8a52d; background: #fffaf0; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .product-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 840px) {
  .auth-screen { padding: 0; }
  .auth-shell { min-height: 100vh; border-radius: 0; grid-template-columns: 1fr; }
  .auth-brand { min-height: 330px; padding: 32px 28px; }
  .brand-copy { margin: 54px 0 30px; }
  .brand-copy h1 { font-size: 42px; }
  .brand-copy p { font-size: 15px; }
  .secure-note, .prompt-preview { display: none; }
  .auth-card { padding: 42px 28px; }
  .sidebar { width: min(86vw, 310px); transform: translateX(-102%); transition: transform .25s ease; will-change: transform; touch-action: pan-y; }
  .sidebar.open { transform: translateX(0); }
  .mobile-close { display: block; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(11,18,34,.5); backdrop-filter: blur(3px); }
  .sidebar-backdrop.show { display: block; }
  .app-main { margin-left: 0; }
  .menu-button { display: block; }
  .topbar { padding: 0 20px; }
  .view { min-height: calc(100dvh - 86px); padding: 24px 20px calc(28px + env(safe-area-inset-bottom)); animation: mobile-view-in .18s ease; }
  .assistant-view { padding: 16px; }
  .welcome-row { align-items: flex-start; flex-direction: column; }
  .welcome-actions { width: 100%; flex-direction: column-reverse; align-items: stretch; }
  .dashboard-customize-button { width: 100%; }
  .ask-button { min-width: 0; width: 100%; }
  .dashboard-widget-tray { grid-template-columns: 1fr; }
  .product-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .last-purchase-box { grid-template-columns: 1fr; }
  .management-heading { align-items: stretch; }
  .management-heading > div:first-child { width: 100%; }
  .management-heading > .btn { width: 100%; }
  .period-filter { width: 100%; }
}

@keyframes mobile-view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 570px) {
  .sale-document-preview > header { display: block; }
  .sale-document-preview header > div:last-child { margin-top: 12px; padding: 12px 0 0; border-top: 1px solid #111827; border-left: 0; text-align: left; }
  .api-grid { grid-template-columns: 1fr 90px; }
  .protocol-field { grid-column: 1 / -1; }
  .metric-grid, .settings-grid, .dashboard-pinned-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 166px; }
  .quick-list { grid-template-columns: 1fr; }
  .api-pill { display: none; }
  .topbar h1 { font-size: 20px; }
  .chat-head { padding: 13px; }
  .chat-head .secondary-button { width: 38px; overflow: hidden; padding: 0 9px; white-space: nowrap; }
  .chat-messages { padding: 20px 13px; }
  .message { max-width: 94%; }
  .chat-composer { margin: 0 12px; }
  .similar-history { margin: 0 12px 9px; align-items: flex-start; flex-direction: column; }
  .history-search { grid-template-columns: 1fr 1fr; }.history-search input { grid-column: 1 / -1; }
  .history-item { align-items: flex-start; flex-wrap: wrap; }
  .history-actions { width: 100%; margin-left: 54px; }
  .topbar { height: 72px; padding-top: env(safe-area-inset-top); }
  .view { min-height: calc(100dvh - 72px); padding-left: 16px; padding-right: 16px; }
  .auth-card { padding: 34px 20px calc(34px + env(safe-area-inset-bottom)); }
  .auth-brand { min-height: 285px; padding: calc(26px + env(safe-area-inset-top)) 22px 26px; }
  .brand-copy { margin-top: 42px; }
  .brand-copy h1 { font-size: clamp(32px, 11vw, 42px); }
  button, input, select, textarea { font-size: 16px; }
  .management-card { min-height: 128px; padding: 16px; }
  .management-card > strong { font-size: 21px; }
  .management-panel { padding: 16px; }
  .stock-highlight > i { display: none; }
  .person-card .person-head { flex-direction: column; }.credit-limit { width: 100%; text-align: left; }
  .plan-summary > div { justify-content: flex-start; gap: .75rem; flex-direction: column; }
}
