/* HWeb V3 — unified app layer over the V2 tokens.
   Calm surfaces, one strong action per view, pastel atmosphere from the
   literal V2 palette, purposeful motion that respects reduced motion. */

:root {
  --app-bg: #fbfaf8;
  --side-bg: #f4f3f1;
  --side-width: 272px;
  --line: #ecebe8;
  --line-strong: #dcdad6;
  --text: var(--ink);
  --text-2: #57534e;
  --text-3: #8a847d;
  --card: #ffffff;
  --hover: rgba(12, 10, 9, 0.05);
  --press: rgba(12, 10, 9, 0.09);
  --focus: 0 0 0 3px rgba(200, 184, 224, 0.75);
  --shadow-1: 0 1px 2px rgba(12, 10, 9, 0.05), 0 1px 1px rgba(12, 10, 9, 0.03);
  --shadow-2: 0 10px 30px -12px rgba(12, 10, 9, 0.18), 0 2px 6px rgba(12, 10, 9, 0.05);
  --shadow-3: 0 24px 60px -20px rgba(12, 10, 9, 0.28), 0 4px 12px rgba(12, 10, 9, 0.06);
  --aurora: radial-gradient(60% 80% at 15% 0%, rgba(167, 229, 211, 0.38), transparent 60%),
            radial-gradient(50% 70% at 85% 5%, rgba(200, 184, 224, 0.36), transparent 60%),
            radial-gradient(45% 60% at 55% 0%, rgba(244, 197, 168, 0.30), transparent 60%);
  --brand-gradient: conic-gradient(from 210deg, var(--gradient-mint), var(--gradient-sky), var(--gradient-lavender), var(--gradient-rose), var(--gradient-peach), var(--gradient-mint));
  --ok: #15803d; --ok-bg: #e8f6ee;
  --warn: #a16207; --warn-bg: #fdf3dc;
  --bad: #b91c1c; --bad-bg: #fdeaea;
  --info: #3b5b8c; --info-bg: #e9f0fa;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Base (classless defaults so every page looks right) ---------- */
html { -webkit-text-size-adjust: 100%; }
body.app-body { background: var(--app-bg); color: var(--text); font: 400 15px/1.55 var(--font-body); letter-spacing: 0; }
.app-body h1 { font: 500 28px/1.2 var(--font-body); letter-spacing: -0.02em; margin: 0 0 6px; color: var(--text); }
.app-body h2 { font: 600 17px/1.35 var(--font-body); letter-spacing: -0.01em; margin: 0 0 10px; color: var(--text); }
.app-body h3 { font: 600 15px/1.4 var(--font-body); margin: 0 0 6px; }
.app-body p { color: var(--text-2); margin: 0 0 12px; }
.app-body a { color: var(--text); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.app-body a:hover { text-decoration-color: currentColor; }
.app-body small, .app-body .caption, .muted { color: var(--text-3); font-size: 13px; }
.app-body :focus-visible { outline: none; box-shadow: var(--focus); }
/* Rounded ring only where the element has no radius of its own (links, summaries). */
:where(.app-body :focus-visible) { border-radius: 10px; }
.app-body hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.app-body code { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-strong); padding: 1px 6px; border-radius: 6px; }
.app-body dl { display: grid; grid-template-columns: minmax(120px, 220px) 1fr; gap: 10px 20px; margin: 0; }
.app-body dt { color: var(--text-3); font-size: 13px; }
.app-body dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.app-body table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.app-body th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.app-body td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.app-body tr:last-child td { border-bottom: 0; }
.app-body ul, .app-body ol { color: var(--text-2); padding-left: 20px; }
.app-body details { border-radius: 14px; }
.app-body summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 40px; color: var(--text); font-weight: 500; }
.app-body summary::-webkit-details-marker { display: none; }
.app-body summary::after { content: ''; width: 16px; height: 16px; margin-left: auto; background: currentColor; opacity: .5;
  -webkit-mask: url('assets/icons/chevron-down.svg') center/16px no-repeat; mask: url('assets/icons/chevron-down.svg') center/16px no-repeat; transition: transform .2s var(--ease-out); }
.app-body details[open] > summary::after { transform: rotate(180deg); }
.app-body .no-chevron > summary::after { display: none; }

