/* Dark mode premium — limitado à autenticação, aplicação e modais. */
.theme-dark :is(.auth-view, .app, dialog) {
  --color-background: #071b18;
  --color-surface: #0d2924;
  --color-surface-subtle: #0a2420;
  --color-surface-raised: #12342e;
  --color-text-primary: #eef7f5;
  --color-text-secondary: #b7c9c5;
  --color-border: #294a43;
  --color-border-strong: #3a6259;
  --color-primary: #61c4b5;
  --color-primary-hover: #79d0c3;
  --color-primary-active: #4aae9f;
  --color-mint: #153b34;
  --color-soft-mint: #0a2420;
  --color-focus: rgba(97, 196, 181, .26);
  --color-success: #73d3c2;
  --color-success-surface: #153b34;
  --color-warning: #f2bd7d;
  --color-warning-surface: #3c2c1e;
  --color-danger: #ff9a83;
  --color-danger-surface: #432820;
  --color-info: #8cc6d8;
  --color-info-surface: #183641;
  --color-overlay: rgba(2, 12, 10, .78);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .24);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, .3);
  --shadow-lg: 0 30px 78px rgba(0, 0, 0, .46);
}

/* Login */
.theme-dark .auth-view {
  background: #071b18;
}

.theme-dark .auth-brand {
  border-right: 1px solid rgba(97, 196, 181, .12);
  background:
    radial-gradient(circle at 18% 82%, rgba(242, 163, 111, .055), transparent 25%),
    linear-gradient(148deg, #071b18 0%, #0b2c27 58%, #103c36 100%);
}

.theme-dark .auth-brand::before {
  background: radial-gradient(circle, rgba(97, 196, 181, .1), rgba(97, 196, 181, 0) 68%);
}

.theme-dark .auth-brand::after {
  border-top-color: rgba(97, 196, 181, .15);
}

.theme-dark .auth-brand .brand-copy p {
  color: rgba(238, 247, 245, .72);
}

.theme-dark .auth-panel {
  border-left: 1px solid rgba(97, 196, 181, .08);
  background:
    radial-gradient(circle at 96% 4%, rgba(97, 196, 181, .045), transparent 30%),
    linear-gradient(145deg, #09211d, #071b18 72%);
  box-shadow: inset 24px 0 54px rgba(0, 0, 0, .08);
}

.theme-dark .auth-panel::before {
  background: rgba(97, 196, 181, .18);
  opacity: .2;
  filter: blur(12px);
}

.theme-dark .auth-form h2 {
  color: #eef7f5;
}

.theme-dark .auth-form > .muted,
.theme-dark .auth-switch {
  color: #b7c9c5;
}

.theme-dark .auth-form label {
  color: #dce9e6;
}

.theme-dark .auth-form input {
  border-color: #31534b;
  background: #0d2924;
  color: #eef7f5;
  caret-color: #61c4b5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .018), 0 1px 2px rgba(0, 0, 0, .2);
}

.theme-dark .auth-form input::placeholder {
  color: #849c96;
  opacity: 1;
}

.theme-dark .auth-form input:hover {
  border-color: #466e65;
  background: #102f2a;
}

.theme-dark .auth-form input:focus,
.theme-dark .auth-form input:focus-visible {
  border-color: #61c4b5;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(97, 196, 181, .2), 0 8px 24px rgba(0, 0, 0, .16);
}

.theme-dark .auth-form input:user-invalid,
.theme-dark .auth-form input[aria-invalid="true"] {
  border-color: #ff9a83;
  background: #241f1b;
  box-shadow: 0 0 0 3px rgba(255, 154, 131, .14);
}

.theme-dark .auth-form input:-webkit-autofill,
.theme-dark .auth-form input:-webkit-autofill:hover,
.theme-dark .auth-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: #eef7f5;
  box-shadow: 0 0 0 1000px #0d2924 inset;
  caret-color: #61c4b5;
}

.theme-dark .auth-form .btn.primary,
.theme-dark dialog .btn.primary,
.theme-dark .app .btn.primary {
  border-color: #238b80;
  background: linear-gradient(135deg, #187a71, #12645e);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .24), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.theme-dark .auth-form .btn.primary:hover,
.theme-dark dialog .btn.primary:hover,
.theme-dark .app .btn.primary:hover {
  border-color: #38a396;
  background: linear-gradient(135deg, #1b8479, #176f68);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .1);
}

.theme-dark .auth-form .btn.primary:focus-visible,
.theme-dark dialog .btn.primary:focus-visible,
.theme-dark .app .btn.primary:focus-visible {
  outline-color: rgba(97, 196, 181, .42);
}

.theme-dark .auth-form .btn.primary:disabled,
.theme-dark dialog .btn.primary:disabled,
.theme-dark .app .btn.primary:disabled {
  border-color: #31534b;
  background: #24433d;
  color: #9eb3ae;
  box-shadow: none;
}

.theme-dark .auth-switch button,
.theme-dark .checkout-back,
.theme-dark .checkout-step {
  color: #61c4b5;
}

.theme-dark .plan-card {
  border-color: #315b52;
  background: #0d2d28;
  box-shadow: var(--shadow-xs);
}

.theme-dark .prototype-payment {
  border-color: #60442f;
  background: #33261d;
  color: #f2c49c;
}

/* Canvas e shell autenticado */
.theme-dark .app,
.theme-dark .app > main {
  background-color: #071b18;
}

.theme-dark .app > main {
  background-image:
    radial-gradient(circle at 94% 3%, rgba(97, 196, 181, .045), transparent 24%),
    radial-gradient(circle at 8% 96%, rgba(16, 60, 54, .26), transparent 22%);
}

.theme-dark .app .sidebar {
  border-color: #294a43;
  background: #0b2622;
  box-shadow: 8px 0 26px rgba(0, 0, 0, .12);
}

.theme-dark .app .sidebar::before {
  background: linear-gradient(90deg, #61c4b5, rgba(97, 196, 181, 0) 78%);
  opacity: .72;
}

.theme-dark .app .sidebar > .logo,
.theme-dark .app .topbar h2 {
  color: #eef7f5;
}

.theme-dark .app .sidebar-tip {
  border-color: #2c4d46;
  background: #0f302a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .018);
}

.theme-dark .app .sidebar-tip > span {
  background: #3c2c1e;
  color: #f2ae78;
}

.theme-dark .app .sidebar nav button {
  color: #aebfbb;
}

.theme-dark .app .sidebar nav button:is(:hover, .active) {
  background: #153b34;
  color: #73d3c2;
}

.theme-dark .app .sidebar nav button:focus-visible {
  outline-color: rgba(97, 196, 181, .38);
}

.theme-dark .app .profile-mini {
  border-color: #31534b;
  background: #0f302a;
  box-shadow: var(--shadow-xs);
}

.theme-dark .app .profile-mini > span:first-child {
  background: #18433b;
  color: #73d3c2;
}

.theme-dark .app .topbar {
  border-bottom-color: #294a43;
  background: rgba(9, 31, 27, .94);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .12);
}

.theme-dark .app.personal-mode .topbar,
.theme-dark .app.business-mode .topbar {
  border-top-color: #4fb4a6;
}

.theme-dark .app .icon-btn,
.theme-dark .app .month-picker,
.theme-dark .app .report-period {
  border-color: #31534b;
  background: #0f302a;
  color: #b7c9c5;
  box-shadow: var(--shadow-xs);
}

.theme-dark .app .icon-btn:is(:hover, :focus-visible) {
  border-color: #4b746a;
  background: #18433b;
  color: #73d3c2;
}

.theme-dark .app .profile-switcher {
  border-color: #31534b;
  background: #09211d;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .24);
}

.theme-dark .app .profile-switcher::before {
  border-color: #3a6259;
  background: #143731;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .025);
}

.theme-dark .app .profile-switcher button {
  background: transparent;
  color: #9fb4af;
}

.theme-dark .app .profile-switcher button.active,
.theme-dark .app.business-mode .profile-switcher button.active {
  background: transparent;
  color: #73d3c2;
}

.theme-dark .app .alerts-badge {
  border-color: #0f302a;
  background: #f08a74;
  color: #151d1b;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .28);
}

.theme-dark .app .alerts-panel,
.theme-dark .app .alerts-head {
  border-color: #31534b;
  background: #12342e;
}

.theme-dark .app .alerts-panel {
  box-shadow: var(--shadow-lg);
}

.theme-dark .app .alert-item {
  border-color: #294a43;
  color: #eef7f5;
}

.theme-dark .app .alert-item:hover {
  background: #173c35;
}

/* Superfícies financeiras */
.theme-dark .app #page-dashboard > .stats-grid .stat-card:not(.balance),
.theme-dark .app #page-dashboard .dashboard-grid > .panel {
  border-color: #31534b;
  background: #0d2924;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}

.theme-dark .app.personal-mode #page-dashboard > .stats-grid .stat-card.balance {
  background: linear-gradient(140deg, #197f75, #0e5b54);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .24);
}

.theme-dark .app.business-mode #page-dashboard > .stats-grid .stat-card:nth-child(2) {
  background: linear-gradient(140deg, #238f84, #176f68);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .24);
}

.theme-dark .app.business-mode #page-dashboard > .stats-grid .stat-card:nth-child(4) {
  border-color: #60423a;
}

.theme-dark .app #page-dashboard .stat-head i,
.theme-dark .app #page-dashboard .transaction-icon {
  background: #143731;
}

.theme-dark .app #page-dashboard > .clara-insight {
  border-color: #31534b;
  background: linear-gradient(105deg, #12342e, #0d2924);
  box-shadow: var(--shadow-xs);
}

.theme-dark .app #page-dashboard .pie-legend span,
.theme-dark .app.business-mode #page-dashboard #recent-list .transaction-row {
  border-color: #294a43;
  background: #0a2420;
}

.theme-dark .app #page-dashboard .goal-ring circle {
  stroke: #24443d;
}

