/* ============================================================
   SIGMA ERP — app.css  (Gmail-inspired redesign)
   Mobile-first: 320px base | 768px tablet | 1280px desktop
   ============================================================ */

/* ── 1. CSS Custom Properties ─────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg:           #0f172a;
  --bg-surface:   #1e293b;
  --bg-elevated:  #263348;
  --bg-hover:     #2d3f55;
  --border:       #2d3f55;
  --border-light: #334155;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-subtle:  #64748b;
  --accent:       #22c55e;
  --accent-dark:  #16a34a;
  --accent-light: rgba(34,197,94,0.12);
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --sidebar-w:    256px;
  --header-h:     60px;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.3);
  --shadow:       0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.5);
  --transition:   0.15s ease;
}

[data-theme="light"] {
  --bg:           #f1f5f9;
  --bg-surface:   #ffffff;
  --bg-elevated:  #f8fafc;
  --bg-hover:     #f1f5f9;
  --border:       #e2e8f0;
  --border-light: #f1f5f9;
  --text:         #0f172a;
  --text-muted:   #475569;
  --text-subtle:  #94a3b8;
  --accent:       #16a34a;
  --accent-dark:  #15803d;
  --accent-light: rgba(22,163,74,0.1);
  --danger:       #dc2626;
  --warning:      #d97706;
  --info:         #2563eb;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow:       0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.15);
}

/* ── 2. Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }

/* ── 3. Skip Link ─────────────────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: 0;
  background: var(--accent); color: #fff;
  padding: 0.5rem 1rem; font-weight: 600;
  z-index: 10000; border-radius: 0 0 var(--radius) 0;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ── 4. Layout Shell ──────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── 5. Sidebar ───────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 150;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto; overflow-x: hidden;
}
.sidebar.is-open { transform: translateX(0); }

.sidebar-brand {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1.5rem; height: var(--header-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 32px; height: 32px;
  background: var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.25);
}
.sidebar-logo svg { width: 20px; height: 20px; }
.sidebar-logo-img { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; }

.sidebar-title {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; letter-spacing: -0.015em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }

.nav-section-label,
.section-label {
  font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 1rem 1.5rem 0.35rem; display: block;
}

.nav-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem; height: 40px;
  color: var(--text-muted); font-size: 0.875rem; font-weight: 500;
  border-radius: 20px; cursor: pointer;
  transition: background var(--transition), color var(--transition), padding var(--transition);
  text-decoration: none; white-space: nowrap; overflow: hidden;
  border: none; background: none;
  width: calc(100% - 1.5rem); margin: 3px 0.75rem; text-align: left;
}
.nav-item:hover, .nav-item:focus-visible {
  background: var(--bg-hover); color: var(--text); outline: none;
}
.nav-item.active {
  background: var(--accent-light); color: var(--accent); font-weight: 600;
}
.nav-icon { font-size: 1.15rem; flex-shrink: 0; width: 24px; text-align: center; transition: transform var(--transition); }
.nav-item:hover .nav-icon { transform: scale(1.1); }
.nav-label { flex: 1; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.25rem; flex-shrink: 0;
  background: var(--bg-elevated);
}
.sidebar-user { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; font-weight: 700; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-user-name {
  font-size: 0.85rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.72rem; color: var(--text-subtle);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Collapsed (Gmail style) */
.sidebar.is-collapsed { width: 72px; }
.sidebar.is-collapsed .sidebar-title,
.sidebar.is-collapsed .nav-label,
.sidebar.is-collapsed .nav-section-label,
.sidebar.is-collapsed .section-label,
.sidebar.is-collapsed .sidebar-user-info { display: none; }
.sidebar.is-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.sidebar.is-collapsed .nav-item {
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 6px auto;
  padding: 0;
  border-radius: 50%; /* Rounded capsules become circles */
}
.sidebar.is-collapsed .sidebar-user { justify-content: center; }
.sidebar.is-collapsed .sidebar-footer { padding: 0.75rem 0; }

