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

:root {
    /* Modern Corporate Palette */
    --primary-color: #2563eb;      /* Blue 600 */
    --primary-dark: #1d4ed8;       /* Blue 700 */
    --primary-light: #60a5fa;      /* Blue 400 */
    --primary-50: #eff6ff;         /* Blue 50 */
    --secondary-color: #475569;    /* Slate 600 */
    --accent-color: #f59e0b;       /* Amber 500 */
    --success-color: #059669;      /* Emerald 600 */
    --success-bg: #d1fae5;         /* Emerald 100 */
    --warning-color: #d97706;      /* Amber 600 */
    --warning-bg: #fef3c7;         /* Amber 100 */
    --danger-color: #dc2626;       /* Red 600 */
    --danger-bg: #fee2e2;          /* Red 100 */
    --background-color: #f8fafc;   /* Slate 50 */
    --surface-color: #ffffff;      /* White */
    --text-primary: #0f172a;       /* Slate 900 */
    --text-secondary: #334155;     /* Slate 700 */
    --text-muted: #64748b;         /* Slate 500 */
    --border-color: #e2e8f0;       /* Slate 200 */
    --bg-secondary: var(--background-color);
    --text-color: var(--text-primary);
    --color-primary: var(--primary-color);
    
    /* Refined Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Updated Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;              
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Layout */
    --sidebar-width: 280px;
    --header-height: 64px;         
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input,
select,
textarea {
    font-family: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

.app-logo {
    width: 120px;
    height: auto;
    display: block;
    filter: grayscale(100%) contrast(1.2);
}

.logo-small {
    width: 80px;
    height: auto;
    filter: grayscale(100%) contrast(1.2);
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-card {
    background: var(--surface-color);
    padding: 3rem 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.login-logo {
    margin-bottom: 2rem;
}

.login-logo img {
    width: 120px;
    height: auto;
    margin: 0 auto;
}

.login-title {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 2rem;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: var(--surface-color);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:disabled,
.form-group select:disabled {
    background: var(--background-color);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

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

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

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

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--background-color);
}

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

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

.import-dropdown {
    position: relative;
}

.dropdown-balloon {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    min-width: 180px;
    z-index: 100;
    padding: 0.5rem 0;
}

.dropdown-balloon.active {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-align: left;
    transition: background-color 0.15s;
}

.dropdown-item:hover {
    background: var(--background-color);
}

.dropdown-item svg {
    color: var(--text-secondary);
}

.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-error {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--success-bg);
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

.import-errors {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

.import-errors ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.import-errors li {
    margin-bottom: 0.25rem;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
    color: white;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand h1 {
    font-size: 1.125rem;
    color: white;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.025em;
}

.sidebar-brand .company-name {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* Hide restricted nav items until auth is resolved to prevent UI flash */
body:not(.auth-resolved) .nav-link[href="funcionarios.html"],
body:not(.auth-resolved) .nav-link[href="estoque.html"],
body:not(.auth-resolved) .nav-link[href="usuarios.html"],
body:not(.auth-resolved) .nav-link[href="contratos.html"],
body:not(.auth-resolved) #adminSection {
    display: none !important;
}

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

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

.nav-section-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    padding: 0.5rem 1.5rem;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    margin: 0 1rem 0.25rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-md);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 600;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-link {
    display: block;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    text-decoration: none;
    margin-bottom: 0.75rem;
    transition: color 0.2s ease;
}

.sidebar-link:hover {
    color: rgba(255, 255, 255, 1);
    text-decoration: underline;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1rem;
}

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

.user-details {
    flex: 1;
    min-width: 0;
    color: white;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

.mobile-header {
    display: none;
    height: var(--header-height);
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.mobile-menu-btn:hover {
    background: var(--background-color);
}

.mobile-logo img {
    height: 32px;
    width: auto;
    filter: grayscale(100%) contrast(1.2);
}

.main-header {
    background: var(--surface-color);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.main-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.025em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.main-body {
    flex: 1;
    padding: 2rem;
}

.page-intro {
    margin-bottom: 2rem;
}

.page-intro h1 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.page-intro p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-card h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon.blue {
    background: var(--primary-50);
    color: var(--primary-color);
}

.stat-card-icon.green {
    background: var(--success-bg);
    color: var(--success-color);
}

.stat-card-icon.yellow {
    background: var(--warning-bg);
    color: var(--warning-color);
}

.stat-card-icon.red {
    background: var(--danger-bg);
    color: var(--danger-color);
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.stat-card .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 2rem;
}

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

.card-header h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
    overflow-x: auto;
}

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

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.toolbar-search {
    display: flex;
    gap: 0.75rem;
    flex: 1;
    max-width: 400px;
}

.toolbar-search input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

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

.toolbar-actions {
    display: flex;
    gap: 0.75rem;
}

.data-table-wrapper {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--background-color);
    white-space: nowrap;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:nth-child(even) {
    background-color: var(--background-color);
}

.data-table tbody tr:hover {
    background-color: var(--primary-50);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .actions {
    display: flex;
    gap: 0.5rem;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-color);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-color);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-color);
}

.badge-info {
    background: var(--primary-50);
    color: var(--primary-color);
}

.badge-secondary {
    background: var(--border-color);
    color: var(--text-secondary);
}

.badge-muted {
    background: var(--background-color);
    color: var(--text-secondary);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-content.modal-lg {
    max-width: 800px;
}

.modal.active .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

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

.modal-content form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 0;
    flex: 1;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
    background: var(--background-color);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.75rem;
}

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

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: var(--text-muted);
}

.empty-state h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.empty-state p {
    font-size: 0.875rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.item-row {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.item-row:last-child {
    margin-bottom: 0;
}

.item-row-content {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.item-actions {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0.25rem;
}

.signature-section {
    background: var(--background-color);
    padding: 1rem;
    border-radius: var(--radius-md);
}

.signature-wrapper {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: white;
}

.signature-pad {
    display: block;
    width: 100%;
    height: 150px;
    cursor: crosshair;
    background: white;
}

.signature-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
}

.signature-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

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

.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;
}

.hidden {
    display: none !important;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 999;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --header-height: 60px;
    }

    .sidebar {
        width: 280px;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .main-content {
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
    }

    .main-header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 0.75rem;
    }

    .main-header h2 {
        font-size: 1.25rem;
    }

    .main-header>div {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .main-header>div .btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
        font-size: 0.8125rem;
        padding: 0.625rem 0.75rem;
    }

    .main-body {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-card .value {
        font-size: 1.5rem;
    }

    .card-header {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-search {
        max-width: none;
    }

    .toolbar-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .toolbar-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }

    .data-table .actions {
        flex-direction: column;
        gap: 0.25rem;
    }

    .modal-content {
        max-width: 95%;
        margin: auto;
        border-radius: var(--radius-lg);
        max-height: 90vh;
    }

    .modal-header {
        padding: 1.25rem 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }

    .page-intro h1 {
        font-size: 1.25rem;
    }
}

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .data-table-wrapper {
        margin: 0 -1rem;
        padding: 0 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
    }

    .data-table .actions {
        flex-direction: column;
        gap: 0.25rem;
    }

    .item-row-content {
        flex-direction: column;
        align-items: stretch;
    }

    .item-row-content .form-group {
        flex: 1;
    }

    .signature-pad {
        height: 120px;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }

    .page-intro h1 {
        font-size: 1.25rem;
    }
}

@media print {
    .sidebar,
    .mobile-header,
    .toolbar,
    .btn,
    .modal {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* CSP inline-style replacements */
.u-inline-001 { margin-top: 1.5rem; }
.u-inline-002 { font-size: 0.875rem; text-decoration: underline; }
.u-inline-003 { display: block; margin-top: 0.25rem; font-size: 0.75rem; }
.u-inline-004 { text-align: right; margin-top: 0.5rem; }
.u-inline-005 { font-size: 0.8125rem; text-decoration: underline; }
.u-inline-006 { font-size: 0.8125rem; }
.u-inline-007 { margin-top: 1.5rem; text-align: center; }
.u-inline-008 { font-size: 0.8125rem; padding: 0.5rem 1rem; }
.u-inline-009 { margin-right: 0.5rem; }
.u-inline-010 { display: block; margin-top: 4px; font-size: 0.75rem; }
.u-inline-011 { margin-bottom: 0.5rem; }
.u-inline-012 { font-weight: bold; margin-top: 2px; }
.u-inline-013 { display: none; }
.u-inline-014 { width: 44px; }
.u-inline-015 { color: var(--text-muted); }
.u-inline-016 { padding: 0.5rem; background: var(--background-color); border-radius: 4px; color: var(--text-muted); }
.u-inline-017 { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.u-inline-018 { width: auto; }
.u-inline-019 { color: var(--danger-color); display: none; }
.u-inline-020 { display: none; margin-bottom: 1.5rem; }
.u-inline-021 { margin-bottom: 1rem; }
.u-inline-022 { max-width: 800px; }
.u-inline-023 { padding: 0; }
.u-inline-024 { flex: 2; margin-bottom: 0; }
.u-inline-025 { flex: 1; margin-bottom: 0; }
.u-inline-026 { max-width: 600px; }
.u-inline-027 { background: var(--background-color); padding: 1rem; border-radius: var(--radius-md); font-size: 0.875rem; margin-bottom: 1rem; color: var(--text-primary); border: 1px solid var(--border-color); }
.u-inline-028 { padding-left: 1.5rem; margin-bottom: 0.5rem; }
.u-inline-029 { margin-bottom: 0; }
.u-inline-030 { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: bold; }
.u-inline-031 { color: var(--primary-color); text-decoration: underline; }
.u-inline-032 { max-width: 700px; }
.u-inline-033 { max-height: 300px; overflow-y: auto; }
.u-inline-034 { padding: 1rem; }
.u-inline-035 { color: var(--text-muted); font-size: 0.875rem; }
.u-inline-036 { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1rem; }
.u-inline-037 { margin-bottom: 1.5rem; }
.u-inline-038 { display: none; cursor: pointer; }
.u-inline-039 { display: none; background-color: #fff3cd; color: #856404; padding: 1rem; border-radius: 0.5rem; margin-bottom: 1rem; border: 1px solid #ffeeba; display: flex; align-items: center; gap: 0.5rem; }
.u-inline-040 { white-space: pre-wrap; }
.u-inline-041 { display: flex; gap: 10px; }
.u-inline-042 { display: none; position: relative; }
.u-inline-043 { margin-left: 4px; }
.u-inline-044 { width: 100%; }
.u-inline-045 { display: flex; align-items: flex-end; }
.u-inline-046 { margin-top: 0.5rem; }
.u-inline-047 { display: none; margin-bottom: 1rem; }
.u-inline-048 { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.u-inline-049 { display: flex; gap: 0.5rem; }
.u-inline-050 { flex: 1; }
.u-inline-051 { padding: 0.75rem; background: var(--bg-secondary); border-radius: 4px; margin-bottom: 1rem; }
.u-inline-052 { margin: 0 0 0.5rem 0; color: var(--text-muted); font-size: 0.875rem; }
.u-inline-053 { margin: 0 0 0.5rem 0; font-weight: 500; }
.u-inline-054 { margin: 0; color: var(--text-muted); font-size: 0.875rem; }
.u-inline-055 { padding: 2px 6px; border-radius: 4px; background: #dcfce7; color: #166534; font-size: 12px; }
.u-inline-056 { padding: 2px 6px; border-radius: 4px; background: #fee2e2; color: #991b1b; font-size: 12px; }
.u-inline-057 { display: flex; gap: 1rem; margin-bottom: 1rem; }
.u-inline-058 { flex: 1; margin: 0; }
.u-inline-059 { margin: 0.5rem 0 0 1.5rem; padding: 0; }
.u-inline-060 { width: 14px; height: 14px; border-width: 2px; }
.u-inline-061 { font-size: 0.8em; color: var(--primary-color); text-decoration: underline; }
.u-inline-062 { margin-top:10px; }
.u-inline-063 { margin-right: 4px; }
.u-inline-064 { margin-right: 4px; display: inline-block; margin-bottom: 2px; }
.u-inline-065 { font-size: 0.8em; color: var(--primary-color); }
