:root{
    --paper:#F7F8FA;
    --paper-soft:#EEF1F5;
    --ink:#1C2433;
    --ink-soft:#6B7280;
    --navy:#2B4C7E;
    --navy-light:#5B7FB5;
    --navy-dark:#1E3A60;
    --navy-wash:#E4EBF5;
    --sage:#4F7A6B;
    --sage-wash:#E2EEEA;
    --alert:#B5654A;
    --alert-wash:#F3E2DB;
    --gold:#B8932F;
    --gold-wash:#F4EBD8;
    --line:#E2E6EC;
    --white:#FFFFFF;
    --radius:14px;
    --shadow: 0 1px 2px rgba(28,36,51,0.04), 0 4px 16px rgba(28,36,51,0.06);
  }

  [data-theme="dark"]{
    --paper:#15191F;
    --paper-soft:#1C212A;
    --ink:#E8EAED;
    --ink-soft:#8B93A1;
    --navy:#6E94CC;
    --navy-light:#7FA3DC;
    --navy-dark:#4A6FA0;
    --navy-wash:#26334A;
    --sage:#7FAE9B;
    --sage-wash:#1F2E29;
    --alert:#D08A72;
    --alert-wash:#3A2622;
    --gold:#D4B466;
    --gold-wash:#332B1A;
    --line:#2C323D;
    --white:#1C212A;
    --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.3);
  }
  [data-theme="dark"] .client-avatar,
  [data-theme="dark"] .mini-avatar,
  [data-theme="dark"] .brand-mark{ filter:brightness(0.92); }
  [data-theme="dark"] img{ filter:brightness(0.92); }

  *{box-sizing:border-box; margin:0; padding:0;}
  body{
    font-family:'Inter', Arial, sans-serif; background:var(--paper); color:var(--ink); -webkit-font-smoothing:antialiased;
    transition:background .2s ease, color .2s ease;
  }
  h1,h2,h3,.display{ font-family:'Outfit', Arial, sans-serif; font-weight:700; letter-spacing:-0.02em; }
  .mono{ font-family:'JetBrains Mono', monospace; }
  button{ font-family:inherit; }
  input, select, textarea{ font-family:'Inter', Arial, sans-serif; }

  .app{ display:flex; min-height:100vh; }

  .sidebar{
    width:240px; flex-shrink:0; background:var(--white);
    border-right:1px solid var(--line); padding:28px 20px;
    display:flex; flex-direction:column; gap:28px;
    position:sticky; top:0; height:100vh; overflow-y:auto;
  }
  .brand{ display:flex; align-items:center; gap:10px; padding:0 6px; }
  .brand-mark{
    width:34px; height:34px; border-radius:10px;
    background:linear-gradient(155deg, var(--navy-light), var(--navy-dark));
    display:flex; align-items:center; justify-content:center;
    color:white; font-family:'Outfit',sans-serif; font-weight:800; font-size:18px;
  }
  .brand-name{ font-family:'Outfit', sans-serif; font-weight:700; font-size:18px; }
  .brand-sub{ font-size:10.5px; color:var(--ink-soft); margin-top:1px; line-height:1.3; max-width:150px; }

  .daypart{
    display:flex; align-items:center; gap:8px; font-size:12px; color:var(--ink-soft);
    padding:9px 12px; border-radius:10px; background:var(--paper-soft); border:1px solid var(--line);
  }
  .daypart-dot{ width:8px; height:8px; border-radius:50%; background:var(--navy-light); flex-shrink:0; }

  nav{ display:flex; flex-direction:column; gap:4px; flex:1; }
  .nav-label{ font-size:11px; text-transform:uppercase; letter-spacing:0.06em; color:var(--ink-soft); padding:0 12px; margin:10px 0 6px; }
  .nav-item{
    display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:10px;
    color:var(--ink-soft); font-size:14.5px; font-weight:600; cursor:pointer;
    transition:background .15s, color .15s; border:none; background:none; width:100%; text-align:left;
  }
  .nav-item svg{ width:18px; height:18px; flex-shrink:0; opacity:0.75; }
  .nav-item:hover{ background:var(--paper-soft); color:var(--ink); }
  .nav-item.active{ background:var(--navy-wash); color:var(--navy); }
  .nav-item.active svg{ opacity:1; }
  .nav-item:disabled{ opacity:.4; cursor:default; }

  .sidebar-footer{ display:flex; align-items:center; gap:10px; padding:10px 12px; border-top:1px solid var(--line); padding-top:18px; }
  .avatar{
    width:34px; height:34px; border-radius:50%; background:var(--sage-wash); color:var(--sage);
    display:flex; align-items:center; justify-content:center; font-family:'Outfit',sans-serif; font-weight:700; font-size:14px;
  }
  .footer-name{ font-size:13.5px; font-weight:700; }
  .footer-role{ font-size:11.5px; color:var(--ink-soft); }

  main{ flex:1; padding:32px 40px 60px; max-width:1180px; }
  .page{ display:none; animation:fadeIn .25s ease; }
  .page.active{ display:block; }
  @keyframes fadeIn{ from{opacity:0;} to{opacity:1;} }

  .page-header{ display:flex; justify-content:space-between; align-items:flex-end; margin-bottom:28px; gap:20px; flex-wrap:wrap; }
  .page-header h1{ font-size:28px; }
  .page-header p{ color:var(--ink-soft); font-size:14px; margin-top:4px; }

  .btn{
    display:inline-flex; align-items:center; gap:8px; padding:10px 18px; border-radius:10px; border:none;
    font-size:14px; font-weight:600; cursor:pointer; transition:transform .1s, box-shadow .15s, background .15s;
    white-space:nowrap;
  }
  .btn:active{ transform:scale(0.97); }
  .btn-primary{ background:var(--navy); color:white; box-shadow:0 2px 8px rgba(43,76,126,0.25); }
  .btn-primary:hover{ background:var(--navy-dark); }
  .btn-ghost{ background:var(--white); color:var(--ink); border:1px solid var(--line); }
  .btn-ghost:hover{ border-color:var(--navy-light); }
  .btn-ghost.active{ background:var(--navy-wash); border-color:var(--navy-light); color:var(--navy); }
  .btn-sm{ padding:7px 13px; font-size:13px; border-radius:8px; }
  .btn-danger-text{ background:none; border:none; color:var(--alert); font-size:13px; font-weight:600; cursor:pointer; }

  .kpi-row{ display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:28px; }
  .kpi-card{ background:var(--white); border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; box-shadow:var(--shadow); }
  .kpi-label{ font-size:12.5px; color:var(--ink-soft); margin-bottom:10px; }
  .kpi-value{ font-family:'Outfit',sans-serif; font-size:26px; font-weight:700; }
  .kpi-value.mono{ font-family:'JetBrains Mono', monospace; font-weight:500; font-size:23px; }
  .kpi-trend{ font-size:12px; margin-top:6px; color:var(--sage); }
  .kpi-trend.down{ color:var(--alert); }

  .card{ background:var(--white); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); }

  .agenda-toolbar{ display:flex; justify-content:space-between; align-items:center; margin-bottom:18px; flex-wrap:wrap; gap:12px; }
  .week-nav{ display:flex; align-items:center; gap:10px; }
  .week-nav button{ width:32px; height:32px; border-radius:8px; border:1px solid var(--line); background:var(--white); cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--ink-soft); }
  .week-nav button:hover{ border-color:var(--navy-light); color:var(--navy); }
  .week-label{ font-family:'Outfit',sans-serif; font-size:16px; font-weight:700; min-width:190px; text-align:center; }
  .view-toggle{ display:flex; background:var(--paper-soft); border-radius:9px; padding:3px; border:1px solid var(--line); }
  .view-toggle button{ border:none; background:none; padding:6px 14px; font-size:13px; font-weight:600; color:var(--ink-soft); border-radius:7px; cursor:pointer; }
  .view-toggle button.active{ background:var(--white); color:var(--navy); box-shadow:0 1px 3px rgba(0,0,0,0.08); }

  .week-grid{ display:grid; grid-template-columns:56px repeat(5,1fr); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; background:var(--white); }
  .week-grid .head{ background:var(--paper-soft); padding:12px 8px; text-align:center; border-bottom:1px solid var(--line); border-left:1px solid var(--line); }
  .week-grid .head:first-child{ border-left:none; }
  .head .dow{ font-size:11px; color:var(--ink-soft); text-transform:uppercase; letter-spacing:0.04em; }
  .head .dnum{ font-family:'Outfit',sans-serif; font-size:18px; font-weight:700; margin-top:2px; }
  .head.today{ background:var(--navy-wash); }
  .head.today .dnum{ color:var(--navy); }

  .time-col{ display:flex; flex-direction:column; }
  .time-cell{ height:64px; font-size:11px; color:var(--ink-soft); text-align:right; padding:4px 8px 0 0; border-top:1px solid var(--line); }
  .time-cell:first-child{ border-top:none; }

  .day-col{ position:relative; }
  .day-col.bordered{ border-left:1px solid var(--line); }
  .slot{ height:64px; border-top:1px solid var(--line); transition:background .1s; cursor:pointer; }
  .slot:first-child{ border-top:none; }
  .slot:hover{ background:var(--paper-soft); }

  .appt{
    position:absolute; left:4px; right:4px; border-radius:8px; padding:6px 9px; font-size:12px; line-height:1.3;
    box-shadow:0 1px 3px rgba(0,0,0,0.08); cursor:pointer; overflow:hidden; border-left:3px solid var(--navy);
    background:var(--navy-wash); transition:filter .15s, transform .1s; z-index:2;
  }
  .appt:hover{ filter:brightness(0.97); }
  .appt .name{ font-weight:700; color:var(--ink); }
  .appt .time{ color:var(--ink-soft); font-family:'JetBrains Mono',monospace; font-size:10.5px; margin-top:1px; }
  .appt.confirmed{ background:var(--sage-wash); border-left-color:var(--sage); }
  .appt.pending{ background:var(--gold-wash); border-left-color:var(--gold); }
  .appt.online{ background:var(--navy-wash); border-left-color:var(--navy-light); }

  .agenda-list{ display:flex; flex-direction:column; gap:10px; }
  .day-group-label{ font-size:12px; text-transform:uppercase; letter-spacing:0.05em; color:var(--ink-soft); margin:18px 0 8px; font-weight:600; }
  .day-group-label:first-child{ margin-top:0; }
  .appt-row{ display:flex; align-items:center; gap:16px; background:var(--white); border:1px solid var(--line); border-radius:12px; padding:13px 16px; cursor:pointer; }
  .appt-row .time-block{ font-family:'JetBrains Mono',monospace; font-size:13px; font-weight:500; color:var(--ink); width:54px; flex-shrink:0; }
  .appt-row .duration{ font-size:11px; color:var(--ink-soft); display:block; }
  .status-dot{ width:8px; height:8px; border-radius:50%; flex-shrink:0; }
  .status-dot.confirmed{ background:var(--sage); }
  .status-dot.pending{ background:var(--gold); }
  .status-dot.online{ background:var(--navy-light); }
  .appt-row .client-name{ font-weight:700; font-size:14.5px; }
  .appt-row .session-type{ font-size:12.5px; color:var(--ink-soft); }
  .tag{ font-size:11px; padding:3px 9px; border-radius:20px; font-weight:700; white-space:nowrap; }
  .tag.confirmed{ background:var(--sage-wash); color:var(--sage); }
  .tag.pending{ background:var(--gold-wash); color:#8A6F1A; }
  .tag.online{ background:var(--navy-wash); color:var(--navy); }
  .empty-day{ font-size:13px; color:var(--ink-soft); padding:20px; text-align:center; background:var(--paper-soft); border-radius:10px; border:1px dashed var(--line); }

  .clients-toolbar{ display:flex; gap:12px; margin-bottom:20px; align-items:center; flex-wrap:wrap; }
  .search-box{ flex:1; min-width:220px; display:flex; align-items:center; gap:8px; background:var(--white); border:1px solid var(--line); border-radius:10px; padding:9px 14px; }
  .search-box input{ border:none; outline:none; font-size:14px; flex:1; background:none; }
  .search-box svg{ width:16px; height:16px; color:var(--ink-soft); flex-shrink:0; }

  .clients-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
  .client-card{ background:var(--white); border:1px solid var(--line); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow); cursor:pointer; transition:border-color .15s; }
  .client-card:hover{ border-color:var(--navy-light); }
  .client-top{ display:flex; gap:12px; align-items:center; margin-bottom:14px; }
  .client-avatar{ width:42px; height:42px; border-radius:50%; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-family:'Outfit',sans-serif; font-weight:700; font-size:15px; color:white; }
  .client-name{ font-weight:700; font-size:15px; }
  .client-since{ font-size:11.5px; color:var(--ink-soft); }
  .client-meta{ display:flex; flex-direction:column; gap:7px; font-size:13px; color:var(--ink-soft); margin-bottom:14px; }
  .client-meta span{ display:flex; align-items:center; gap:7px; }
  .client-meta svg{ width:14px; height:14px; opacity:0.6; flex-shrink:0; }
  .client-footer{ display:flex; justify-content:space-between; align-items:center; padding-top:12px; border-top:1px solid var(--line); }
  .client-status{ font-size:11.5px; padding:3px 10px; border-radius:20px; font-weight:700; }
  .client-status.ativo{ background:var(--sage-wash); color:var(--sage); }
  .client-status.pausa{ background:var(--gold-wash); color:#8A6F1A; }
  .next-session{ font-size:11.5px; color:var(--ink-soft); }
  .empty-state{ text-align:center; padding:60px 20px; color:var(--ink-soft); }
  .empty-state h3{ color:var(--ink); margin-bottom:8px; font-size:17px; }

  .fin-tabs{ display:flex; gap:6px; margin-bottom:22px; border-bottom:1px solid var(--line); }
  .fin-tab{ padding:10px 4px; margin-right:22px; font-size:14px; font-weight:600; color:var(--ink-soft); border:none; background:none; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; }
  .fin-tab.active{ color:var(--navy); border-bottom-color:var(--navy); }

  table{ width:100%; border-collapse:collapse; }
  thead th{ text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:0.04em; color:var(--ink-soft); padding:12px 16px; border-bottom:1px solid var(--line); font-weight:700; }
  tbody td{ padding:14px 16px; border-bottom:1px solid var(--paper-soft); font-size:13.5px; vertical-align:middle; }
  tbody tr:last-child td{ border-bottom:none; }
  tbody tr:hover{ background:var(--paper-soft); }
  .row-client{ display:flex; align-items:center; gap:10px; font-weight:700; }
  .mini-avatar{ width:30px; height:30px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-family:'Outfit',sans-serif; font-size:12px; color:white; flex-shrink:0; }
  .pay-status{ font-size:11.5px; padding:4px 11px; border-radius:20px; font-weight:700; display:inline-flex; align-items:center; gap:5px; white-space:nowrap; }
  .pay-status.pago{ background:var(--sage-wash); color:var(--sage); }
  .pay-status.aberto{ background:var(--alert-wash); color:var(--alert); }
  .pay-status.parcial{ background:var(--gold-wash); color:#8A6F1A; }
  .value-mono{ font-family:'JetBrains Mono',monospace; font-weight:500; }

  .fin-summary{ display:grid; grid-template-columns:1.3fr 1fr; gap:16px; margin-bottom:24px; }
  .chart-card{ padding:22px; }
  .chart-card h3{ font-size:15px; margin-bottom:18px; font-family:'Outfit',sans-serif; }
  .bars{ display:flex; align-items:flex-end; gap:14px; height:140px; }
  .bar-group{ flex:1; display:flex; flex-direction:column; align-items:center; gap:8px; height:100%; justify-content:flex-end; }
  .bar{ width:100%; border-radius:6px 6px 0 0; background:var(--navy-wash); }
  .bar.filled{ background:var(--navy-light); }
  .bar-label{ font-size:11px; color:var(--ink-soft); }

  .open-list{ display:flex; flex-direction:column; gap:10px; max-height:260px; overflow-y:auto; }
  .open-item{ display:flex; justify-content:space-between; align-items:center; padding:11px 0; border-bottom:1px solid var(--paper-soft); }
  .open-item:last-child{ border-bottom:none; padding-bottom:0; }
  .open-item .name{ font-weight:700; font-size:13.5px; }
  .open-item .since{ font-size:11.5px; color:var(--alert); }
  .open-item .amt{ font-family:'JetBrains Mono',monospace; font-weight:600; color:var(--alert); font-size:13.5px; }

  .modal-overlay{ position:fixed; inset:0; background:rgba(28,36,51,0.45); display:flex; align-items:center; justify-content:center; z-index:500; padding:20px; animation:fadeIn .15s ease; }
  #modal-root-2 .modal-overlay{ z-index:550; }
  .modal{ background:var(--white); border-radius:18px; width:100%; max-width:480px; max-height:88vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,0.25); }
  .modal-header{ display:flex; justify-content:space-between; align-items:center; padding:22px 24px 0; }
  .modal-header h2{ font-size:20px; }
  .modal-close{ width:30px; height:30px; border-radius:8px; border:none; background:var(--paper-soft); color:var(--ink-soft); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:16px; }
  .modal-close:hover{ background:var(--line); }
  .modal-body{ padding:20px 24px 24px; display:flex; flex-direction:column; gap:16px; }
  .field{ display:flex; flex-direction:column; gap:6px; }
  .field label{ font-size:12.5px; font-weight:600; color:var(--ink-soft); }
  .field input, .field select, .field textarea{
    border:1px solid var(--line); border-radius:9px; padding:10px 12px; font-size:14px; outline:none;
    transition:border-color .15s; background:var(--paper); width:100%;
  }
  .field input:focus, .field select:focus, .field textarea:focus{ border-color:var(--navy-light); background:var(--white); }
  .field-row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  .modal-actions{ display:flex; gap:10px; justify-content:flex-end; margin-top:6px; }
  .radio-group{ display:flex; gap:8px; flex-wrap:wrap; }
  .radio-pill{ border:1px solid var(--line); border-radius:20px; padding:7px 14px; font-size:13px; font-weight:600; cursor:pointer; color:var(--ink-soft); background:var(--white); }
  .radio-pill.selected{ background:var(--navy-wash); border-color:var(--navy-light); color:var(--navy); }
  .toast{
    position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--ink); color:white;
    padding:13px 22px; border-radius:12px; font-size:13.5px; font-weight:600; box-shadow:0 8px 24px rgba(0,0,0,0.2);
    z-index:600; display:flex; align-items:center; gap:10px; animation:toastIn .25s ease;
  }
  @keyframes toastIn{ from{ opacity:0; transform:translateX(-50%) translateY(10px);} to{ opacity:1; transform:translateX(-50%) translateY(0);} }

  /* Prontuário */
  .prontuario-header{ display:flex; align-items:center; gap:16px; margin-bottom:24px; }
  .back-btn{
    width:36px; height:36px; border-radius:10px; border:1px solid var(--line); background:var(--white);
    display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--ink-soft); flex-shrink:0;
  }
  .back-btn:hover{ border-color:var(--navy-light); color:var(--navy); }
  .prontuario-id{ display:flex; align-items:center; gap:14px; flex:1; }
  .prontuario-id .client-avatar{ width:48px; height:48px; font-size:17px; }
  .prontuario-id h1{ font-size:22px; }
  .prontuario-id p{ color:var(--ink-soft); font-size:13.5px; margin-top:2px; }

  .prontuario-grid{ display:grid; grid-template-columns:1fr 1.6fr; gap:18px; align-items:start; }
  .info-list{ display:flex; flex-direction:column; gap:14px; padding:20px; }
  .info-row{ display:flex; flex-direction:column; gap:3px; }
  .info-row .label{ font-size:11.5px; color:var(--ink-soft); text-transform:uppercase; letter-spacing:0.04em; }
  .info-row .val{ font-size:14px; font-weight:600; }

  /* Lista de sessões (registros estruturados) */
  .records-header{ display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; }
  .records-header h3{ font-size:15px; }
  .record-card{ background:var(--white); border:1px solid var(--line); border-radius:12px; padding:16px 18px; margin-bottom:12px; }
  .record-card:last-child{ margin-bottom:0; }
  .record-top{ display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
  .record-date{ font-family:'JetBrains Mono',monospace; font-weight:600; font-size:13.5px; color:var(--navy); }
  .record-field{ margin-bottom:9px; }
  .record-field:last-child{ margin-bottom:0; }
  .record-field .rf-label{ font-size:11px; text-transform:uppercase; letter-spacing:0.04em; color:var(--ink-soft); font-weight:700; margin-bottom:2px; }
  .record-field .rf-val{ font-size:13.5px; line-height:1.55; color:var(--ink); white-space:pre-wrap; }
  .records-empty{ font-size:13px; color:var(--ink-soft); text-align:center; padding:32px 20px; background:var(--paper-soft); border-radius:10px; border:1px dashed var(--line); }

  /* Formulário de nova sessão */
  .session-form-card{ padding:20px; margin-bottom:18px; border:1px solid var(--navy-light); }
  .session-form-card h3{ font-size:15px; margin-bottom:14px; }

  /* Pacotes de sessões */
  .packages-section{ margin-bottom:22px; }
  .package-card{
    background:var(--white); border:1px solid var(--line); border-radius:12px; padding:16px 18px; margin-bottom:10px;
  }
  .package-card.status-encerrado, .package-card.status-cancelado{ opacity:0.6; }
  .package-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:12px; }
  .package-name{ font-weight:700; font-size:14.5px; }
  .package-dates{ font-size:12px; color:var(--ink-soft); margin-top:2px; }
  .package-progress-track{ height:8px; background:var(--paper-soft); border-radius:6px; overflow:hidden; margin-bottom:8px; }
  .package-progress-fill{ height:100%; background:var(--navy-light); border-radius:6px; transition:width .3s ease; }
  .package-progress-fill.low{ background:var(--gold); }
  .package-progress-fill.critical{ background:var(--alert); }
  .package-meta{ display:flex; justify-content:space-between; align-items:center; font-size:12.5px; color:var(--ink-soft); }
  .package-actions{ display:flex; gap:8px; margin-top:12px; }

  /* Cartão de alerta de pacotes na Agenda */
  .package-alert-card{
    background:var(--alert-wash); border:1px solid var(--alert); border-radius:14px; padding:16px 20px; margin-bottom:20px;
  }
  .package-alert-header{ display:flex; align-items:center; gap:10px; margin-bottom:12px; color:var(--alert); font-weight:700; font-size:14px; }
  .package-alert-item{
    display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 0;
    border-top:1px solid rgba(181,101,74,0.2);
  }
  .package-alert-item .client-name{ font-weight:600; font-size:13.5px; }
  .package-alert-item .package-remaining{ font-size:12px; color:var(--alert); }

  /* Atestados */
  .certificate-editor-card{ max-width:760px; }
  .certificate-toolbar{ display:flex; justify-content:space-between; align-items:center; margin-bottom:18px; gap:12px; flex-wrap:wrap; }
  .certificate-paper{
    background:var(--white); border:1px solid var(--line); border-radius:14px; padding:50px 56px; min-height:500px;
  }
  .certificate-logo-area{ text-align:center; margin-bottom:24px; }
  .certificate-logo-area img{ max-height:64px; max-width:220px; object-fit:contain; }
  .certificate-issuer{ text-align:center; font-size:13px; color:var(--ink-soft); margin-bottom:36px; line-height:1.5; }
  .certificate-textarea{
    width:100%; min-height:320px; border:none; outline:none; resize:vertical; background:transparent;
    font-family:'Inter',sans-serif; font-size:14.5px; line-height:1.9; color:var(--ink);
  }
  .certificate-meta-fields{ display:flex; gap:16px; margin-bottom:18px; flex-wrap:wrap; }
  .certificate-meta-fields .field{ min-width:220px; flex:1; }

  /* Templates de mensagem */
  .template-textarea{
    width:100%; border:1px solid var(--line); border-radius:10px; padding:14px;
    font-size:13.5px; line-height:1.6; font-family:'Inter',sans-serif; resize:vertical; outline:none; background:var(--paper);
  }
  .template-textarea:focus{ border-color:var(--navy-light); background:var(--white); }
  .template-placeholder-list{ display:flex; gap:6px; flex-wrap:wrap; margin-top:10px; }
  .template-placeholder-chip{
    font-family:'JetBrains Mono',monospace; font-size:11px; padding:4px 9px; border-radius:6px;
    background:var(--navy-wash); color:var(--navy); cursor:pointer; border:none; transition:filter .15s;
  }
  .template-placeholder-chip:hover{ filter:brightness(0.95); }

  /* Tela de senha (gate) */
  .password-gate{ max-width:380px; margin:60px auto; text-align:center; }
  .password-gate .gate-icon{
    width:52px; height:52px; border-radius:14px; background:var(--navy-wash); color:var(--navy);
    display:flex; align-items:center; justify-content:center; margin:0 auto 18px;
  }
  .password-gate h2{ font-size:19px; margin-bottom:6px; }
  .password-gate p{ font-size:13.5px; color:var(--ink-soft); margin-bottom:22px; line-height:1.5; }
  .password-gate .field{ text-align:left; margin-bottom:14px; }
  .password-gate input{ text-align:center; letter-spacing:0.15em; font-size:16px; }
  .password-error{ font-size:12.5px; color:var(--alert); margin-top:-6px; margin-bottom:14px; min-height:16px; }

  /* Compilado geral */
  .compilado-client-block{ margin-bottom:28px; }
  .compilado-client-header{ display:flex; align-items:center; gap:12px; margin-bottom:12px; padding-bottom:10px; border-bottom:2px solid var(--line); }
  .compilado-client-header .client-name{ font-size:16px; }
  .compilado-empty{ font-size:13px; color:var(--ink-soft); padding:8px 0 0; }

  /* Contas a pagar */
  .bills-kpi-row{ display:grid; grid-template-columns:repeat(3,1fr); gap:16px; margin-bottom:24px; }
  .bill-row-icon{
    width:36px; height:36px; border-radius:10px; flex-shrink:0;
    display:flex; align-items:center; justify-content:center; background:var(--paper-soft); color:var(--ink-soft);
  }
  .pay-status.a-pagar{ background:var(--navy-wash); color:var(--navy); }
  .pay-status.atrasado{ background:var(--alert-wash); color:var(--alert); }
  .bill-fixed-tag{ display:inline-flex; align-items:center; gap:4px; font-size:11px; color:var(--ink-soft); }

  /* Configurações */
  .settings-card{ padding:22px 24px; margin-bottom:18px; max-width:560px; }
  .settings-card h3{ font-size:15px; margin-bottom:18px; }
  .settings-photo-row{ display:flex; align-items:center; gap:20px; }
  .settings-avatar-preview{
    width:72px; height:72px; border-radius:50%; flex-shrink:0; overflow:hidden;
    background:var(--sage-wash); color:var(--sage);
    display:flex; align-items:center; justify-content:center;
    font-family:'Outfit',sans-serif; font-weight:700; font-size:24px;
  }
  .settings-avatar-preview img{ width:100%; height:100%; object-fit:cover; }
  .settings-photo-actions{ display:flex; flex-direction:column; align-items:flex-start; gap:8px; }
  .settings-hint{ font-size:12px; color:var(--ink-soft); margin-top:2px; }
  .settings-footer{ display:flex; justify-content:space-between; align-items:center; margin-top:18px; }

  /* Layout de Configurações com sub-navegação */
  .settings-layout{ display:flex; gap:28px; align-items:flex-start; }
  .settings-nav{ display:flex; flex-direction:column; gap:2px; width:190px; flex-shrink:0; }
  .settings-nav-item{
    text-align:left; padding:9px 12px; border-radius:9px; border:none; background:none;
    font-size:13.5px; font-weight:600; color:var(--ink-soft); cursor:pointer; transition:background .15s, color .15s;
  }
  .settings-nav-item:hover{ background:var(--paper-soft); color:var(--ink); }
  .settings-nav-item.active{ background:var(--navy-wash); color:var(--navy); }
  .settings-content{ flex:1; min-width:0; }
  .settings-tab-panel{ animation:fadeIn .2s ease; }

  /* Seletor visual de tema */
  .theme-options{ display:flex; gap:14px; flex-wrap:wrap; }
  .theme-option{ cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:8px; }
  .theme-preview{
    width:110px; height:74px; border-radius:10px; border:2px solid var(--line);
    padding:10px; display:flex; flex-direction:column; gap:8px; transition:border-color .15s; position:relative; overflow:hidden;
  }
  .theme-option.selected .theme-preview{ border-color:var(--navy); }
  .theme-preview-light{ background:#F7F8FA; }
  .theme-preview-light .tp-bar{ background:#E4EBF5; }
  .theme-preview-light .tp-dot{ background:#2B4C7E; }
  .theme-preview-dark{ background:#15191F; }
  .theme-preview-dark .tp-bar{ background:#26334A; }
  .theme-preview-dark .tp-dot{ background:#7FA3DC; }
  .theme-preview-system{ background:linear-gradient(135deg, #F7F8FA 50%, #15191F 50%); }
  .theme-preview-system .tp-bar{ background:linear-gradient(90deg, #E4EBF5 50%, #26334A 50%); }
  .theme-preview-system .tp-dot{ background:linear-gradient(90deg, #2B4C7E 50%, #7FA3DC 50%); }
  .tp-bar{ width:60%; height:8px; border-radius:4px; }
  .tp-dot{ width:22px; height:22px; border-radius:50%; }
  .theme-option-label{ font-size:13px; font-weight:600; color:var(--ink-soft); }
  .theme-option.selected .theme-option-label{ color:var(--navy); }

  /* Toggle / switch */
  .toggle-row{ display:flex; justify-content:space-between; align-items:center; padding:14px 0; border-bottom:1px solid var(--paper-soft); gap:16px; }
  .toggle-row-title{ font-size:14px; font-weight:600; }
  .toggle-row-desc{ font-size:12.5px; color:var(--ink-soft); margin-top:2px; }
  .switch{ position:relative; display:inline-block; width:42px; height:24px; flex-shrink:0; }
  .switch input{ opacity:0; width:0; height:0; }
  .switch-track{
    position:absolute; cursor:pointer; inset:0; background:var(--line); border-radius:24px; transition:background .2s;
  }
  .switch-track::before{
    content:''; position:absolute; height:18px; width:18px; left:3px; bottom:3px; background:white; border-radius:50%; transition:transform .2s;
    box-shadow:0 1px 3px rgba(0,0,0,0.2);
  }
  .switch input:checked + .switch-track{ background:var(--navy); }
  .switch input:checked + .switch-track::before{ transform:translateX(18px); }

  @media (max-width: 720px){
    .settings-layout{ flex-direction:column; }
    .settings-nav{ flex-direction:row; flex-wrap:wrap; width:100%; }
  }

  /* Modal de cobrança */
  .charge-preview{
    background:var(--paper-soft); border:1px solid var(--line); border-radius:12px; padding:16px;
    font-size:13.5px; line-height:1.65; white-space:pre-wrap; color:var(--ink);
  }
  .charge-actions{ display:flex; gap:10px; }
  .charge-actions .btn{ flex:1; justify-content:center; }
  .btn-whatsapp{ background:#25D366; color:white; }
  .btn-whatsapp:hover{ background:#1FB855; }

  ::-webkit-scrollbar{ width:8px; height:8px; }
  ::-webkit-scrollbar-thumb{ background:var(--line); border-radius:4px; }

  /* ---------- Mobile: barra superior + menu deslizante ---------- */
  .mobile-topbar{ display:none; }
  .mobile-menu-overlay{ display:none; }

  @media (max-width: 980px){
    .clients-grid{ grid-template-columns:repeat(2,1fr); }
    .kpi-row{ grid-template-columns:repeat(2,1fr); }
    .fin-summary{ grid-template-columns:1fr; }
  }
  @media (max-width: 720px){
    body{ padding-top:56px; }

    .mobile-topbar{
      display:flex; align-items:center; justify-content:space-between; gap:12px;
      position:fixed; top:0; left:0; right:0; height:56px; z-index:300;
      background:var(--white); border-bottom:1px solid var(--line); padding:0 14px;
    }
    .mobile-topbar .brand{ padding:0; }
    .mobile-topbar .brand-mark{ width:30px; height:30px; font-size:15px; }
    .mobile-topbar .brand-name{ font-size:15px; }
    .mobile-menu-btn{
      width:38px; height:38px; border-radius:9px; border:1px solid var(--line); background:var(--white);
      display:flex; align-items:center; justify-content:center; color:var(--ink); cursor:pointer; flex-shrink:0;
    }
    .mobile-menu-btn:active{ background:var(--paper-soft); }

    .mobile-menu-overlay{
      display:block; position:fixed; inset:0; background:rgba(28,36,51,0.45); z-index:399;
      opacity:0; pointer-events:none; transition:opacity .2s ease;
    }
    .mobile-menu-overlay.open{ opacity:1; pointer-events:auto; }

    .sidebar{
      display:flex; position:fixed; top:0; left:0; bottom:0; height:100vh; z-index:400;
      width:78vw; max-width:300px; box-shadow:0 0 30px rgba(0,0,0,0.18);
      transform:translateX(-100%); transition:transform .25s ease;
    }
    .sidebar.open{ transform:translateX(0); }
    .sidebar .daypart{ display:none; } /* já mostrado na topbar, evita repetição */

    main{ padding:20px; }
    .clients-grid{ grid-template-columns:1fr; }
    .kpi-row{ grid-template-columns:1fr 1fr; }
    .field-row{ grid-template-columns:1fr; }
    .prontuario-grid{ grid-template-columns:1fr; }
  }

  /* Botão de ícone genérico (usado no logout, imprimir sessão, etc) */
  .btn-icon{
    width:30px; height:30px; border-radius:8px; border:1px solid var(--line); background:var(--white);
    display:flex; align-items:center; justify-content:center; color:var(--ink-soft); cursor:pointer; flex-shrink:0;
  }
  .btn-icon:hover{ border-color:var(--navy-light); color:var(--navy); background:var(--paper-soft); }

  /* Impressão */
  .print-icon-btn{
    width:26px; height:26px; border-radius:7px; border:1px solid var(--line); background:var(--white);
    display:flex; align-items:center; justify-content:center; color:var(--ink-soft); cursor:pointer; flex-shrink:0;
  }
  .print-icon-btn:hover{ border-color:var(--navy-light); color:var(--navy); }
  .print-only{ display:none; }
  .print-header{ margin-bottom:20px; }
  .print-header h1{ font-size:22px; margin-bottom:4px; }
  .print-header p{ font-size:12px; color:var(--ink-soft); }

  @media print{
    body *{ visibility:hidden; }
    #print-area, #print-area *,
    #printable-prontuario, #printable-prontuario *,
    #printable-certificate, #printable-certificate *{ visibility:visible; }
    #print-area{ display:block; position:absolute; left:0; top:0; width:100%; padding:24px; }
    #printable-prontuario{ position:absolute; left:0; top:0; width:100%; padding:24px; }
    #printable-certificate{ position:absolute; left:0; top:0; width:100%; padding:24px; }
    .no-print{ display:none !important; }
    .print-only{ display:block !important; }
    .card{ box-shadow:none; border:1px solid #ccc; break-inside:avoid; }
    .record-card{ break-inside:avoid; }
    [data-theme="dark"]{ --paper:#fff; --paper-soft:#fff; --ink:#000; --ink-soft:#333; --line:#ccc; --white:#fff; }
  }
