/* ==========================================================================
   Notification Platform Admin Portal - Modern Green Theme Design System
   Fully Responsive for Mobile, Tablet, Laptop, and Desktop Screens
   ========================================================================== */

:root {
    /* Emerald / Green Brand Palette */
    --brand-50: #f0fdf4;
    --brand-100: #dcfce7;
    --brand-200: #bbf7d0;
    --brand-300: #86efac;
    --brand-400: #4ade80;
    --brand-500: #22c55e;
    --brand-600: #16a34a;
    --brand-700: #15803d;
    --brand-800: #166534;
    --brand-900: #14532d;
    --brand-950: #052e16;

    /* Primary & Accent Accents */
    --primary: #059669;
    --primary-hover: #047857;
    --primary-active: #065f46;
    --primary-light: #ecfdf5;
    --primary-ring: rgba(5, 150, 105, 0.25);
    
    /* Neutrals & Slate */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --slate-950: #020617;

    /* Feedback / Status Colors */
    --success-bg: #dcfce7;
    --success-text: #15803d;
    --success-border: #86efac;
    --warning-bg: #fef3c7;
    --warning-text: #b45309;
    --warning-border: #fde68a;
    --danger-bg: #fee2e2;
    --danger-text: #b91c1c;
    --danger-border: #fca5a5;
    --info-bg: #e0f2fe;
    --info-text: #0369a1;
    --info-border: #bae6fd;

    /* Shadows & Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--slate-800);
    background-color: var(--slate-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Top Navigation Header */
.app-header {
    background: var(--slate-900);
    border-bottom: 3px solid var(--primary);
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.header-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--brand-400), var(--primary));
    color: #ffffff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
    flex-shrink: 0;
}

.brand-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.18);
    color: var(--brand-300);
    border: 1px solid rgba(52, 211, 153, 0.3);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 0.2rem;
}

/* Desktop Navigation */
.desktop-nav {
    display: flex;
    align-items: center;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

.nav-link {
    color: var(--slate-300);
    text-decoration: none;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.85rem;
    transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
    color: var(--brand-300);
    background: rgba(5, 150, 105, 0.22);
    border-bottom: 2px solid var(--brand-400);
    font-weight: 600;
}

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    color: var(--slate-200);
    white-space: nowrap;
}

.user-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--brand-600);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-role-tag {
    background: rgba(16, 185, 129, 0.25);
    color: var(--brand-300);
    font-size: 0.6875rem;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.signout-link {
    color: var(--slate-400);
    text-decoration: none;
    font-size: 0.8125rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
    white-space: nowrap;
}

.signout-link:hover {
    color: var(--danger-border);
    background: rgba(239, 68, 68, 0.1);
}

/* Mobile Hamburger Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 0.45rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Collapsible Mobile Navigation Drawer */
.mobile-nav-panel {
    display: none;
    background: var(--slate-950);
    border-bottom: 1px solid var(--slate-800);
    padding: 1.25rem;
}

.mobile-nav-panel.open {
    display: block;
    animation: slideDown 0.2s ease-out forwards;
}

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

.mobile-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--slate-900);
    border: 1px solid var(--slate-800);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.mobile-nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mobile-nav-links .nav-link {
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    justify-content: flex-start;
}

.mobile-nav-divider {
    height: 1px;
    background: var(--slate-800);
    margin: 0.75rem 0;
}

/* Main Container & Page Layout */
.app-main {
    flex: 1;
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

/* Breadcrumbs */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8125rem;
    color: var(--slate-500);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
}

.breadcrumb-nav a {
    color: var(--slate-600);
    text-decoration: none;
    transition: color 0.15s;
}

.breadcrumb-nav a:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: var(--slate-400);
    font-size: 0.75rem;
}

.breadcrumb-current {
    color: var(--slate-800);
    font-weight: 600;
}

/* Page Header & Action Bar */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.page-title-group {
    flex: 1;
    min-width: 260px;
}

.page-title-group h1 {
    font-size: clamp(1.3rem, 2.5vw, 1.625rem);
    font-weight: 700;
    color: var(--slate-900);
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    line-height: 1.3;
}

.page-description {
    color: var(--slate-500);
    font-size: 0.875rem;
    margin-top: 0.4rem;
    line-height: 1.5;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

/* Flash Messages / Alerts */
.alert-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.95rem 1.15rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    font-size: 0.9rem;
    word-break: break-word;
}

.alert-success {
    background-color: var(--brand-50);
    border: 1px solid var(--brand-300);
    color: var(--brand-900);
}

