/* =========================================================================
   LINKDOC - App Component Library
   Construido sobre tokens.css (Dark Periwinkle). Backbone visual do SaaS.
   ========================================================================= */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: var(--lh-normal);
  font-size: var(--fs-body);
  overflow-x: hidden;
}

::selection { background: var(--accent-soft); color: var(--text-primary); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-4); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================================
   TIPOGRAFIA util
   ========================================================================= */
.h1 { font-size: var(--fs-h1); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.h2 { font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
.display { font-size: var(--fs-display); font-weight: var(--fw-extra); letter-spacing: var(--ls-tight); line-height: var(--lh-tight); }
.muted { color: var(--text-secondary); }
.dim { color: var(--text-tertiary); }
.accent-text { color: var(--accent-300); }
.tnum { font-variant-numeric: tabular-nums; }
.label-cap { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--ls-wide); color: var(--text-tertiary); }

/* =========================================================================
   APP SHELL - janela flutuante sobre slate
   ========================================================================= */
.app {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-canvas);
  display: grid;
  grid-template-columns: var(--nav-rail) 1fr;
}

/* Rail de icones (unica navegacao) - fixo em tela cheia */
.rail {
  height: 100%; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 26px 0; border-right: 1px solid var(--border-hair); z-index: var(--z-sticky);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .brand-dot { width: 58px; height: 58px; border-radius: var(--radius-full); background: linear-gradient(145deg, #2B2D31, #141416); border: 1px solid var(--border-strong); display: grid; place-items: center; margin-bottom: 4px; }
.rail .brand-dot svg { width: 26px; height: 26px; color: #fff; }
.rail .nav-i { width: var(--nav-i); height: var(--nav-i); border-radius: var(--radius-full); border: 1px solid var(--border-strong); background: transparent; display: grid; place-items: center; color: var(--text-secondary); position: relative; transition: all var(--dur-base) var(--ease-out); flex-shrink: 0; }
.rail .nav-i:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); transform: translateY(-1px); }
.rail .nav-i.active { background: var(--accent-gradient); color: #fff; border-color: transparent; box-shadow: var(--accent-glow); }
.rail .nav-i svg { width: 21px; height: 21px; }
.rail .nav-i[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 66px; top: 50%; transform: translateY(-50%); background: var(--surface-3); color: var(--text-primary); padding: 8px 11px; border-radius: 10px; font-size: var(--fs-xs); font-weight: var(--fw-medium); white-space: nowrap; z-index: var(--z-dropdown); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); }
.rail .spacer { flex: 1; min-height: 8px; }
.rail .avatar-mini { width: var(--nav-i); height: var(--nav-i); border-radius: var(--radius-full); object-fit: cover; border: 1px solid rgba(255,255,255,0.18); }

.sidebar { display: none; }

/* Main - rola internamente; rail e topbar ficam fixos */
.main { min-width: 0; height: 100%; overflow-y: auto; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: 14px; padding: 22px 30px 14px; background: var(--bg-canvas); }
.topbar .grow { flex: 1; }
.search-bar { height: 52px; min-width: 280px; width: min(440px, 32vw); border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: rgba(255,255,255,0.02); display: flex; align-items: center; gap: 12px; padding: 0 18px; color: var(--text-tertiary); transition: all var(--dur-base); }
.search-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(142,168,255,0.10); }
.search-bar input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text-primary); font-size: var(--fs-body); }
.pill-btn { height: 52px; padding: 0 18px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: rgba(255,255,255,0.02); color: var(--text-primary); display: inline-flex; align-items: center; gap: 9px; font-size: var(--fs-sm); font-weight: var(--fw-medium); transition: all var(--dur-base); white-space: nowrap; }
.pill-btn:hover { border-color: var(--border-strong); background: rgba(255,255,255,0.055); }
.pill-btn svg { width: 17px; height: 17px; color: var(--accent-300); }
.pill-btn.url { color: var(--text-secondary); max-width: 240px; }
.pill-btn.url b { color: var(--text-primary); font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; }
.notif-dot { position: absolute; right: -2px; top: -3px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: var(--fw-bold); display: grid; place-items: center; border: 2px solid var(--bg-canvas); }

