/* ============================================
   Service Directory — Modern SaaS Design System
   ============================================ */

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

/* ---------- Design Tokens ---------- */
:root {
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-size-xs: 0.8125rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 0.9375rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;

    /* Colors */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #3b82f6;
    --color-primary-alpha: rgba(37, 99, 235, 0.12);

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-hover: #f9fafb;

    --color-text: #0f172a;
    --color-text-secondary: #334155;
    --color-text-muted: #64748b;
    --color-text-faint: #94a3b8;

    --color-border: #e2e8f0;
    --color-border-hover: #cbd5e1;

    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-warning: #d97706;
    --color-warning-light: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;

    /* Focus */
    --color-focus-ring: rgba(37, 99, 235, 0.4);

    /* Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 10px;
    --radius-xl: 14px;
    --radius-full: 999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

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

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --color-primary-light: #2563eb;
    --color-primary-alpha: rgba(59, 130, 246, 0.15);

    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-hover: #334155;

    --color-text: #f1f5f9;
    --color-text-secondary: #cbd5e1;
    --color-text-muted: #94a3b8;
    --color-text-faint: #64748b;

    --color-border: #334155;
    --color-border-hover: #475569;

    --color-focus-ring: rgba(59, 130, 246, 0.5);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}
@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --color-primary: #3b82f6;
        --color-primary-hover: #60a5fa;
        --color-primary-light: #2563eb;
        --color-primary-alpha: rgba(59, 130, 246, 0.15);

        --color-bg: #0f172a;
        --color-surface: #1e293b;
        --color-surface-hover: #334155;

        --color-text: #f1f5f9;
        --color-text-secondary: #cbd5e1;
        --color-text-muted: #94a3b8;
        --color-text-faint: #64748b;

        --color-border: #334155;
        --color-border-hover: #475569;

        --color-focus-ring: rgba(59, 130, 246, 0.5);

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    }
}
/* Dark mode overrides for hardcoded colors */
[data-theme="dark"] .navbar,
[data-theme="system"] .navbar {
    background: rgba(30, 41, 59, 0.85);
}
@media (prefers-color-scheme: light) {
    [data-theme="system"] .navbar { background: rgba(255, 255, 255, 0.85); }
}
[data-theme="dark"] .badge-active { background: #166534; color: #bbf7d0; }
[data-theme="dark"] .badge-draft { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-deprecated { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-retired { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .badge-pending { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-suspended { background: #7c2d12; color: #fed7aa; }
[data-theme="dark"] .badge-rejected { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .badge-cancelled { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-cancellation_pending { background: #831843; color: #fbcfe8; }
[data-theme="dark"] .badge-notice_pending { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-data-green { background: #065f46; color: #d1fae5; }
[data-theme="dark"] .badge-data-yellow { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-data-red { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .badge-data-black { background: #111827; color: #d1d5db; }
[data-theme="dark"] .badge-company { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-customer { background: #166534; color: #bbf7d0; }
[data-theme="dark"] .badge-partner { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-vendor { background: #581c87; color: #d8b4fe; }
[data-theme="dark"] .badge-role { background: #334155; color: #94a3b8; }
[data-theme="dark"] .alert-success { background: #166534; color: #bbf7d0; border-color: #15803d; }
[data-theme="dark"] .alert-error { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fde68a; border-color: #92400e; }
[data-theme="dark"] .alert-info { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }
[data-theme="dark"] .badge-info { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .notification-unread { background: rgba(59, 130, 246, 0.1); }
[data-theme="dark"] .notification-unread:hover { background: rgba(59, 130, 246, 0.15); }
[data-theme="dark"] .form-errors { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
[data-theme="dark"] .form-group input:disabled { background: #0f172a; color: #64748b; }

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

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--font-size-base);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container { max-width: 1320px; margin: 0 auto; padding: 0 1.5rem; }

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

/* Focus ring for accessibility */
:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

/* ---------- Navbar ---------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    padding: 0 0;
}
.navbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.navbar-brand {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}
.navbar-brand:hover { color: var(--color-text); }

/* Hamburger menu button (mobile only) */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.375rem;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}
.navbar-toggle:hover { color: var(--color-text); }
.navbar-toggle svg { display: block; }

.navbar-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.navbar-links a {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.navbar-links a:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

/* User avatar in navbar */
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: #fff;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

/* Customer portal badge */
.navbar-portal-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--color-primary-alpha);
    color: var(--color-primary);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* ---------- Footer ---------- */
.footer {
    margin-top: auto;
    padding: 2rem 0;
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--color-text-faint);
    border-top: 1px solid var(--color-border);
}

/* ---------- Page Header ---------- */
.page-header {
    margin: 2.5rem 0 2rem;
}
.page-header h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}
.page-header p {
    color: var(--color-text-muted);
    margin-top: 0.375rem;
    font-size: var(--font-size-base);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.5;
}
.btn:hover { text-decoration: none; }

.btn-sm { padding: 0.3125rem 0.625rem; font-size: var(--font-size-xs); }
.btn-lg { padding: 0.625rem 1.25rem; font-size: var(--font-size-base); }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.15);
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    color: #fff;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-hover);
    color: var(--color-text);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: none;
}
.btn-ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.15);
}
.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
    transform: translateY(-1px);
}

/* ---------- Filters Bar ---------- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.filters-bar input[type="text"],
.filters-bar select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
    transition: all var(--transition-fast);
}
.filters-bar input[type="text"]:hover,
.filters-bar select:hover {
    border-color: var(--color-border-hover);
}
.filters-bar input[type="text"]:focus,
.filters-bar select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}
.filters-bar input[type="text"] { flex: 1; min-width: 200px; }
.filters-bar select { min-width: 140px; }

/* ---------- Service Cards ---------- */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.service-card {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-base);
    overflow: hidden;
}
.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-primary);
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.service-card:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.service-card:hover::before { opacity: 1; }
.service-card h3 { margin-bottom: 0.125rem; font-size: var(--font-size-base); }
.service-card h3 a { color: var(--color-text); font-weight: 600; }
.service-card h3 a:hover { color: var(--color-primary); }
.service-card .description {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin: 0.5rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}
.service-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
    margin-top: 1rem;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Service card header (customer portal variant) */
.service-card-header {
    margin-bottom: 0.125rem;
}
.service-card-badges { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.service-card-description {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin: 0.5rem 0;
    line-height: 1.5;
}
.service-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    font-size: var(--font-size-xs);
}
.service-card-tags { display: flex; gap: 0.25rem; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.6;
}
.badge-active { background: #dcfce7; color: #15803d; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-deprecated { background: #fef3c7; color: #92400e; }
.badge-retired { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-suspended { background: #fed7aa; color: #9a3412; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f1f5f9; color: #475569; }
.badge-cancellation_pending { background: #fce7f3; color: #9d174d; }
.badge-notice_pending { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f1f5f9; color: #475569; }

/* Data classification badges */
.badge-data-green { background: #d1fae5; color: #065f46; }
.badge-data-yellow { background: #fef3c7; color: #92400e; }
.badge-data-red { background: #fee2e2; color: #991b1b; }
.badge-data-black { background: #1f2937; color: #f9fafb; }

/* Classification labels (subtle, for customer list table) */
.classification-label { font-weight: 500; }
.classification-green { color: #065f46; }
.classification-yellow { color: #92400e; }
.classification-red { color: #991b1b; }
.classification-black { color: #1f2937; }
[data-theme="dark"] .classification-green { color: #6ee7b7; }
[data-theme="dark"] .classification-yellow { color: #fde68a; }
[data-theme="dark"] .classification-red { color: #fca5a5; }
[data-theme="dark"] .classification-black { color: #d1d5db; }

/* Organization type badges */
.badge-company { background: #dbeafe; color: #1e40af; }
.badge-customer { background: #dcfce7; color: #15803d; }
.badge-partner { background: #fef3c7; color: #92400e; }
.badge-vendor { background: #f3e8ff; color: #6b21a8; }

/* Role & certification badges */
.badge-role { background: #f1f5f9; color: #475569; }
.badge-cert-certified { background: #dcfce7; color: #15803d; }
.badge-cert-expiring_soon { background: #fef3c7; color: #92400e; }
.badge-cert-expired { background: #fee2e2; color: #991b1b; }
.badge-cert-never_certified { background: #f1f5f9; color: #475569; }

/* ---------- Tags ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    line-height: 1.4;
}
/* Dynamic colored tags — solid variant */
.tag[style*="--tag-color"] {
    background-color: var(--tag-color);
    color: #fff;
}
/* Dynamic colored tags — subtle variant */
.tag[style*="--tag-bg"] {
    background-color: var(--tag-bg);
    color: var(--tag-color);
}
/* Fallback for legacy inline style tags */
.tag:not([style*="--tag"]) {
    color: #fff;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}
.breadcrumb a {
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb .sep {
    margin: 0 0.5rem;
    color: var(--color-text-faint);
    font-size: var(--font-size-xs);
}

/* ---------- Detail Pages ---------- */
.detail-header { margin: 1rem 0 1.5rem; }
.detail-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.detail-header h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}
.detail-header .meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.detail-body,
.detail-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}
@media (max-width: 768px) {
    .detail-body,
    .detail-layout { grid-template-columns: 1fr; }
}

.detail-main {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-xs);
}
.detail-sidebar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
    height: fit-content;
}

.detail-main h2 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}
.detail-main h2:not(:first-of-type) {
    margin-top: 2rem;
}

.detail-sidebar h3 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.625rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--color-border);
}
.detail-sidebar h3:not(:first-of-type) {
    margin-top: 1.5rem;
}

/* Info list (sidebar key-value pairs) */
.info-list { list-style: none; }
.info-list li {
    padding: 0.375rem 0;
    font-size: var(--font-size-sm);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}
.info-list li .label { color: var(--color-text-muted); flex-shrink: 0; }
.info-list a { overflow-wrap: anywhere; }
.info-list li.info-list-block {
    display: block;
}
.info-list li.info-list-block .badge { margin-left: 0.25rem; }

/* Dependency list */
.dep-list { list-style: none; }
.dep-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
}
.dep-list li:last-child { border-bottom: none; }
.dep-type {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

/* Sidebar sections (customer service detail) */
.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-section:last-child { margin-bottom: 0; }
.sidebar-section h3 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.625rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--color-border);
}

/* ---------- Unsubscribe Section ---------- */
.unsubscribe-section summary {
    cursor: pointer;
    list-style: none;
}
.unsubscribe-section summary::-webkit-details-marker { display: none; }
.unsubscribe-section[open] summary { margin-bottom: 0.5rem; }

/* ---------- Dependency Tree ---------- */
.tree-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}
@media (max-width: 768px) { .tree-container { grid-template-columns: 1fr; } }

.tree-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
}
.tree-section h2 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}
.tree-empty { color: var(--color-text-muted); font-size: var(--font-size-sm); }

ul.tree {
    list-style: none;
    padding-left: 1.25rem;
    border-left: 2px solid var(--color-border);
}
ul.tree > li {
    padding: 0.375rem 0;
    font-size: var(--font-size-sm);
}
ul.tree > li::before {
    content: "\2014\00a0";
    color: var(--color-text-faint);
}
/* Collapsible tree */
ul.tree.collapsed { display: none; }
.tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    margin-right: 0.375rem;
    transition: all var(--transition-fast);
    vertical-align: middle;
    line-height: 1;
    flex-shrink: 0;
}
.tree-toggle:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-hover);
    color: var(--color-text);
}

/* Rich tree nodes */
.tree-node {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
}
.tree-node:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-sm);
}
.tree-node-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.tree-node-header a {
    font-weight: 600;
    font-size: var(--font-size-sm);
}
.tree-node-details {
    margin-top: 0.5rem;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.tree-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    align-items: center;
}
.tree-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.tree-node-subscribed {
    border-left: 3px solid var(--color-success);
}
.tree-node-pending {
    border-left: 3px solid var(--color-warning);
}
.tree-node-not-subscribed {
    border-left: 3px solid var(--color-border);
}

/* Prerequisite label */
.badge-prerequisite {
    background: #fef2f2;
    color: #991b1b;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.0625rem 0.375rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
[data-theme="dark"] .badge-prerequisite { background: #7f1d1d; color: #fca5a5; }

/* Related services section (customer detail) */
.related-services-section {
    margin-top: 2rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1.5rem;
}
.related-group {
    margin-bottom: 1.5rem;
}
.related-group h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--color-text);
}
.related-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}
.related-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    transition: border-color 0.15s;
}
.related-card:hover { border-color: var(--color-primary-light); }
.related-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
}
.related-card-header a {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    text-decoration: none;
}
.related-card-header a:hover { text-decoration: underline; }
.related-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}
.related-card-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin: 0.25rem 0 0;
    line-height: 1.4;
}
.related-card-cost {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin: 0.25rem 0 0;
    font-weight: 500;
}

/* Cost estimate table (customer detail) */
.cost-estimate-section {
    margin-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1.25rem;
}
.cost-estimate-section h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--color-text);
}
.cost-table {
    width: 100%;
    max-width: 400px;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}
.cost-table td {
    padding: 0.375rem 0;
    color: var(--color-text);
}
.cost-table .cost-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.cost-table tfoot {
    border-top: 2px solid var(--color-border);
}
.cost-table tfoot td {
    padding-top: 0.5rem;
}

[data-theme="dark"] .related-card {
    background: var(--color-surface);
    border-color: var(--color-border);
}
[data-theme="dark"] .cost-estimate-section { border-top-color: var(--color-border); }
[data-theme="dark"] .related-services-section { border-top-color: var(--color-border); }

/* Prerequisite missing list on pending subscriptions */
.prereq-missing-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0;
}
.prereq-missing-list li::before {
    content: "\2022\00a0";
    color: var(--color-danger);
}

/* Cost rollup summary */
.cost-rollup {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.cost-rollup strong {
    color: var(--color-primary);
}

/* Customer filter for dependency tree */
.tree-customer-filter {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.tree-customer-filter label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-muted);
}
.tree-customer-filter select {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
}

/* Impact analysis */
.impact-summary {
    background: var(--color-warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: var(--font-size-sm);
}
[data-theme="dark"] .impact-summary {
    background: #78350f;
    color: #fde68a;
    border-color: #92400e;
}

/* ---------- Subcontractors ---------- */
.subcontractor-list { list-style: none; }
.subcontractor-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
}
.subcontractor-list li:last-child { border-bottom: none; }
.subcontractor-meta { color: var(--color-text-muted); font-size: var(--font-size-xs); }
.subcontractor-link { font-size: var(--font-size-xs); margin-right: 0.75rem; }

/* ---------- Tables ---------- */
.subscription-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.subscription-table th,
.subscription-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--color-border);
}
.subscription-table th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}
.subscription-table tbody tr {
    transition: background var(--transition-fast);
}
.subscription-table tbody tr:hover {
    background: var(--color-surface-hover);
}
.subscription-table tr:last-child td { border-bottom: none; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.375rem;
    margin: 2.5rem 0;
}
.pagination a, .pagination span {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}
.pagination a:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-hover);
    color: var(--color-text);
}
.pagination .current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.pagination-info {
    display: flex;
    align-items: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    padding: 0 0.5rem;
}

/* ---------- Empty States ---------- */
.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--color-text-muted);
}
.empty-state h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}
.empty-state p { font-size: var(--font-size-sm); }

.empty-hint {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    padding: 1rem 0;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
    position: fixed;
    top: 4.5rem;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 420px;
}
.toast {
    pointer-events: auto;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    animation: toast-in 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform: translateX(100%);
    opacity: 0;
}
.toast.toast-out {
    animation: toast-out 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.toast-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in {
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Legacy static alerts (fallback when JS disabled) */
.messages { margin-top: 1.5rem; }
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    margin-bottom: 0.75rem;
    font-weight: 500;
}
.alert-success {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ---------- Login & Auth Pages ---------- */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}
.login-container h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.375rem;
    text-align: center;
}
.login-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: 1.5rem;
}
.login-container .login-subtitle:first-of-type {
    margin-top: 0;
}

.staff-login-link {
    text-align: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}
.staff-login-link a {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 500;
}
.staff-login-link a:hover { color: var(--color-primary); }

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--color-text-secondary);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5625rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
    transition: all var(--transition-fast);
    line-height: 1.5;
}
.form-group input:hover,
.form-group textarea:hover,
.form-group select:hover {
    border-color: var(--color-border-hover);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--color-text-faint);
}
.form-group input:disabled {
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: not-allowed;
}
.form-group textarea {
    resize: vertical;
    min-height: 72px;
}
.form-errors {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: var(--font-size-xs);
}

/* Customer service filters */
.service-filters { margin-bottom: 2rem; }
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.search-input,
.filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
    transition: all var(--transition-fast);
}
.search-input { flex: 1; min-width: 200px; }
.filter-select { min-width: 140px; }
.search-input:hover,
.filter-select:hover { border-color: var(--color-border-hover); }
.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

/* ---------- View Toggle ---------- */
.view-toggle {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
}
.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
    cursor: pointer;
}
.view-toggle-btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-hover);
    color: var(--color-text);
}
.view-toggle-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.view-toggle-btn.active:hover {
    background: var(--color-primary-hover);
}

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
}
.stat-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
a.stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
a.stat-card-link:hover {
    border-color: var(--color-primary);
}
.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    letter-spacing: -0.02em;
}
.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: 0.375rem;
    font-weight: 500;
}