/* Forms */
.app-body label { display: block; font-size: 13.5px; font-weight: 500; color: var(--text); margin: 0 0 6px; }
.app-body label:has(> input[type='checkbox']), .app-body label:has(> input[type='radio']) { display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--text-2); }
/* Form controls. Generic rules live in :where() (specificity of a single class)
   so component classes win without !important. The `.field` selector keeps the
   V2 `.field input/select` rules from tokens.css from overriding the V3 look.
   Controls never inherit the 13.5px label size; 16px on phones avoids iOS zoom. */
:root {
  --control-h: 44px;
  --control-radius: 12px;
  --control-border: var(--line-strong);
  --control-border-hover: #bdb9b3;
  --control-border-focus: #7c6aa6;
  /* Thin-line chevron drawn with two diagonal strokes (no image request, CSP safe). */
  --select-chevron-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  --select-chevron-size: 6px 6px, 6px 6px;
}
.app-body :where(input:not([type='checkbox'], [type='radio'], [type='hidden'], [type='submit'], [type='button'], [type='reset'], [type='file'], [type='range'], [type='color'], [type='image']), select, textarea),
.app-body .field :where(input:not([type='checkbox'], [type='radio'], [type='hidden'], [type='submit'], [type='button'], [type='reset'], [type='file'], [type='range'], [type='color'], [type='image']), select, textarea) {
  display: block; width: 100%; max-width: 100%; min-width: 0; min-height: var(--control-h); margin: 0; padding: 10px 14px;
  border: 1px solid var(--control-border); border-radius: var(--control-radius); background-color: var(--card); color: var(--text);
  font-family: inherit; font-size: 15px; font-weight: 400; line-height: 1.4; letter-spacing: 0;
  transition: border-color .15s, box-shadow .15s, background-color .15s; }
.app-body :where(select:not([multiple], [size]:not([size='1']))),
.app-body .field :where(select:not([multiple], [size]:not([size='1']))) {
  -webkit-appearance: none; appearance: none; height: var(--control-h); padding-top: 0; padding-bottom: 0; padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 38%, var(--chevron-color, var(--text-2)) 38%, var(--chevron-color, var(--text-2)) 60%, transparent 60%), linear-gradient(-45deg, transparent 38%, var(--chevron-color, var(--text-2)) 38%, var(--chevron-color, var(--text-2)) 60%, transparent 60%);
  background-position: var(--select-chevron-position); background-size: var(--select-chevron-size); background-repeat: no-repeat;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.app-body :where(select[multiple], select[size]:not([size='1'])) { padding: 6px; }
.app-body :where(select) option { color: var(--text); background: var(--card); }
.app-body :where(select) optgroup { color: var(--text-3); font-weight: 600; }
.app-body :where(input:not(:disabled, :focus):hover, select:not(:disabled, :focus):hover, textarea:not(:disabled, :focus):hover) { border-color: var(--control-border-hover); }
.app-body :where(input, select, textarea):focus { outline: 2px solid transparent; outline-offset: 2px; border-color: var(--control-border-focus); box-shadow: var(--focus); }
.app-body :where(input, select, textarea):disabled { background-color: var(--surface-strong); color: var(--text-3); border-color: var(--line); cursor: not-allowed; opacity: 1; }
.app-body :where(select):disabled { --chevron-color: var(--muted-soft); }
.app-body :where(input, select, textarea)[aria-invalid='true'] { border-color: var(--bad); }
.app-body :where(input, select, textarea)::placeholder { color: var(--text-3); opacity: 1; }
/* A "Filtros/Período" disclosure sitting in a row of filter controls lines up with them. */
.app-body :is(.ops-filter-bar, .ops-search) > .ops-filter-more { margin-top: calc(13.5px * 1.55); border-color: var(--control-border); border-radius: var(--control-radius); }
.app-body :is(.ops-filter-bar, .ops-search) > .ops-filter-more > summary { min-height: calc(var(--control-h) - 10px); }
.app-body :is(.ops-filter-bar, .ops-search) > button { margin-top: calc(13.5px * 1.55) !important; min-height: var(--control-h) !important; }
@media (max-width: 640px) {
  .app-body :is(.ops-filter-bar, .ops-search) > .ops-filter-more { margin-top: 0; }
  .app-body :is(.ops-filter-bar, .ops-search) > button { margin-top: 0 !important; }
}
@media (max-width: 640px) {
  .app-body :where(input:not([type='checkbox'], [type='radio']), select, textarea),
  .app-body .field :where(input:not([type='checkbox'], [type='radio']), select, textarea) { font-size: 16px; }
}
.app-body input[type='checkbox'], .app-body input[type='radio'] { width: 18px; height: 18px; accent-color: var(--ink); flex: 0 0 18px; }
/* Compact select inside the conversation search pill: its `background !important`
   would drop the shared chevron, so re-apply it. */