/* Page head (abaixo do topbar) */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; padding: 6px 30px 20px; }
.page-head .eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-extra); text-transform: uppercase; letter-spacing: var(--ls-wide); color: var(--text-tertiary); }
.page-head h1 { font-size: var(--fs-h1); font-weight: var(--fw-semibold); letter-spacing: var(--ls-tight); line-height: var(--lh-tight); margin-top: 6px; }
.page-head p { font-size: var(--fs-body); color: var(--text-secondary); margin-top: 8px; }
.page-head .head-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.content { padding: 2px 30px 48px; width: 100%; }

@media (max-width: 1080px) {
  #btn-url { display: none; }
  .search-bar { width: min(360px, 40vw); min-width: 0; }
}
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 16px 20px 12px; }
  .search-bar { order: 3; width: 100%; flex-basis: 100%; }
  .page-head { padding: 6px 20px 18px; }
  .content { padding: 2px 20px 44px; }
  #ha-onboarding { display: none; }
}
@media (max-width: 640px) {
  :root { --nav-rail: 72px; --nav-i: 48px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .page-head .head-actions { width: 100%; }
  .page-head h1 { font-size: 26px; }
  .topbar { padding: 14px 16px 10px; gap: 10px; }
  .page-head { padding: 4px 16px 16px; }
  .content { padding: 2px 16px 40px; }
}

/* =========================================================================
   CARD
   ========================================================================= */
.card { background: var(--surface-1); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); transition: border-color var(--dur-base), background var(--dur-base); }
.card.pad { padding: var(--card-pad); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 20px var(--card-pad); border-bottom: 1px solid var(--divider); }
.card-head h3 { font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-snug); }
.card-head .grow { flex: 1; }
.card-body { padding: var(--card-pad); }
.card.hover:hover { border-color: var(--border-strong); background: var(--surface-2); }

/* Grid helpers */
.grid { display: grid; gap: var(--grid-gap); }
.grid > * { min-width: 0; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-12 { grid-template-columns: repeat(12, 1fr); }
.span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; }
@media (max-width: 900px){ .g-4,.g-3,.g-2{grid-template-columns:1fr 1fr;} .span-4,.span-6,.span-8,.span-5,.span-7{grid-column:1/-1;} }
@media (max-width: 560px){ .g-4,.g-3,.g-2{grid-template-columns:1fr;} }

.flex { display: flex; align-items: center; gap: 12px; }
.flex-col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}.gap-6{gap:24px}
.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-6{margin-top:24px}.mb-4{margin-bottom:16px}.mb-6{margin-bottom:24px}

/* =========================================================================
   STAT / KPI
   ========================================================================= */
