/* Tema e menu de perfil */
:root{
  color-scheme:light;
  --theme-surface:#ffffff;
  --theme-surface-soft:#f8fbff;
  --theme-elevated:#ffffff;
  --theme-input:#ffffff;
  --theme-overlay:rgba(2,14,29,.48);
  --theme-shadow:0 18px 45px rgba(7,21,44,.12);
}

html[data-theme="dark"]{
  color-scheme:dark;
  --bg:#07111f;
  --panel:#0d1828;
  --ink:#eef4fb;
  --muted:#98a8bc;
  --line:#26354a;
  --line-soft:#1b293b;
  --soft:#102a43;
  --brand:#3b82f6;
  --brand2:#22d3ee;
  --green:#34d399;
  --green-soft:#0d2d26;
  --amber:#fbbf24;
  --amber-soft:#33250c;
  --red:#fb7185;
  --red-soft:#381725;
  --side:#040b14;
  --side2:#081425;
  --theme-surface:#0d1828;
  --theme-surface-soft:#101d2e;
  --theme-elevated:#111f31;
  --theme-input:#111f31;
  --theme-overlay:rgba(0,5,12,.72);
  --theme-shadow:0 22px 60px rgba(0,0,0,.34);
}

body,.topbar,.card,.panel,.toolbar,.date-badge,.access-box,.period-field select,.period-field input,.access-row input,.manual-card,.manual-field input,.manual-field select,.profile-trigger,.profile-dropdown,.theme-options{
  transition:background-color .22s ease,border-color .22s ease,color .22s ease,box-shadow .22s ease;
}