.theme-dark .app #page-dashboard .goal-ring circle + circle {
  stroke: #53b9aa;
}

.theme-dark .app #page-dashboard .bar {
  background: #193832;
}

.theme-dark .app #page-dashboard canvas {
  filter: saturate(.86) brightness(.98);
}

.theme-dark .app #page-dashboard .dashboard-grid .empty {
  border-color: #3a6259;
  background: linear-gradient(145deg, #0a2420, #0d2924);
}

.theme-dark .app #page-dashboard > .dashboard-first-action {
  border-color: #31534b;
  background:
    radial-gradient(circle at 88% 20%, rgba(21, 59, 52, .72), transparent 29%),
    linear-gradient(135deg, #0d2924, #071b18);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .14);
}

.theme-dark .app #page-dashboard > .dashboard-first-action::after {
  border-color: rgba(97, 196, 181, .1);
}

/* Estados de interação */
@media (hover: hover) and (pointer: fine) {
  .theme-dark .app #page-dashboard > .stats-grid .stat-card:hover,
  .theme-dark .app #page-dashboard .dashboard-grid > .panel:hover {
    border-color: #476f66;
    box-shadow: 0 14px 32px rgba(0, 0, 0, .22);
  }

  .theme-dark .app.business-mode #page-dashboard #recent-list .transaction-row:hover {
    border-color: #3f6b61;
    background: #12342e;
  }
}