/* ---------- Customer Detail ---------- */
.service-short-desc {
    font-size: var(--font-size-lg);
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}
.service-description {
    margin-bottom: 1rem;
    line-height: 1.7;
}
.service-tags {
    margin-top: 1rem;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* ---------- Certification ---------- */
.certification-block { margin-top: 0.625rem; }
.certification-block .info-list { margin-top: 0.75rem; }
.certification-block .form-group textarea {
    font-size: var(--font-size-xs);
}
.cert-form { margin-top: 0.75rem; }
.cert-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

/* Pending subscriptions count badge */
.pending-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    border-radius: var(--radius-full);
    background: var(--color-warning);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    margin-left: 0.25rem;
}

/* ---------- Org link in header ---------- */
.org-link {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ---------- Settings Page ---------- */
.settings-form {
    max-width: 640px;
    margin-bottom: 2.5rem;
}
.settings-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.settings-section-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.settings-section-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.125rem;
}
.settings-section-body {
    padding: 1.5rem;
}
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.settings-actions {
    display: flex;
    justify-content: flex-start;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Radio group for preferences */
.radio-group {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
}
.radio-option {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--color-text);
    cursor: pointer;
}
.radio-option input[type="radio"] {
    width: auto;
    accent-color: var(--color-primary);
}

/* ---------- Notifications ---------- */
.notifications-section {
    margin-bottom: 2rem;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.section-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}
