/* ============================================================
   RV Service Suite — Customer Portal Design System
   Mobile-first, CSS Custom Properties, Clean & Professional
   ============================================================ */

/* === CSS Custom Properties === */
:root {
    /* Portal primary - fallback from tenant branding via data attributes */
    --portal-primary: var(--tenant-primary, #3b82f6);
    --portal-primary-hover: var(--tenant-primary-hover, #2563eb);
    --portal-primary-light: var(--tenant-primary-light, #eff6ff);
    --portal-primary-subtle: var(--tenant-primary-subtle, rgba(59, 130, 246, 0.08));
    --portal-primary-glow: var(--tenant-primary-glow, rgba(59, 130, 246, 0.15));

    /* Sidebar */
    --portal-sidebar-width: 260px;
    --portal-sidebar-bg: #0f172a;
    --portal-sidebar-border: rgba(255, 255, 255, 0.06);
    --portal-sidebar-text: #94a3b8;
    --portal-sidebar-text-hover: #e2e8f0;
    --portal-sidebar-text-active: #ffffff;

    /* Semantic colors */
    --portal-success: #10b981;
    --portal-success-light: #ecfdf5;
    --portal-warning: #f59e0b;
    --portal-warning-light: #fffbeb;
    --portal-danger: #ef4444;
    --portal-danger-light: #fef2f2;
    --portal-info: #3b82f6;
    --portal-info-light: #eff6ff;

    /* Neutrals */
    --portal-text: #1e293b;
    --portal-text-secondary: #64748b;
    --portal-text-muted: #94a3b8;
    --portal-bg: #f8fafc;
    --portal-bg-card: #ffffff;
    --portal-border: #e2e8f0;
    --portal-border-light: #f1f5f9;

    /* Typography */
    --portal-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --portal-space-xs: 0.25rem;
    --portal-space-sm: 0.5rem;
    --portal-space-md: 1rem;
    --portal-space-lg: 1.5rem;
    --portal-space-xl: 2rem;
    --portal-space-2xl: 3rem;

    /* Radius */
    --portal-radius-sm: 0.375rem;
    --portal-radius-md: 0.5rem;
    --portal-radius-lg: 0.75rem;
    --portal-radius-xl: 1rem;
    --portal-radius-full: 9999px;

    /* Shadows */
    --portal-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --portal-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --portal-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --portal-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --portal-transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --portal-transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}


/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--portal-font);
    color: var(--portal-text);
    line-height: 1.6;
    background: var(--portal-bg);
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--portal-primary);
    text-decoration: none;
    transition: color var(--portal-transition-fast);
}

a:hover {
    color: var(--portal-primary-hover);
}

:focus-visible {
    outline: 2px solid var(--portal-primary);
    outline-offset: 2px;
}


/* ============================================================
   PORTAL LAYOUT
   ============================================================ */
.portal-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}


/* ============================================================
   SIDEBAR
   ============================================================ */
.portal-sidebar {
    width: var(--portal-sidebar-width);
    background: var(--portal-sidebar-bg);
    color: var(--portal-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    border-right: 1px solid var(--portal-sidebar-border);
    overflow: hidden;
    transition: transform var(--portal-transition-slow);
}

.portal-sidebar-header {
    padding: var(--portal-space-lg) var(--portal-space-lg);
    border-bottom: 1px solid var(--portal-sidebar-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.portal-sidebar-header a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.portal-sidebar .logo-img {
    max-height: 36px;
    width: auto;
    border-radius: var(--portal-radius-lg);
    object-fit: contain;
    flex-shrink: 0;
    background: #fff;
}

.portal-sidebar .logo-text {
    color: #fff;
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* --- Sidebar Navigation --- */
.portal-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--portal-space-sm) 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.portal-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    margin: 1px 0.75rem;
    border-radius: var(--portal-radius-md);
    color: var(--portal-sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--portal-transition-fast);
    cursor: pointer;
    white-space: nowrap;
}

.portal-nav .nav-item:hover {
    color: var(--portal-sidebar-text-hover);
    background: rgba(255, 255, 255, 0.06);
}

.portal-nav .nav-item.active {
    color: var(--portal-sidebar-text-active);
    background: var(--portal-primary-subtle);
    box-shadow: 0 0 12px var(--portal-primary-glow);
}

.portal-nav .nav-item.active .nav-icon {
    color: var(--portal-primary);
}

.portal-nav .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.8;
}

.portal-nav .nav-item.active .nav-icon {
    opacity: 1;
}

.portal-nav .nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 0.5rem 1.25rem;
}