.stat { position: relative; overflow: hidden; min-height: 158px; transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out); }
.stat::after { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 999px; right: -95px; top: -120px; background: radial-gradient(circle, rgba(142,168,255,.24), transparent 68%); filter: blur(38px); pointer-events: none; opacity: .7; transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
.stat:hover { border-color: var(--accent-soft-border); background: var(--surface-2); box-shadow: 0 0 0 1px var(--accent-soft-border), 0 24px 60px -30px rgba(142,168,255,.45); }
.stat:hover::after { opacity: 1; transform: scale(1.18); }
.stat .stat-top { display: flex; align-items: center; gap: 12px; color: var(--text-secondary); font-size: var(--fs-sm); font-weight: var(--fw-medium); position: relative; }
.stat .stat-ic { width: 46px; height: 46px; border-radius: 15px; background: var(--accent-soft); border: 1px solid var(--accent-soft-border); color: var(--accent-300); display: grid; place-items: center; flex-shrink: 0; }
.stat .stat-ic svg { width: 21px; height: 21px; }
.stat .stat-val { font-size: var(--fs-display); font-weight: var(--fw-bold); letter-spacing: -.06em; margin-top: 18px; position: relative; }
.stat .stat-sub { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 8px; position: relative; }

/* =========================================================================
   BOTOES
   ========================================================================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h); padding: 0 20px; border-radius: var(--radius-pill); font-size: var(--fs-body); font-weight: var(--fw-semibold); border: 1px solid transparent; transition: transform var(--dur-fast) var(--ease-out), background var(--dur-base), box-shadow var(--dur-base), border-color var(--dur-base), color var(--dur-base); white-space: nowrap; }
.btn:active { transform: scale(0.97); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent-gradient); color: #fff; box-shadow: var(--accent-glow); }
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-secondary { background: rgba(255,255,255,0.02); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: rgba(255,255,255,0.06); border-color: var(--border-strong); }
.btn-ghost { background: rgba(255,255,255,0.03); color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.btn-subtle { background: var(--accent-soft); color: var(--accent-300); border-color: var(--accent-soft-border); }
.btn-subtle:hover { background: rgba(142,168,255,0.16); }
.btn-danger { color: #FF7A82; border-color: rgba(255,77,87,0.35); background: rgba(255,77,87,0.07); }
.btn-danger:hover { background: rgba(255,77,87,0.14); }
.btn-sm { height: var(--control-h-sm); padding: 0 14px; font-size: var(--fs-sm); }
.btn-lg { height: 52px; padding: 0 28px; font-size: var(--fs-h3); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.icon-btn { width: var(--icon-btn); height: var(--icon-btn); border-radius: var(--radius-full); background: rgba(255,255,255,0.02); border: 1px solid var(--border-strong); color: var(--text-secondary); display: grid; place-items: center; transition: all var(--dur-base) var(--ease-out); flex-shrink: 0; position: relative; }
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.icon-btn.sm { width: var(--icon-btn-sm); height: var(--icon-btn-sm); }
.icon-btn.accent { background: var(--accent-gradient); color: #fff; border-color: transparent; box-shadow: var(--accent-glow); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

/* Segmented */
.segmented { display: inline-flex; background: rgba(255,255,255,0.02); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); padding: 4px; gap: 2px; }
.segmented button { height: 36px; padding: 0 16px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--text-secondary); font-size: var(--fs-sm); font-weight: var(--fw-semibold); transition: all var(--dur-fast); }
.segmented button.active { background: var(--accent-gradient); color: #fff; box-shadow: var(--accent-glow); }

/* =========================================================================
   FORM
   ========================================================================= */
.field-lbl { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary); margin-bottom: 8px; }
.field-lbl .req { color: var(--accent-300); }
.input, .textarea, .select { width: 100%; background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); color: var(--text-primary); font-size: var(--fs-body); padding: 0 16px; height: var(--control-h); transition: border-color var(--dur-base), box-shadow var(--dur-base); outline: none; }
.textarea { height: auto; padding: 12px 16px; min-height: 90px; resize: vertical; line-height: var(--lh-normal); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent-soft-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%2362626B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 42px; }
.field-hint { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 6px; }
.field-search { display: flex; align-items: center; gap: 10px; height: var(--control-h); padding: 0 16px; background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); color: var(--text-secondary); }
.field-search:focus-within { border-color: var(--accent-soft-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-search svg { width: 18px; height: 18px; flex-shrink: 0; }
.field-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text-primary); font-size: var(--fs-body); }
.field-search input::placeholder { color: var(--text-tertiary); }

/* Switch */
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #2C2D31; border: 1px solid var(--border-strong); border-radius: 999px; transition: all var(--dur-base); }
.switch .track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #777B86; border-radius: 50%; transition: all var(--dur-base) var(--ease-out); }
.switch input:checked + .track { background: rgba(142,168,255,.22); border-color: var(--accent-soft-border); }
.switch input:checked + .track::before { transform: translateX(18px); background: var(--accent-300); }

/* Radio card / choice */
.choice { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); transition: all var(--dur-base); cursor: pointer; }
.choice:hover { border-color: var(--border-strong); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--text-tertiary); flex-shrink: 0; display: grid; place-items: center; transition: all var(--dur-base); }
.choice.selected .radio { border-color: var(--accent); }
.choice.selected .radio::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* =========================================================================
   BADGES / CHIPS
   ========================================================================= */
