/* ===== CSS Variables ===== */
:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --secondary: #059669;
    --secondary-light: #10b981;
    --danger: #dc2626;
    --danger-light: #ef4444;
    --warning: #d97706;
    --warning-light: #f59e0b;
    --info: #0284c7;
    --info-light: #38bdf8;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --header-height: 64px;
    --transition: all 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== Loading Screen ===== */
.loading-screen {
    position: fixed; inset: 0; background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    display: flex; align-items: center; justify-content: center; z-index: 9999;
    transition: opacity 0.5s ease;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-content { text-align: center; color: #fff; }
.loading-logo { font-size: 4rem; margin-bottom: 1rem; animation: pulse 2s infinite; }
.loading-content h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.loading-content p { opacity: 0.8; margin-bottom: 1.5rem; }
.loading-spinner {
    width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%; margin: 0 auto;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
    padding: 1rem;
}
.login-card {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 2.5rem;
    width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.login-card .logo { text-align: center; margin-bottom: 2rem; }
.login-card .logo i { font-size: 3rem; color: var(--primary); }
.login-card .logo h1 { font-size: 1.5rem; color: var(--text); margin-top: 0.5rem; }
.login-card .logo p { color: var(--text-light); font-size: 0.875rem; }

/* ===== Setup Page ===== */
.setup-card { max-width: 500px; }
.setup-card .step-indicator { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; justify-content: center; }
.setup-card .step { width: 40px; height: 4px; background: var(--border); border-radius: 2px; }
.setup-card .step.active { background: var(--primary); }

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-sidebar); color: #fff;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    display: flex; flex-direction: column; transition: transform 0.3s ease;
    overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar-header {
    padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; gap: 0.75rem;
}
.sidebar-header i { font-size: 1.5rem; color: var(--primary-light); }
.sidebar-header h2 { font-size: 1.125rem; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-nav .nav-section { padding: 0.5rem 1.5rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-top: 0.5rem; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7); cursor: pointer; transition: var(--transition);
    border-left: 3px solid transparent; font-size: 0.9rem;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,0.15); color: var(--primary-light); border-left-color: var(--primary-light); }
.nav-item i { width: 20px; text-align: center; font-size: 1rem; }
.nav-item .badge {
    margin-left: auto; background: var(--danger); color: #fff; font-size: 0.7rem;
    padding: 0.15rem 0.5rem; border-radius: 10px; font-weight: 600;
}
.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-footer .user-info { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-footer .user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem;
}
.sidebar-footer .user-name { font-size: 0.875rem; font-weight: 500; }
.sidebar-footer .user-role { font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; }
.btn-logout {
    width: 100%; margin-top: 0.75rem; padding: 0.625rem; border: 1px solid rgba(255,255,255,0.15);
    background: rgba(220,38,38,0.1); color: #fca5a5; border-radius: var(--radius);
    cursor: pointer; font-size: 0.8rem; font-weight: 500; display: flex; align-items: center;
    justify-content: center; gap: 0.5rem; transition: var(--transition);
}
.btn-logout:hover { background: rgba(220,38,38,0.25); color: #fff; border-color: rgba(220,38,38,0.5); }
.btn-header-logout {
    color: var(--danger) !important; display: flex; align-items: center; gap: 0.375rem;
    font-size: 0.85rem; font-weight: 500; padding: 0.4rem 0.75rem !important;
    border-radius: var(--radius); border: 1px solid transparent;
}
.btn-header-logout:hover { background: #fee2e2 !important; border-color: #fecaca; }

/* Main Content */
.main-content {
    flex: 1; margin-left: var(--sidebar-width); min-height: 100vh;
    display: flex; flex-direction: column;
}

/* Header */
.top-header {
    height: var(--header-height); background: var(--bg-card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.25rem; color: var(--text); cursor: pointer; padding: 0.5rem; }
.header-title h1 { font-size: 1.25rem; font-weight: 600; }
.header-title p { font-size: 0.8rem; color: var(--text-light); }
.header-right { display: flex; align-items: center; gap: 1rem; }
.header-btn {
    background: none; border: none; color: var(--text-light); cursor: pointer;
    padding: 0.5rem; border-radius: var(--radius); position: relative; font-size: 1.1rem;
    transition: var(--transition);
}
.header-btn:hover { background: var(--bg); color: var(--text); }
.header-btn .notification-dot {
    position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
    background: var(--danger); border-radius: 50%;
}

/* Page Content */
.page-content { flex: 1; padding: 1.5rem; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow);
    border: 1px solid var(--border); overflow: hidden;
}
.card-header {
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem;
}
.card-header h2 { font-size: 1.1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: #f8fafc; }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow); border: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem; transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius); display: flex;
    align-items: center; justify-content: center; font-size: 1.25rem;
}
.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--secondary); }
.stat-icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-info h3 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-info p { font-size: 0.8rem; color: var(--text-light); }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; color: var(--text); }
.form-group label .required { color: var(--danger); }
.form-control {
    width: 100%; padding: 0.625rem 0.875rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.9rem; transition: var(--transition);
    background: var(--bg-card); color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; }