/* ── 6. Overlay ───────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 149;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.is-visible { display: block; }

/* ── 7. Header ────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem; z-index: 100;
  transition: padding-left var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn-hamburger {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.5rem;
  border-radius: 50%; /* Circle shape like Gmail */
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.btn-hamburger:hover, .btn-hamburger:focus-visible {
  background: var(--bg-hover); color: var(--text); outline: none;
}
.btn-hamburger svg { width: 20px; height: 20px; }

.header-title {
  font-size: 1.15rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
  min-width: 140px;
}

/* Gmail-style Central Search Bar */
.header-search {
  flex: 1;
  max-width: 680px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-hover);
  border-radius: 24px;
  padding: 0 1rem;
  height: 44px;
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.header-search:focus-within {
  background: var(--bg-surface);
  box-shadow: var(--shadow);
  border-color: var(--border-light);
}
.header-search input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
}
.header-search .search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.btn-icon-header {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.5rem;
  border-radius: 50%; /* Circular button */
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  font-size: 1.15rem; position: relative;
}
.btn-icon-header:hover, .btn-icon-header:focus-visible {
  background: var(--bg-hover); color: var(--text); outline: none;
}
.btn-icon-header svg { width: 20px; height: 20px; }

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700;
  flex-shrink: 0; cursor: default; user-select: none;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--border-light);
}

.header-tabs { display: flex; align-items: center; gap: 0.25rem; flex: 1; }

/* ── 8. Main Content ──────────────────────────────────────── */
.main-content {
  flex: 1; margin-top: var(--header-h); margin-left: 0;
  padding: 1.25rem 1rem; min-width: 0;
  transition: margin-left var(--transition);
}

/* ── 9. Page Header ───────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem;
}
.page-title { font-size: 1.25rem; font-weight: 700; color: var(--text); }

/* ── 10. Cards ────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 0.9375rem; font-weight: 600; }

.cards-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.5rem; }

.indicator-card { display: flex; align-items: center; gap: 1rem; }

.card-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.card-icon-green  { background: rgba(34,197,94,0.15); }
.card-icon-red    { background: rgba(239,68,68,0.15); }
.card-icon-yellow { background: rgba(245,158,11,0.15); }
.card-icon-blue   { background: rgba(59,130,246,0.15); }
.card-icon-orange { background: rgba(249,115,22,0.15); }
.card-icon-purple { background: rgba(168,85,247,0.15); }

.card-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.2rem; font-weight: 500; }
.card-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }

.chart-card { margin-bottom: 1.5rem; }
.chart-container { overflow-x: auto; }
.chart-container canvas { max-width: 100%; }
.chart-legend { display: flex; gap: 1.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-green { background: #22c55e; }
.legend-red   { background: #ef4444; }

/* ── 11. Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.5rem 1rem;
  border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap; text-decoration: none; line-height: 1.4;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-success { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-success:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

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

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 0.3rem; border-radius: var(--radius);
  color: var(--text-muted); font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tab-btn {
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: transparent; color: var(--text-muted);
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
.tab-btn.active {
  background: var(--accent-light); color: var(--accent);
  border-color: var(--accent); font-weight: 600;
}

.btn-spinner { display: inline-flex; }
.btn-spinner .spinner { width: 16px; height: 16px; }

/* ── 12. Forms ────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-muted); }

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 0.875rem; padding: 0.5rem 0.75rem; width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-input[aria-invalid="true"], .form-select[aria-invalid="true"],
.form-input.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1rem; }

.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-right: 2.5rem; }

.toggle-password {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.25rem;
  display: flex; align-items: center;
}
.toggle-password:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }

.field-error { font-size: 0.78rem; color: var(--danger); min-height: 1.2em; }
.field-hint  { font-size: 0.78rem; color: var(--text-subtle); margin-top: 0.2rem; }

/* ── 13. Filters Bar ──────────────────────────────────────── */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end;
  margin-bottom: 1rem; padding: 0.875rem 1rem;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 140px; }