.badge { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: var(--fw-semibold); border: 1px solid var(--border-subtle); white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge.success { color: var(--success); background: var(--success-soft); border-color: transparent; } .badge.success .dot { background: var(--success); }
.badge.warning { color: var(--warning); background: var(--warning-soft); border-color: transparent; } .badge.warning .dot { background: var(--warning); }
.badge.danger  { color: var(--danger); background: var(--danger-soft); border-color: transparent; }  .badge.danger .dot  { background: var(--danger); }
.badge.info    { color: var(--accent-300); background: var(--accent-soft); border-color: transparent; } .badge.info .dot  { background: var(--accent); }
.badge.neutral { color: var(--text-secondary); } .badge.neutral .dot { background: var(--text-tertiary); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border-subtle); font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-secondary); }
.chip.removable { padding-right: 6px; }
.chip .x { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-secondary); }
.chip .x:hover { background: var(--danger-soft); color: var(--danger); }
.trend { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: var(--radius-pill); border: 1px solid var(--accent-soft-border); background: var(--accent-soft); color: var(--accent-300); font-size: var(--fs-micro); font-weight: var(--fw-semibold); }
.trend.up { color: var(--success); border-color: rgba(131,231,182,.5); background: var(--success-soft); }
.trend.down { color: #FF848C; border-color: rgba(255,77,87,.5); background: var(--danger-soft); }
.trend svg { width: 12px; height: 12px; }

/* =========================================================================
   TABELA
   ========================================================================= */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 0 16px 14px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-tertiary); }
.table td { padding: 14px 16px; border-top: 1px solid var(--divider); font-size: var(--fs-sm); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.clickable { cursor: pointer; }
.cell-lead { display: flex; align-items: center; gap: 12px; }
.avatar-sq { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: var(--fw-bold); font-size: 14px; color: #fff; flex-shrink: 0; object-fit: cover; }
.avatar-c { border-radius: 50% !important; }
.cell-sub { color: var(--text-tertiary); font-size: var(--fs-xs); }

/* =========================================================================
   MODAL / DRAWER / TOAST
   ========================================================================= */
.overlay { position: fixed; inset: 0; background: rgba(6,6,8,0.72); backdrop-filter: blur(6px); z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; transition: opacity var(--dur-base); }
.overlay.open { opacity: 1; }
.modal { background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--radius-xl); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-pop); transform: translateY(16px) scale(.98); transition: transform var(--dur-base) var(--ease-out); }
.overlay.open .modal { transform: none; }
.modal.wide { max-width: 780px; }
.modal.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 24px 24px 16px; }
.modal-head .grow { flex: 1; }
.modal-head h3 { font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.modal-head p { font-size: var(--fs-sm); color: var(--text-secondary); margin-top: 4px; }
.modal-body { padding: 4px 24px 20px; }
.modal-foot { display: flex; gap: 12px; padding: 16px 24px 24px; justify-content: flex-end; border-top: 1px solid var(--divider); margin-top: 8px; }

.drawer-overlay { position: fixed; inset: 0; background: rgba(6,6,8,0.6); backdrop-filter: blur(4px); z-index: var(--z-modal); opacity: 0; transition: opacity var(--dur-base); }
.drawer-overlay.open { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw; background: var(--surface-1); border-left: 1px solid var(--border-strong); z-index: var(--z-modal); transform: translateX(100%); transition: transform var(--dur-slow) var(--ease-out); display: flex; flex-direction: column; box-shadow: var(--shadow-pop); }
.drawer.open { transform: none; }
.drawer.left { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--border-strong); transform: translateX(-100%); }
.drawer.left.open { transform: none; }
/* overlay transparente e nao-bloqueante: mantem o preview visivel e editavel atras */
.drawer-overlay.bare { background: transparent; backdrop-filter: none; pointer-events: none; }
/* preview embutido no drawer de tema (aparece no mobile, onde nao ha preview lateral) */
.th-live-preview { display: none; }
@media (max-width: 820px) { .th-live-preview { display: block; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 22px 24px; border-bottom: 1px solid var(--divider); }
.drawer-head h3 { font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-foot { padding: 18px 24px; border-top: 1px solid var(--divider); display: flex; gap: 12px; }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 12px; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 14px 18px; min-width: 280px; box-shadow: var(--shadow-pop); transform: translateX(120%); transition: transform var(--dur-base) var(--ease-out); }
.toast.show { transform: none; }
.toast .t-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.toast.success .t-ic { background: var(--success-soft); color: var(--success); }
.toast.info .t-ic { background: var(--accent-soft); color: var(--accent-300); }
.toast.warning .t-ic { background: var(--warning-soft); color: var(--warning); }
.toast .t-msg { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.toast .t-sub { font-size: var(--fs-xs); color: var(--text-secondary); }

/* =========================================================================
   TABS
   ========================================================================= */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--divider); }