/* Sidebar footer area */
.portal-sidebar-footer {
    padding: var(--portal-space-md) var(--portal-space-lg);
    border-top: 1px solid var(--portal-sidebar-border);
    flex-shrink: 0;
}

/* Sidebar overlay for mobile */
.portal-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--portal-transition-base);
}

.portal-sidebar-overlay.visible {
    display: block;
    opacity: 1;
}


/* ============================================================
   MAIN CONTENT
   ============================================================ */
.portal-main {
    margin-left: var(--portal-sidebar-width);
    flex-grow: 1;
    padding: var(--portal-space-xl);
    background: var(--portal-bg);
    min-height: 100vh;
    min-height: 100dvh;
}


/* ============================================================
   MOBILE HEADER (hamburger + logo, mobile only)
   ============================================================ */
.portal-mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    border-bottom: 1px solid var(--portal-border);
    padding: 0.75rem 1rem;
    align-items: center;
    gap: 0.75rem;
}

.portal-mobile-header .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--portal-text);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--portal-radius-md);
    transition: background var(--portal-transition-fast);
}

.portal-mobile-header .hamburger-btn:hover {
    background: var(--portal-border-light);
}

.portal-mobile-header .mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--portal-text);
    text-decoration: none;
    font-size: 1rem;
}

.portal-mobile-header .mobile-logo img {
    max-height: 28px;
    width: auto;
}


/* ============================================================
   PORTAL AUTH (Login / Register Pages)
   ============================================================ */
.portal-auth-body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f0f4ff 0%, var(--portal-bg, #f8fafc) 50%, #f0f4ff 100%);
    min-height: 100vh;
}

.portal-auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem 1rem;
}

.portal-auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 2.5rem 2rem 2rem;
    border: 1px solid #e2e8f0;
}

.portal-auth-logo-area {
    text-align: center;
    margin-bottom: 1.75rem;
}

.portal-auth-logo-img {
    max-height: 64px;
    width: auto;
    display: block;
    margin: 0 auto;
}

.portal-auth-logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--portal-text, #1e293b);
    letter-spacing: -0.02em;
}

.portal-auth-heading {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--portal-text, #1e293b);
    margin: 0 0 0.375rem;
    text-align: center;
}

.portal-auth-subtext {
    font-size: 0.875rem;
    color: #64748b;
    text-align: center;
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

.portal-auth-alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    line-height: 1.4;
}

.portal-auth-alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.portal-auth-alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.portal-auth-card .portal-form .form-group {
    margin-bottom: 1rem;
}

.portal-auth-card .portal-form label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--portal-text, #1e293b);
    margin-bottom: 0.375rem;
}