.app-body .chat-search select { background-image: linear-gradient(45deg, transparent 38%, var(--text-2) 38%, var(--text-2) 60%, transparent 60%), linear-gradient(-45deg, transparent 38%, var(--text-2) 38%, var(--text-2) 60%, transparent 60%) !important;
  background-position: calc(100% - 17px) 50%, calc(100% - 11px) 50% !important; background-size: 6px 6px, 6px 6px !important; background-repeat: no-repeat !important;
  padding-right: 30px !important; height: 32px; }
/* Visually hidden stays hidden even when it is a form control. */
.app-body .sr-only, .app-body select.sr-only, .app-body input.sr-only { position: absolute; width: 1px; height: 1px; min-width: 0; min-height: 0; padding: 0; margin: -1px; border: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.app-body form p { margin: 0 0 16px; }
.app-body .helptext, .app-body .hint { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.app-body .errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--bad); font-size: 13px; }
.app-body fieldset { border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 0 0 16px; }
.app-body legend { font-weight: 600; padding: 0 6px; }

/* Buttons: legacy .pill keeps working, restyled. */
.btn, .app-body .pill, .app-body :where(button:not(.bare, .icon-btn, .chip-btn, .seg, .send-btn, .side-item, .menu-item, .conversation-copy)) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid transparent; background: var(--ink); color: #fff; font: 500 14px/1 var(--font-body);
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform .15s var(--ease-out), background .15s, box-shadow .15s, opacity .15s; margin: 0; }
.btn:hover, .app-body .pill:hover, .app-body :where(button:not(.bare, .icon-btn, .chip-btn, .seg, .send-btn, .side-item, .menu-item, .conversation-copy)):hover { background: #292524; color: #fff; box-shadow: var(--shadow-2); }
.btn:active, .app-body .pill:active { transform: scale(.97); }
.btn.secondary, .app-body .pill.secondary, .btn-soft, .app-body :where(button.secondary) { background: var(--card); color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover, .app-body .pill.secondary:hover, .btn-soft:hover, .app-body :where(button.secondary):hover { background: var(--card); color: var(--text); border-color: #bdb9b3; box-shadow: var(--shadow-1); }
.btn-ghost { background: transparent !important; color: var(--text) !important; border-color: transparent !important; }
.btn-ghost:hover { background: var(--hover) !important; box-shadow: none !important; }
.btn-danger { background: var(--bad) !important; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; }
.btn-sm { min-height: 32px !important; padding: 0 12px !important; font-size: 13px !important; }
.app-body button:disabled, .btn[aria-disabled='true'], .app-body .pill:disabled { opacity: .45; cursor: not-allowed; box-shadow: none !important; transform: none !important; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; padding: 0; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.text-link, .app-body .text-button { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; cursor: pointer; font: inherit; min-height: 0; }

/* Icons via mask so they inherit color. */
.i { display: inline-block; width: 18px; height: 18px; flex: 0 0 auto; background: currentColor; -webkit-mask: var(--icon) center/contain no-repeat; mask: var(--icon) center/contain no-repeat; }
.i-sm { width: 16px; height: 16px; } .i-lg { width: 22px; height: 22px; }
.i-house { --icon: url('assets/icons/house.svg'); } .i-new { --icon: url('assets/icons/square-pen.svg'); }
.i-chat { --icon: url('assets/icons/message-circle.svg'); } .i-tasks { --icon: url('assets/icons/list-checks.svg'); }
.i-bot { --icon: url('assets/icons/bot.svg'); } .i-users { --icon: url('assets/icons/users.svg'); }
.i-settings { --icon: url('assets/icons/settings.svg'); } .i-logout { --icon: url('assets/icons/log-out.svg'); }
.i-search { --icon: url('assets/icons/search.svg'); } .i-plus { --icon: url('assets/icons/plus.svg'); }
.i-clip { --icon: url('assets/icons/paperclip.svg'); } .i-stop { --icon: url('assets/icons/square.svg'); }
.i-more { --icon: url('assets/icons/ellipsis.svg'); } .i-ok { --icon: url('assets/icons/circle-check.svg'); }
.i-warn { --icon: url('assets/icons/triangle-alert.svg'); } .i-clock { --icon: url('assets/icons/clock.svg'); }
.i-key { --icon: url('assets/icons/key-round.svg'); } .i-right { --icon: url('assets/icons/chevron-right.svg'); }
.i-left { --icon: url('assets/icons/chevron-left.svg'); } .i-menu { --icon: url('assets/icons/menu.svg'); }
.i-share { --icon: url('assets/icons/share-2.svg'); } .i-archive { --icon: url('assets/icons/archive.svg'); }
.i-pencil { --icon: url('assets/icons/pencil.svg'); } .i-spark { --icon: url('assets/icons/sparkles.svg'); }
.i-layers { --icon: url('assets/icons/layers.svg'); } .i-user-plus { --icon: url('assets/icons/user-plus.svg'); }
.i-plug { --icon: url('assets/icons/plug.svg'); } .i-back { --icon: url('assets/icons/arrow-left.svg'); }
.i-info { --icon: url('assets/icons/info.svg'); } .i-lock { --icon: url('assets/icons/lock.svg'); }
.i-activity { --icon: url('assets/icons/activity.svg'); } .i-refresh { --icon: url('assets/icons/refresh-cw.svg'); }
.i-sliders { --icon: url('assets/icons/sliders-horizontal.svg'); } .i-x-circle { --icon: url('assets/icons/circle-x.svg'); }
.i-loader { --icon: url('assets/icons/loader-circle.svg'); } .i-send { --icon: url('assets/icons/send.svg'); }
.i-mail { --icon: url('assets/icons/mail.svg'); } .i-panel { --icon: url('assets/icons/panel-right.svg'); }
.i-panel-left { --icon: url('assets/icons/panel-left.svg'); } .i-compass { --icon: url('assets/icons/compass.svg'); }
.i-zap { --icon: url('assets/icons/zap.svg'); } .i-copy { --icon: url('assets/icons/copy.svg'); }
.i-up { --icon: url('assets/icons/arrow-up.svg'); } .i-x { --icon: url('assets/icons/x.svg'); }
.i-shield { --icon: url('assets/icons/shield-check.svg'); } .i-file { --icon: url('assets/icons/file-text.svg'); }
.i-help { --icon: url('assets/icons/circle-question-mark.svg'); } .i-hourglass { --icon: url('assets/icons/hourglass.svg'); }
.i-ban { --icon: url('assets/icons/ban.svg'); } .i-user { --icon: url('assets/icons/user.svg'); }
.i-check { --icon: url('assets/icons/check.svg'); } .i-folder { --icon: url('assets/icons/folder.svg'); }
.spin { animation: hw-spin 1s linear infinite; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--side-width) minmax(0, 1fr); min-height: 100dvh; }
.app.side-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app.side-collapsed .app-side { transform: translateX(-100%); visibility: hidden; }
.app-side { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 12px 10px; background: var(--side-bg); border-right: 1px solid var(--line); overflow: hidden; transition: transform .28s var(--ease-out), visibility .28s; z-index: 40; }
.side-top { display: flex; align-items: center; gap: 6px; padding: 2px 4px 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 15px; letter-spacing: -.01em; padding: 6px; border-radius: 10px; }
.brand-mark { width: 26px; height: 26px; border-radius: 9px; background: var(--brand-gradient); box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), var(--shadow-1); position: relative; overflow: hidden; }
.brand-mark::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: rgba(255,255,255,.75); filter: blur(2px); }
.side-top .icon-btn { margin-left: auto; }
.org-switch { position: relative; }
.org-switch > summary { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; min-height: 44px; font-weight: 500; }
.org-switch > summary:hover { background: var(--hover); }
.org-avatar, .avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--card); box-shadow: var(--shadow-1); font: 600 12px/1 var(--font-body); color: var(--text); flex: 0 0 28px; }
.avatar { border-radius: 50%; background: var(--brand-gradient); color: var(--ink); }
.org-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
/* ---------- Menus: <details data-menu> + .menu ----------
   CSS gives the anchored fallback; app.js places the open menu with
   position: fixed, keeps it inside the viewport (flips up/down, clamps the
   sides), and sets --menu-avail to the free height so long menus scroll
   inside. Below 640px menus outside the sidebar become a full-width panel
   (16px from each edge). Components keep width/alignment through their own
   classes (.menu-right, .menu.up); opt out of placement with data-menu-manual. */