.tab { padding: 12px 16px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--dur-base); background: none; border-top: 0; border-left: 0; border-right: 0; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-300); border-bottom-color: var(--accent); }

/* =========================================================================
   KANBAN
   ========================================================================= */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 300px; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.kcol { background: var(--surface-1); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: 72vh; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--divider); }
.kcol-head .k-dot { width: 8px; height: 8px; border-radius: 50%; }
.kcol-head h4 { font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.kcol-head .count { margin-left: auto; font-size: var(--fs-xs); color: var(--text-tertiary); background: var(--surface-2); padding: 2px 9px; border-radius: 999px; }
.kcol-body { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.kcard { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 14px; cursor: grab; transition: border-color var(--dur-fast), transform var(--dur-fast); }
.kcard:hover { border-color: var(--border-strong); }
.kcard.dragging { opacity: .5; }
.kcard .k-name { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.kcard .k-meta { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 4px; }
.sortable-ghost { opacity: .35; }

/* =========================================================================
   PHONE MOCKUP (preview do editor + demo)
   ========================================================================= */
.phone { width: 380px; height: 780px; background: #000; border-radius: 44px; padding: 12px; box-shadow: 0 40px 80px -20px rgba(0,0,0,.8), 0 0 0 1px var(--border-strong); position: relative; }
.phone::before { content: ''; position: absolute; top: 22px; left: 50%; transform: translateX(-50%); width: 120px; height: 26px; background: #000; border-radius: 999px; z-index: 5; }
.phone-screen { width: 100%; height: 100%; border-radius: 34px; overflow: hidden; background: var(--bg-canvas); position: relative; }
.phone-scroll { height: 100%; overflow-y: auto; scrollbar-width: none; }
.phone-scroll::-webkit-scrollbar { display: none; }

/* =========================================================================
   PROGRESS / MISC
   ========================================================================= */
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent-gradient); border-radius: 999px; transition: width var(--dur-slow) var(--ease-out); }
.divider { height: 1px; background: var(--divider); border: 0; margin: 20px 0; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-tertiary); display: inline-block; }
.empty { text-align: center; padding: 48px 24px; color: var(--text-tertiary); }
.empty svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: .5; }
.avatar-ring { border-radius: 50%; border: 2px solid var(--accent-soft-border); object-fit: cover; }

/* Funnel bars */
.funnel-row { display: grid; grid-template-columns: 150px 1fr 60px; align-items: center; gap: 14px; padding: 9px 0; }
.funnel-row .f-lbl { font-size: var(--fs-sm); color: var(--text-secondary); }
.funnel-row .f-bar { height: 30px; background: var(--accent-gradient); border-radius: 8px; display: flex; align-items: center; padding: 0 12px; color: #fff; font-weight: var(--fw-bold); font-size: var(--fs-xs); min-width: 40px; transition: width var(--dur-slow) var(--ease-out); }
.funnel-row .f-pct { text-align: right; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-tertiary); }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.anim-in { animation: fadeUp var(--dur-slow) var(--ease-out) both; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.pulsing { animation: pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* =========================================================================
   CONCIERGE / CHAT (Recepcionista IA) - compartilhado bio + editor
   ========================================================================= */
.cc { display: flex; flex-direction: column; }
.cc-stream { display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.cc-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.cc-msg.user { justify-content: flex-end; }
.cc-av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-gradient); color: #fff; display: grid; place-items: center; flex-shrink: 0; box-shadow: var(--accent-glow); }
.cc-b { background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: 18px 18px 18px 6px; padding: 11px 14px; font-size: 14px; line-height: 1.45; max-width: 82%; }
.cc-b b { color: var(--accent-300); font-weight: var(--fw-semibold); }
.cc-msg.user .cc-b { background: var(--accent); color: #fff; border-radius: 18px 18px 6px 18px; border-color: transparent; font-weight: var(--fw-medium); }
.cc-typing { display: flex; gap: 4px; }
.cc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); animation: ccblink 1.2s infinite; }
.cc-typing span:nth-child(2){ animation-delay: .2s; } .cc-typing span:nth-child(3){ animation-delay: .4s; }
@keyframes ccblink { 0%,60%,100%{ opacity:.25; transform:translateY(0);} 30%{ opacity:1; transform:translateY(-3px);} }
.cc-opts { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; padding-left: 36px; }
.cc-opt { background: var(--surface-1); border: 1px solid var(--accent-soft-border); color: var(--text-primary); border-radius: 14px; padding: 10px 14px; font-size: 13.5px; font-weight: var(--fw-medium); text-align: right; transition: all var(--dur-fast); max-width: 100%; }
.cc-opt:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.cc-opt:disabled { opacity: .4; }
.cc-opt.picked { background: var(--accent); color: #fff; border-color: transparent; opacity: 1; }
.cc-rec { border: 1px solid var(--accent-soft-border); background: linear-gradient(180deg, var(--accent-soft), var(--surface-2)); border-radius: 18px; padding: 16px; max-width: 88%; }
.cc-rec-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: var(--fw-bold); color: var(--accent-300); text-transform: uppercase; letter-spacing: .04em; }
.cc-rec-title { font-size: 18px; font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); margin: 8px 0 6px; }
.cc-rec-reason { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.cc-rec-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.cc-rec-meta .chip { font-size: 11px; padding: 4px 9px; }
.cc-rec-pro { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-tertiary); margin-bottom: 12px; }
.cc-cta { margin-top: 2px; }
.cc-disc { font-size: 10.5px; color: var(--text-tertiary); margin-top: 10px; line-height: 1.4; display: flex; gap: 5px; }
.cc-urgent { background: var(--danger-soft); border: 1px solid rgba(240,87,75,.3); border-radius: 16px; padding: 14px; }
.cc-urgent-ic { width: 34px; height: 34px; border-radius: 10px; background: rgba(240,87,75,.18); color: var(--danger); display: grid; place-items: center; margin-bottom: 8px; }
.cc-urgent strong { display: block; color: var(--danger); font-size: 15px; margin-bottom: 6px; }
.cc-urgent p { font-size: 13px; color: var(--text-secondary); margin-top: 6px; line-height: 1.45; }
.cc-form strong { font-size: 14px; display: block; }
.cc-form .input { height: 42px; font-size: 13.5px; }
.cc-consent { display: flex; gap: 9px; align-items: flex-start; font-size: 11.5px; color: var(--text-tertiary); line-height: 1.4; cursor: pointer; }
.cc-consent input { margin-top: 2px; width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--accent); }