.portal-auth-card .portal-form input[type="email"],
.portal-auth-card .portal-form input[type="password"],
.portal-auth-card .portal-form input[type="text"] {
    width: 100%;
    padding: 0.75rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: #fff;
    color: var(--portal-text, #1e293b);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    box-sizing: border-box;
}

.portal-auth-card .portal-form input:focus {
    border-color: var(--portal-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.portal-auth-card .portal-form input::placeholder {
    color: #9ca3af;
}

.portal-auth-card .portal-btn-block {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    background: var(--portal-primary, #2563eb);
    color: #fff;
    transition: all 0.15s;
    margin-top: 0.5rem;
}

.portal-auth-card .portal-btn-block:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.portal-auth-toggle {
    text-align: center;
    margin-top: 1rem;
}

.portal-auth-toggle a {
    font-size: 0.8125rem;
    color: var(--portal-primary, #2563eb);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.15s;
}

.portal-auth-toggle a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.portal-auth-help {
    text-align: center;
    font-size: 0.8125rem;
    color: #94a3b8;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.portal-auth-footer {
    text-align: center;
    margin-top: 1.5rem;
}

.portal-auth-footer a {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: color 0.15s;
}

.portal-auth-footer a:hover {
    color: var(--portal-primary, #2563eb);
}


/* ============================================================
   PAGE HEADER
   ============================================================ */
.portal-page-header {
    margin-bottom: var(--portal-space-xl);
}

.portal-page-header h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--portal-text);
    line-height: 1.3;
}

.portal-page-header .subtitle {
    font-size: 0.9375rem;
    color: var(--portal-text-secondary);
    margin-top: var(--portal-space-xs);
}


/* ============================================================
   CARDS
   ============================================================ */
.portal-card {
    background: var(--portal-bg-card);
    border-radius: var(--portal-radius-lg);
    border: 1px solid var(--portal-border);
    padding: var(--portal-space-lg);
    margin-bottom: var(--portal-space-lg);
}

.portal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--portal-space-md);
    margin-bottom: var(--portal-space-md);
    border-bottom: 1px solid var(--portal-border-light);
    gap: var(--portal-space-md);
}

.portal-card-title {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--portal-text);
}

.portal-card-body {
    color: var(--portal-text);
}


/* ============================================================
   EMPTY STATE
   ============================================================ */
.portal-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--portal-space-2xl) var(--portal-space-lg);
}

.portal-empty .empty-icon {
    font-size: 2.5rem;
    color: var(--portal-text-muted);
    margin-bottom: var(--portal-space-md);
    opacity: 0.5;
}

.portal-empty h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: var(--portal-space-xs);
}

.portal-empty p {
    font-size: 0.875rem;
    color: var(--portal-text-secondary);
    max-width: 320px;
}


/* ============================================================
   BADGES
   ============================================================ */
.portal-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--portal-radius-full);
    white-space: nowrap;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* Status variants */
.portal-badge-pending {
    background: var(--portal-warning-light);
    color: #92400e;
}

.portal-badge-confirmed,
.portal-badge-sent {
    background: var(--portal-info-light);
    color: #1e40af;
}

.portal-badge-completed,
.portal-badge-accepted,
.portal-badge-paid {
    background: var(--portal-success-light);
    color: #065f46;
}

.portal-badge-cancelled,
.portal-badge-declined,
.portal-badge-overdue {
    background: var(--portal-danger-light);
    color: #991b1b;
}

.portal-badge-draft,
.portal-badge-gray {
    background: #f1f5f9;
    color: #475569;
}

.portal-badge-in_progress,
.portal-badge-amber {
    background: #fef3c7;
    color: #92400e;
}

.portal-badge-invoiced,
.portal-badge-purple {
    background: #f3e8ff;
    color: #6b21a8;
}

.portal-badge-green {
    background: var(--portal-success-light);
    color: #065f46;
}

.portal-badge-blue {
    background: var(--portal-info-light);
    color: #1e40af;
}

.portal-badge-red {
    background: var(--portal-danger-light);
    color: #991b1b;
}

.portal-badge-yellow {
    background: var(--portal-warning-light);
    color: #92400e;
}


/* ============================================================
   TABLES
   ============================================================ */
.portal-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--portal-radius-lg);
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.portal-table thead {
    background: var(--portal-border-light);
}

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

.portal-table td {
    padding: 0.75rem;
    font-size: 0.875rem;
    color: var(--portal-text);
    border-bottom: 1px solid var(--portal-border-light);
    vertical-align: middle;
}

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

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

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

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

.portal-table .text-nowrap {
    white-space: nowrap;
}


/* ============================================================
   BUTTONS
   ============================================================ */
.portal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--portal-font);
    line-height: 1.4;
    border-radius: var(--portal-radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--portal-transition-fast);
    background: var(--portal-primary);
    color: #fff;
}

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

.portal-btn:active {
    transform: translateY(1px);
}

.portal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

.portal-btn-outline:hover {
    background: var(--portal-primary-light);
    color: var(--portal-primary-hover);
}

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

.portal-btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.portal-btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
}

.portal-btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.portal-btn-block {
    display: flex;
    width: 100%;
}