.alert-error {
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.policy-server-errors.validation-summary-valid {
    display: none;
}

.policy-server-errors ul {
    margin: 0;
    padding-left: 1.15rem;
}

.toast-region {
    position: fixed;
    z-index: 1200;
    top: 5.25rem;
    right: 1rem;
    display: grid;
    width: min(26rem, calc(100vw - 2rem));
    gap: 0.65rem;
    pointer-events: none;
}

.portal-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 0.9rem 0.9rem 1rem;
    background: var(--surface, #fdfefd);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 40px rgba(20, 38, 29, 0.18);
    opacity: 0;
    pointer-events: auto;
    transform: translateY(-0.5rem);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.portal-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.portal-toast-error {
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

.portal-toast-success {
    background: var(--brand-50);
    border-color: var(--brand-300);
}

.portal-toast-content {
    min-width: 0;
    flex: 1;
}

.portal-toast-content strong {
    display: block;
    color: var(--slate-900);
    font-size: 0.86rem;
}

.portal-toast-content p {
    margin: 0.25rem 0 0;
    color: var(--slate-600);
    font-size: 0.8rem;
    line-height: 1.45;
}

.portal-toast-close {
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    color: var(--slate-500);
    background: transparent;
    border: 0;
    border-radius: 0.35rem;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.portal-toast-close:hover,
.portal-toast-close:focus-visible {
    color: var(--slate-900);
    background: var(--slate-100);
    outline: none;
}

/* Cards */
.card {
    background: var(--surface, #ffffff);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.75rem;
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    width: 100%;
}

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

.card-header {
    padding: 1.1rem 1.35rem;
    background: var(--surface, #ffffff);
    border-bottom: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--slate-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.35rem;
}

.card-footer {
    padding: 0.95rem 1.35rem;
    background: var(--slate-50);
    border-top: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* KPI / Stat Cards Grid (Responsive 1-col, 2-col, 4-col) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.1rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--surface, #ffffff);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.stat-card.featured {
    background: linear-gradient(135deg, var(--brand-50) 0%, #ffffff 100%);
    border-color: var(--brand-300);
}

.stat-card.featured::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-400), var(--primary));
}

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

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--slate-500);
}

.stat-icon-wrapper {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: var(--brand-100);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-wrapper.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.stat-icon-wrapper.danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.stat-icon-wrapper.info {
    background: var(--info-bg);
    color: var(--info-text);
}

.stat-value {
    font-size: clamp(1.5rem, 3.5vw, 1.875rem);
    font-weight: 700;
    color: var(--slate-900);
    line-height: 1.2;
    word-break: break-word;
}

.stat-subtext {
    font-size: 0.8125rem;
    color: var(--slate-500);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* Green Highlight Callout */
.green-callout {
    background: linear-gradient(135deg, var(--brand-50) 0%, #ffffff 100%);
    border: 1px solid var(--brand-300);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 1.15rem 1.35rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.green-callout-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
    color: var(--brand-900);
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
    flex-wrap: wrap;
}

.green-callout-content {
    color: var(--slate-700);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Modern Responsive Data Tables */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-400);
    pointer-events: none;
    width: 15px;
    height: 15px;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.15rem !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--slate-300) !important;
    font-size: 0.875rem !important;
    background: var(--surface, #ffffff) !important;
    box-shadow: var(--shadow-xs);
}

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

.table-container {
    background: var(--surface, #ffffff);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.75rem;
    width: 100%;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    position: relative;
}

/* A wide table's rightmost columns (often the row's actions) can scroll fully out of view on
   narrow screens with no visual cue that more content exists — this hint only shows below the
   tablet breakpoint, where a table is actually likely to overflow its container. */
@media (max-width: 768px) {
    .table-responsive::after {
        content: "\2194  Scroll to see more";
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: var(--slate-400);
        padding: 0.4rem 0 0.1rem;
    }
}

/* Keeps a table's row-actions column reachable without hunting through horizontal scroll —
   applied via the .actions-col class on that column's <th>/<td> (see Templates/Details.cshtml). */
.modern-table .actions-col {
    position: sticky;
    right: 0;
    background: var(--surface, #ffffff);
    box-shadow: -6px 0 8px -6px rgba(15, 23, 42, 0.12);
}

table.modern-table thead th.actions-col {
    background: var(--slate-100);
}

table.modern-table tbody tr:hover td.actions-col {
    background-color: var(--brand-50);
}

table.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    text-align: left;
    min-width: 600px; /* Ensures minimum readable width before horizontal scrolling */
}

table.modern-table thead th {
    background: var(--slate-100);
    color: var(--slate-700);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
}

table.modern-table tbody tr {
    transition: background-color 0.15s ease;
}

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

table.modern-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--slate-100);
}

table.modern-table td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    color: var(--slate-700);
}

table.modern-table td.primary-cell {
    font-weight: 600;
    color: var(--slate-900);
}

table.modern-table td.primary-cell a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

table.modern-table td.primary-cell a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Badges & Status Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    line-height: 1.3;
    white-space: nowrap;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.badge-approved, .badge-active, .badge-verified, .badge-success {
    background: var(--brand-100);
    color: var(--brand-800);
    border-color: var(--brand-300);
}
.badge-approved .badge-dot, .badge-active .badge-dot, .badge-verified .badge-dot {
    background: var(--primary);
}

.badge-pending, .badge-processing, .badge-scheduled, .badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}
.badge-pending .badge-dot, .badge-processing .badge-dot {
    background: #f59e0b;
}

.badge-draft, .badge-info, .badge-unverified {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-border);
}
.badge-draft .badge-dot, .badge-info .badge-dot {
    background: #0284c7;
}