/* =========================================================================
   NAVEGACAO MOBILE (bottom bar flutuante + burger)
   ========================================================================= */
.mobile-only { display: none; }
.topbar-brand { align-items: center; gap: 9px; }
.topbar-brand .brand-dot { background: var(--accent-gradient); display: grid; place-items: center; box-shadow: var(--accent-glow); flex-shrink: 0; }
.topbar-brand .brand-dot svg { color: #fff; }
.topbar-brand .wm { font-size: 17px; font-weight: var(--fw-extra); letter-spacing: -.02em; white-space: nowrap; }
.topbar-brand .wm span { color: var(--accent-300); }

.bottombar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: var(--z-overlay); align-items: center; justify-content: space-around; gap: 2px;
  width: calc(100vw - 24px); max-width: 480px;
  background: rgba(28,28,30,.85); backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong); border-radius: 24px; padding: 7px;
  box-shadow: 0 18px 44px -12px rgba(0,0,0,.7);
}
.bb-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: var(--text-tertiary); font-size: 10px; font-weight: var(--fw-semibold); padding: 7px 4px; border-radius: 16px; transition: color var(--dur-fast), background var(--dur-fast); }
.bb-item svg { width: 22px; height: 22px; }
.bb-item.active { color: var(--accent-300); background: var(--accent-soft); }