/* Modais e formulários autenticados */
.theme-dark dialog {
  border-color: #3a6259;
  background: #12342e;
  color: #eef7f5;
  box-shadow: 0 30px 78px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .025);
}

.theme-dark dialog::backdrop {
  background: rgba(2, 12, 10, .78);
  backdrop-filter: blur(5px);
}

.theme-dark dialog .modal-head {
  border-bottom-color: #294a43;
}

.theme-dark dialog .modal-head h2 {
  color: #eef7f5;
}

.theme-dark dialog .modal-head p,
.theme-dark dialog label {
  color: #b7c9c5;
}

.theme-dark dialog .modal-head button {
  border-radius: var(--radius-sm);
  color: #9fb4af;
}

.theme-dark dialog .modal-head button:is(:hover, :focus-visible) {
  background: #193f38;
  color: #eef7f5;
}

.theme-dark dialog :is(input, select, textarea),
.theme-dark .app :is(.settings-form, .filters, .payment-history-filters) :is(input, select, textarea) {
  border-color: #31534b;
  background: #0a2420;
  color: #eef7f5;
  caret-color: #61c4b5;
}

.theme-dark dialog :is(input, textarea)::placeholder,
.theme-dark .app :is(input, textarea)::placeholder {
  color: #849c96;
  opacity: 1;
}

.theme-dark dialog :is(input, select, textarea):hover,
.theme-dark .app :is(.settings-form, .filters, .payment-history-filters) :is(input, select, textarea):hover {
  border-color: #466e65;
  background: #0f302a;
}

.theme-dark dialog :is(input, select, textarea):focus,
.theme-dark dialog :is(input, select, textarea):focus-visible,
.theme-dark .app :is(.settings-form, .filters, .payment-history-filters) :is(input, select, textarea):focus-visible {
  border-color: #61c4b5;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(97, 196, 181, .2);
}

.theme-dark dialog :is(input, select, textarea):user-invalid,
.theme-dark dialog :is(input, select, textarea)[aria-invalid="true"] {
  border-color: #ff9a83;
  background: #241f1b;
  box-shadow: 0 0 0 3px rgba(255, 154, 131, .14);
}

.theme-dark dialog .type-toggle {
  border: 1px solid #294a43;
  background: #09211d;
}

.theme-dark dialog .type-toggle input:checked + span {
  background: #173c35;
  color: #73d3c2;
  box-shadow: var(--shadow-xs);
}

.theme-dark dialog .btn.outline,
.theme-dark .app .btn.outline {
  border-color: #3a6259;
  background: #0f302a;
  color: #dce9e6;
}

.theme-dark dialog .btn.outline:hover,
.theme-dark .app .btn.outline:hover {
  border-color: #527c72;
  background: #173c35;
}

/* Badges e feedback */
.theme-dark :is(.app, dialog) :is(.badge--success, .bill-status.paid, .fixed-state.paid) {
  background: #153b34;
  color: #73d3c2;
}

.theme-dark :is(.app, dialog) :is(.badge--warning, .fixed-state.pending) {
  background: #3c2c1e;
  color: #f2bd7d;
}

.theme-dark :is(.app, dialog) :is(.badge--danger, .bill-status.overdue, .fixed-state.overdue) {
  background: #432820;
  color: #ff9a83;
}

.theme-dark :is(.app, dialog) :is(.badge--info, .detail-kind) {
  background: #183641;
  color: #8cc6d8;
}

.theme-dark #toast {
  border: 1px solid #3a6259;
  border-left: 3px solid #f2ae78;
  background: #173c35;
  color: #eef7f5;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .38);
}

@media (max-width: 1024px) {
  .theme-dark .app .sidebar {
    border-top-color: #31534b;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .26);
  }
}
