/* Fortune 100 Corporate Design System - Subscription Administration */
/* Navy/charcoal palette, IBM Plex typography, enterprise-grade components */

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

:root {
    /* Brand */
    --brand-900: #0f172a;
    --brand-800: #1e293b;
    --brand-700: #334155;
    --brand-500: #64748b;
    --brand-300: #94a3b8;
    /* Accent blue */
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-subtle: rgba(37, 99, 235, 0.07);
    /* Surfaces */
    --bg-canvas: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f8fafc;
    --bg-elevated: #ffffff;
    /* Text — high contrast on white */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-inverse: #ffffff;
    /* Borders */
    --border-default: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-subtle: #f1f5f9;
    /* Semantic */
    --success: #15803d;
    --success-bg: #f0fdf4;
    --warning: #92400e;
    --warning-bg: #fffbeb;
    --error: #b91c1c;
    --error-bg: #fef2f2;
    --info: #0369a1;
    --info-bg: #f0f9ff;
    /* Keep for legacy refs */
    --corporate-navy: #0f172a;
    --corporate-navy-hover: #1e293b;
    --corporate-navy-light: #334155;
    --charcoal: #334155;
    --charcoal-light: #475569;
    --slate: #64748b;
    --slate-light: #94a3b8;
    /* Topbar & Sidebar */
    --topbar-bg: #0f172a;
    --topbar-text: #ffffff;
    --sidebar-border: rgba(255,255,255,0.08);
    --sidebar-active: rgba(37,99,235,0.2);
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.03);
    --shadow-md: 0 4px 6px rgba(15,23,42,0.05), 0 2px 4px rgba(15,23,42,0.04);
    --shadow-lg: 0 10px 20px rgba(15,23,42,0.07), 0 4px 8px rgba(15,23,42,0.04);
    --shadow-xl: 0 24px 48px rgba(15,23,42,0.1);
    /* Radius */
    --radius-sm: 5px;
    --radius-md: 7px;
    --radius-lg: 10px;
    --radius-xl: 14px;
    /* Transitions */
    --transition: 0.15s ease;
    --transition-fast: 0.1s ease;
}

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----- Corporate top bar ----- */
.corporate-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: #0f172a;
    color: var(--topbar-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.topbar-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 -8px 0 0;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-inverse);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background var(--transition);
}
.topbar-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}
.topbar-menu-icon {
    width: 24px;
    height: 24px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-logo-mark {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent) 0%, #63b3ed 100%);
    color: var(--text-inverse);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.topbar-app-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar-user {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
}

.topbar-link {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color var(--transition);
}

.topbar-link:hover {
    color: var(--text-inverse);
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.topbar-btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-inverse);
}

.topbar-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    color: var(--text-inverse);
}

.topbar-logout-form {
    margin: 0;
}

.topbar-logout {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}

.topbar-logout:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* System Menu Dropdown */
.topbar-dropdown {
    position: relative;
}

.topbar-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all var(--transition);
}

.topbar-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.topbar-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.topbar-dropdown.open .topbar-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 12px 16px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.dropdown-form {
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-surface-alt);
}

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

/* ----- App shell (sidebar + main) ----- */
.app-shell {
    display: flex;
    padding-top: 52px;
    min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 52px;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1005;
    opacity: 0;
    transition: opacity var(--transition);
}
.app-shell.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 52px;
    bottom: 0;
    width: 248px;
    background: #1e293b;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1010;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.nav-menu {
    flex: 1;
    padding: 8px 10px 20px;
    overflow-y: auto;
}

.nav-menu::-webkit-scrollbar {
    width: 5px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    margin-bottom: 1px;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.18s ease;
    position: relative;
}

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

.nav-item.active {
    background: rgba(66, 153, 225, 0.25);
    color: #ffffff;
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: #63b3ed;
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #e2e8f0;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    color: #ffffff;
}

.nav-text {
    letter-spacing: 0.01em;
    white-space: nowrap;
}

/* Section dividers (Business / Plus / Settings) */
.nav-section-label {
    padding: 20px 12px 6px 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #7dd3fc;
    user-select: none;
    position: relative;
}

