/* =====================================================
   BPO FINANCEIRO - MICROSOFT FLUENT DESIGN SYSTEM
   Temas: blue | dark | white
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Segoe+UI:wght@300;400;600;700&display=swap');

/* ─── CSS TOKENS ─── */
:root {
  --ms-font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --ms-radius: 4px;
  --ms-radius-lg: 8px;
  --ms-shadow-sm: 0 1.6px 3.6px rgba(0,0,0,.132), 0 .3px .9px rgba(0,0,0,.108);
  --ms-shadow-md: 0 6.4px 14.4px rgba(0,0,0,.132), 0 1.2px 3.6px rgba(0,0,0,.108);
  --ms-shadow-lg: 0 25.6px 57.6px rgba(0,0,0,.22), 0 4.8px 14.4px rgba(0,0,0,.18);
  --transition: 0.15s ease;
  --sidebar-width: 240px;
  --sidebar-collapsed: 56px;
  --header-h: 48px;
}

/* ─── THEME: BLUE (BPO Desembolo — DEFAULT) ─── */
body.theme-blue {
  --bg-app: #F8FAFC;
  --bg-sidebar: #0B3D91;
  --bg-sidebar-hover: rgba(255,255,255,.12);
  --bg-sidebar-active: rgba(255,255,255,.20);
  --bg-header: #0B3D91;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-table-header: #F1F5F9;
  --bg-table-hover: #F1F5F9;
  --bg-modal: #ffffff;
  --bg-overlay: rgba(15,23,42,.5);
  --text-sidebar: #ffffff;
  --text-sidebar-muted: rgba(255,255,255,.72);
  --text-header: #ffffff;
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --border-input: #CBD5E1;
  --border-focus: #0066CC;
  --accent: #0066CC;
  --accent-hover: #0052B4;
  --accent-active: #0B3D91;
  --accent-text: #ffffff;
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --warning: #F59E0B;
  --success: #00875A;
  --info: #0066CC;
  --badge-danger: #FEE2E2;
  --badge-danger-text: #B91C1C;
  --badge-warning: #FEF3C7;
  --badge-warning-text: #92400E;
  --badge-success: #DCFCE8;
  --badge-success-text: #00875A;
  --badge-info: #DCE6F5;
  --badge-info-text: #0B3D91;
  --logo-color: #ffffff;
  --scrollbar: #CBD5E1;
}

/* ─── THEME: DARK ─── */
body.theme-dark {
  --bg-app: #0B1220;
  --bg-sidebar: #07101F;
  --bg-sidebar-hover: rgba(255,255,255,.06);
  --bg-sidebar-active: rgba(77,148,219,.18);
  --bg-header: #07101F;
  --bg-card: #152033;
  --bg-input: #1E2A41;
  --bg-table-header: #152033;
  --bg-table-hover: #1E2A41;
  --bg-modal: #152033;
  --bg-overlay: rgba(0,0,0,.65);
  --text-sidebar: #E8EDF5;
  --text-sidebar-muted: rgba(232,237,245,.65);
  --text-header: #E8EDF5;
  --text-primary: #E8EDF5;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border: #243049;
  --border-input: #334155;
  --border-focus: #4D94DB;
  --accent: #4D94DB;
  --accent-hover: #6BA8E5;
  --accent-active: #0066CC;
  --accent-text: #ffffff;
  --danger: #F87171;
  --danger-hover: #FCA5A5;
  --warning: #FBBF24;
  --success: #34D399;
  --info: #60A5FA;
  --badge-danger: rgba(248,113,113,.12);
  --badge-danger-text: #FCA5A5;
  --badge-warning: rgba(251,191,36,.12);
  --badge-warning-text: #FCD34D;
  --badge-success: rgba(52,211,153,.12);
  --badge-success-text: #34D399;
  --badge-info: rgba(96,165,250,.12);
  --badge-info-text: #93C5FD;
  --logo-color: #4D94DB;
  --scrollbar: #243049;
}

