/* Gestão Engevalli V5.8 — temas claro/escuro globais */
:root{
  --theme-page:#f6f7fb;
  --theme-surface:#ffffff;
  --theme-surface-2:#f8f9fb;
  --theme-surface-3:#eef1f5;
  --theme-border:#e6e8ee;
  --theme-text:#202630;
  --theme-muted:#778190;
  --theme-input:#ffffff;
  --theme-hover:#f5f7fa;
  --theme-shadow:0 8px 24px rgba(25,31,45,.07);
  --theme-calendar-grid:#e8eaed;
}
html[data-theme="dark"]{
  --theme-page:#0d1117;
  --theme-surface:#161b22;
  --theme-surface-2:#1b2129;
  --theme-surface-3:#232a34;
  --theme-border:#2b3440;
  --theme-text:#edf2f7;
  --theme-muted:#9aa6b5;
  --theme-input:#11161d;
  --theme-hover:#202731;
  --theme-shadow:0 10px 30px rgba(0,0,0,.24);
  --theme-calendar-grid:#2a313b;
  --ev-bg:var(--theme-page);
  --ev-surface:var(--theme-surface);
  --ev-surface-soft:var(--theme-surface-2);
  --ev-border:var(--theme-border);
  --ev-text:var(--theme-text);
  --ev-muted:var(--theme-muted);
  --ev-shadow:var(--theme-shadow);
  --ev-shadow-hover:0 15px 38px rgba(0,0,0,.34);
  --bs-body-color:var(--theme-text);
  --bs-body-bg:var(--theme-page);
  --bs-border-color:var(--theme-border);
  --bs-secondary-color:var(--theme-muted);
  --bs-tertiary-bg:var(--theme-surface-2);
  color-scheme:dark;
}
html[data-theme="light"]{color-scheme:light}

.theme-toggle{position:relative;overflow:hidden}
.theme-toggle i{transition:transform .2s ease,opacity .2s ease}
.theme-toggle:hover i{transform:rotate(10deg) scale(1.06)}
.theme-floating-toggle{position:fixed;right:18px;top:18px;z-index:3000;width:44px;height:44px;border:1px solid var(--theme-border);border-radius:12px;background:var(--theme-surface);color:var(--theme-text);display:grid;place-items:center;box-shadow:var(--theme-shadow);cursor:pointer}