/* Burger drawer */
.m-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.m-actions .btn { justify-content: flex-start; }
.m-group { margin-bottom: 16px; }
.m-group-t { font-size: 11px; font-weight: var(--fw-extra); text-transform: uppercase; letter-spacing: .08em; color: var(--text-tertiary); padding: 0 6px 8px; }
.m-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; background: none; border-radius: 12px; color: var(--text-secondary); font-size: 14.5px; font-weight: var(--fw-medium); text-align: left; transition: background var(--dur-fast), color var(--dur-fast); }
.m-link:hover { background: var(--surface-3); color: var(--text-primary); }
.m-link.active { background: var(--accent-soft); color: var(--accent-300); }
.m-link svg:first-child { width: 19px; height: 19px; flex-shrink: 0; }
.m-count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: var(--fw-bold); padding: 1px 8px; border-radius: 999px; }

@media (max-width: 820px) {
  .desktop-only { display: none !important; }
  .rail { display: none; }
  .app { grid-template-columns: 1fr; }
  #btn-burger { display: grid; }
  .topbar-brand { display: flex; }
  .bottombar { display: flex; }
  .topbar { padding: 14px 16px; gap: 10px; }
  .page-head { padding: 8px 16px 14px; }
  .page-head h1 { font-size: 24px; }
  .content { padding: 2px 16px 108px; }
  /* tabelas rolam dentro do card em vez de vazar a pagina */
  .card-body:has(.table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { white-space: nowrap; }
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
  .ed-preview { overflow: hidden; }
  .ed-grid > * { min-width: 0; }
  .card-head { flex-wrap: wrap; row-gap: 10px; }
}

/* =========================================================================
   AGENDA - linha de agendamento (alinhada vertical a esquerda)
   ========================================================================= */
.ag-appt { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius-md); transition: background var(--dur-fast); }
.ag-appt:hover { background: var(--surface-2); }
.ag-time { font-weight: var(--fw-extra); font-size: 16px; letter-spacing: -.01em; min-width: 46px; padding-top: 1px; flex-shrink: 0; }
.ag-line { width: 1px; align-self: stretch; background: var(--divider); flex-shrink: 0; }
.ag-info { flex: 1; min-width: 0; }
.ag-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ag-patient { font-weight: var(--fw-semibold); font-size: 14px; }
.ag-svc { color: var(--text-tertiary); font-size: 12.5px; margin-top: 3px; }
.ag-pro { display: flex; align-items: center; gap: 7px; margin-top: 8px; color: var(--text-tertiary); font-size: 11.5px; }
.ag-menu { flex-shrink: 0; margin-top: 1px; }

/* =========================================================================
   GATING POR PLANO (cadeados + tela bloqueada)
   ========================================================================= */
.rail .nav-i.gated { opacity: .55; }
.rail .nav-i.gated.active { opacity: 1; }
.nav-lock { position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text-secondary); display: grid; place-items: center; }
.nav-lock svg { width: 9px; height: 9px; }
.bb-item.gated { opacity: .6; }
.bb-lock { position: absolute; top: 4px; left: 50%; margin-left: 5px; color: var(--text-tertiary); }
.bb-lock svg { width: 9px; height: 9px; }

.locked-view { max-width: 540px; margin: 56px auto; text-align: center; display: flex; flex-direction: column; align-items: center; padding: 0 20px; }
.locked-view .lock-ic { width: 66px; height: 66px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--accent-300); display: grid; place-items: center; margin-bottom: 16px; }
.lock-plan { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius-pill); background: var(--accent-soft); border: 1px solid var(--accent-soft-border); color: var(--accent-300); font-size: var(--fs-xs); font-weight: var(--fw-semibold); margin-bottom: 14px; }
.locked-view h2 { font-size: var(--fs-h1); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); }
.locked-view p { color: var(--text-secondary); font-size: 14.5px; line-height: 1.6; margin: 12px 0 22px; }

.hidden { display: none !important; }