/* ============================================================
   FORMS
   ============================================================ */
.portal-form .form-group {
    margin-bottom: var(--portal-space-md);
}

.portal-form label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: var(--portal-space-xs);
}

.portal-form input[type="text"],
.portal-form input[type="email"],
.portal-form input[type="password"],
.portal-form input[type="tel"],
.portal-form input[type="number"],
.portal-form input[type="date"],
.portal-form input[type="time"],
.portal-form input[type="url"],
.portal-form input[type="search"],
.portal-form select,
.portal-form textarea {
    display: block;
    width: 100%;
    padding: 0.5625rem 0.875rem;
    font-size: 0.875rem;
    font-family: var(--portal-font);
    line-height: 1.5;
    color: var(--portal-text);
    background: var(--portal-bg-card);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-md);
    transition: border-color var(--portal-transition-fast), box-shadow var(--portal-transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

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

.portal-form input::placeholder,
.portal-form textarea::placeholder {
    color: var(--portal-text-muted);
}

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

.portal-form select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}

.portal-form .form-hint {
    font-size: 0.8125rem;
    color: var(--portal-text-muted);
    margin-top: var(--portal-space-xs);
}

.portal-form .form-error {
    font-size: 0.8125rem;
    color: var(--portal-danger);
    margin-top: var(--portal-space-xs);
}

.portal-form .form-error + input,
.portal-form .form-error + select,
.portal-form .form-error + textarea {
    border-color: var(--portal-danger);
}

.portal-form-actions {
    display: flex;
    align-items: center;
    gap: var(--portal-space-md);
    margin-top: var(--portal-space-lg);
}


/* ============================================================
   DETAIL PAGES
   ============================================================ */
.portal-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--portal-space-md) var(--portal-space-xl);
}

.portal-detail-row {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.portal-detail-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--portal-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.portal-detail-value {
    font-size: 0.9375rem;
    color: var(--portal-text);
}

/* Line items table (invoices, estimates) */
.portal-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--portal-space-md);
}

.portal-items-table th {
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--portal-text-secondary);
    border-bottom: 2px solid var(--portal-border);
    background: var(--portal-border-light);
}

.portal-items-table td {
    padding: 0.75rem;
    font-size: 0.875rem;
    color: var(--portal-text);
    border-bottom: 1px solid var(--portal-border-light);
}

.portal-items-table tfoot td {
    font-weight: 700;
    border-top: 2px solid var(--portal-border);
    border-bottom: none;
}


/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.portal-flash {
    position: fixed;
    top: var(--portal-space-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 0.75rem 1.25rem;
    border-radius: var(--portal-radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--portal-shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 480px;
    width: calc(100% - 2rem);
    animation: portalFlashIn 0.3s ease-out;
}

.portal-flash-success {
    background: #065f46;
    color: #fff;
}

.portal-flash-error {
    background: #991b1b;
    color: #fff;
}

.portal-flash-warning {
    background: #92400e;
    color: #fff;
}

.portal-flash .flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.125rem;
    opacity: 0.7;
    transition: opacity var(--portal-transition-fast);
    padding: 0;
    line-height: 1;
}

.portal-flash .flash-close:hover {
    opacity: 1;
}

@keyframes portalFlashIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes portalFlashOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-12px);
    }
}

