/**
 * VALOR DIGITAL - Sistema de Gestão de Assistência
 * Stylesheet Principal
 * Design System: tokens em :root, sem gradientes
 */

:root {
    --primary: #0B4F9C;
    --primary-light: rgba(11, 79, 156, 0.08);
    --primary-hover: #093f7d;
    --secondary: #9333ea;
    --secondary-hover: #7928c7;
    --dark: #1a1a2e;
    --darker: #111;
    --light: #f8f9fa;
    --gray: #6c757d;
    --gray-light: #e5e7eb;
    --gray-muted: #9ca3af;
    --surface: #f3f4f6;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #eab308;
    --orange: #ea580c;
    --info: #0891b2;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: var(--surface);
}

/* Evitar “layout maior que o ecrã” (sobretudo em mobile)
   Nota: isto não impede scroll normal vertical.
*/
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body.no-scroll {
    overflow: hidden;
}

/* ===================================
   TYPOGRAPHY
   =================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--darker);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.4rem; }
h6 { font-size: 1rem; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: #0B4F9C;
    text-decoration: none;
}

/* ===================================
   LAYOUT
   =================================== */
.wrapper {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

.sidebar {
    width: 260px;
    background: var(--dark);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.sidebar-logo {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo img {
    max-width: 180px;
    height: auto;
}

.sidebar-logo h2 {
    color: white;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.sidebar-logo .text-cyan {
    color: var(--primary);
}

.sidebar-logo .text-magenta {
    color: var(--secondary);
}

.sidebar-logo p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu-section {
    margin-bottom: 1.5rem;
}

.menu-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    cursor: pointer;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-left: 3px solid var(--primary);
}

.menu-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-left: 3px solid var(--primary);
    font-weight: 600;
}

.menu-item i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.menu-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    background: var(--surface);
    max-width: 100vw;
    overflow-x: hidden;
}

.top-bar {
    background: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
    max-width: 100vw;
}

.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-right: 10px;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    background: #fff;
    cursor: pointer;
}

.mobile-menu-toggle i {
    font-size: 1.3rem;
    color: var(--darker);
}

/* Linhas clicáveis */
tr[data-href]:hover {
    background: #f8fafc;
}

/* Autocomplete */
.ac-wrap {
    position: relative;
}

.ac-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow: auto;
    z-index: 2000;
}

/* ===================================
   MULTI-SELECT (tags + dropdown)
   - componente interno (sem libs)
   =================================== */
.ms-wrap {
    position: relative;
}

.ms-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-md);
    background: #fff;
}

.ms-control:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.ms-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ms-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #111827;
    font-size: 12px;
    line-height: 1;
}

.ms-tag button {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    color: #6b7280;
    font-size: 14px;
    line-height: 1;
}

.ms-search {
    border: 0;
    outline: 0;
    min-width: 120px;
    flex: 1 1 auto;
    padding: 6px 4px;
    background: transparent;
}

.ms-caret {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 6px 6px;
    color: #6b7280;
}

.ms-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow: auto;
    z-index: 1200;
    display: none;
}

.ms-group {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    background: #f9fafb;
    border-bottom: 1px solid #f1f5f9;
}

.ms-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
}

.ms-item:hover {
    background: #f8fafc;
}