.nav-section-label::before {
    content: '';
    display: block;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin-bottom: 10px;
}

.nav-section-label:first-of-type::before {
    display: none;
}

/* Collapsible settings toggle */
.nav-section-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 12px 6px 12px;
    transition: color 0.18s ease;
}

.nav-section-toggle:hover {
    color: #bae6fd;
}

.nav-section-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #7dd3fc;
}

.nav-section-arrow.open {
    transform: rotate(180deg);
}

.nav-section-toggle:hover .nav-section-arrow {
    color: #bae6fd;
}

/* Submenu with smooth expand/collapse */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    opacity: 0;
}

.nav-submenu.open {
    max-height: 500px;
    opacity: 1;
}

.nav-subitem {
    padding-left: 20px !important;
    font-size: 13px;
}

.nav-subitem .nav-icon {
    width: 15px;
    height: 15px;
    color: #cbd5e1;
}

.nav-subitem:hover .nav-icon,
.nav-subitem.active .nav-icon {
    color: #ffffff;
}

.nav-subitem .nav-text {
    color: #e2e8f0;
}

.nav-subitem:hover .nav-text,
.nav-subitem.active .nav-text {
    color: #ffffff;
}

/* ----- Main content ----- */
.main-content {
    margin-left: 248px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    padding: 16px 32px;
    position: sticky;
    top: 52px;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(15,23,42,0.04);
}

.page-header-with-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0;
}

.global-search-wrap {
    position: relative;
    flex-shrink: 0;
}

.global-search-input {
    width: 240px;
    max-width: 100%;
    padding: 8px 14px;
    font-size: 13.5px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-surface-alt);
    transition: all var(--transition);
}

.global-search-input:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.12);
    width: 280px;
}

.global-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    z-index: 200;
}

.global-search-dropdown .search-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.global-search-dropdown .search-item:last-child {
    border-bottom: none;
}

.global-search-dropdown .search-item:hover {
    background: var(--bg-surface-alt);
}

.global-search-dropdown .search-item small {
    display: block;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.content-container {
    padding: 24px 32px 48px;
    max-width: 100%;
    width: 100%;
}

/* ----- Cards ----- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.card-header h3, .card-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin: 0;
    line-height: 1.4;
}

.card-description {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.card-body {
    padding: 20px 24px;
    overflow: visible;
}

/* ----- Tables ----- */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overflow-y: visible;
}
.table-wrapper::after {
    content: '';
    display: block;
    height: 0;
    clear: both;
}

.table-scroll-hint {
    display: none;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 8px 0 4px 0;
}
@media (max-width: 1024px) {
    .table-scroll-hint {
        display: block;
    }
}

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

.data-table thead {
    background: #f8fafc;
}

.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-default);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
    vertical-align: middle;
    font-size: 13px;
}

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

.data-table tbody tr:hover {
    background: #f8fafc;
}

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

/* Row/button/badge/alert styles moved to inline <style> in _Layout.cshtml
   for instant F5 refresh — no external CSS caching dependency. */

/* Color selector - square radio buttons */
.color-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.color-option {
    display: inline-flex;
    cursor: pointer;
    margin: 0;
}

.color-option input[type="radio"] {
    display: none;
}

.color-box {
    display: block;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-strong);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.color-option input[type="radio"]:checked + .color-box {
    border-color: var(--corporate-navy);
    box-shadow: 0 0 0 3px rgba(15, 41, 66, 0.25);
    transform: scale(1.1);
}

.color-option:hover .color-box {
    border-color: var(--charcoal-light);
}