/* ── 14. Tables ───────────────────────────────────────────── */
.table-container {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
  position: relative; box-shadow: var(--shadow-sm);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th, .data-table td {
  padding: 0.625rem 1rem; text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.data-table th {
  background: var(--bg-elevated); font-weight: 600;
  color: var(--text-muted); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.section-title {
  font-size: 0.875rem; font-weight: 600; color: var(--text);
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* ── 15. Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem; border-radius: 9999px;
  font-size: 0.72rem; font-weight: 600; line-height: 1.4;
}
.badge-success   { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge-danger    { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-warning   { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-info      { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-secondary { background: var(--bg-elevated);    color: var(--text-muted); }
[data-theme="light"] .badge-success { color: #16a34a; }
[data-theme="light"] .badge-danger  { color: #dc2626; }
[data-theme="light"] .badge-warning { color: #d97706; }
[data-theme="light"] .badge-info    { color: #2563eb; }

/* ── 16. Alerts ───────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius);
  font-size: 0.875rem; border: 1px solid transparent;
}
.alert-error   { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.3);  color: var(--danger); }
.alert-success { background: var(--accent-light);   border-color: rgba(34,197,94,0.3);  color: var(--accent); }
.alert-warning { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: var(--warning); }
.alert-info    { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.3); color: var(--info); }
.alert-container { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── 17. Modal / Dialog ───────────────────────────────────── */

/*
 * Native <dialog> with showModal():
 * The browser positions it centered in the viewport automatically.
 * We only style appearance — no position/transform overrides.
 */
dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: min(560px, calc(100vw - 2rem));
  width: 100%;
  max-height: min(90vh, 800px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  margin: auto;
  z-index: 1000;
  /* Do NOT set position, top, left, or transform — showModal() handles centering */
}

dialog[open] {
  /* Do not use display: flex here as it breaks centering on some WebKit browsers.
     The .modal-content div inside handles the flex layout. */
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}

/* .modal class — CSS-only fallback (no showModal) */
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: min(560px, calc(100vw - 2rem));
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  margin: 0;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}

.modal-lg,
dialog.modal-lg { max-width: min(720px, calc(100vw - 2rem)); }

.modal-content { display: flex; flex-direction: column; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-surface); z-index: 1;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.25rem; padding: 0.25rem;
  border-radius: var(--radius); line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--accent); }
.modal-form { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; padding-top: 0.5rem; }

/* ── 18. Spinner & Loading ────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; border-radius: var(--radius);
}

/* ── 19. Progress Bars ────────────────────────────────────── */
#sigma-progress {
  position: fixed; top: 0; left: 0; width: 0%; height: 3px;
  background: var(--accent); z-index: 9999;
  transition: width 0.3s ease, opacity 0.4s ease;
  opacity: 0; border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--accent);
}
#sigma-progress.is-running { opacity: 1; }

.progress-bar {
  width: 100%; height: 6px; background: var(--bg-elevated);
  border-radius: 9999px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 9999px; transition: width 0.3s ease;
}

/* ── 20. Login Page ───────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem; background: var(--bg);
}
.login-container { width: 100%; max-width: 420px; }
.login-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo {
  display: flex; justify-content: center; align-items: center;
  height: 80px; margin-bottom: 1rem;
}
.login-logo img { max-height: 64px; max-width: 180px; object-fit: contain; }
.login-logo-icon {
  width: 56px; height: 56px; background: var(--accent);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
}
.login-logo-icon svg { width: 32px; height: 32px; }
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-subtitle { color: var(--text-muted); font-size: 0.875rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-footer { text-align: center; margin-top: 1.5rem; font-size: 0.8rem; color: var(--text-subtle); }

/* ── 21. Chat Layout ──────────────────────────────────────── */
.chat-layout {
  display: flex; height: calc(100vh - var(--header-h) - 2.5rem);
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.chat-sidebar {
  width: 280px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; background: var(--bg-surface);
}
.chat-sidebar-header {
  padding: 1rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9375rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-title { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.chat-window { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-subtle); font-size: 0.875rem;
  flex-direction: column; gap: 0.5rem;
}
.chat-active { display: flex; flex-direction: column; flex: 1; }
.chat-header {
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.75rem;
  flex-shrink: 0; background: var(--bg-surface);
}
.chat-partner-name { font-weight: 600; font-size: 0.9375rem; color: var(--text); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.chat-input-bar {
  padding: 0.75rem 1rem; border-top: 1px solid var(--border);
  display: flex; gap: 0.5rem; align-items: flex-end;
  flex-shrink: 0; background: var(--bg-surface);
}
.chat-input {
  flex: 1; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--text);
  font-size: 0.875rem; padding: 0.5rem 0.875rem;
  resize: none; font-family: inherit; max-height: 120px;
  transition: border-color var(--transition);
}
.chat-input:focus { outline: none; border-color: var(--accent); }

.message { display: flex; flex-direction: column; max-width: 70%; }
.message-mine  { align-self: flex-end;  align-items: flex-end; }
.message-other { align-self: flex-start; align-items: flex-start; }
.message-bubble {
  padding: 0.5rem 0.875rem; border-radius: var(--radius-lg);
  font-size: 0.875rem; line-height: 1.5; word-break: break-word;
}
.message-mine  .message-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.message-other .message-bubble { background: var(--bg-elevated); color: var(--text); border-bottom-left-radius: 4px; }
.message-time { font-size: 0.7rem; color: var(--text-subtle); margin-top: 0.2rem; padding: 0 0.25rem; }

.online-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
  flex-shrink: 0; box-shadow: 0 0 0 2px var(--bg-surface);
}

.user-list, .conversation-list { flex: 1; overflow-y: auto; padding: 0.25rem 0; }

.user-item, .conversation-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 1rem; cursor: pointer;
  transition: background var(--transition);
  border: none; background: none; width: 100%;
  text-align: left; color: var(--text);
}
.user-item:hover, .conversation-item:hover { background: var(--bg-hover); }
.conversation-item.unread .conv-nome { font-weight: 700; }
.conversation-item.unread .conv-preview { color: var(--text); }

.conv-nome {
  font-size: 0.875rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-preview {
  font-size: 0.78rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.online-users, .conversations { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* ── 22. Pagination ───────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination-info { font-size: 0.8125rem; color: var(--text-muted); margin-right: auto; }

/* ── 23. Result Box ───────────────────────────────────────── */
.result-box {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  font-size: 0.875rem; line-height: 1.8; margin-top: 0.75rem;
}

/* ── 24. Utility Classes ──────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-subtle  { color: var(--text-subtle); }
.text-success { color: var(--accent); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.hidden, [hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ── 25. Focus & Scrollbar ────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ============================================================
   BREAKPOINT: 768px (tablet)
   ============================================================ */
@media (min-width: 768px) {
  .main-content { padding: 1.5rem; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: repeat(2, 1fr); }
  .filters-bar { flex-wrap: nowrap; }
  .login-card { padding: 2.5rem 2rem; }
}

/* ============================================================
   BREAKPOINT: 1024px (desktop & laptops)
   ============================================================ */
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0); position: fixed; }
  .main-content { margin-left: var(--sidebar-w); }
  .app-header { padding-left: calc(var(--sidebar-w) + 1.5rem); }
  .sidebar.is-collapsed ~ .main-content,
  .app-shell.sidebar-collapsed .main-content { margin-left: 72px; }
  .sidebar.is-collapsed ~ .app-header,
  .app-shell.sidebar-collapsed .app-header { padding-left: calc(72px + 1.5rem); }
  .cards-grid { grid-template-columns: repeat(4, 1fr); }
  .sidebar-overlay { display: none !important; }
  .chat-layout { height: calc(100vh - var(--header-h) - 3rem); }
}

/* ============================================================
   BREAKPOINT: 768px (tablet & medium viewports)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  .header-search { max-width: 320px; margin: 0 0.5rem; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   MOBILE (<768px)
   ============================================================ */
@media (max-width: 767px) {
  .header-search { display: none; } /* Hide search bar on mobile headers to optimize space */
  .chat-layout { flex-direction: column; height: auto; }
  .chat-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
  .chat-window { min-height: 400px; }
  .message { max-width: 85%; }
  .page-header { margin-bottom: 1rem; }
  .page-title { font-size: 1.15rem; }
  .cards-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}