.topbar-actions{display:flex;align-items:flex-end;justify-content:flex-end;gap:12px;min-width:0}
.profile-menu{position:relative;flex:0 0 auto}
.profile-trigger{height:44px;display:flex;align-items:center;gap:10px;padding:5px 9px 5px 6px;border:1px solid var(--line);border-radius:14px;background:var(--theme-surface);color:var(--ink);cursor:pointer;box-shadow:0 5px 16px rgba(7,21,44,.04)}
.profile-trigger:hover{border-color:#a9c6df;box-shadow:0 8px 22px rgba(7,21,44,.08)}
.profile-trigger[aria-expanded="true"]{border-color:#7ebce0;box-shadow:0 0 0 3px rgba(32,199,242,.12)}
.profile-avatar{width:32px;height:32px;display:grid;place-items:center;border-radius:10px;background:linear-gradient(135deg,var(--brand),var(--brand2));color:#fff;font-family:var(--font-title);font-size:13px;font-weight:700;box-shadow:0 7px 16px rgba(14,59,125,.2)}
.profile-copy{display:grid;gap:1px;min-width:112px;text-align:left}
.profile-copy strong{font-family:var(--font-title);font-size:12px;font-weight:700;line-height:1.25;color:var(--ink)}
.profile-copy small{font-size:10px;font-weight:400;line-height:1.25;color:var(--muted)}
.profile-chevron{width:16px;height:16px;color:var(--muted);transition:transform .2s ease}
.profile-trigger[aria-expanded="true"] .profile-chevron{transform:rotate(180deg)}
.profile-dropdown{position:absolute;top:calc(100% + 10px);right:0;z-index:80;width:300px;padding:12px;border:1px solid var(--line);border-radius:18px;background:var(--theme-elevated);color:var(--ink);box-shadow:var(--theme-shadow)}
.profile-dropdown[hidden]{display:none}
.profile-summary{display:flex;align-items:center;gap:11px;padding:7px}
.profile-summary .profile-avatar{width:38px;height:38px;border-radius:12px;font-size:14px}
.profile-summary strong{display:block;font-family:var(--font-title);font-size:13px;font-weight:700;color:var(--ink)}
.profile-summary small{display:block;margin-top:2px;font-size:10.5px;color:var(--muted)}
.profile-divider{height:1px;margin:10px 2px;background:var(--line-soft)}
.theme-label{display:block;margin:0 5px 8px;color:var(--muted);font-size:9.5px;font-weight:700;text-transform:uppercase;letter-spacing:.08em}
.theme-options{display:grid;grid-template-columns:1fr 1fr;gap:7px;padding:5px;border:1px solid var(--line);border-radius:13px;background:var(--theme-surface-soft)}
.theme-option{min-height:38px;display:flex;align-items:center;justify-content:center;gap:7px;border:0;border-radius:9px;background:transparent;color:var(--muted);font-size:11px;font-weight:600;cursor:pointer}
.theme-option svg{width:16px;height:16px}
.theme-option.active{background:var(--theme-surface);color:var(--ink);box-shadow:0 4px 12px rgba(7,21,44,.1)}
.profile-foot{padding:10px 6px 3px;color:var(--muted);font-size:10px;line-height:1.45}

html[data-theme="dark"] body{background:linear-gradient(180deg,#091525,var(--bg));color:var(--ink)}
html[data-theme="dark"] .topbar{border-bottom-color:rgba(38,53,74,.92);background:rgba(7,17,31,.92)}
html[data-theme="dark"] .sidebar{background:radial-gradient(circle at 15% 0%,rgba(34,211,238,.13),transparent 28%),linear-gradient(180deg,var(--side),var(--side2))}
html[data-theme="dark"] .card{border-color:var(--line);background:linear-gradient(180deg,#111f31,#0d1828);box-shadow:0 15px 35px rgba(0,0,0,.22)}
html[data-theme="dark"] .panel,html[data-theme="dark"] .toolbar{border-color:var(--line);background:var(--panel);box-shadow:0 18px 42px rgba(0,0,0,.2)}
html[data-theme="dark"] .date-badge,html[data-theme="dark"] .period-field select,html[data-theme="dark"] .period-field input,html[data-theme="dark"] .access-row input{border-color:var(--line);background:var(--theme-input);color:var(--ink)}
html[data-theme="dark"] .period-field select{color-scheme:dark}
html[data-theme="dark"] .access-box{border-color:var(--line);background:linear-gradient(180deg,#111f31,#0d1828)}
html[data-theme="dark"] .notice{border-color:#1c4b69;background:linear-gradient(135deg,#0d263a,#102e45);color:#b9e4ff}
html[data-theme="dark"] .pill.blue{border-color:#214f70;background:#102d46;color:#a9dcff}
html[data-theme="dark"] .pill.green{background:var(--green-soft);color:#72e5bd}
html[data-theme="dark"] .pill.amber{background:var(--amber-soft);color:#ffd66b}
html[data-theme="dark"] .pill.red{background:var(--red-soft);color:#ff9aac}
html[data-theme="dark"] .success{border-color:#1b5d4a;background:var(--green-soft);color:#76e6c0}
html[data-theme="dark"] .danger{border-color:#6b2638;background:var(--red-soft);color:#ff9caf}
html[data-theme="dark"] .soft{border-color:#225477;background:#102d46;color:#b9e4ff}
html[data-theme="dark"] th{color:#8394aa}
html[data-theme="dark"] td{border-top-color:var(--line-soft);color:#c5d1df}
html[data-theme="dark"] .contact,html[data-theme="dark"] .amount{color:#f3f7fb}
html[data-theme="dark"] .foot{border-top-color:var(--line-soft)}
html[data-theme="dark"] .manual-modal{background:var(--theme-overlay)!important}
html[data-theme="dark"] .manual-card{border-color:var(--line)!important;background:var(--panel)!important;box-shadow:0 28px 90px rgba(0,0,0,.48)!important}
html[data-theme="dark"] .manual-head,html[data-theme="dark"] .manual-actions{border-color:var(--line-soft)!important}
html[data-theme="dark"] .manual-head h2,html[data-theme="dark"] .manual-field input,html[data-theme="dark"] .manual-field select{color:var(--ink)!important}
html[data-theme="dark"] .manual-field input,html[data-theme="dark"] .manual-field select{border-color:var(--line)!important;background:var(--theme-input)!important}
html[data-theme="dark"] .manual-close{background:#17263a!important;color:var(--ink)!important}
html[data-theme="dark"] .profile-trigger:hover{border-color:#3d5874;box-shadow:0 8px 22px rgba(0,0,0,.22)}
html[data-theme="dark"] .theme-option.active{background:#18273a;box-shadow:0 4px 12px rgba(0,0,0,.24)}
html[data-theme="dark"] input::placeholder{color:#72839a}
html[data-theme="dark"] ::selection{background:#1d5f89;color:#fff}

@media(max-width:1050px){
  .topbar-actions{align-items:flex-start;justify-content:space-between}
  .profile-menu{margin-left:auto}
}
@media(max-width:700px){
  .topbar-actions{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;width:100%}
  .period-control{min-width:0}
  .profile-copy{display:none}
  .profile-trigger{width:44px;padding:5px;justify-content:center}
  .profile-chevron{display:none}
  .profile-dropdown{position:fixed;top:74px;right:14px;left:14px;width:auto}
}
@media(max-width:560px){
  .topbar-actions{grid-template-columns:1fr auto}
  .profile-menu{align-self:end}
}