.badge-rejected, .badge-retired, .badge-suspended, .badge-danger, .badge-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
}
.badge-rejected .badge-dot, .badge-retired .badge-dot, .badge-suspended .badge-dot {
    background: #dc2626;
}

.badge-neutral {
    background: var(--slate-100);
    color: var(--slate-700);
    border-color: var(--slate-300);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
    line-height: 1.35;
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
    touch-action: manipulation;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.btn-primary {
    background: linear-gradient(180deg, var(--brand-500) 0%, var(--primary) 100%);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: linear-gradient(180deg, var(--brand-600) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface, #ffffff);
    color: var(--slate-700);
    border-color: var(--slate-300);
}

.btn-secondary:hover {
    background: var(--slate-100);
    color: var(--slate-900);
    border-color: var(--slate-400);
}

.btn-danger {
    background: #dc2626;
    color: #ffffff;
    border-color: #b91c1c;
}

.btn-danger:hover {
    background: #b91c1c;
    color: #ffffff;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 0.45rem;
    border-radius: var(--radius-md);
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.15rem;
}

@media (min-width: 768px) {
    .form-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
    .form-grid-3 {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.form-group {
    margin-bottom: 1.15rem;
    width: 100%;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--slate-800);
    margin-bottom: 0.35rem;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--slate-500);
    margin-top: 0.3rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    color: var(--slate-900);
    background: var(--surface, #ffffff);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

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

textarea.form-control {
    min-height: 5.5rem;
    font-family: inherit;
    resize: vertical;
}

textarea.code-editor {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.84rem;
    background: #f8fafc;
    tab-size: 2;
}

.checkbox-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.65rem;
    margin-top: 0.5rem;
}

.checkbox-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.85rem;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
}

.checkbox-card:hover {
    background: var(--brand-50);
    border-color: var(--brand-300);
}

.checkbox-card input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.checkbox-card-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--slate-800);
}

/* Searchable, version-aware policy selectors */
.policy-picker-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.policy-picker-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.policy-selection-count {
    margin-right: 0.25rem;
    color: var(--slate-500);
    font-size: 0.78rem;
    font-weight: 600;
}

