:root {
    /* Warm olive-brown scale (base: #29261b) */
    --forest-950: #1a1814;
    --forest-900: #29261b;
    --forest-800: #3d382a;
    --forest-700: #524c3a;
    --forest-600: #68614b;
    --forest-500: #7d755c;
    --forest-400: #978e74;
    --forest-300: #b5ad96;
    --forest-200: #d4cfc0;
    --forest-100: #e8e5dc;
    --forest-50: #f6f4ef;
    /* Warm cream */
    --sage-50: #f6f4ef;
    --sage-100: #edeae0;
    --sage-200: #ddd9cd;
    --cream: #f6f4ef;
    /* Terra cotta accent */
    --terra-700: #b8573a;
    --terra-600: #c96445;
    --terra-500: #D97757;
    --terra-400: #e18f73;
    --terra-300: #e9a790;
    --terra-200: #f2cfc3;
    --terra-100: #f8e7e1;
    --terra-50: #fdf3f0;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
    font-size: 0.8125rem;
    line-height: 1.4;
}

h1, h2, h3, .font-serif {
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-weight: 600;
}

.brand-logo {
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 600;
}

/* Sidebar — light theme */
.sidebar {
    background: #ffffff;
    border-right: 1px solid rgba(0,0,0,0.08);
}

.sidebar-link {
    transition: all 0.15s ease;
    border-left: 2px solid transparent;
}

.sidebar-link:hover {
    background: rgba(41,38,27,0.04);
    border-left-color: var(--forest-300);
}

.sidebar-link.active {
    background: rgba(41,38,27,0.06);
    border-left-color: var(--terra-500);
    font-weight: 500;
}

/* Tables */
.data-table {
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(41,38,27,0.45);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding: 0.75rem 1rem;
}

.data-table tbody td {
    padding: 0.7rem 1rem;
    font-size: 0.8125rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    color: rgba(41,38,27,0.85);
}

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

.data-table tbody tr:hover {
    background: rgba(0,0,0,0.025);
}

/* Cards */
.card {
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: rgba(0,0,0,0.18);
    box-shadow: 0 4px 16px rgba(41,38,27,0.06);
}

/* Forms */
.form-input {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    transition: all 0.15s ease;
    background: rgba(255,255,255,0.6);
}

.form-input:focus {
    outline: none;
    border-color: rgba(0,0,0,0.25);
    background: rgba(255,255,255,0.85);
    box-shadow: 0 0 0 3px rgba(217,119,87,0.1);
}

.form-input[readonly] {
    background: var(--sage-50);
    color: rgba(41,38,27,0.5);
}

/* Buttons */
.btn-primary {
    background: var(--terra-500);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.btn-primary:hover {
    background: var(--terra-600);
}

.btn-secondary {
    background: white;
    color: var(--forest-800);
    padding: 0.5rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid rgba(0,0,0,0.1);
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.18);
}

.btn-danger {
    color: #b91c1c;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: color 0.15s ease;
}

.btn-danger:hover {
    color: #991b1b;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-active { background: var(--terra-50); color: var(--terra-700); }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-superadmin { background: #fef2f2; color: #991b1b; }
.badge-am { background: var(--forest-100); color: var(--forest-700); }
.badge-client { background: #eff6ff; color: #1e40af; }
.badge-brand-admin { background: #faf5ff; color: #6b21a8; }
.badge-warehouse { background: #fffbeb; color: #92400e; }
.badge-production { background: #f0fdf4; color: #166534; }

/* Pagination */
.pagination-link {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0.375rem;
    color: var(--forest-800);
    transition: all 0.15s ease;
}

.pagination-link:hover {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.18);
}

/* Search input */
.search-input {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    padding-left: 2.25rem;
    font-size: 0.8125rem;
    background: rgba(255,255,255,0.6);
    transition: all 0.15s ease;
    width: 16rem;
}

.search-input:focus {
    outline: none;
    border-color: rgba(0,0,0,0.25);
    background: rgba(255,255,255,0.85);
    box-shadow: 0 0 0 3px rgba(217,119,87,0.1);
}

/* HTMX indicators */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }

/* Modal */
.modal-backdrop {
    background: rgba(41,38,27,0.4);
    backdrop-filter: blur(2px);
}

/* Sidebar nav counts */
.nav-count {
    font-size: 0.625rem;
    font-weight: 500;
    color: rgba(41,38,27,0.25);
    min-width: 1.25rem;
    text-align: right;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-count-visible {
    opacity: 1;
}

/* Dividers */
.divider-label {
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(41,38,27,0.35);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* Credential cards */
.cred-card {
    transition: all 0.2s ease;
}

.cred-card:hover {
    border-color: rgba(0,0,0,0.18);
    box-shadow: 0 4px 16px rgba(41,38,27,0.06);
}

.cred-initials-badge {
    letter-spacing: 0.05em;
}

.cred-field-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(41,38,27,0.4);
    min-width: 5.5rem;
    flex-shrink: 0;
}

.cred-action-btn {
    flex-shrink: 0;
    padding: 0.25rem;
    border-radius: 0.25rem;
    color: rgba(41,38,27,0.25);
    transition: all 0.15s ease;
    opacity: 0;
}

.cred-field-row:hover .cred-action-btn,
.cred-action-btn:focus {
    opacity: 1;
}

.cred-action-btn:hover {
    color: var(--terra-500);
    background: var(--terra-50);
}

/* Stats cards (mappings, etc.) */
.stat-card {
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: rgba(0,0,0,0.18);
    box-shadow: 0 2px 8px rgba(41,38,27,0.04);
}

/* Empty state */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: rgba(41,38,27,0.45);
}

/* Link styles */
.link-primary {
    color: var(--terra-500);
    transition: color 0.15s ease;
}

.link-primary:hover {
    color: var(--terra-600);
}

/* Brand switcher */
.brand-select {
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.1);
    color: var(--forest-900);
    font-size: 0.8125rem;
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    width: 100%;
    transition: border-color 0.15s ease;
}

.brand-select:focus {
    outline: none;
    border-color: rgba(0,0,0,0.25);
}

.brand-select option {
    background: white;
    color: var(--forest-900);
}

/* ── Toast notifications ──────────────────────────────────────── */
.toast {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    background: white;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.06);
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
    min-width: 280px;
    max-width: 420px;
}

.toast-enter {
    transform: translateX(0);
    opacity: 1;
}

.toast-exit {
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
}

.toast-success { border-left: 3px solid #22c55e; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-warning { border-left: 3px solid #f59e0b; }
.toast-info { border-left: 3px solid #3b82f6; }

.toast-icon { flex-shrink: 0; display: flex; align-items: center; }
.toast-text { flex: 1; color: var(--forest-900); line-height: 1.4; }

.toast-close {
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: rgba(0,0,0,0.2);
    font-size: 1.125rem;
    padding: 0 0.125rem;
    transition: color 0.15s ease;
    line-height: 1;
}

.toast-close:hover { color: rgba(0,0,0,0.5); }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    animation: toast-timer 4s linear forwards;
}

.toast-progress-success, .toast-progress[style*="background:#22c55e"] { background: #22c55e; }
.toast-progress-error, .toast-progress[style*="background:#ef4444"] { background: #ef4444; }
.toast-progress-warning, .toast-progress[style*="background:#f59e0b"] { background: #f59e0b; }
.toast-progress-info, .toast-progress[style*="background:#3b82f6"] { background: #3b82f6; }

@keyframes toast-timer {
    from { width: 100%; }
    to { width: 0%; }
}