.color-box.color-white { background: #ffffff; border-color: #ccc; }
.color-box.color-green { background: #4caf50; }
.color-box.color-blue { background: #2196f3; }
.color-box.color-yellow { background: #ffeb3b; }
.color-box.color-red { background: #f44336; }
.color-box.color-gray { background: #9e9e9e; }
.color-box.color-purple { background: #9c27b0; }

.action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

/* ----- Forms ----- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

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

.form-text {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.date-format-note {
    margin: 0 0 16px 0;
    font-size: 12px;
    color: var(--text-tertiary);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--corporate-navy);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

/* Badges, alerts, tg-indicator, row-backup-reminder: moved to inline <style> in _Layout.cshtml */

/* ----- Page actions ----- */
.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-actions-multi {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
}

.page-actions-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.filter-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-label-color { margin-left: 8px; }

.filter-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.sort-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}

.form-control-inline {
    width: auto;
    min-width: 200px;
}

.actions-col {
    white-space: nowrap;
    min-width: 200px;
}

.action-form {
    display: inline;
}

.group-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.info-cell {
    max-width: 220px;
}

.info-preview {
    display: inline-block;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    font-size: 12px;
    color: var(--text-secondary);
}

.info-empty {
    color: var(--text-tertiary);
    font-size: 13px;
}

.btn-note {
    margin-left: 6px;
    padding: 4px 10px;
    font-size: 12px;
}

/* ----- Stats grid (dashboard) ----- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, #63b3ed 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-subtle);
    border-radius: var(--radius-md);
    color: var(--accent);
}

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    letter-spacing: -0.03em;
}

.stat-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

/* ----- Dashboard grid ----- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 24px;
}

/* ----- Activity list ----- */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-md);
    color: var(--corporate-navy);
}

.activity-icon svg {
    width: 16px;
    height: 16px;
}

.activity-details {
    flex: 1;
}

.activity-action {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 2px 0;
}

.activity-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

/* ----- Dashboard (modern interactive) ----- */
.dashboard-page {
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-hero {
    margin-bottom: 28px;
}

.dashboard-hero h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.dashboard-hero p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}

.dashboard-kpi-rows {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.dashboard-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

@media (max-width: 768px) {
    .dashboard-kpi-row {
        grid-template-columns: 1fr;
    }
}

.dashboard-kpi-card.kpi-stat-only {
    cursor: default;
    pointer-events: none;
}

.dashboard-kpi-card.kpi-stat-only:hover {
    transform: none;
}

.dashboard-kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
}

.dashboard-kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.dashboard-kpi-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.dashboard-kpi-card.kpi-customers::before { background: #2563eb; }
.dashboard-kpi-card.kpi-active-customers::before { background: var(--success); }
.dashboard-kpi-card.kpi-subscriptions::before { background: #0d9488; }
.dashboard-kpi-card.kpi-active-subs::before { background: #059669; }
.dashboard-kpi-card.kpi-expiring::before { background: var(--warning); }
.dashboard-kpi-card.kpi-groups::before { background: #7c3aed; }
.dashboard-kpi-card.kpi-active-groups::before { background: #5b21b6; }
.dashboard-kpi-card.kpi-banned::before { background: var(--error); }
.dashboard-kpi-card.kpi-stat::before { background: #64748b; }

.dashboard-kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.dashboard-kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 500;
}

.dashboard-kpi-card .kpi-hint {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.dashboard-kpi-card.kpi-empty {
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
}

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

.dashboard-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.dashboard-card .card-header {
    padding: 16px 20px;
    background: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-default);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.dashboard-card .card-body {
    padding: 16px 20px;
}

.dashboard-expiring-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.dashboard-expiring-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-default);
}

.dashboard-expiring-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.dashboard-expiring-table tr:hover td {
    background: var(--bg-surface-alt);
}

.dashboard-expiring-table .expires-at {
    font-variant-numeric: tabular-nums;
    color: var(--warning);
    font-weight: 500;
}

.dashboard-card .empty-message {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    padding: 12px 0;
}

/* ----- Bot Notifications (send form) ----- */
.bot-notif-email-row {
    position: relative;
}

.bot-notif-email-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bot-notif-email-input {
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.bot-notif-email-gap {
    width: 12px;
    flex-shrink: 0;
}

.bot-notif-suggestions {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.bot-notif-suggestions .list-group-item {
    background: var(--bg-surface);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    color: var(--text-primary);
}

.bot-notif-suggestions .list-group-item:last-child {
    border-bottom: none;
}

.bot-notif-suggestions .list-group-item:hover {
    background: var(--info-bg);
    color: var(--info);
}

.bot-notif-editor-row {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

.bot-notif-message-col {
    flex: 1;
    min-width: 0;
}

.bot-notif-preview-col {
    flex: 1;
    min-width: 280px;
    max-width: 50%;
}

.bot-notif-preview-box {
    min-height: 200px;
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-surface-alt);
}

@media (max-width: 900px) {
    .bot-notif-editor-row {
        flex-direction: column;
    }
    .bot-notif-preview-col {
        max-width: none;
    }
}

/* ----- Login ----- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--corporate-navy);
    padding: 40px;
    position: relative;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%);
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-default);
}

.login-form {
    padding-top: 0;
}

.login-bg-video {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.login-bg-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.4;
}

.login-bg-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(15, 41, 66, 0.85) 0%, rgba(26, 54, 93, 0.75) 50%, rgba(15, 41, 66, 0.9) 100%);
}

.login-branding {
    text-align: center;
    margin-bottom: 32px;
    color: #fff;
}

.login-logo {
    margin-bottom: 16px;
}

.login-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.1) 100%);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 16px;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.05em;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-brand-title {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0 0 8px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.login-brand-tagline {
    font-size: 14px;
    color: rgba(255,255,255,0.75);
    margin: 0;
    letter-spacing: 0.02em;
}

.login-card {
    background: var(--bg-surface);
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.1);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}

.login-footer p {
    margin: 0;
    font-size: 12px;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

.input-with-icon {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.form-control-icon {
    padding-left: 44px;
}

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--corporate-navy) 0%, var(--corporate-navy-light) 100%);
    border: none;
    box-shadow: 0 4px 14px rgba(15, 41, 66, 0.35);
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(15, 41, 66, 0.45);
}

.btn-arrow {
    width: 18px;
    height: 18px;
    transition: transform var(--transition);
}

.btn-login:hover .btn-arrow {
    transform: translateX(4px);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.login-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.login-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ----- Modal ----- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    background: rgba(15, 41, 66, 0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-default);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    font-family: inherit;
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-surface-alt);
}

/* ----- Empty state ----- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ----- Validation ----- */
.text-danger {
    color: var(--error);
    font-size: 12px;
    display: block;
    margin-top: 4px;
    font-weight: 500;
}

/* ----- Autocomplete ----- */
.autocomplete-suggestions {
    position: absolute;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    max-height: 280px;
    overflow-y: auto;
    width: 100%;
    max-width: 400px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    margin-top: 4px;
}

.autocomplete-item {
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--bg-surface-alt);
}

.customer-email-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.customer-email-list .btn {
    margin: 0;
}

/* ----- Responsive ----- */
/* Sidebar disappears first (1200px) so menu hides before page content is squeezed */
@media (max-width: 1200px) {
    .topbar-menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }
    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

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

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

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

/* Page content adapts at smaller widths after menu is already hidden */
@media (max-width: 768px) {
    .content-container {
        padding: 20px 16px 32px;
    }

    .page-header {
        padding: 16px 20px;
    }

    .page-title {
        font-size: 18px;
    }

    .corporate-topbar {
        padding: 0 16px;
    }

    .topbar-app-name {
        display: none;
    }

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

    .table-wrapper {
        margin: 0 -16px;
        padding: 0 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100vw;
    }
    .data-table {
        min-width: 600px;
    }
}

/* Groups: hide Payment Gateway and IP on small screens */
@media (max-width: 900px) {
    .col-payment-gateway,
    .col-ip-address {
        display: none;
    }
}

/* Prevent body scroll when sidebar overlay is open on mobile */
@media (max-width: 1200px) {
    body.sidebar-open {
        overflow: hidden;
    }
}

/* ----- Modern polish: scrollbar, selection, smooth scroll ----- */
html {
    scroll-behavior: smooth;
}

::selection {
    background: rgba(66, 153, 225, 0.2);
    color: var(--text-primary);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--slate-light);
    background-clip: padding-box;
}

/* Subtle page load animation */
.content-container {
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Link styling inside tables */
.data-table a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.data-table a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}