.policy-picker-viewport {
    height: 30rem;
    min-height: 0;
    padding: 0.55rem;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-color: var(--slate-400) var(--slate-100);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.policy-picker-viewport:focus-visible {
    outline: 3px solid var(--primary-ring);
    outline-offset: 2px;
}

.policy-picker-viewport::-webkit-scrollbar {
    width: 10px;
}

.policy-picker-viewport::-webkit-scrollbar-track {
    background: var(--slate-100);
    border-radius: 999px;
}

.policy-picker-viewport::-webkit-scrollbar-thumb {
    background: var(--slate-400);
    border: 2px solid var(--slate-100);
    border-radius: 999px;
}

.policy-card-list {
    display: grid;
    min-width: 0;
    gap: 0.65rem;
    align-content: start;
}

.brand-asset-grid {
    display: grid;
    gap: 0.75rem;
}

.brand-asset-card {
    background: var(--surface, #fdfefd);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.brand-asset-card > summary {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    list-style: none;
}

.brand-asset-card > summary img,
.brand-revision-row > img {
    width: 3rem;
    height: 3rem;
    object-fit: contain;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
}

.brand-asset-card > summary span:nth-child(2) { display: grid; flex: 1; min-width: 0; }
.brand-asset-card small { display: block; color: var(--slate-500); font-size: 0.75rem; }
.brand-asset-body { display: grid; gap: 0.75rem; padding: 1rem; border-top: 1px solid var(--slate-200); }
.brand-revision-row { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem; background: var(--slate-50); border-radius: var(--radius-md); }
.brand-revision-row > div { min-width: 0; flex: 1; }
.brand-usage-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.brand-usage-list a { padding: 0.2rem 0.4rem; color: var(--brand-800); background: var(--brand-100); border-radius: 0.3rem; font-size: 0.7rem; }
.brand-revision-form,
.brand-attach-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.brand-revision-form .form-control,
.brand-attach-form .form-control { width: auto; min-width: 13rem; flex: 1; }

@media (max-width: 480px) {
    .brand-asset-card > summary { align-items: flex-start; flex-wrap: wrap; }
    .brand-asset-card > summary .badge { margin-left: 3.85rem; }
    .brand-revision-form .form-control,
    .brand-attach-form .form-control,
    .brand-revision-form .btn,
    .brand-attach-form .btn { width: 100%; }
}

.policy-option-card {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.policy-option-card:hover,
.policy-option-card[open] {
    border-color: var(--brand-300);
}

.policy-option-card:has(input:checked) {
    background: var(--brand-50);
    border-color: var(--brand-400);
}

.policy-option-card-incompatible {
    background: var(--slate-100);
    border-color: var(--slate-200);
}

.policy-option-card-incompatible:not(:has(input:checked)) {
    opacity: 0.72;
}

.policy-option-card-incompatible .policy-card-summary {
    cursor: default;
}

.policy-type-status {
    color: var(--slate-600);
}

.policy-type-status-allowed {
    color: var(--brand-800);
    background: var(--brand-100);
    border-color: var(--brand-200);
}

.policy-validation-message {
    margin: 0 0 0.75rem;
    padding: 0.75rem 0.85rem;
    color: var(--danger-700, #9f2d26);
    background: var(--danger-50, #fff1f0);
    border: 1px solid var(--danger-200, #f3b8b3);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    line-height: 1.5;
}

.policy-card-summary {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    list-style: none;
}

.policy-card-summary::-webkit-details-marker {
    display: none;
}

.policy-card-summary::after {
    content: "›";
    margin-left: 0.2rem;
    color: var(--slate-400);
    font-size: 1.3rem;
    line-height: 1;
    transform: rotate(90deg);
    transition: transform 0.18s ease;
}

.policy-option-card[open] > .policy-card-summary::after {
    transform: rotate(-90deg);
}

.policy-card-summary-selectable > input[type="checkbox"],
.policy-version-option > input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.policy-card-main {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 0.16rem;
}

.policy-card-title {
    color: var(--slate-900);
    font-size: 0.88rem;
    font-weight: 700;
}

.policy-card-subtitle {
    overflow: hidden;
    color: var(--slate-500);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.policy-card-meta,
.policy-eligibility-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.policy-card-details {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--slate-200);
}

.policy-version-list {
    display: grid;
    gap: 0.5rem;
    padding-top: 0.75rem;
}

.policy-version-option {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.75rem;
    background: var(--surface, #fdfefd);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.policy-version-option:hover,
.policy-version-option:has(input:checked) {
    border-color: var(--brand-400);
    background: var(--brand-50);
}

.policy-version-option-invalid,
.policy-version-option-invalid:hover {
    background: var(--danger-50, #fff1f0);
    border-color: var(--danger-400, #d95b51);
}

.policy-version-content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 0.28rem;
}

.policy-version-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--slate-500);
    font-size: 0.72rem;
}

.policy-version-heading strong {
    color: var(--slate-800);
    font-size: 0.82rem;
}

.policy-version-subject {
    color: var(--slate-700);
    font-size: 0.8rem;
}

.policy-variable-groups {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.25rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--slate-200);
}

.policy-variable-group {
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1fr);
    align-items: start;
    gap: 0.5rem;
}

.policy-variable-label {
    padding-top: 0.18rem;
    color: var(--slate-500);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.policy-variable-list {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.policy-variable-chip {
    padding: 0.18rem 0.38rem;
    color: var(--brand-800);
    background: var(--brand-100);
    border: 1px solid var(--brand-200);
    border-radius: 0.3rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.68rem;
    overflow-wrap: anywhere;
}

.policy-variable-chip-optional {
    color: var(--slate-700);
    background: var(--slate-100);
    border-color: var(--slate-200);
}

.policy-variable-empty {
    padding-top: 0.18rem;
    color: var(--slate-400);
    font-size: 0.72rem;
    font-style: italic;
}

.policy-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0.85rem 0;
}

.policy-detail-grid div {
    min-width: 0;
}

.policy-detail-grid dt {
    color: var(--slate-400);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.policy-detail-grid dd {
    margin: 0.2rem 0 0;
    color: var(--slate-800);
    font-size: 0.82rem;
    font-weight: 600;
}

.policy-no-results {
    padding: 1.25rem;
    color: var(--slate-500);
    text-align: center;
    border: 1px dashed var(--slate-300);
    border-radius: var(--radius-md);
}

/* Empty State Component */
.empty-state {
    padding: 3rem 1.25rem;
    text-align: center;
    background: var(--surface, #ffffff);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--slate-300);
}

.empty-state-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.85rem;
    background: var(--brand-50);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--slate-800);
    margin-bottom: 0.35rem;
}

.empty-state-description {
    font-size: 0.875rem;
    color: var(--slate-500);
    max-width: 420px;
    margin: 0 auto 1.25rem;
    line-height: 1.5;
}

/* Copy to Clipboard Chip */
.copy-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.45rem;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    color: var(--slate-700);
    cursor: pointer;
    transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
    word-break: break-all;
    max-width: 100%;
}

.copy-chip:hover {
    background: var(--brand-100);
    border-color: var(--brand-300);
    color: var(--brand-900);
}

/* Template Preview Frame */
.preview-container {
    background: var(--surface, #ffffff);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 1rem;
}

.preview-toolbar {
    background: var(--slate-100);
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preview-iframe {
    width: 100%;
    min-height: 420px;
    border: none;
    background: var(--surface, #ffffff);
    transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
}

/* Progress Bars */
.progress-bar-wrapper {
    background: var(--slate-200);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-400), var(--primary));
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

/* Footer */
.app-footer {
    background: var(--slate-900);
    color: var(--slate-400);
    border-top: 1px solid var(--slate-800);
    padding: 1.5rem 1.25rem;
    font-size: 0.8125rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.system-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--brand-300);
    font-weight: 500;
}

.status-pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--brand-400);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.35);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

/* ==========================================================================
   Home / Admin landing page
   ========================================================================== */

.home-hero {
    background: linear-gradient(135deg, var(--brand-50) 0%, #ffffff 60%);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.home-hero h1 {
    font-size: clamp(1.4rem, 3vw, 1.75rem);
    font-weight: 700;
    color: var(--slate-900);
    margin-bottom: 0.4rem;
}

.home-hero p {
    color: var(--slate-600);
    font-size: 0.9375rem;
    max-width: 62ch;
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.1rem;
    margin-bottom: 1.75rem;
}

.section-card {
    display: flex;
    flex-direction: column;
    background: var(--surface, #ffffff);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.section-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-300);
}

.section-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    margin-bottom: 0.85rem;
}

.section-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--slate-900);
    margin-bottom: 0.35rem;
}

.section-card-description {
    font-size: 0.85rem;
    color: var(--slate-500);
    line-height: 1.5;
    flex: 1;
}

.section-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: 0.9rem;
}

.section-card:hover .section-card-cta {
    color: var(--primary-hover);
}

/* ==========================================================================
   Responsive Media Queries
   ========================================================================== */

/* Large Tablets & Laptops (<= 1024px) */
@media (max-width: 1024px) {
    .desktop-nav,
    .header-user-section {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .app-main {
        padding: 1.5rem 1rem 2.5rem;
    }
}

/* Tablets & Small Devices (<= 768px) */
@media (max-width: 768px) {
    .policy-picker-viewport {
        height: 24rem;
    }

    .policy-picker-toolbar {
        align-items: stretch;
    }

    .policy-picker-actions {
        width: 100%;
    }

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

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

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

    .search-input-wrapper {
        max-width: 100%;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

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

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

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 0.85rem;
    }

    .stat-card {
        padding: 1rem;
    }

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

    .footer-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* Mobile Phones (<= 480px) */
@media (max-width: 480px) {
    .section-grid {
        grid-template-columns: 1fr;
    }

    .home-hero {
        padding: 1.25rem 1.25rem;
    }

    .policy-picker-viewport {
        height: 20rem;
        padding: 0.4rem;
    }

    .policy-card-summary {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 0.75rem;
    }

    .policy-card-meta {
        width: calc(100% - 2rem);
    }

    .policy-card-summary::after {
        margin-left: auto;
    }

    .policy-picker-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .policy-variable-group {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .policy-version-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.1rem;
    }

    .app-main {
        padding: 1.25rem 0.85rem 2rem;
    }

    .brand-logo span span {
        display: inline;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card-body {
        padding: 1rem;
    }

    .checkbox-card-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
    }
}