.portal-flash.dismissing {
    animation: portalFlashOut 0.25s ease-in forwards;
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-muted { color: var(--portal-text-muted); }
.text-secondary { color: var(--portal-text-secondary); }
.text-danger { color: var(--portal-danger); }
.text-success { color: var(--portal-success); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.8125rem; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: var(--portal-space-md); }
.mt-2 { margin-top: var(--portal-space-xl); }
.mb-1 { margin-top: var(--portal-space-md); }
.mb-2 { margin-bottom: var(--portal-space-xl); }


/* ============================================================
   RESPONSIVE — Mobile (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
    /* Sidebar becomes slide-in drawer */
    .portal-sidebar {
        transform: translateX(-100%);
    }

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

    /* Main content full-width */
    .portal-main {
        margin-left: 0;
        padding: var(--portal-space-md);
        padding-top: 0;
    }

    /* Mobile header visible */
    .portal-mobile-header {
        display: flex;
    }

    /* Page header */
    .portal-page-header h1 {
        font-size: 1.375rem;
    }

    /* Cards full width */
    .portal-card {
        border-radius: var(--portal-radius-md);
        padding: var(--portal-space-md);
    }

    .portal-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--portal-space-sm);
    }

    /* Tables scroll horizontally */
    .portal-table-wrapper {
        margin: 0 calc(-1 * var(--portal-space-md));
        padding: 0 var(--portal-space-md);
    }

    /* Detail grid single column */
    .portal-detail-grid {
        grid-template-columns: 1fr;
        gap: var(--portal-space-md);
    }

    /* Forms */
    .portal-form-actions {
        flex-direction: column;
    }

    .portal-form-actions .portal-btn {
        width: 100%;
    }

    /* Auth */
    .portal-auth-card {
        padding: var(--portal-space-lg);
        box-shadow: var(--portal-shadow-sm);
    }

    /* Flash */
    .portal-flash {
        top: var(--portal-space-md);
        max-width: calc(100% - 2rem);
    }

    /* Buttons full width on mobile */
    .portal-btn-mobile-block {
        display: flex;
        width: 100%;
    }
}

/* Desktop sidebar always visible */
@media (min-width: 769px) {
    .portal-sidebar {
        transform: translateX(0);
    }

    .portal-mobile-header {
        display: none;
    }

    .portal-sidebar-overlay {
        display: none !important;
    }
}


/* ============================================================
   DASHBOARD - Summary Cards
   ============================================================ */
.portal-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.portal-summary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    background: var(--portal-bg-card);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-lg);
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}

.portal-summary-card:hover {
    border-color: var(--portal-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.portal-summary-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--portal-primary-light, rgba(37, 99, 235, 0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--portal-primary);
    margin-bottom: 0.75rem;
}

.portal-summary-count {
    font-size: 2rem;
    font-weight: 800;
    color: var(--portal-text);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.portal-summary-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--portal-text-secondary);
}

/* Quick Actions */
.portal-quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* ============================================================
   FORMS - Standalone classes (outside .portal-form wrapper)
   ============================================================ */
.portal-form-group {
    margin-bottom: 1rem;
}

.portal-form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--portal-text);
    margin-bottom: 0.375rem;
}

.portal-form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: var(--portal-font);
    color: var(--portal-text);
    background: var(--portal-bg-card);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-md);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.portal-form-control:focus {
    outline: none;
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px var(--portal-primary-subtle, rgba(37, 99, 235, 0.1));
}

.portal-form-control::placeholder {
    color: var(--portal-text-muted);
}

.portal-form-control:disabled {
    background: var(--portal-border-light, #f1f5f9);
    color: var(--portal-text-secondary);
    cursor: not-allowed;
}

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

.portal-help-text {
    font-size: 0.75rem;
    color: var(--portal-text-muted);
    margin-top: 0.25rem;
}

.portal-required {
    color: var(--portal-danger, #ef4444);
}

/* ============================================================
   DETAIL PAGE
   ============================================================ */
.portal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.portal-detail-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--portal-text-secondary);
    margin-bottom: 0.25rem;
}

.portal-detail-item span {
    font-size: 0.9375rem;
    color: var(--portal-text);
}

/* Back link */
.portal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--portal-text-secondary);
    text-decoration: none;
    margin-bottom: 1rem;
    transition: color 0.15s;
}

.portal-back-link:hover {
    color: var(--portal-primary);
}

/* Utility */
.portal-text-muted { color: var(--portal-text-muted); }
.portal-text-success { color: #059669; }
.portal-mt-3 { margin-top: 1rem; }
.portal-mt-4 { margin-top: 1.5rem; }

@media (max-width: 768px) {
    .portal-summary-grid {
        grid-template-columns: 1fr;
    }
    .portal-quick-actions {
        flex-direction: column;
    }
    .portal-quick-actions .portal-btn {
        width: 100%;
    }
    .portal-form-row {
        grid-template-columns: 1fr;
    }
    .portal-detail-grid {
        grid-template-columns: 1fr;
    }
}