/* Base administrativa */
html[data-theme="dark"] body,
html[data-theme="dark"] body.bg-slate-50{background:var(--theme-page)!important;color:var(--theme-text)!important}
html[data-theme="dark"] .main{background:var(--theme-page)!important}
html[data-theme="dark"] .topbar{background:rgba(13,17,23,.94)!important;border-color:var(--theme-border)!important;box-shadow:0 1px 0 rgba(255,255,255,.02)}
html[data-theme="dark"] .topbar h1,
html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6{color:var(--theme-text)}
html[data-theme="dark"] .breadcrumb-mini,
html[data-theme="dark"] .page-subtitle,
html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] .table-sub,
html[data-theme="dark"] .project-meta,
html[data-theme="dark"] .small-muted{color:var(--theme-muted)!important}
html[data-theme="dark"] .top-search,
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .profile-btn,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .section-head,
html[data-theme="dark"] .card,
html[data-theme="dark"] .module-card,
html[data-theme="dark"] .workspace-card,
html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .action-tile,
html[data-theme="dark"] .project-card,
html[data-theme="dark"] .agenda-summary-card,
html[data-theme="dark"] .tabs-clean,
html[data-theme="dark"] .agenda-week-shell,
html[data-theme="dark"] .gantt-wrap{background:var(--theme-surface)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:var(--theme-shadow)}
html[data-theme="dark"] .top-search input{color:var(--theme-text)!important}
html[data-theme="dark"] .top-search input::placeholder{color:#7f8a99}
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .profile-btn{color:#cbd4df}
html[data-theme="dark"] .icon-btn:hover,
html[data-theme="dark"] .profile-btn:hover,
html[data-theme="dark"] .dropdown-item:hover{background:var(--theme-hover)!important;color:#fff}
html[data-theme="dark"] .notif-dot{border-color:var(--theme-surface)}
html[data-theme="dark"] .dropdown-item{color:var(--theme-text)}
html[data-theme="dark"] .card-header{background:var(--theme-surface)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important}
html[data-theme="dark"] .card:hover{border-color:#3b4654}

/* Formulários */
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .form-check-label{color:#bdc7d3}
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{background-color:var(--theme-input);border-color:#35404d;color:var(--theme-text)}
html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{color:#74808f}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus{background:var(--theme-input);color:var(--theme-text);border-color:#d3a900;box-shadow:0 0 0 3px rgba(255,193,7,.14)}
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus{-webkit-text-fill-color:var(--theme-text);-webkit-box-shadow:0 0 0 1000px var(--theme-input) inset;transition:background-color 9999s ease-out 0s}

/* Botões e tabelas */
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-dark,
html[data-theme="dark"] .btn-outline-success{background:var(--theme-surface-2);color:#d7dee8;border-color:#3b4654}
html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-dark:hover{background:#262e39;color:#fff}
html[data-theme="dark"] .table{background:var(--theme-surface)!important;color:var(--theme-text)!important}
html[data-theme="dark"] .table thead th{background:#1c222b!important;color:#aeb9c7!important;border-color:var(--theme-border)!important}
html[data-theme="dark"] .table tbody td{background:var(--theme-surface)!important;border-color:#262f3a!important;color:var(--theme-text)!important}
html[data-theme="dark"] .table tbody tr:hover td{background:#1d242d!important}
html[data-theme="dark"] .table-title,
html[data-theme="dark"] .table a{color:#e7edf5!important}
html[data-theme="dark"] .table a:hover{color:#ffd34d!important}
html[data-theme="dark"] .border-bottom{border-color:var(--theme-border)!important}

/* Chips, painéis e componentes operacionais */
html[data-theme="dark"] .analytics-chip,
html[data-theme="dark"] .quick-action-grid .action-tile,
html[data-theme="dark"] .kanban-col,
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .calendar-day,
html[data-theme="dark"] .agenda-event,
html[data-theme="dark"] .notif-item,
html[data-theme="dark"] .empty-icon{background:var(--theme-surface-2)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important}
html[data-theme="dark"] .kanban-col{background:#131820!important}
html[data-theme="dark"] .task-card:hover{border-color:#826d16!important;box-shadow:0 8px 20px rgba(0,0,0,.22)}
html[data-theme="dark"] .calendar-grid{background:var(--theme-calendar-grid);border-color:var(--theme-calendar-grid)}
html[data-theme="dark"] .calendar-grid .weekday{background:#1a2028;color:#aeb8c5}
html[data-theme="dark"] .cal-task{background:#3b3310;color:#f5e5a2}
html[data-theme="dark"] .progress{background:#29313c}
html[data-theme="dark"] .tabs-clean a{color:#aab5c2}
html[data-theme="dark"] .tabs-clean a:hover{background:#202731;color:#fff}
html[data-theme="dark"] .tabs-clean a.active{background:#edf2f7;color:#151a20}
html[data-theme="dark"] .notif-item.unread{background:#24200f!important}
html[data-theme="dark"] .empty-state p{color:var(--theme-muted)}

/* Alertas preservando semântica no escuro */
html[data-theme="dark"] .alert-warning{background:#2b250d;border-color:#5a4b14;color:#f3dea1}
html[data-theme="dark"] .alert-danger{background:#2d171c;border-color:#61303a;color:#ffc0ca}
html[data-theme="dark"] .alert-success{background:#12271d;border-color:#29573d;color:#aee9c6}
html[data-theme="dark"] .alert-info{background:#142236;border-color:#2b4d79;color:#bed8ff}

/* Clima */
html[data-theme="dark"] .weather-day{background:var(--theme-surface-2)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}
html[data-theme="dark"] .weather-day:hover{border-color:#786a29!important;box-shadow:0 8px 22px rgba(0,0,0,.22)!important}
html[data-theme="dark"] .weather-day.active{background:#2b260f!important;border-color:#d4ad00!important}
html[data-theme="dark"] .weather-day-dow{color:#d5dce6!important}
html[data-theme="dark"] .weather-day-date,
html[data-theme="dark"] .weather-day-desc,
html[data-theme="dark"] .weather-hour>span:not(.weather-hour-temp),
html[data-theme="dark"] .weather-hourly-head span,
html[data-theme="dark"] .weather-source-line,
html[data-theme="dark"] .weather-hourly-note{color:#99a5b4!important}
html[data-theme="dark"] .weather-day-rain{background:#16283c!important;color:#9fcaff!important}
html[data-theme="dark"] .weather-hourly-panel,
html[data-theme="dark"] .weather-hour,
html[data-theme="dark"] .weather-hourly-close,
html[data-theme="dark"] .weather-hourly-unavailable{background:var(--theme-surface-2)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important}
html[data-theme="dark"] .weather-loading,
html[data-theme="dark"] .weather-error{background:#151b22!important;border-color:#394452!important;color:#a6b0bd!important}

/* Google Calendar / Agenda */
html[data-theme="dark"] .gcal-toolbar,
html[data-theme="dark"] .gcal-days-head,
html[data-theme="dark"] .gcal-all-day,
html[data-theme="dark"] .gcal-time-layout,
html[data-theme="dark"] .gcal-view-switch,
html[data-theme="dark"] .gcal-view-switch a,
html[data-theme="dark"] .gcal-month-calendar,
html[data-theme="dark"] .gcal-month-weekdays,
html[data-theme="dark"] .gcal-month-cell,
html[data-theme="dark"] .gcal-modal{background:#12161c!important;color:#e8edf3!important;border-color:#303946!important}
html[data-theme="dark"] .gcal-view-switch a{color:#aeb8c5!important;border-color:#303946!important}
html[data-theme="dark"] .gcal-view-switch a:hover{background:#20262e!important;color:#fff!important}
html[data-theme="dark"] .gcal-view-switch a.is-active{background:#3a310e!important;color:#ffe483!important;box-shadow:inset 0 -2px 0 #ffc107}
html[data-theme="dark"] .gcal-day-head,
html[data-theme="dark"] .gcal-all-day-cell,
html[data-theme="dark"] .gcal-time-day,
html[data-theme="dark"] .gcal-month-weekdays>div,
html[data-theme="dark"] .gcal-month-cell{border-color:#2b323d!important}
html[data-theme="dark"] .gcal-time-day{background-color:#11161c!important;background-image:linear-gradient(to bottom,transparent 0,transparent 29px,rgba(77,86,99,.32) 29px,rgba(77,86,99,.32) 30px)!important}
html[data-theme="dark"] .gcal-time-day.is-today,
html[data-theme="dark"] .gcal-month-cell.is-today{background-color:#211e10!important}
html[data-theme="dark"] .gcal-time-day.is-over,
html[data-theme="dark"] .gcal-month-cell.is-over{background-color:#2b250e!important;box-shadow:inset 0 0 0 2px rgba(255,193,7,.36)}
html[data-theme="dark"] .gcal-month-cell.is-other-month{background:#0e1217!important}
html[data-theme="dark"] .gcal-month-daynum,
html[data-theme="dark"] .gcal-modal-head h3,
html[data-theme="dark"] .gcal-check{color:#e8edf3!important}
html[data-theme="dark"] .gcal-modal-kicker,
html[data-theme="dark"] .gcal-field>span,
html[data-theme="dark"] .gcal-modal-close,
html[data-theme="dark"] .gcal-help-row,
html[data-theme="dark"] .gcal-month-more{color:#aab5c2!important}
html[data-theme="dark"] .gcal-modal-close:hover,
html[data-theme="dark"] .gcal-cancel-btn,
html[data-theme="dark"] .gcal-month-more:hover{background:#222831!important;color:#fff!important}
html[data-theme="dark"] .gcal-field input,
html[data-theme="dark"] .gcal-field textarea,
html[data-theme="dark"] .gcal-field select{background:#0f141a!important;border-color:#343e4b!important;color:#edf2f7!important}

/* Google Drive */
html[data-theme="dark"] .drive-docs-hero{background:linear-gradient(110deg,#171c23 0%,#131820 100%)!important;border-color:var(--theme-border)!important;box-shadow:var(--theme-shadow)}
html[data-theme="dark"] .drive-docs-hero-copy p,
html[data-theme="dark"] .drive-connect-state p,
html[data-theme="dark"] .drive-doc-meta,
html[data-theme="dark"] .drive-doc-last,
html[data-theme="dark"] .drive-docs-summary span,
html[data-theme="dark"] .drive-docs-summary small{color:var(--theme-muted)!important}
html[data-theme="dark"] .drive-doc-card{background:var(--theme-surface)!important;border-color:var(--theme-border)!important;box-shadow:var(--theme-shadow)}
html[data-theme="dark"] .drive-doc-preview{background:linear-gradient(145deg,#17263c,#141a22)!important;border-color:var(--theme-border)!important}
html[data-theme="dark"] .drive-doc-sheet{background:#f7f9fc!important;color:#1a73e8!important}
html[data-theme="dark"] .drive-doc-title{color:#edf2f7!important}
html[data-theme="dark"] .drive-doc-flags span{background:#232a34!important;color:#b8c2ce!important}
html[data-theme="dark"] .drive-doc-actions{border-color:var(--theme-border)!important}
html[data-theme="dark"] .drive-connect-illustration{background:#17263c!important;box-shadow:inset 0 0 0 1px #29405f}

/* Modais Bootstrap */
html[data-theme="dark"] .modal-content{background:var(--theme-surface);color:var(--theme-text);border-color:var(--theme-border)}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer{border-color:var(--theme-border)}
html[data-theme="dark"] .btn-close{filter:invert(1) grayscale(100%) brightness(180%)}

/* Login / recuperação */
html[data-theme="dark"] body.login-theme{background:#0b0f14!important;color:var(--theme-text)!important}
html[data-theme="dark"] body.login-theme .wrap,
html[data-theme="dark"] body.login-theme .login,
html[data-theme="dark"] body.auth-simple .box{background:#151a21!important;color:var(--theme-text)!important;border-color:#2c3440!important}
html[data-theme="dark"] body.login-theme .muted,
html[data-theme="dark"] body.login-theme .google-note,
html[data-theme="dark"] body.login-theme .aux a,
html[data-theme="dark"] body.login-theme .login-legal,
html[data-theme="dark"] body.login-theme .login-legal a,
html[data-theme="dark"] body.login-theme .small-status,
html[data-theme="dark"] body.auth-simple .text-secondary{color:#9ca8b7!important}
html[data-theme="dark"] body.login-theme .google-btn{background:#1b2129!important;color:#edf2f7!important;border-color:#343e4b!important}
html[data-theme="dark"] body.login-theme .field input,
html[data-theme="dark"] body.auth-simple .form-control{background:#0f141a!important;color:#edf2f7!important;border-color:#343e4b!important}
html[data-theme="dark"] body.login-theme .divider:before,
html[data-theme="dark"] body.login-theme .divider:after{background:#303946!important}
html[data-theme="dark"] body.login-theme .small-status{background:#1b2129!important}
html[data-theme="dark"] body.login-theme .small-status strong{color:#e5ebf2!important}

/* Portal do Cliente */
html[data-theme="dark"] body.portal-theme{background:#0d1117!important;color:#edf2f7!important}
html[data-theme="dark"] body.portal-theme .card{background:#161b22!important;color:#edf2f7!important;box-shadow:0 6px 22px rgba(0,0,0,.24)!important}
html[data-theme="dark"] body.portal-theme .text-secondary,
html[data-theme="dark"] body.portal-theme .small-muted{color:#9aa6b5!important}
html[data-theme="dark"] body.portal-theme .doc-row{border-color:#2b3440!important}
html[data-theme="dark"] body.portal-theme .table{--bs-table-bg:#161b22;--bs-table-color:#edf2f7;--bs-table-border-color:#2b3440}
html[data-theme="dark"] body.portal-theme .progress{background:#29313c!important}
html[data-theme="dark"] body.portal-theme .btn-outline-secondary{background:#1b2129!important;color:#dbe3ec!important;border-color:#3b4654!important}
html[data-theme="dark"] body.portal-login-theme .box{background:#151a21!important;color:#edf2f7!important}
html[data-theme="dark"] body.portal-login-theme .text-secondary,
html[data-theme="dark"] body.portal-login-theme .back{color:#9aa6b5!important}
html[data-theme="dark"] body.portal-login-theme .form-control{background:#0f141a!important;color:#edf2f7!important;border-color:#343e4b!important}

@media(prefers-reduced-motion:reduce){.theme-toggle i{transition:none}}

/* Seletor de aparência */
.appearance-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.appearance-option{appearance:none;text-align:left;border:1px solid var(--ev-border);background:var(--ev-surface);color:var(--ev-text);border-radius:14px;padding:14px;cursor:pointer;transition:.15s ease;display:flex;align-items:center;gap:12px}
.appearance-option:hover{transform:translateY(-1px);border-color:#c9aa20}
.appearance-option.is-active{border-color:#d1a900;box-shadow:0 0 0 3px rgba(255,193,7,.12)}
.appearance-option-icon{width:42px;height:42px;border-radius:11px;display:grid;place-items:center;background:var(--ev-yellow-100);color:#7f6200;font-size:1.05rem;flex:0 0 auto}
.appearance-option strong{display:block;font-size:.78rem}.appearance-option small{display:block;color:var(--ev-muted);font-size:.62rem;margin-top:2px}
html[data-theme="dark"] .appearance-option{background:var(--theme-surface-2);border-color:var(--theme-border)}
html[data-theme="dark"] .appearance-option-icon{background:#3a310e;color:#ffd958}
body.auth-simple{background:#eef1f4!important;color:#17202b!important}
body.portal-login-theme{background:#eef1f4!important;color:#17202b!important}
html[data-theme="dark"] body.auth-simple{background:#0b0f14!important;color:var(--theme-text)!important}
html[data-theme="dark"] body.portal-login-theme{background:#0b0f14!important;color:var(--theme-text)!important}
@media(max-width:560px){.appearance-options{grid-template-columns:1fr}}
html[data-theme="dark"] .alert-light{background:#1b2129!important;border-color:#35404d!important;color:#cbd5e1!important}
html[data-theme="dark"] code{color:#ffd65b;background:#202630;border-radius:5px;padding:.08rem .28rem}