.input-group { display: flex; }
.input-group .input-prefix {
    padding: 0.625rem 0.75rem; background: var(--bg); border: 1px solid var(--border);
    border-right: none; border-radius: var(--radius) 0 0 var(--radius); color: var(--text-light);
    font-size: 0.875rem; white-space: nowrap;
}
.input-group .form-control { border-radius: 0 var(--radius) var(--radius) 0; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.625rem 1.25rem;
    border: none; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--secondary); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
    padding: 0.75rem 1rem; text-align: left; font-weight: 600; color: var(--text-light);
    background: #f8fafc; border-bottom: 2px solid var(--border); white-space: nowrap;
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.025em;
}
tbody td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: #f8fafc; }
tbody tr.clickable { cursor: pointer; }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0.6rem;
    border-radius: 20px; font-size: 0.75rem; font-weight: 500;
}
.badge-active { background: #d1fae5; color: #065f46; }
.badge-expiring { background: #fef3c7; color: #92400e; }
.badge-expired { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #e2e8f0; color: #475569; }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-editor { background: #dbeafe; color: #1e40af; }
.badge-viewer { background: #e2e8f0; color: #475569; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
    background: var(--bg-card); border-radius: var(--radius-lg); width: 100%;
    max-width: 700px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
    transform: translateY(20px); transition: transform 0.3s ease;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.25rem; color: var(--text-light); cursor: pointer; padding: 0.25rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ===== Alerts/Toast ===== */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 0.875rem 1.25rem; border-radius: var(--radius); color: #fff; font-size: 0.875rem;
    box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 0.75rem;
    min-width: 300px; max-width: 450px; animation: slideIn 0.3s ease;
}
.toast-success { background: var(--secondary); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }
.toast .toast-close { background: none; border: none; color: rgba(255,255,255,0.8); cursor: pointer; margin-left: auto; font-size: 1rem; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Alert Banners ===== */
.alert {
    padding: 0.875rem 1.25rem; border-radius: var(--radius); margin-bottom: 1rem;
    display: flex; align-items: flex-start; gap: 0.75rem; font-size: 0.875rem;
}
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert i { margin-top: 0.125rem; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.25rem; margin-top: 1rem; }
.pagination button {
    padding: 0.5rem 0.75rem; border: 1px solid var(--border); background: var(--bg-card);
    border-radius: var(--radius); cursor: pointer; font-size: 0.8rem; transition: var(--transition);
}
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Filters ===== */
.filters-bar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    padding: 1rem 1.5rem; background: #f8fafc; border-bottom: 1px solid var(--border);
}
.search-input {
    flex: 1; min-width: 200px; position: relative;
}
.search-input input { padding-left: 2.5rem; }
.search-input i { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.filter-select { min-width: 150px; }

/* ===== Comments ===== */
.comment-list { display: flex; flex-direction: column; gap: 0.75rem; }
.comment-item { padding: 0.75rem; background: var(--bg); border-radius: var(--radius); }
.comment-header { display: flex; justify-content: space-between; margin-bottom: 0.375rem; }
.comment-author { font-weight: 600; font-size: 0.85rem; }
.comment-date { font-size: 0.75rem; color: var(--text-muted); }
.comment-text { font-size: 0.875rem; color: var(--text); }
.comment-form { display: flex; gap: 0.5rem; margin-top: 1rem; }
.comment-form input { flex: 1; }

/* ===== Audit Log ===== */
.audit-item { display: flex; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.audit-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0; }
.audit-icon.create { background: #d1fae5; color: #065f46; }
.audit-icon.update { background: #dbeafe; color: #1e40af; }
.audit-icon.delete { background: #fee2e2; color: #991b1b; }
.audit-icon.login { background: #ede9fe; color: #5b21b6; }
.audit-info { flex: 1; }
.audit-info .audit-action { font-size: 0.875rem; font-weight: 500; }
.audit-info .audit-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ===== Contract Detail ===== */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.detail-item label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-item .value { font-size: 1rem; font-weight: 500; margin-top: 0.125rem; }
.additive-warning {
    background: linear-gradient(135deg, #fef3c7, #fde68a); border: 1px solid #f59e0b;
    border-radius: var(--radius); padding: 1rem; margin: 1rem 0;
    display: flex; align-items: center; gap: 0.75rem;
}
.additive-warning.danger { background: linear-gradient(135deg, #fee2e2, #fecaca); border-color: #ef4444; }
.additive-warning i { font-size: 1.5rem; }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 0.5rem; }
.progress-bar .fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.progress-bar .fill.green { background: var(--secondary); }
.progress-bar .fill.yellow { background: var(--warning); }
.progress-bar .fill.red { background: var(--danger); }

/* ===== KPI Dashboard ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card {
    border-radius: var(--radius-lg); padding: 1.5rem; color: #fff;
    position: relative; overflow: hidden; box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-icon {
    font-size: 1.5rem; opacity: 0.9; margin-bottom: 0.75rem;
}
.kpi-value { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.kpi-label { font-size: 0.85rem; opacity: 0.9; margin-top: 0.375rem; font-weight: 500; }
.kpi-sub { font-size: 0.72rem; opacity: 0.7; margin-top: 0.5rem; display: flex; align-items: center; gap: 0.375rem; }
.kpi-card::after {
    content: ''; position: absolute; top: -30px; right: -30px;
    width: 120px; height: 120px; border-radius: 50%;
    background: rgba(255,255,255,0.08);
}
.kpi-card::before {
    content: ''; position: absolute; bottom: -40px; left: -20px;
    width: 100px; height: 100px; border-radius: 50%;
    background: rgba(255,255,255,0.05);
}

.kpi-highlight {
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); border: 1px solid var(--border);
    overflow: hidden;
}
.kpi-highlight-inner {
    padding: 1.5rem; display: flex; align-items: center; justify-content: space-between;
    border-left: 4px solid var(--primary);
}

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* ===== Tabs ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab {
    padding: 0.75rem 1.25rem; cursor: pointer; font-size: 0.875rem; font-weight: 500;
    color: var(--text-light); border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-light); }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.125rem; margin-bottom: 0.5rem; color: var(--text); }
.empty-state p { font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .sidebar-overlay {
        position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99;
        opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
    }
    .sidebar-overlay.active { opacity: 1; pointer-events: all; }
}

@media (max-width: 768px) {
    /* Login - bonito no celular */
    .login-page { padding: 1rem; align-items: flex-start; padding-top: 8vh; }
    .login-card {
        padding: 1.75rem 1.5rem;
        border-radius: var(--radius-lg);
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
    .login-card .logo i { font-size: 2.5rem; }
    .login-card .logo h1 { font-size: 1.35rem; }
    .login-card .logo p { font-size: 0.8rem; }
    .login-card .form-control { padding: 0.75rem 1rem; font-size: 1rem; }
    .login-card .btn-lg { padding: 0.875rem; font-size: 1rem; }

    /* Layout geral */
    .page-content { padding: 0.75rem; }
    .top-header { padding: 0 1rem; height: 56px; }
    .top-header h1 { font-size: 1rem; }
    .header-title p { display: none; }

    /* Cards */
    .card { border-radius: var(--radius); }
    .card-header {
        flex-direction: column; align-items: flex-start; gap: 0.5rem;
        padding: 1rem;
    }
    .card-header h2 { font-size: 0.95rem; }
    .card-body { padding: 1rem; }

    /* Stats - 2 colunas no celular */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .stat-card { padding: 0.875rem; gap: 0.75rem; }
    .stat-icon { width: 40px; height: 40px; font-size: 1rem; }
    .stat-value { font-size: 1.25rem !important; }
    .stat-label { font-size: 0.7rem !important; }

    /* KPI Dashboard */
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.625rem; }
    .kpi-card { padding: 1rem; }
    .kpi-icon { font-size: 1.1rem; margin-bottom: 0.5rem; }
    .kpi-value { font-size: 1.75rem; }
    .kpi-label { font-size: 0.72rem; }
    .kpi-sub { font-size: 0.65rem; }
    .kpi-highlight-inner { padding: 1rem; flex-direction: column; gap: 0.5rem; }
    .kpi-highlight-inner > div:last-child { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; gap: 1rem; }

    /* Tabelas - não cortar dados */
    .table-container { margin: 0 -1rem; padding: 0 0; }
    table { font-size: 0.78rem; min-width: 600px; }
    thead th { padding: 0.5rem 0.625rem; font-size: 0.7rem; }
    tbody td { padding: 0.5rem 0.625rem; }

    /* Forms */
    .form-row { grid-template-columns: 1fr; }
    .form-control { font-size: 1rem; padding: 0.75rem; }
    .filters-bar { flex-direction: column; padding: 0.75rem !important; gap: 0.5rem !important; }
    .search-input { width: 100%; }
    .filter-select { width: 100%; min-width: 0 !important; }

    /* Modal */
    .modal-overlay { padding: 0.5rem; align-items: flex-start; padding-top: 5vh; }
    .modal { max-width: 100%; border-radius: var(--radius-lg); }
    .modal-header { padding: 1rem; }
    .modal-body { padding: 1rem; }
    .modal-footer { padding: 0.75rem 1rem; }

    /* Botões */
    .btn-group { flex-wrap: wrap; gap: 0.375rem; }
    .btn-sm { padding: 0.375rem 0.625rem; font-size: 0.78rem; }

    /* Toast */
    .toast-container { top: 0.5rem; right: 0.5rem; left: 0.5rem; }
    .toast { min-width: auto; max-width: 100%; font-size: 0.8rem; padding: 0.75rem 1rem; }

    /* Detail grid */
    .detail-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }

    /* Audit */
    .audit-grid { grid-template-columns: 1fr !important; }
    .audit-tabs { flex-direction: column !important; }
    .audit-tabs button { border-left: none !important; border-top: 2px solid var(--primary) !important; }
    .audit-tabs button:first-child { border-top: none !important; }
    .audit-item { gap: 0.625rem; padding: 0.625rem 0; }
    .audit-icon { width: 28px; height: 28px; font-size: 0.7rem; }

    /* Comments */
    .comment-form { flex-direction: column; }
    .comment-form .btn { width: 100%; justify-content: center; }

    /* Empty state */
    .empty-state { padding: 2rem 1rem; }
    .empty-state i { font-size: 2rem; }

    /* Pagination */
    .pagination { flex-wrap: wrap; }
    .pagination button { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
}

@media (max-width: 480px) {
    /* Login ainda mais compacto */
    .login-page { padding-top: 5vh; }
    .login-card { padding: 1.5rem 1.25rem; }

    /* Stats empilhados */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }

    /* Tabelas menores */
    table { min-width: 500px; font-size: 0.72rem; }
    thead th, tbody td { padding: 0.4rem 0.5rem; }

    /* Header compacto */
    .top-header h1 { font-size: 0.9rem; }
    .top-header .subtitle { font-size: 0.65rem; }
    .header-right .btn span { display: none; }

    /* Botões menores */
    .btn-group .btn-icon { min-width: 32px; min-height: 32px; padding: 0.25rem; }
    .card-header .btn-group .btn-sm { font-size: 0.72rem; padding: 0.3rem 0.5rem; }
    .card-header .btn-group .btn-sm i { font-size: 0.7rem; }

    /* Detail grid empilhado */
    .detail-grid { grid-template-columns: 1fr; }

    /* Additive warning */
    .additive-warning { flex-direction: column; text-align: center; padding: 0.75rem; }
    .additive-warning i { font-size: 1.25rem; }
}

.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger); }
.text-success { color: var(--secondary); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.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; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.currency::before { content: 'R$ '; }

/* ===== Print ===== */
@media print {
    .sidebar, .top-header, .menu-toggle, .btn, .filters-bar, .pagination { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}