/* ─── THEME: WHITE ─── */
body.theme-white {
  --bg-app: #FAFBFC;
  --bg-sidebar: #F1F5F9;
  --bg-sidebar-hover: rgba(11,61,145,.06);
  --bg-sidebar-active: rgba(11,61,145,.10);
  --bg-header: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-table-header: #F1F5F9;
  --bg-table-hover: #F8FAFC;
  --bg-modal: #ffffff;
  --bg-overlay: rgba(15,23,42,.5);
  --text-sidebar: #0F172A;
  --text-sidebar-muted: #64748B;
  --text-header: #0F172A;
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --border-input: #CBD5E1;
  --border-focus: #0066CC;
  --accent: #0066CC;
  --accent-hover: #0052B4;
  --accent-active: #0B3D91;
  --accent-text: #ffffff;
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --warning: #F59E0B;
  --success: #00875A;
  --info: #0066CC;
  --badge-danger: #FEE2E2;
  --badge-danger-text: #B91C1C;
  --badge-warning: #FEF3C7;
  --badge-warning-text: #92400E;
  --badge-success: #DCFCE8;
  --badge-success-text: #00875A;
  --badge-info: #DCE6F5;
  --badge-info-text: #0B3D91;
  --logo-color: #0B3D91;
  --scrollbar: #CBD5E1;
}

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--ms-font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-app);
  color: var(--text-primary);
  transition: background var(--transition), color var(--transition);
  overflow: hidden;
  height: 100vh;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }

/* ─── LAYOUT ─── */
#app { display: flex; height: 100vh; overflow: hidden; }
#login-page { display: flex; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), min-width var(--transition);
  overflow: hidden;
  z-index: 100;
  box-shadow: var(--ms-shadow-sm);
}