.notification-list {
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.notification-item {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition-fast);
}
.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--color-surface-hover); }
.notification-unread {
    border-left: 3px solid var(--color-primary);
    background: var(--color-primary-alpha);
}
.notification-unread:hover {
    background: rgba(37, 99, 235, 0.08);
}
.notification-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
}
.notification-title a { color: var(--color-text); }
.notification-title a:hover { color: var(--color-primary); }
.notification-message {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    margin-top: 0.375rem;
    line-height: 1.5;
}
/* Diff highlighting inside notifications */
.notification-message .diff-item {
    margin-top: 0.25rem;
}
.notification-message .diff-content {
    margin-top: 0.125rem;
    padding: 0.375rem 0.5rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    line-height: 1.6;
}
.notification-message del {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    text-decoration: line-through;
    border-radius: 2px;
    padding: 0 2px;
}
.notification-message ins {
    background: rgba(22, 163, 74, 0.2);
    color: #86efac;
    text-decoration: none;
    border-radius: 2px;
    padding: 0 2px;
}
.notification-message .diff-ellipsis {
    color: var(--color-text-faint);
    padding: 0 0.25rem;
}
.notification-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}
.section-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Navbar notification badge */
.navbar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.3125rem;
    border-radius: var(--radius-full);
    background: var(--color-danger);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    margin-left: 0.25rem;
    line-height: 1;
}