.ms-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ms-check {
    width: 16px;
    height: 16px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.ms-item.selected .ms-check::after {
    content: "✓";
    font-size: 12px;
    color: var(--primary);
}

.ms-label {
    flex: 1 1 auto;
}


.ac-item {
    padding: 0.55rem 0.75rem;
    cursor: pointer;
}

.ac-item:hover {
    background: #f3f4f6;
}

.ac-label {
    font-weight: 700;
}

.ac-sub {
    font-size: 0.85rem;
    color: #6b7280;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 900;
}

.sidebar-overlay.show {
    display: block;
}

.client-scope-form {
    margin-top: 8px;
}

.client-scope {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    background: #fff;
}

.client-scope select {
    border: 0;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    max-width: 360px;
}

/* ===================================
   FILTER PANELS (responsive)
   =================================== */
.filters-panel {
    border: 1px solid #e9ecef;
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
}

.filters-grid {
    margin-top: 0.25rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.filters-grid label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: #495057;
}

.filters-grid input,
.filters-grid select,
.filters-grid textarea {
    width: 100%;
    min-width: 0;
}

.filters-wide {
    grid-column: span 2;
}

.filters-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filters-actions .btn {
    white-space: nowrap;
}

/* Formulários inline (ex.: adicionar intervenção no ticket) */
.inline-form-grid {
    display: grid;
    grid-template-columns: 140px 1fr 170px;
    gap: 0.75rem;
    align-items: end;
}

/* Grelha de pequenos resumos (ex.: relatório horas) */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

@media (max-width: 768px) {
    /* Inline forms (ex.: adicionar intervenção no ticket)
       Queremos compacto mas utilizável: 2 colunas + descrição a ocupar a linha toda.
    */
    .inline-form-grid { grid-template-columns: 1fr 1fr; }
    .inline-form-grid > div:nth-of-type(2) { grid-column: 1 / -1; }
    .inline-form-grid button { width: 100%; }
}

.top-bar-left h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--darker);
}

.top-bar-left .breadcrumb {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-width: 0;
}

.logo-link{
  display:block;
  padding: 6px 0;
}

.logo-img{
  display:block;
  width: auto;
  max-width: 120px;
  max-height: 48px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.search-box {
    position: relative;
}

.search-box input {
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-md);
    width: 300px;
    max-width: 100%;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.notifications {
    position: relative;
    cursor: pointer;
}

.notifications i {
    font-size: 1.4rem;
    color: var(--gray);
}

.notifications .badge-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid white;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

.user-menu:hover {
    background: var(--light);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--darker);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: capitalize;
}

.content {
    padding: 2rem;
}

/* ===================================
   CARDS
   =================================== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--darker);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--gray-light);
}

/* ===================================
   STATS CARDS
   =================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.stat-card-link:visited {
    color: inherit;
}


.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.stat-card.cyan::before {
    background: var(--primary);
}

.stat-card.magenta::before {
    background: var(--secondary);
}

.stat-card.success::before {
    background: var(--success);
}

.stat-card.warning::before {
    background: var(--warning);
}

.stat-card.orange::before {
    background: var(--orange);
}

.stat-card.danger::before {
    background: var(--danger);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--darker);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.stat-icon.cyan {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.magenta {
    background: rgba(147, 51, 234, 0.1);
    color: var(--secondary);
}

.stat-icon.success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning);
}

.stat-icon.orange {
    background: rgba(253, 126, 20, 0.12);
    color: var(--orange);
}

.stat-icon.danger {
    background: rgba(220, 53, 69, 0.12);
    color: var(--danger);
}

/* ===================================
   BUTTONS
   =================================== */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    text-align: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
    box-shadow: var(--shadow-md);
}

.btn-dark {
    background: var(--dark);
    color: #fff;
}

.btn-dark:hover:not(:disabled) {
    background: var(--darker);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: var(--darker);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* ===================================
   FORMS
   =================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--darker);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control:disabled {
    background: #f8f9fa;
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

/* ===================================
   TABLES
   =================================== */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: var(--surface);
}

table thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--darker);
    border-bottom: 2px solid var(--gray-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tbody tr {
    border-bottom: 1px solid var(--gray-light);
    transition: background 0.2s ease;
}

table tbody tr:hover {
    background: var(--primary-light);
}

table tbody td {
    padding: 1rem;
    font-size: 0.9rem;
}

/* ===================================
   BADGES
   =================================== */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary { background: var(--primary); color: #fff; }
.badge-secondary { background: var(--secondary); color: #fff; }
.badge-success { background: var(--success); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-warning { background: var(--warning); color: var(--darker); }
.badge-info { background: var(--info); color: #fff; }
.badge-dark { background: var(--darker); color: #fff; }
.badge-orange { background: var(--orange); color: #fff; }

/* ===================================
   ALERTS
   =================================== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    border-color: var(--success);
    color: #155724;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border-color: var(--danger);
    color: #721c24;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border-color: var(--warning);
    color: #856404;
}

.alert-info {
    background: rgba(23, 162, 184, 0.1);
    border-color: var(--info);
    color: #0c5460;
}

/* ===================================
   UTILITIES
   =================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-cyan { color: var(--primary); }
.text-magenta { color: var(--secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ===================================
   MODAL
   =================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-light);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ===================================
   LOGIN PAGE
   =================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dark);
    padding: 2rem;
}

.login-box {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    overflow: hidden;
}

.login-header {
    background: var(--dark);
    color: white;
    padding: 2rem;
    text-align: center;
}

.login-header h1 {
    color: white;
    margin-bottom: 0.5rem;
}

.login-body {
    padding: 2rem;
}

.login-footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--gray-light);
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 768px) {
    /*
      iOS Safari: quando os inputs têm font-size < 16px, o browser faz auto-zoom ao focar
      (e muitas vezes mantém o zoom), o que dá a sensação de “site ampliado” e depois o menu fica pequeno.
    */
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    /*
      Mantemos inputs a 16px (evita auto-zoom no iOS),
      mas baixamos um pouco a UI geral para caber melhor no ecrã.
    */
    body { font-size: 13px; }
    body.role-admin { font-size: 11px; }
    input, select, textarea, button { font-size: 16px; }

    /* Compactar layout no mobile (evita a sensação de “site demasiado ampliado”) */
    .content { padding: 1rem; }

    /*
      IMPORTANTE: se a top-bar não “caber”, o browser pode forçar um viewport maior
      (dando a sensação de que o site abre ampliado). Por isso no mobile deixamos
      a top-bar quebrar para 2 linhas e nunca ultrapassar o ecrã.
    */
    .top-bar { padding: 0.75rem 1rem; gap: 0.75rem; flex-wrap: wrap; }
    .top-bar-left { flex: 1 1 100%; min-width: 0; }
    .top-bar-right { flex: 1 1 100%; min-width: 0; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
    .top-bar-left h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .top-bar-left h1 { font-size: 1.4rem; line-height: 1.2; }
    .top-bar-left .breadcrumb { font-size: 0.8rem; }

    .top-bar-right { gap: 0.75rem; }

    .search-box { flex: 1 1 100%; min-width: 0; }
    .search-box input { width: 100%; max-width: 100%; padding: 0.45rem 0.9rem 0.45rem 2.25rem; }
    .search-box i { left: 0.65rem; }

    .user-avatar { width: 34px; height: 34px; }
    .user-name { font-size: 0.85rem; }
    .user-role { font-size: 0.7rem; }

    .card-header { padding: 0.9rem 1rem; }
    .card-body { padding: 1rem; }
    .card-footer { padding: 0.75rem 1rem; }

    .stat-card { padding: 0.9rem; }
    .stat-label { font-size: 0.65rem; letter-spacing: 0.4px; margin-bottom: 0.25rem; }
    .stat-value { font-size: 1.45rem; }
    .stat-icon { width: 40px; height: 40px; font-size: 1.15rem; }

    .mobile-menu-toggle {
        display: inline-flex;
        width: 46px;
        height: 46px;
    }

    .mobile-menu-toggle i {
        font-size: 1.6rem;
    }

    /* Admin: compactar barra superior */
    body.role-admin .user-info { display: none; }
    body.role-admin .search-box input { width: 100%; }
    body.role-admin .top-bar { padding: 0.6rem 0.8rem; }

    /* Admin: ainda mais compacto no mobile */
    body.role-admin .top-bar-left h1 { font-size: 1.25rem; }
    body.role-admin .search-box input { width: 100%; }
    body.role-admin .stat-card { padding: 0.75rem; }
    body.role-admin .stat-label { font-size: 0.6rem; }
    body.role-admin .stat-value { font-size: 1.25rem; }
    body.role-admin .stat-icon { width: 36px; height: 36px; font-size: 1.05rem; }

    /* Filtros (forms em grid) — empilhar no mobile */
    .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters-wide { grid-column: 1 / -1; }
    .filters-actions { grid-column: 1 / -1; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
    

    /* Tabelas: nunca devem “estourar” o ecrã; no mobile fazem scroll horizontal dentro da própria tabela */
    table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table thead th, table tbody td { white-space: nowrap; }
}

@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filters-grid { grid-template-columns: 1fr; }
}