details[data-menu] { position: relative; }
details[data-menu] > summary { -webkit-user-select: none; user-select: none; }
.menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 80; min-width: 0; max-width: calc(100vw - 16px);
  max-height: min(var(--menu-max, 440px), var(--menu-avail, calc(100dvh - 96px))); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-3); padding: 6px; color: var(--text);
  font: 400 14px/1.4 var(--font-body); text-align: left; animation: hw-pop .18s var(--ease-out); }
.menu.up { top: auto; bottom: calc(100% + 6px); }
.menu[data-side='top'] { animation-name: hw-pop-up; }
html[data-menus] details[data-menu]:not([data-menu-manual])[open] > .menu:not([data-placed]) { visibility: hidden; }
.menu a, .menu button.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; padding: 9px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font: inherit; background: none; border: 0; min-height: 40px; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.menu a:hover, .menu button.menu-item:hover, .menu a:focus-visible, .menu button.menu-item:focus-visible { background: var(--hover); color: var(--text); }
.menu a[aria-current] { background: var(--hover); font-weight: 500; }
.menu a > .i-check:last-child { margin-left: auto; }
.menu a > .i, .menu button.menu-item > .i { color: var(--text-2); }
.menu form { margin: 0; }
.menu-label { padding: 8px 10px 4px; font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
/* Header bar rises above page content (and drawers) while one of its menus is open. */
.app-topbar:has(details[data-menu][open]) { z-index: 70; }
@media (max-width: 639px) {
  /* Fallback before/without JS placement: full-width panel under the top bar. */
  .app-main .menu { position: fixed; left: 16px; right: 16px; top: 64px; width: auto; min-width: 0; max-width: none; }
  .app-main .menu.up { top: auto; bottom: 16px; }
}
.side-new { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; padding: 0 12px; min-height: 42px; border-radius: 12px; background: var(--card); color: var(--text); text-decoration: none; font-weight: 500; font-size: 14px; box-shadow: var(--shadow-1); border: 1px solid var(--line); transition: box-shadow .15s, transform .15s var(--ease-out); }
.side-new:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.side-new kbd { margin-left: auto; font: 11px/1 var(--font-body); color: var(--text-3); }
.side-nav { display: grid; gap: 1px; }
.side-item { display: flex; align-items: center; gap: 10px; padding: 0 10px; min-height: 38px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 14px; border: 0; background: none; width: 100%; cursor: pointer; text-align: left; transition: background .12s, color .12s; }
.side-item:hover { background: var(--hover); color: var(--text); }
.side-item[aria-current] { background: var(--card); color: var(--text); font-weight: 500; box-shadow: var(--shadow-1); }
.side-label { padding: 16px 10px 6px; font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
.side-recents { display: grid; gap: 1px; overflow-y: auto; min-height: 0; flex: 1 1 auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.side-recents a { display: block; padding: 8px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-recents a:hover { background: var(--hover); color: var(--text); }
.side-recents a[aria-current] { background: var(--card); color: var(--text); box-shadow: var(--shadow-1); }
.side-empty { padding: 6px 10px; font-size: 13px; color: var(--text-3); }
.side-bottom { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); position: relative; }
.side-bottom > summary { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; min-height: 48px; }
.side-bottom > summary:hover { background: var(--hover); }
.account-text { min-width: 0; display: grid; }
.account-text strong { font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text span { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-main { position: relative; min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.app-main::before { content: ''; position: absolute; inset: 0 0 auto; height: 320px; background: var(--aurora); pointer-events: none; opacity: .9; z-index: 0; }
.app-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 16px; background: color-mix(in srgb, var(--app-bg) 78%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.app-topbar .crumb { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13.5px; min-width: 0; }
.app-topbar .crumb a { color: var(--text-3); text-decoration: none; }
.app-topbar .crumb a:hover { color: var(--text); }
.app-topbar .crumb strong { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.show-when-collapsed { display: none; }
.app.side-collapsed .show-when-collapsed { display: inline-grid; }
.app-content { position: relative; z-index: 1; flex: 1; width: 100%; }
.page { width: min(100% - 48px, 1040px); margin: 8px auto 64px; animation: hw-rise .45s var(--ease-out) both; }
.page-narrow { width: min(100% - 48px, 720px); }
.page-wide { width: min(100% - 48px, 1240px); }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 24px; }
.page-head .eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); margin-bottom: 8px; }
.page-head p { margin: 4px 0 0; max-width: 60ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.display-title { font: 300 44px/1.08 var(--font-display) !important; letter-spacing: -0.02em !important; }

/* Cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px; box-shadow: var(--shadow-1); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--text); box-shadow: var(--shadow-1); transition: transform .2s var(--ease-out), box-shadow .2s; overflow: hidden; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.tile .tile-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-strong); }
.tile strong { font-weight: 600; font-size: 15px; }
.tile span { color: var(--text-3); font-size: 13px; }
.tile.mint .tile-icon { background: #def5ee; } .tile.lav .tile-icon { background: #ece5f6; }
.tile.peach .tile-icon { background: #fbe6d8; } .tile.sky .tile-icon { background: #e1edf8; } .tile.rose .tile-icon { background: #f7e3e8; }
.list { display: grid; background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-1); }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; text-decoration: none; color: var(--text); border-top: 1px solid var(--line); transition: background .12s; min-width: 0; }
.list-row:first-child { border-top: 0; }
a.list-row:hover, .list-row.hoverable:hover { background: #faf9f7; }
.list-row .lead { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-strong); flex: 0 0 36px; color: var(--text-2); }
.list-row .main { min-width: 0; flex: 1; display: grid; gap: 2px; }
.list-row .main strong { font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .main span { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .trail { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; color: var(--text-3); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--surface-strong); color: var(--text-2); white-space: nowrap; line-height: 1.5; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip.plain::before { display: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info { background: var(--info-bg); color: var(--info); }
.chip.live::before { animation: hw-pulse 1.4s ease-in-out infinite; }
.chip-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text-2); font: 500 13.5px/1.2 var(--font-body); cursor: pointer; text-align: left; transition: border-color .15s, color .15s, transform .15s var(--ease-out), box-shadow .15s; }
.chip-btn:hover { color: var(--text); border-color: #bdb9b3; transform: translateY(-1px); box-shadow: var(--shadow-1); }

/* Notices */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 14px; background: var(--info-bg); color: var(--info); border: 0; font-size: 14px; }
.notice p { color: inherit; margin: 0; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad, .notice.error { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.neutral { background: var(--surface-strong); color: var(--text-2); }
.messages { display: grid; gap: 8px; margin-bottom: 16px; }

/* Empty states */
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 48px 24px; }
.empty h2 { font: 500 20px/1.3 var(--font-body); margin: 8px 0 0; }
.empty p { max-width: 46ch; margin: 0 0 8px; }

/* Orb (ambient, from V2 palette) */
.orb { position: relative; width: 72px; height: 72px; border-radius: 50%; background:
  radial-gradient(circle at 30% 25%, rgba(255,255,255,.95), transparent 38%),
  radial-gradient(circle at 25% 65%, var(--gradient-mint), transparent 60%),
  radial-gradient(circle at 75% 30%, var(--gradient-peach), transparent 60%),
  radial-gradient(circle at 70% 75%, var(--gradient-lavender), transparent 62%),
  radial-gradient(circle at 50% 50%, var(--gradient-sky), var(--gradient-rose));
  box-shadow: 0 20px 50px -18px rgba(200,184,224,.9), inset 0 -6px 18px rgba(255,255,255,.35);
  animation: hw-orb 14s ease-in-out infinite; }
.orb::after { content: ''; position: absolute; inset: -18px; border-radius: 50%; background: inherit; filter: blur(28px); opacity: .45; z-index: -1; }
.orb-lg { width: 112px; height: 112px; } .orb-sm { width: 30px; height: 30px; animation-duration: 9s; } .orb-xs { width: 22px; height: 22px; }
.orb-xs::after, .orb-sm::after { inset: -6px; filter: blur(10px); }
.thinking .orb-sm, .orb.busy { animation: hw-orb-busy 2.2s ease-in-out infinite; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-strong); width: fit-content; margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 10px; text-decoration: none; color: var(--text-2); font-size: 13.5px; font-weight: 500; }
.tabs a[aria-current] { background: var(--card); color: var(--text); box-shadow: var(--shadow-1); }
.tabs a:hover { color: var(--text); }

/* Stat */
.stat { display: grid; gap: 4px; }
.stat strong { font: 500 26px/1 var(--font-body); letter-spacing: -.02em; }
.stat span { font-size: 13px; color: var(--text-3); }

/* Disclosure panels ("Saiba mais") */
.more { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 4px 16px; }
.more[open] { padding-bottom: 14px; }
.more > summary { min-height: 46px; }
.more p:last-child { margin-bottom: 0; }

/* Form layout */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow-1); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.field { margin: 0 0 16px; }

/* ---------- Guest (auth) layout ---------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-form { display: flex; flex-direction: column; padding: 28px clamp(24px, 6vw, 80px); }
.auth-form .brand { align-self: flex-start; }
.auth-inner { width: min(100%, 400px); margin: auto; padding: 32px 0; animation: hw-rise .5s var(--ease-out) both; }
.auth-inner h1 { font: 300 40px/1.1 var(--font-display) !important; letter-spacing: -.02em !important; margin-bottom: 8px; }
.auth-inner > p { margin-bottom: 24px; }
.auth-inner .btn, .auth-inner button[type='submit'] { width: 100%; min-height: 48px; font-size: 15px; }
.auth-foot { font-size: 13.5px; color: var(--text-3); text-align: center; margin-top: 20px; }
.auth-art { position: relative; margin: 12px; border-radius: 28px; overflow: hidden; background: #f3efe9; display: grid; place-items: center; isolation: isolate; }
.auth-art::before { content: ''; position: absolute; inset: -20%; background:
  radial-gradient(40% 40% at 25% 30%, var(--gradient-mint), transparent 70%),
  radial-gradient(38% 38% at 75% 25%, var(--gradient-lavender), transparent 70%),
  radial-gradient(42% 42% at 70% 75%, var(--gradient-peach), transparent 70%),
  radial-gradient(36% 36% at 25% 80%, var(--gradient-sky), transparent 70%),
  radial-gradient(30% 30% at 50% 50%, var(--gradient-rose), transparent 70%);
  filter: blur(30px); animation: hw-drift 22s ease-in-out infinite alternate; z-index: -1; }
.auth-quote { width: min(80%, 460px); }
.auth-quote .orb { margin-bottom: 28px; }
.auth-quote h2 { font: 300 40px/1.12 var(--font-display) !important; letter-spacing: -.02em; color: var(--ink); margin: 0 0 12px; }
.auth-quote p { color: #44403c; font-size: 15px; }
.auth-points { display: grid; gap: 10px; margin-top: 20px; padding: 0; list-style: none; }
.auth-points li { display: flex; gap: 10px; align-items: center; color: #44403c; font-size: 14px; }
.auth-points .i { color: var(--ink); }

/* ---------- Motion ---------- */
@keyframes hw-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes hw-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes hw-pop-up { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes hw-spin { to { transform: rotate(360deg); } }
@keyframes hw-pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes hw-orb { 0%, 100% { transform: translateY(0) rotate(0deg) scale(1); } 33% { transform: translateY(-4px) rotate(40deg) scale(1.03); } 66% { transform: translateY(2px) rotate(-30deg) scale(.98); } }
@keyframes hw-orb-busy { 0%, 100% { transform: scale(1) rotate(0deg); filter: saturate(1); } 50% { transform: scale(1.12) rotate(180deg); filter: saturate(1.4); } }
@keyframes hw-drift { from { transform: translate(-3%, -2%) rotate(0deg); } to { transform: translate(3%, 3%) rotate(12deg); } }
@keyframes hw-shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
.stagger > * { animation: hw-rise .5s var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: .04s; } .stagger > *:nth-child(3) { animation-delay: .08s; }
.stagger > *:nth-child(4) { animation-delay: .12s; } .stagger > *:nth-child(5) { animation-delay: .16s; }
.stagger > *:nth-child(6) { animation-delay: .2s; } .stagger > *:nth-child(n+7) { animation-delay: .24s; }
.shimmer-text { background: linear-gradient(90deg, var(--text-3) 0%, var(--text) 40%, var(--text-3) 80%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: hw-shimmer 2.2s linear infinite; }
body[data-movement='reduced'] *, body[data-movement='reduced'] *::before, body[data-movement='reduced'] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Responsive ---------- */
.scrim { display: none; }
@media (max-width: 1023px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app-side { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-102%); visibility: hidden; box-shadow: var(--shadow-3); }
  .app.side-open .app-side { transform: none; visibility: visible; }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(12,10,9,.28); z-index: 30; animation: hw-rise .2s both; }
  .show-when-collapsed, .show-mobile { display: inline-grid !important; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .app-body dl { grid-template-columns: 1fr; gap: 2px 0; }
  .app-body dd { margin-bottom: 10px; }
}
@media (min-width: 861px) { .show-mobile { display: none !important; } }
@media (max-width: 640px) {
  .page, .page-narrow, .page-wide { width: calc(100% - 28px); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .app-body h1 { font-size: 24px; }
  .display-title { font-size: 34px !important; }
  .page-head { margin: 4px 0 18px; }
  .card, .form-card { padding: 16px; border-radius: 18px; }
  .list-row { padding: 12px 14px; }
  .app-body table { display: block; overflow-x: auto; }
}
@media (forced-colors: active) { .orb, .auth-art::before, .app-main::before { display: none; } .chip { border: 1px solid; } }

/* Guest pages reuse the page wrapper without width constraints. */
.auth-inner .page { width: 100%; margin: 0; animation: none; }
.auth-inner .messages { margin-bottom: 16px; }
[data-copy-message].done { color: var(--ok); }
.topbar-actions details.topbar-menu > summary.icon-btn { display: inline-grid; }

/* Links styled as buttons keep their own colors. */
.app-body a.btn, .app-body a.pill { color: #fff; text-decoration: none; }
.app-body a.btn.secondary, .app-body a.pill.secondary, .app-body a.btn-soft { color: var(--text); }
.app-body a.btn-ghost { color: var(--text); }
.app-body a.chip-btn, .app-body a.chip { text-decoration: none; }
/* Primary "new" action reads as the main button; nav selection stays quiet. */
.side-new { background: var(--ink); color: #fff; border-color: var(--ink); }
.side-new:hover { color: #fff; }
.side-item[aria-current] { box-shadow: none; background: rgba(12, 10, 9, 0.07); }
.side-recents a[aria-current] { box-shadow: none; background: rgba(12, 10, 9, 0.07); }
.side-label { color: #6b655e; }

.app-body a.side-new, .app-body a.side-new:hover { color: #fff; text-decoration: none; }
.app-body .side-item, .app-body .side-recents a, .app-body .menu a, .app-body .brand { text-decoration: none; }
.side-recents { align-content: start; }

/* ---------- Notifications (S11.01–S11.03) ---------- */
.i-bell { --icon: url('assets/icons/bell.svg'); } .i-check-check { --icon: url('assets/icons/check-check.svg'); }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.head-actions form { margin: 0; }
.notification-list .notification.unread { background: #f7f3fd; }
.notification-list .notification.unread strong { font-weight: 650; }
.notification-list time { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b5a8e; flex: 0 0 8px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; font-size: 14.5px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-row:last-of-type { border-bottom: 0; }
.check-row input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 18px; }
.pager { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.notif-bell { position: relative; }
.app-body a.notif-bell { color: var(--text-2); }
.notif-badge { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: #6b5a8e; color: #fff; font: 600 10.5px/17px var(--font-body); text-align: center; box-shadow: 0 0 0 2px var(--card, #fff); }
.notif-badge[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .notif-badge.bump { animation: hw-bump .5s var(--ease-out, ease-out); } }
@keyframes hw-bump { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
/* Offline / reconnection banner (S11.05). */
.net-banner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 120; display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; background: var(--ink, #0c0a09); color: #fff; font-size: 13.5px; box-shadow: var(--shadow-3, 0 8px 24px rgba(0,0,0,.18)); max-width: calc(100vw - 24px); }
.net-banner[hidden] { display: none; }
.net-banner.ok { background: #14532d; }
/* Button loading state (S11.05): set by app.js on submit. */
.is-loading { position: relative; cursor: progress; opacity: .85; }
.is-loading::after { content: ''; width: 14px; height: 14px; margin-left: 8px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; vertical-align: -2px; }
@media (prefers-reduced-motion: no-preference) { .is-loading::after { animation: hw-spin .8s linear infinite; } }
@keyframes hw-spin { to { transform: rotate(360deg); } }
/* Skeleton placeholders (S11.10): shape only, never a progress value. */
.skeleton-stack { display: grid; gap: 12px; padding: 8px 0; }
.skeleton { display: block; height: 14px; border-radius: 8px; background: linear-gradient(90deg, #f0efed 25%, #f7f6f4 50%, #f0efed 75%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: hw-skeleton 1.4s ease-in-out infinite; } }
@keyframes hw-skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
body[data-movement='reduced'] .skeleton, body[data-movement='reduced'] .is-loading::after, body[data-movement='reduced'] .notif-badge.bump { animation: none; }
/* Contrast AA on the sidebar surface (S11.06/H23). */
.app-body .account-text span { color: #6b655e; }
/* Long identifiers never widen the page on small screens. */
.app-content :where(p, li, dd, td, span, div) > code { overflow-wrap: anywhere; word-break: break-word; }