/* Info badge (used for unread count on dashboard) */
.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ---------- Utility Classes ---------- */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.ml-1 { margin-left: 0.25rem; }

.w-full { width: 100%; }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-center { text-align: center; }

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

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.inline-form { display: inline; }
.inline-form + .inline-form { margin-left: 0.25rem; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl, 12px);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 540px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modal-in 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.modal-header h2 {
    font-size: var(--font-size-lg, 1.125rem);
    font-weight: 600;
    margin: 0;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: var(--radius-sm, 4px);
    transition: all 0.15s;
}
.modal-close:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}
.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
}

/* Subscribe service list inside modal */
.subscribe-services-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.subscribe-service-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    gap: 1rem;
}
.subscribe-service-target {
    border-color: var(--color-primary);
    background: var(--color-primary-alpha);
}
.subscribe-service-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.subscribe-service-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
}
.subscribe-service-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.subscribe-service-quantity label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
}
.quantity-input {
    width: 72px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    text-align: center;
}
.quantity-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-alpha, rgba(59, 130, 246, 0.15));
}
.subscribe-cost-summary {
    padding: 0.75rem 1rem;
    background: var(--color-surface-hover);
    border-radius: var(--radius);
}
@media (max-width: 640px) {
    .modal { max-width: 100%; border-radius: var(--radius-lg, 8px); }
    .subscribe-service-item { flex-direction: column; align-items: stretch; }
    .subscribe-service-quantity { justify-content: flex-end; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .navbar-toggle { display: block; }
    .navbar-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--color-surface);
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-lg);
        padding: 0.5rem 0;
    }
    .navbar-links.open { display: flex; }
    .navbar-links a {
        padding: 0.625rem 1.5rem;
        border-radius: 0;
    }
    .navbar-links .user-avatar {
        margin: 0.25rem 1.5rem;
        width: 32px;
    }
    .navbar-content { position: relative; }
}
@media (max-width: 640px) {
    .container { padding: 0 1rem; }
    .navbar-content { height: 48px; }
    .page-header h1 { font-size: var(--font-size-2xl); }
    .detail-header h1 { font-size: var(--font-size-2xl); }
    .service-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .login-container { margin: 2rem 1rem; padding: 1.5rem; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar input[type="text"] { min-width: auto; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .search-input { min-width: auto; }
    .settings-row { grid-template-columns: 1fr; }
    .toast-container { right: 1rem; left: 1rem; max-width: none; }
}

/* ---------- Announcements ---------- */
.announcement-list { display: flex; flex-direction: column; gap: 1rem; }
.announcement-item {
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--color-primary, #3b82f6);
    background: var(--color-surface-hover, #f1f5f9);
    border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
}
.announcement-item h4 { margin: 0 0 0.25rem; font-size: 0.95rem; }
.announcement-item p { margin: 0.25rem 0 0; }

/* ---------- Getting Started ---------- */
.getting-started-section { margin: 1.5rem 0; }
.getting-started-section .btn { margin-bottom: 0.75rem; }

/* ---------- Responsive Table (Card Pattern) ---------- */
/* At mobile breakpoint, each <tr> becomes a card with data-label pseudo-content */
@media (max-width: 640px) {
    .responsive-table thead { display: none; }
    .responsive-table tbody tr {
        display: block;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        padding: 0.75rem 1rem;
        margin-bottom: 0.75rem;
        box-shadow: var(--shadow-xs);
    }
    .responsive-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.375rem 0;
        border-bottom: 1px solid var(--color-border);
        font-size: var(--font-size-sm);
    }
    .responsive-table tbody td:last-child { border-bottom: none; }
    .responsive-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: var(--font-size-xs);
        color: var(--color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        margin-right: 0.5rem;
    }
    .responsive-table tbody td[data-label=""]::before { display: none; }
    .responsive-table tfoot { display: block; }
    .responsive-table tfoot tr {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        background: var(--color-bg);
        border-radius: var(--radius);
    }
    .responsive-table tfoot td {
        display: inline;
        padding: 0;
        border: none;
    }

    /* Collapsible filter bar */
    .filter-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.625rem 1rem;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        font-family: var(--font-sans);
        font-size: var(--font-size-sm);
        font-weight: 500;
        color: var(--color-text-muted);
        cursor: pointer;
        margin-bottom: 0.5rem;
        box-shadow: var(--shadow-xs);
    }
    .filter-toggle-btn:hover {
        background: var(--color-surface-hover);
        color: var(--color-text);
    }
    .filter-form.collapsed-mobile { display: none; }

    /* Info list stack on mobile */
    .info-list li {
        flex-direction: column;
        gap: 0.125rem;
    }

    /* Related cards single column */
    .related-cards { grid-template-columns: 1fr; }

    /* Cost table full width */
    .cost-table { max-width: 100%; }

    /* Modal bottom-sheet style */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 90vh;
    }
    .modal-header { padding: 1rem; }
    .modal-body { padding: 1rem; }
    .modal-footer { padding: 0.75rem 1rem; }

    /* Responsive utility classes */
    .hidden-mobile { display: none !important; }
}