.sidebar.collapsed { width: var(--sidebar-collapsed); min-width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-section-title { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-icon { margin: 0; }

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.theme-white .sidebar-logo { border-bottom-color: var(--border); }

.sidebar-logo-icon {
  font-size: 20px; flex-shrink: 0;
  color: var(--logo-color);
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  width: 28px; height: 28px;
  border-radius: var(--ms-radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; letter-spacing: -0.5px;
}

.theme-white .sidebar-logo-icon { background: var(--accent); }
.theme-dark .sidebar-logo-icon { background: #2899f5; }

.sidebar-logo-text {
  font-size: 13px; font-weight: 600;
  color: var(--text-sidebar);
  white-space: nowrap;
  line-height: 1.2;
}

.sidebar-logo-text small {
  display: block; font-size: 10px;
  font-weight: 400;
  color: var(--text-sidebar-muted);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.sidebar-section { padding: 0; }

.sidebar-section-title {
  font-size: 10px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-sidebar-muted);
  padding: 16px 16px 4px;
  white-space: nowrap;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 0;
  color: var(--text-sidebar);
  transition: background var(--transition);
  user-select: none;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover { background: var(--bg-sidebar-hover); }

.nav-item.active {
  background: var(--bg-sidebar-active);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--accent-text);
  border-radius: 0 2px 2px 0;
}

.theme-white .nav-item.active::before { background: var(--accent); }

.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-label { font-size: 13px; }

.sidebar-footer {
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.theme-white .sidebar-footer { border-top-color: var(--border); }

/* ─── MAIN CONTENT ─── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── HEADER ─── */
.header {
  height: var(--header-h);
  background: var(--bg-header);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--ms-shadow-sm);
  z-index: 50;
}

.theme-white .header { border-bottom: 1px solid var(--border); }

.header-toggle {
  background: none; border: none;
  color: var(--text-header); cursor: pointer;
  font-size: 16px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--ms-radius);
  transition: background var(--transition);
  flex-shrink: 0;
}

.header-toggle:hover { background: var(--bg-sidebar-hover); }

.header-breadcrumb {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-header);
}

.header-breadcrumb span { opacity: .75; }
.header-breadcrumb strong { font-weight: 600; }

.header-actions {
  display: flex; align-items: center; gap: 8px;
}

.header-btn {
  background: none; border: none;
  color: var(--text-header); cursor: pointer;
  font-size: 14px; padding: 4px 10px;
  border-radius: var(--ms-radius);
  display: flex; align-items: center; gap: 6px;
  transition: background var(--transition);
  white-space: nowrap;
}

.header-btn:hover { background: var(--bg-sidebar-hover); }

.header-user {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--ms-radius);
  transition: background var(--transition);
}

.header-user:hover { background: var(--bg-sidebar-hover); }

.user-avatar {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: var(--text-header);
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.4);
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.theme-white .user-avatar { background: var(--accent); color: #fff; border-color: var(--border); }

.user-info { display: flex; flex-direction: column; text-align: right; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text-header); line-height: 1.2; }
.user-role { font-size: 10px; color: var(--text-header); opacity: .75; }

/* ─── THEME SELECTOR ─── */
.theme-switcher {
  display: flex; gap: 4px;
}

.theme-btn {
  width: 20px; height: 20px;
  border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: border-color var(--transition);
}

.theme-btn:hover, .theme-btn.active { border-color: var(--text-header); }
.theme-btn.blue { background: #0B3D91; }
.theme-btn.dark { background: #0B1220; }
.theme-btn.white { background: #F8FAFC; border-color: rgba(255,255,255,.4); }

/* ─── CONTENT AREA ─── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-app);
}

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-title { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ─── CARDS ─── */
.card {
  background: var(--bg-card);
  border-radius: var(--ms-radius-lg);
  box-shadow: var(--ms-shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-table-header);
}

/* ─── KPI CARDS ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--ms-radius-lg);
  padding: 16px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--ms-shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: default;
}

.kpi-card:hover { box-shadow: var(--ms-shadow-md); transform: translateY(-1px); }

.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 300; color: var(--text-primary); margin-bottom: 4px; }
.kpi-value.danger { color: var(--danger); }
.kpi-value.success { color: var(--success); }
.kpi-value.warning { color: var(--warning); }
.kpi-value.info { color: var(--accent); }
.kpi-delta { font-size: 11px; color: var(--text-muted); }
.kpi-icon { font-size: 28px; float: right; opacity: .35; margin-top: -4px; }

/* ─── GRID LAYOUTS ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  font-size: 13px; font-family: var(--ms-font);
  border-radius: var(--ms-radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  font-weight: 400;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

.btn-primary {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }

.btn-secondary {
  background: transparent; color: var(--text-primary);
  border-color: var(--border-input);
}
.btn-secondary:hover { background: var(--bg-table-hover); }

.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost {
  background: transparent; color: var(--accent);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-table-hover); }

.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-lg { padding: 8px 20px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 6px; min-width: 32px; justify-content: center; }

/* ─── TABLES ─── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-table-header);
  color: var(--text-secondary);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--text-primary); }
thead th .sort-icon { opacity: .5; margin-left: 4px; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-table-hover); }

td { padding: 10px 14px; color: var(--text-primary); vertical-align: middle; }
td.nowrap { white-space: nowrap; }
td.right { text-align: right; }
td.center { text-align: center; }

.table-actions { display: flex; gap: 4px; }

/* ─── TOOLBAR ─── */
.toolbar {
  display: flex; align-items: center;
  gap: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ─── FORM ELEMENTS ─── */
.form-group { margin-bottom: 16px; }

label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 4px;
}

.required::after { content: ' *'; color: var(--danger); }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=tel],
select, textarea {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px; font-family: var(--ms-font);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
  border-radius: var(--ms-radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(0,120,212,.2);
}

select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
input[type=number] { -moz-appearance: textfield; }

.search-input {
  width: 200px; min-width: 140px;
  padding-left: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px center;
}

.form-row { display: grid; gap: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 3px; }

/* ─── BADGES / STATUS ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 100px;
  white-space: nowrap;
}

.badge-danger { background: var(--badge-danger); color: var(--badge-danger-text); }
.badge-warning { background: var(--badge-warning); color: var(--badge-warning-text); }
.badge-success { background: var(--badge-success); color: var(--badge-success-text); }
.badge-info { background: var(--badge-info); color: var(--badge-info-text); }
.badge-muted { background: var(--border); color: var(--text-secondary); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal {
  background: var(--bg-modal);
  border-radius: var(--ms-radius-lg);
  box-shadow: var(--ms-shadow-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: slideUp .15s ease;
  border: 1px solid var(--border);
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 380px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

.modal-close {
  background: none; border: none;
  font-size: 18px; color: var(--text-muted);
  cursor: pointer; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--ms-radius);
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover { background: var(--bg-table-hover); color: var(--text-primary); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}

/* ─── ALERTS ─── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--ms-radius);
  font-size: 13px; margin-bottom: 12px;
  border: 1px solid transparent;
}

.alert-danger { background: var(--badge-danger); color: var(--badge-danger-text); border-color: rgba(209,52,56,.2); }
.alert-warning { background: var(--badge-warning); color: var(--badge-warning-text); border-color: rgba(255,140,0,.2); }
.alert-success { background: var(--badge-success); color: var(--badge-success-text); border-color: rgba(16,124,16,.2); }
.alert-info { background: var(--badge-info); color: var(--badge-info-text); border-color: rgba(0,120,212,.2); }
.alert-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

/* ─── TABS ─── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }

.tab-btn {
  padding: 8px 16px; background: none; border: none;
  font-size: 13px; font-family: var(--ms-font);
  color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  font-weight: 400;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── TOGGLE SWITCH ─── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; }

.toggle {
  position: relative; display: inline-block;
  width: 40px; height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-input);
  border-radius: 22px;
  transition: background var(--transition);
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 2px; bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-label { font-size: 13px; color: var(--text-primary); }

/* ─── CHART CONTAINER ─── */
.chart-container {
  position: relative;
  width: 100%; height: 220px;
  overflow: hidden;
}

.chart-bars {
  display: flex; align-items: flex-end;
  gap: 8px; height: 180px;
  padding-bottom: 24px;
}

.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }

.chart-bar {
  width: 100%; border-radius: var(--ms-radius) var(--ms-radius) 0 0;
  transition: opacity var(--transition);
  min-width: 8px; min-height: 2px;
}

.chart-bar.receita { background: var(--success); opacity: .8; }
.chart-bar.despesa { background: var(--danger); opacity: .8; }
.chart-bar:hover { opacity: 1; }
.chart-label { font-size: 10px; color: var(--text-muted); text-align: center; }

.chart-legend {
  display: flex; gap: 16px; margin-top: 8px;
  justify-content: center;
}

.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-dot.receita { background: var(--success); }
.legend-dot.despesa { background: var(--danger); }
.legend-dot.saldo { background: var(--accent); }

/* ─── LOGIN PAGE ─── */
#login-page {
  width: 100vw; height: 100vh;
  background: linear-gradient(135deg, #0B3D91 0%, #061F4D 100%);
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0;
}

.theme-dark #login-page { background: linear-gradient(135deg, #0B1220 0%, #07101F 100%); }
.theme-white #login-page { background: linear-gradient(135deg, #F1F5F9 0%, #DCE6F5 100%); }

.login-card {
  background: var(--bg-modal);
  border-radius: var(--ms-radius-lg);
  box-shadow: var(--ms-shadow-lg);
  padding: 40px;
  width: 100%; max-width: 380px;
  border: 1px solid var(--border);
  animation: slideUp .25s ease;
}

.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: var(--ms-radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; font-weight: 700;
}

.login-logo-text { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.login-logo-text small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 400; }

.login-title { font-size: 22px; font-weight: 300; color: var(--text-primary); margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 28px; }

.login-theme-bar {
  position: absolute; top: 20px; right: 20px;
  display: flex; gap: 8px;
}

.login-theme-btn {
  width: 24px; height: 24px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.4);
  cursor: pointer; transition: border-color var(--transition);
}

.login-theme-btn:hover, .login-theme-btn.active { border-color: rgba(255,255,255,.9); }
.login.theme-btn.blue { background: #0B3D91; }
.login.theme-btn.dark { background: #0B1220; }
.login-theme-btn.white { background: #F8FAFC; }

.login-error {
  background: var(--badge-danger);
  color: var(--badge-danger-text);
  padding: 8px 12px;
  border-radius: var(--ms-radius);
  font-size: 12px; margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-text { font-size: 13px; }

/* ─── DROPDOWN MENU ─── */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--ms-radius-lg);
  box-shadow: var(--ms-shadow-md);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
  animation: slideUp .12s ease;
}

.dropdown-item {
  padding: 8px 14px;
  font-size: 13px; cursor: pointer;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  transition: background var(--transition);
}

.dropdown-item:hover { background: var(--bg-table-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── PROGRESS BAR ─── */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width .3s ease; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }
.progress-bar.info { background: var(--accent); }

/* ─── LOADING ─── */
.loading-spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; gap: 12px; color: var(--text-secondary); font-size: 13px;
}

/* ─── TOAST ─── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--ms-radius-lg);
  padding: 12px 16px;
  box-shadow: var(--ms-shadow-md);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  animation: slideUp .2s ease;
  max-width: 320px;
  color: var(--text-primary);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--accent); }

/* ─── PANEL (expandable) ─── */
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer;
  border-radius: var(--ms-radius);
}

.panel-header:hover { background: var(--bg-table-hover); }

/* ─── MISC ─── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.flex-1 { flex: 1; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { position: absolute; height: 100vh; z-index: 200; transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.mobile-open { transform: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .content-area { padding: 16px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-end; }
}

/* ─── PRINT ─── */
@media print {
  .sidebar, .header, .toolbar, .btn { display: none !important; }
  .content-area { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