/* ---------- Bookmark Button ---------- */
.bookmark-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem;
    color: var(--color-text-faint);
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.bookmark-btn:hover {
    color: #eab308;
    transform: scale(1.15);
}
/* Filled star (bookmarked) */
.bookmark-btn:has(+ .bookmark-btn) { color: #eab308; } /* fallback won't apply; use direct color */
.service-card-header .bookmark-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
}
.service-card-header {
    position: relative;
    padding-right: 2rem;
}
.bookmark-btn-lg {
    font-size: 1.5rem;
    padding: 0.25rem 0.375rem;
}
/* Detail header actions row */
.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ---------- Compliance Badge ---------- */
.compliance-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}
.compliance-badge-lg {
    min-width: 2.25rem;
    height: 2.25rem;
    font-size: 1rem;
    border-radius: var(--radius);
}
.compliance-grade-A { background: #dcfce7; color: #15803d; }
.compliance-grade-B { background: #dbeafe; color: #1e40af; }
.compliance-grade-C { background: #fef3c7; color: #92400e; }
.compliance-grade-D { background: #fed7aa; color: #9a3412; }
.compliance-grade-F { background: #fee2e2; color: #991b1b; }

/* Dark mode compliance grades */
[data-theme="dark"] .compliance-grade-A { background: #166534; color: #bbf7d0; }
[data-theme="dark"] .compliance-grade-B { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .compliance-grade-C { background: #78350f; color: #fde68a; }
[data-theme="dark"] .compliance-grade-D { background: #7c2d12; color: #fed7aa; }
[data-theme="dark"] .compliance-grade-F { background: #7f1d1d; color: #fecaca; }

/* ---------- Compliance Check List (detail sidebar) ---------- */
.compliance-detail-block {
    margin-top: 0.625rem;
}
.compliance-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.compliance-score-text {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}
.compliance-check-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.compliance-check-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--color-border);
}
.compliance-check-item:last-child {
    border-bottom: none;
}
.compliance-check-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}
.compliance-check-pass .compliance-check-icon,
.compliance-check-pass.compliance-check-icon {
    background: #dcfce7;
    color: #15803d;
}
.compliance-check-fail .compliance-check-icon,
.compliance-check-fail.compliance-check-icon {
    background: #fee2e2;
    color: #991b1b;
}
[data-theme="dark"] .compliance-check-pass .compliance-check-icon,
[data-theme="dark"] .compliance-check-pass.compliance-check-icon {
    background: #166534;
    color: #bbf7d0;
}
[data-theme="dark"] .compliance-check-fail .compliance-check-icon,
[data-theme="dark"] .compliance-check-fail.compliance-check-icon {
    background: #7f1d1d;
    color: #fecaca;
}

/* ---------- Compliance Dashboard ---------- */
.compliance-dashboard {
    margin-bottom: 2rem;
}
.compliance-dashboard .subscription-table th,
.compliance-dashboard .subscription-table td {
    text-align: center;
}
.compliance-dashboard .subscription-table th:first-child,
.compliance-dashboard .subscription-table td:first-child {
    text-align: left;
}
.compliance-filter-active {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.625rem 1rem;
    background: var(--color-primary-alpha);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
}
.compliance-stat-A { border-left-color: #16a34a; }
.compliance-stat-B { border-left-color: #2563eb; }
.compliance-stat-C { border-left-color: #d97706; }
.compliance-stat-D { border-left-color: #ea580c; }
.compliance-stat-F { border-left-color: #dc2626; }

/* Desktop-only: hide mobile-only elements */
@media (min-width: 641px) {
    .filter-toggle-btn { display: none; }
    .visible-mobile { display: none !important; }
}
