/* ==========================================================================
   NTDP Tracker - "New look" (beta)

   Loaded after style.css, and only for people who have switched the new look
   on (see inject_ui_look() in app.py). Every rule is scoped under
   html[data-ui="modern"], so nothing here can leak into the classic look.

   Most of the change comes from redefining the existing tokens; the component
   rules below only touch what the tokens can't reach.
   ========================================================================== */

/* ---------- Tokens: light ---------- */
html[data-ui="modern"] {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --secondary-dark: #475569;

    --light-bg: #f5f6f8;
    --card-bg: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f3f6;
    --gray-200: #e6e8ec;
    --gray-300: #d5d9e0;
    --gray-700: #3f4756;
    --border-color: #e6e8ec;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --table-header-bg: #f8fafc;
    --table-header-text: #64748b;
    --table-row-hover: #f3f6fd;

    --m-surface-2: #f8fafc;
    --m-border-strong: #d5d9e0;
    --m-accent-soft: rgba(37, 99, 235, 0.08);
    --m-accent-softer: rgba(37, 99, 235, 0.05);
    --m-accent-text: #1d4ed8;
    --m-ring: 0 0 0 3px rgba(37, 99, 235, 0.22);
    --m-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.04);
    --m-shadow-md: 0 4px 16px -4px rgba(15, 23, 42, 0.10), 0 2px 4px rgba(15, 23, 42, 0.04);
    --m-shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.22);
    --m-nav-bg: rgba(255, 255, 255, 0.78);
    --m-tooltip-bg: #0f172a;
    --m-toast-bg: #0f172a;
    --m-radius: 10px;
    --m-radius-lg: 14px;
    --m-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --m-nav-h: 73px;

    /* Division tints */
    --m-d1-bg: #fef3c7;  --m-d1-fg: #92400e;
    --m-d2-bg: #ece9fb;  --m-d2-fg: #4a3aa7;
    --m-d3-bg: #fde8d7;  --m-d3-fg: #9a3412;
    --m-naia-bg: #dbeafe; --m-naia-fg: #1e40af;
    --m-intl-bg: #dcf5dc; --m-intl-fg: #0b5d0b;
    --m-jc-bg: #fce7ef;  --m-jc-fg: #9d174d;

    /* Division series colors (charts, legend swatches, dots). Order
       D1 D2 D3 NAIA JC Intl validated for colorblind separation. */
    --m-c-D1: #eda100; --m-c-D2: #6250d6; --m-c-D3: #eb6834;
    --m-c-NAIA: #2a78d6; --m-c-JC: #e87ba4; --m-c-International: #008300;

    color-scheme: light;
}

/* ---------- Tokens: dark ---------- */
html[data-ui="modern"][data-theme="dark"] {
    --primary: #4f86ff;
    --primary-dark: #3b72f0;
    --primary-light: #7aa4ff;
    --secondary: #8b95a8;
    --secondary-dark: #a3acbd;

    --light-bg: #0b0f17;
    --card-bg: #121826;
    --white: #121826;
    --gray-50: #161d2c;
    --gray-100: #182032;
    --gray-200: #232c3d;
    --gray-300: #2e3950;
    --gray-700: #c3cad7;
    --gray-800: #dfe4ec;
    --gray-900: #eef1f6;
    --border-color: #222b3b;
    --text-primary: #e8ecf3;
    --text-secondary: #8b95a8;
    --table-header-bg: #141b29;
    --table-header-text: #8b95a8;
    --table-row-hover: #172036;

    --m-surface-2: #141b29;
    --m-border-strong: #2e3950;
    --m-accent-soft: rgba(79, 134, 255, 0.14);
    --m-accent-softer: rgba(79, 134, 255, 0.08);
    --m-accent-text: #8fb0ff;
    --m-ring: 0 0 0 3px rgba(79, 134, 255, 0.35);
    --m-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --m-shadow-md: 0 6px 20px -6px rgba(0, 0, 0, 0.5);
    --m-shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.7);
    --m-nav-bg: rgba(11, 15, 23, 0.72);
    --m-tooltip-bg: #e8ecf3;
    --m-toast-bg: #1c2433;

    --m-d1-bg: rgba(251, 191, 36, 0.16);  --m-d1-fg: #fcd34d;
    --m-d2-bg: rgba(144, 133, 233, 0.18); --m-d2-fg: #c4bdf5;
    --m-d3-bg: rgba(234, 88, 12, 0.18);   --m-d3-fg: #fdba74;
    --m-naia-bg: rgba(79, 134, 255, 0.18); --m-naia-fg: #93b4ff;
    --m-intl-bg: rgba(34, 160, 34, 0.20); --m-intl-fg: #86e086;
    --m-jc-bg: rgba(213, 81, 129, 0.20);  --m-jc-fg: #f6a6c6;

    --m-c-D1: #c98500; --m-c-D2: #9085e9; --m-c-D3: #d95926;
    --m-c-NAIA: #3987e5; --m-c-JC: #d55181; --m-c-International: #008300;

    color-scheme: dark;
}

/* ---------- Base ---------- */
html[data-ui="modern"] body {
    /* the theme bootstrap script sets an inline background - override it */
    background-color: var(--light-bg) !important;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
    text-rendering: optimizeLegibility;
}

html[data-ui="modern"] :focus-visible {
    outline: none;
    box-shadow: var(--m-ring);
}

/* ---------- Navbar ---------- */
html[data-ui="modern"] .navbar {
    background: var(--m-nav-bg);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
}

html[data-ui="modern"] .nav-brand,
html[data-ui="modern"] .nav-brand:hover {
    color: var(--text-primary);
}

html[data-ui="modern"] .nav-brand-text {
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -0.025em;
}

html[data-ui="modern"] .hamburger-menu {
    border-radius: var(--m-radius);
    transition: background-color 0.15s var(--m-ease);
}

html[data-ui="modern"] .hamburger-menu:hover {
    background: var(--gray-100);
}

/* ---------- Slide-out menu ---------- */
html[data-ui="modern"] .slide-menu {
    border-left: 1px solid var(--border-color);
    box-shadow: var(--m-shadow-lg);
}

html[data-ui="modern"] .menu-overlay {
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

html[data-ui="modern"] .menu-content {
    padding-left: 10px;
    padding-right: 10px;
}

html[data-ui="modern"] .menu-item {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.92rem;
    transition: background-color 0.15s var(--m-ease), color 0.15s var(--m-ease);
}

html[data-ui="modern"] .menu-item i {
    color: var(--text-secondary);
    transition: color 0.15s var(--m-ease);
}

html[data-ui="modern"] .menu-item:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

html[data-ui="modern"] .menu-item:hover i {
    color: var(--text-primary);
}

html[data-ui="modern"] .menu-item.active,
html[data-ui="modern"] .menu-item.active i {
    background: var(--m-accent-soft);
    color: var(--m-accent-text);
}

html[data-ui="modern"] .menu-item.active i {
    background: transparent;
}

html[data-ui="modern"] .menu-section-title {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

html[data-ui="modern"] .menu-footer {
    background: transparent;
}

/* ---------- Controls above the table ---------- */
html[data-ui="modern"] .main-content {
    padding-top: 28px;
}

html[data-ui="modern"] .controls-section {
    margin-bottom: 14px;
    gap: 12px;
}

html[data-ui="modern"] .search-box input {
    height: 42px;
    padding: 0 40px 0 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--m-radius);
    font-size: 0.95rem;
    background: var(--card-bg);
    box-shadow: var(--m-shadow-sm);
    transition: border-color 0.15s var(--m-ease), box-shadow 0.15s var(--m-ease);
}

html[data-ui="modern"] .search-box input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

html[data-ui="modern"] .search-box input:focus {
    border-color: var(--primary);
    box-shadow: var(--m-ring);
}

html[data-ui="modern"] .search-box i.fa-search {
    left: 14px;
    font-size: 0.9rem;
}

html[data-ui="modern"] .clear-search-btn:hover {
    color: var(--text-primary);
    background: var(--gray-100);
}

html[data-ui="modern"] .player-count-badge {
    background: transparent;
    color: var(--text-secondary);
    padding: 0 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

html[data-ui="modern"] .player-count-badge #recordCount {
    color: var(--text-primary);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

html[data-ui="modern"] .clear-filters-btn,
html[data-ui="modern"][data-theme="dark"] .clear-filters-btn {
    background: transparent !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 999px;
    padding: 5px 12px;
    font-weight: 500;
    transition: all 0.15s var(--m-ease);
}

html[data-ui="modern"] .clear-filters-btn:hover,
html[data-ui="modern"][data-theme="dark"] .clear-filters-btn:hover {
    background: var(--gray-100) !important;
    color: var(--text-primary) !important;
}

html[data-ui="modern"] .filter-hint-banner,
html[data-ui="modern"][data-theme="dark"] .filter-hint-banner {
    background: var(--m-accent-softer);
    border: 1px solid var(--m-accent-soft);
    border-radius: var(--m-radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 10px 14px;
}

html[data-ui="modern"] .filter-hint-banner i {
    color: var(--primary);
}

html[data-ui="modern"] .active-filters {
    gap: 6px;
}

html[data-ui="modern"] .active-filter-tag {
    background: var(--m-accent-soft);
    color: var(--m-accent-text);
    border-radius: 999px;
    padding: 4px 6px 4px 11px;
    font-weight: 500;
}

html[data-ui="modern"] .active-filter-tag button {
    color: inherit;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

html[data-ui="modern"] .active-filter-tag button:hover {
    opacity: 1;
    background: var(--m-accent-soft);
}

/* ---------- Division section inside the College filter menu ---------- */
html[data-ui="modern"] .filter-section-label {
    padding: 8px 10px 4px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

html[data-ui="modern"] .filter-option-division {
    align-items: center !important;
}

html[data-ui="modern"] .filter-option-text {
    flex: 1 1 auto;
}

html[data-ui="modern"] .filter-option-count {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

html[data-ui="modern"] .filter-option.selected .filter-option-count {
    color: inherit;
}

html[data-ui="modern"] .division-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

html[data-ui="modern"] .division-dot.D1,
html[data-ui="modern"] .division-dot.D2,
html[data-ui="modern"] .division-dot.D3,
html[data-ui="modern"] .division-dot.NAIA,
html[data-ui="modern"] .division-dot.JC,
html[data-ui="modern"] .division-dot.International {
    background: var(--m-div-color);
}

html[data-ui="modern"] .active-filters:empty {
    display: none;
}

/* Filter menus: keep long options readable */
html[data-ui="modern"] .filter-option {
    align-items: flex-start;
    line-height: 1.35;
}

html[data-ui="modern"] .filter-option input[type="checkbox"] {
    flex: 0 0 auto;
    margin-top: 1px;
}

/* ---------- Data tables ---------- */
html[data-ui="modern"] .table-wrapper {
    border: 1px solid var(--border-color);
    border-radius: var(--m-radius-lg);
    box-shadow: var(--m-shadow-sm);
    /* clip (not hidden) keeps the rounded corners without breaking sticky headers */
    overflow: clip;
}

html[data-ui="modern"] .data-table {
    font-size: 0.9rem;
}

html[data-ui="modern"] .data-table thead {
    background: var(--table-header-bg);
    color: var(--table-header-text);
}

html[data-ui="modern"] .data-table th {
    position: sticky;
    top: var(--m-nav-h);
    z-index: 5;
    background: var(--table-header-bg);
    padding: 11px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--table-header-text);
    box-shadow: inset 0 -1px 0 var(--border-color);
    transition: color 0.15s var(--m-ease);
}

html[data-ui="modern"] .data-table th.sortable {
    padding-right: 22px;
}

html[data-ui="modern"] .data-table th.sortable:hover,
html[data-ui="modern"][data-theme="dark"] .data-table th.sortable:hover {
    background: var(--table-header-bg);
    color: var(--text-primary);
}

html[data-ui="modern"] .data-table th i {
    opacity: 0.35;
    margin-left: 4px;
    transition: opacity 0.15s var(--m-ease);
}

html[data-ui="modern"] .data-table th:hover i {
    opacity: 0.8;
}

html[data-ui="modern"] .data-table th i.fa-sort-up,
html[data-ui="modern"] .data-table th i.fa-sort-down {
    opacity: 1;
    color: var(--primary);
}

/* Rows: no zebra striping, hairline dividers, soft hover */
html[data-ui="modern"] .data-table tbody tr,
html[data-ui="modern"] .data-table tbody tr:nth-child(odd),
html[data-ui="modern"] .data-table tbody tr:nth-child(even),
html[data-ui="modern"][data-theme="dark"] .data-table tbody tr:nth-child(even) {
    background-color: var(--card-bg);
    box-shadow: inset 0 -1px 0 var(--border-color);
    transition: background-color 0.12s var(--m-ease);
}

html[data-ui="modern"] .data-table tbody tr:last-child {
    box-shadow: none;
}

html[data-ui="modern"] .data-table td {
    padding: 11px 12px;
    color: var(--m-td-color, var(--text-primary));
}

html[data-ui="modern"] .data-table td[data-field="first_name"] {
    font-weight: 500;
}

html[data-ui="modern"] .data-table td[data-field="last_name"] {
    font-weight: 600;
}

/* Division pills need a little more room than the classic 45px column */
html[data-ui="modern"] .data-table th[data-column="division"],
html[data-ui="modern"] .data-table td[data-field="division"] {
    width: 72px !important;
    max-width: 72px !important;
    text-align: left;
    padding-left: 10px;
    padding-right: 6px;
    overflow: visible;
    text-overflow: clip;
}

html[data-ui="modern"] .data-table td[data-field="first_name"] {
    padding-right: 4px;
}

html[data-ui="modern"] .data-table td[data-field="hs_year"],
html[data-ui="modern"] .data-table td[data-field="position"],
html[data-ui="modern"] .data-table td[data-field="region"] {
    --m-td-color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

html[data-ui="modern"] .data-table tbody tr:hover,
html[data-ui="modern"] .data-table tbody tr:nth-child(odd):hover,
html[data-ui="modern"] .data-table tbody tr:nth-child(even):hover {
    background-color: var(--table-row-hover) !important;
    color: inherit !important;
}

html[data-ui="modern"] .data-table tbody tr:hover td {
    color: var(--m-td-color, var(--text-primary)) !important;
}

html[data-ui="modern"] .data-table.no-hover tbody tr:hover {
    background-color: var(--card-bg) !important;
}

html[data-ui="modern"] .data-table td.loading {
    padding: 56px 20px;
    font-size: 0.9rem;
}

html[data-ui="modern"] .editing-row,
html[data-ui="modern"][data-theme="dark"] .editing-row {
    background-color: var(--m-accent-softer) !important;
    box-shadow: inset 3px 0 0 var(--primary), inset 0 -1px 0 var(--border-color) !important;
}

/* Tooltip for truncated club / college names */
html[data-ui="modern"] .data-table td[data-field="college"][data-full]:hover::after,
html[data-ui="modern"] .data-table td[data-field="club"][data-full]:hover::after {
    background: var(--m-tooltip-bg);
    color: var(--card-bg);
    border-radius: 8px;
    font-size: 0.78rem;
    padding: 6px 10px;
    box-shadow: var(--m-shadow-md);
    animation: m-pop 0.12s var(--m-ease);
}

html[data-ui="modern"] .data-table td[data-field="college"][data-full]:hover::before,
html[data-ui="modern"] .data-table td[data-field="club"][data-full]:hover::before {
    border-bottom-color: var(--m-tooltip-bg);
}

html[data-ui="modern"] .table-wrapper:has(.data-table td[data-field="college"][data-full]:hover),
html[data-ui="modern"] .table-wrapper:has(.data-table td[data-field="club"][data-full]:hover) {
    overflow: visible;
}

/* Division: soft tinted pills instead of solid blocks */
html[data-ui="modern"] .division-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    line-height: 1.5;
    background: var(--gray-100);
    color: var(--text-secondary);
}

html[data-ui="modern"] .division-badge.D1 { background: var(--m-d1-bg); color: var(--m-d1-fg); }
html[data-ui="modern"] .division-badge.D2 { background: var(--m-d2-bg); color: var(--m-d2-fg); }
html[data-ui="modern"] .division-badge.D3 { background: var(--m-d3-bg); color: var(--m-d3-fg); }
html[data-ui="modern"] .division-badge.NAIA { background: var(--m-naia-bg); color: var(--m-naia-fg); }
html[data-ui="modern"] .division-badge.International { background: var(--m-intl-bg); color: var(--m-intl-fg); }
html[data-ui="modern"] .division-badge.JC { background: var(--m-jc-bg); color: var(--m-jc-fg); }

html[data-ui="modern"] .data-table tbody tr:hover .division-badge.D1 { color: var(--m-d1-fg) !important; }
html[data-ui="modern"] .data-table tbody tr:hover .division-badge.D2 { color: var(--m-d2-fg) !important; }
html[data-ui="modern"] .data-table tbody tr:hover .division-badge.D3 { color: var(--m-d3-fg) !important; }
html[data-ui="modern"] .data-table tbody tr:hover .division-badge.NAIA { color: var(--m-naia-fg) !important; }
html[data-ui="modern"] .data-table tbody tr:hover .division-badge.International { color: var(--m-intl-fg) !important; }
html[data-ui="modern"] .data-table tbody tr:hover .division-badge.JC { color: var(--m-jc-fg) !important; }

/* Sessions */
html[data-ui="modern"] .sessions-badge {
    min-width: 26px;
    text-align: center;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--m-accent-soft);
    color: var(--m-accent-text);
    font-size: 0.78rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.15s var(--m-ease);
}

html[data-ui="modern"] .sessions-badge:hover {
    background: var(--primary);
    color: #ffffff;
    transform: none;
}

html[data-ui="modern"] .data-table tbody tr:hover .sessions-badge {
    color: var(--m-accent-text) !important;
}

html[data-ui="modern"] .data-table tbody tr:hover .sessions-badge:hover {
    color: #ffffff !important;
}

html[data-ui="modern"] .sessions-cell > span[style] {
    color: var(--text-secondary) !important;
    opacity: 0.6;
}

html[data-ui="modern"] .session-item {
    background: var(--gray-100);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-weight: 500;
}

html[data-ui="modern"] .data-table tbody tr:hover .session-item {
    color: var(--text-primary) !important;
}

/* Quick-suggest chips for blank cells: a bright "highlighter" amber so
   missing info stands out and invites people to fill it in */
html[data-ui="modern"] {
    --m-add-bg: #fff3c4;
    --m-add-border: #f59e0b;
    --m-add-fg: #92400e;
    --m-add-solid: #f59e0b;
    --m-add-solid-fg: #1f1300;
}

html[data-ui="modern"][data-theme="dark"] {
    --m-add-bg: rgba(251, 191, 36, 0.16);
    --m-add-border: #fbbf24;
    --m-add-fg: #fcd34d;
    --m-add-solid: #fbbf24;
    --m-add-solid-fg: #1f1300;
}

html[data-ui="modern"] .quick-suggest-btn,
html[data-ui="modern"] .data-table tbody tr:hover .quick-suggest-btn {
    border: 1.5px solid var(--m-add-border);
    background: var(--m-add-bg);
    color: var(--m-add-fg) !important;
    border-radius: 999px;
    padding: 3px 10px 3px 8px;
    font-weight: 650;
    box-shadow: 0 1px 2px rgba(245, 158, 11, 0.18);
    transition: background-color 0.15s var(--m-ease), color 0.15s var(--m-ease), transform 0.15s var(--m-ease);
}

html[data-ui="modern"] .quick-suggest-btn i {
    font-size: 0.68rem;
}

html[data-ui="modern"] .quick-suggest-btn:hover,
html[data-ui="modern"] .data-table tbody tr:hover .quick-suggest-btn:hover {
    border: 1.5px solid var(--m-add-solid);
    background: var(--m-add-solid);
    color: var(--m-add-solid-fg) !important;
    transform: translateY(-1px);
}

html[data-ui="modern"] .quick-suggest-done {
    border-radius: 999px;
    font-weight: 600;
}

/* Players page row action: quiet icon button instead of a filled block
   (scoped to #playersTable so labelled buttons like "Undo" elsewhere keep their size) */
html[data-ui="modern"] #playersTable td:last-child > .btn-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary) !important;
    box-shadow: none;
}

html[data-ui="modern"] #playersTable tbody tr:hover td:last-child > .btn-sm {
    border-color: var(--border-color);
    background: var(--card-bg);
}

html[data-ui="modern"] #playersTable td:last-child > .btn-sm:hover {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

/* Report tables */
html[data-ui="modern"] .report-table th {
    background: var(--table-header-bg);
    color: var(--table-header-text);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    box-shadow: inset 0 -1px 0 var(--border-color);
}

/* ---------- Buttons ---------- */
html[data-ui="modern"] .btn {
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 550;
    line-height: 1.3;
    border: 1px solid transparent;
    transition: background-color 0.15s var(--m-ease), border-color 0.15s var(--m-ease),
                color 0.15s var(--m-ease), box-shadow 0.15s var(--m-ease);
}

html[data-ui="modern"] .btn:hover {
    transform: none;
}

html[data-ui="modern"] .btn:active {
    transform: translateY(1px);
}

html[data-ui="modern"] .btn-sm {
    padding: 5px 10px;
    font-size: 0.82rem;
}

html[data-ui="modern"] .btn-primary {
    background: var(--primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

html[data-ui="modern"] .btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

html[data-ui="modern"] .btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
    box-shadow: var(--m-shadow-sm);
}

html[data-ui="modern"] .btn-secondary:hover {
    background: var(--gray-100);
    border-color: var(--m-border-strong);
    box-shadow: var(--m-shadow-sm);
}

html[data-ui="modern"] .btn-danger:hover { background: #dc2626; }
html[data-ui="modern"] .btn-success:hover { background: #059669; }

/* ---------- Forms ---------- */
html[data-ui="modern"] .form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

html[data-ui="modern"] .form-group input,
html[data-ui="modern"] .form-group select,
html[data-ui="modern"] .form-group textarea,
html[data-ui="modern"] .inline-edit-cell input,
html[data-ui="modern"] .inline-edit-cell select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.92rem;
    background: var(--card-bg);
    transition: border-color 0.15s var(--m-ease), box-shadow 0.15s var(--m-ease);
}

html[data-ui="modern"] .inline-edit-cell input,
html[data-ui="modern"] .inline-edit-cell select {
    padding: 5px 8px;
    font-size: 0.85rem;
}

html[data-ui="modern"] .form-group input:focus,
html[data-ui="modern"] .form-group select:focus,
html[data-ui="modern"] .form-group textarea:focus,
html[data-ui="modern"] .inline-edit-cell input:focus,
html[data-ui="modern"] .inline-edit-cell select:focus {
    border-color: var(--primary);
    box-shadow: var(--m-ring);
}

html[data-ui="modern"] .form-group input[readonly] {
    background: var(--gray-100);
    color: var(--text-secondary);
}

/* ---------- Cards & admin pages ---------- */
html[data-ui="modern"] .admin-card,
html[data-ui="modern"] .report-section,
html[data-ui="modern"] .stat-card,
html[data-ui="modern"] .dashboard-card,
html[data-ui="modern"] .login-card {
    border: 1px solid var(--border-color);
    border-radius: var(--m-radius-lg);
    box-shadow: var(--m-shadow-sm);
}

html[data-ui="modern"] .stat-card {
    border-top: 1px solid var(--border-color);
}

html[data-ui="modern"] .admin-page-title,
html[data-ui="modern"] .login-card h2 {
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

html[data-ui="modern"] .admin-card h2,
html[data-ui="modern"] .report-section h2,
html[data-ui="modern"] .stat-card h3,
html[data-ui="modern"] .dashboard-card h3 {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border-color);
}

html[data-ui="modern"] .stat-card h3,
html[data-ui="modern"] .dashboard-card h3 {
    border-bottom: none;
}

html[data-ui="modern"] .admin-card h2 i,
html[data-ui="modern"] .report-section h2 i,
html[data-ui="modern"] .stat-card h3 i,
html[data-ui="modern"] .admin-page-title i {
    color: var(--primary);
}

html[data-ui="modern"] .dashboard-card {
    transition: transform 0.2s var(--m-ease), box-shadow 0.2s var(--m-ease), border-color 0.2s var(--m-ease);
}

html[data-ui="modern"] .dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--m-shadow-md);
    border-color: var(--m-border-strong);
}

html[data-ui="modern"] .dashboard-card i {
    color: var(--primary);
    font-size: 2rem;
}

html[data-ui="modern"] .stat-value {
    background: var(--m-accent-soft);
    color: var(--m-accent-text);
    font-variant-numeric: tabular-nums;
}

html[data-ui="modern"] .stat-item {
    border-radius: 8px;
    border-bottom-color: var(--border-color);
}

/* ---------- Filter menus ---------- */
html[data-ui="modern"] .filter-menu {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--m-shadow-lg);
    padding: 4px;
    animation: m-pop 0.14s var(--m-ease);
}

html[data-ui="modern"] .filter-menu-header {
    background: var(--card-bg);
    border-radius: 8px 8px 0 0;
    padding: 8px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-primary);
}

html[data-ui="modern"] .filter-option {
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 0.87rem;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 450;
}

html[data-ui="modern"] .filter-option:hover {
    background: var(--gray-100);
}

html[data-ui="modern"] .filter-option.selected {
    background: var(--m-accent-soft);
    color: var(--m-accent-text);
}

/* ---------- Modals ---------- */
html[data-ui="modern"] .modal {
    background-color: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

html[data-ui="modern"] .modal-content {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--m-shadow-lg);
    padding: 28px;
    animation: m-modal-in 0.2s var(--m-ease);
}

html[data-ui="modern"] .modal-content h2 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 650;
    letter-spacing: -0.015em;
}

html[data-ui="modern"] .close {
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
    transition: background-color 0.15s var(--m-ease);
}

html[data-ui="modern"] .close:hover {
    background: var(--gray-100);
}

/* ---------- Alerts & toasts ---------- */
html[data-ui="modern"] .alert {
    border-radius: var(--m-radius);
    font-size: 0.9rem;
    padding: 12px 40px 12px 16px;
}

html[data-ui="modern"] .alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
html[data-ui="modern"] .alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
html[data-ui="modern"] .alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

html[data-ui="modern"][data-theme="dark"] .alert-success { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
html[data-ui="modern"][data-theme="dark"] .alert-error   { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
html[data-ui="modern"][data-theme="dark"] .alert-warning { background: rgba(245, 158, 11, 0.12); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }

html[data-ui="modern"] .toast,
html[data-ui="modern"] .toast.success,
html[data-ui="modern"] .toast.error,
html[data-ui="modern"] .toast.info,
html[data-ui="modern"] .toast.warning {
    background: var(--m-toast-bg);
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.9rem;
    box-shadow: var(--m-shadow-lg);
    animation: m-toast-in 0.25s var(--m-ease);
}

html[data-ui="modern"] .toast.hiding {
    animation: fadeOut 0.2s ease forwards;
}

html[data-ui="modern"] .toast.success i { color: #34d399; }
html[data-ui="modern"] .toast.error i   { color: #f87171; }
html[data-ui="modern"] .toast.info i    { color: #7aa4ff; }
html[data-ui="modern"] .toast.warning i { color: #fbbf24; }

/* ---------- Footer & floating bits ---------- */
html[data-ui="modern"] .footer {
    background: transparent;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
    padding: 24px 0;
}

html[data-ui="modern"] .scroll-top-btn {
    width: 44px;
    height: 44px;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--m-shadow-md);
}

html[data-ui="modern"] .scroll-top-btn:hover {
    background: var(--gray-100);
    transform: translateY(-2px);
}

html[data-ui="modern"] .scroll-progress {
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    box-shadow: var(--m-shadow-md);
}

html[data-ui="modern"] .site-banner {
    font-size: 0.9rem;
}

/* ---------- Motion ---------- */
@keyframes m-pop {
    from { opacity: 0; transform: translateY(-3px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

@keyframes m-modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

@keyframes m-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    html[data-ui="modern"] *,
    html[data-ui="modern"] *::before,
    html[data-ui="modern"] *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}


/* ==========================================================================
   Phones: the player table becomes a compact one-line list. Tapping a row
   opens it into a full card (full club/college names, sessions, actions).
   While a search is typed, every row is shown as a full card.

   The open state is the .m-open class on a row, managed by the small script
   in index.html (only loaded with the new look). Column headers turn into a
   scrollable row of chips that still open the same filter menus.
   ========================================================================== */
@media (max-width: 720px) {
    html[data-ui="modern"] .main-content {
        padding-top: 16px;
    }

    html[data-ui="modern"] .search-box {
        min-width: 0;
    }

    html[data-ui="modern"] .scroll-progress {
        display: none;
    }

    html[data-ui="modern"] #playersTab .table-wrapper {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    html[data-ui="modern"] #playersTable {
        display: block;
    }

    /* ---- Header -> chip bar ---- */
    html[data-ui="modern"] #playersTable thead {
        display: block;
        position: sticky;
        top: var(--m-nav-h);
        z-index: 6;
        margin: 0 -20px 10px;
        padding: 8px 20px;
        background: var(--light-bg);
    }

    html[data-ui="modern"] #playersTable thead tr {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    html[data-ui="modern"] #playersTable thead tr::-webkit-scrollbar {
        display: none;
    }

    html[data-ui="modern"] #playersTable th {
        position: static;
        flex: 0 0 auto;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 6px 12px !important;
        border: 1px solid var(--border-color);
        border-radius: 999px;
        background: var(--card-bg);
        box-shadow: none;
        font-size: 0.72rem;
        color: var(--text-primary);
    }

    html[data-ui="modern"] #playersTable th:not([data-column]) {
        display: none;
    }

    /* ---- The list ---- */
    html[data-ui="modern"] #playersTable tbody {
        display: block;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: var(--m-radius-lg);
        box-shadow: var(--m-shadow-sm);
        overflow: clip;
    }

    html[data-ui="modern"] #playersTable td {
        display: block;
        padding: 0;
        max-width: none;
        min-width: 0;
        width: auto;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        text-align: left;
    }

    html[data-ui="modern"] #playersTable td.loading {
        flex: 1 1 100%;
        text-align: center;
        padding: 40px 0;
    }

    /* Full names are shown when a row opens, so the hover tooltip isn't needed */
    html[data-ui="modern"] #playersTable td[data-full]:hover::after {
        content: none;
    }

    /* ---- Compact row (default) ---- */
    html[data-ui="modern"] #playersTable tbody tr,
    html[data-ui="modern"] #playersTable tbody tr:nth-child(odd),
    html[data-ui="modern"] #playersTable tbody tr:nth-child(even),
    html[data-ui="modern"][data-theme="dark"] #playersTable tbody tr:nth-child(even) {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        padding: 12px 14px;
        background: var(--card-bg);
        box-shadow: inset 0 -1px 0 var(--border-color);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    html[data-ui="modern"] #playersTable tbody tr:last-child {
        box-shadow: none;
    }

    html[data-ui="modern"] #playersTable tbody tr:hover,
    html[data-ui="modern"] #playersTable tbody tr:nth-child(odd):hover,
    html[data-ui="modern"] #playersTable tbody tr:nth-child(even):hover {
        background-color: var(--card-bg) !important;
    }

    html[data-ui="modern"] #playersTable tbody tr:active {
        background-color: var(--table-row-hover) !important;
    }

    html[data-ui="modern"] #playersTable td[data-field="first_name"] {
        order: 1;
        flex: 0 0 auto;
        font-weight: 600;
        padding-right: 0;
        margin-right: -4px; /* first + last read as one name */
    }

    html[data-ui="modern"] #playersTable td[data-field="last_name"] {
        order: 2;
        flex: 0 1 auto;
        min-width: 0;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    html[data-ui="modern"] #playersTable td[data-field="hs_year"],
    html[data-ui="modern"] #playersTable td[data-field="position"] {
        flex: 0 0 auto;
        font-size: 0.85rem;
        --m-td-color: var(--text-secondary);
    }

    html[data-ui="modern"] #playersTable td[data-field="hs_year"]  { order: 3; margin-left: 2px; }
    html[data-ui="modern"] #playersTable td[data-field="position"] { order: 4; margin-left: -4px; }

    /* "2027 · OH" on the one-line row: only show the dot when there's a real
       year before it. Scoped to closed rows so it can't replace the
       "Position" label in an open card. */
    html[data-ui="modern"] #playersTable tbody tr:not(.m-open):not(:has(td[data-field="hs_year"] .quick-suggest-btn)):not(:has(td[data-field="hs_year"]:empty)) td[data-field="position"]:not(:empty)::before {
        content: "· ";
    }

    /* Blank year/position on the one-line row: drop the Add chip (the row
       gets an "Add info" flag instead) */
    html[data-ui="modern"] #playersTable tbody tr:not(.m-open) td[data-field="hs_year"]:has(.quick-suggest-btn),
    html[data-ui="modern"] #playersTable tbody tr:not(.m-open) td[data-field="position"]:has(.quick-suggest-btn) {
        display: none;
    }

    html[data-ui="modern"] #playersTable td[data-field="division"] {
        order: 5;
        flex: 0 0 auto;
        margin-left: auto;
        width: auto !important;
        max-width: none !important;
        padding: 0;
    }

    /* Chevron */
    html[data-ui="modern"] #playersTable tbody tr[data-player-id]::before {
        content: "";
        order: 6;
        flex: 0 0 auto;
        width: 7px;
        height: 7px;
        margin: -3px 2px 0 4px;
        border-right: 2px solid var(--text-secondary);
        border-bottom: 2px solid var(--text-secondary);
        transform: rotate(45deg);
        opacity: 0.7;
        transition: transform 0.2s var(--m-ease);
    }

    html[data-ui="modern"] #playersTable td[data-field="region"],
    html[data-ui="modern"] #playersTable td[data-field="club"],
    html[data-ui="modern"] #playersTable td[data-field="college"],
    html[data-ui="modern"] #playersTable td.sessions-cell,
    html[data-ui="modern"] #playersTable td:last-child:not(.loading) {
        display: none;
    }

    /* Rows with missing info get an "Add info" flag, so it's visible
       without opening the row. A missing college alone doesn't count:
       many players don't have one yet. */
    html[data-ui="modern"] #playersTable tbody tr:not(.m-open):has(td:not([data-field="college"]) .quick-suggest-btn) td:last-child {
        display: block;
        order: 5;
        flex: 0 0 auto;
    }

    html[data-ui="modern"] #playersTable tbody tr:not(.m-open):has(td:not([data-field="college"]) .quick-suggest-btn) td:last-child > * {
        display: none;
    }

    html[data-ui="modern"] #playersTable tbody tr:not(.m-open):has(td:not([data-field="college"]) .quick-suggest-btn) td:last-child::after {
        content: "+ Add info";
        display: inline-block;
        padding: 2px 8px;
        border: 1.5px solid var(--m-add-border);
        border-radius: 999px;
        background: var(--m-add-bg);
        color: var(--m-add-fg);
        font-size: 0.7rem;
        font-weight: 650;
        white-space: nowrap;
    }

    /* ---- Open row -> full card ---- */
    html[data-ui="modern"] #playersTable tbody tr.m-open,
    html[data-ui="modern"] #playersTable tbody tr.m-open:nth-child(odd),
    html[data-ui="modern"] #playersTable tbody tr.m-open:nth-child(even),
    html[data-ui="modern"][data-theme="dark"] #playersTable tbody tr.m-open:nth-child(even) {
        flex-wrap: wrap;
        column-gap: 12px;
        row-gap: 10px;
        padding: 14px 14px 16px 16px;
        background: var(--card-bg) !important;
        box-shadow: inset 3px 0 0 var(--primary), inset 0 -1px 0 var(--border-color);
        animation: m-open-in 0.18s var(--m-ease);
    }

    html[data-ui="modern"] #playersTable tbody tr.m-open::before {
        order: 5;
        transform: rotate(-135deg);
        margin-top: 4px;
    }

    /* line break after the first line */
    html[data-ui="modern"] #playersTable tbody tr.m-open::after {
        content: "";
        order: 6;
        flex: 0 0 100%;
        height: 0;
    }

    html[data-ui="modern"] #playersTable tr.m-open td[data-field="first_name"],
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="last_name"] {
        font-size: 1rem;
        font-weight: 650;
    }

    html[data-ui="modern"] #playersTable tr.m-open td[data-field="first_name"] {
        margin-right: -8px; /* sit next to the last name like one word */
    }

    html[data-ui="modern"] #playersTable tr.m-open td[data-field="last_name"] {
        flex: 1 1 auto;
        white-space: normal;
    }

    html[data-ui="modern"] #playersTable tr.m-open td[data-field="division"] {
        order: 3;
        margin-left: 0;
    }

    html[data-ui="modern"] #playersTable tr.m-open td:last-child {
        display: block;
        order: 4;
        flex: 0 0 auto;
    }

    html[data-ui="modern"] #playersTable tr.m-open td:last-child > .btn-sm {
        border-color: var(--border-color);
    }

    /* Second line: HS year, position, region as small labelled stats */
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="hs_year"],
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="position"],
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="region"] {
        display: block;
        flex: 1 1 0;
        align-self: flex-start;
        margin-left: 0;
        font-size: 0.88rem;
        --m-td-color: var(--text-primary);
    }

    html[data-ui="modern"] #playersTable tr.m-open td[data-field="hs_year"]  { order: 7; }
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="position"] { order: 8; }
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="region"]   { order: 9; }

    html[data-ui="modern"] #playersTable tr.m-open .quick-suggest-btn {
        display: inline-flex;
    }

    /* Then full club and college names, then sessions */
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="club"] {
        display: block;
        order: 10;
        flex: 1 1 100%;
    }

    html[data-ui="modern"] #playersTable tr.m-open td[data-field="college"] {
        display: block;
        order: 11;
        flex: 1 1 100%;
    }

    html[data-ui="modern"] #playersTable tr.m-open td.sessions-cell {
        order: 12;
        flex: 1 1 100%;
        padding-top: 10px;
        border-top: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    html[data-ui="modern"] #playersTable tr.m-open .sessions-expanded {
        max-width: none;
        flex-basis: 100%;
    }

    /* Field labels */
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="hs_year"]::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="position"]::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="region"]::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="club"]::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="college"]::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="club"][data-full]:hover::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="college"][data-full]:hover::before,
    html[data-ui="modern"] #playersTable tr.m-open td.sessions-cell::before {
        display: block;
        position: static;
        margin: 0 0 2px;
        border: none;
        font-size: 0.66rem;
        font-weight: 600;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: var(--text-secondary);
    }

    html[data-ui="modern"] #playersTable tr.m-open td[data-field="hs_year"]::before { content: "HS Year"; }
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="position"]::before { content: "Position"; }
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="region"]::before { content: "Region"; }
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="club"]::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="club"][data-full]:hover::before { content: "Club"; }
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="college"]::before,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="college"][data-full]:hover::before { content: "College"; }
    html[data-ui="modern"] #playersTable tr.m-open td.sessions-cell::before {
        content: "NTDP sessions";
        display: inline;
        margin: 0;
    }

    /* Keep blank stats' columns so the three line up */
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="position"]:empty,
    html[data-ui="modern"] #playersTable tr.m-open td[data-field="region"]:empty {
        visibility: hidden;
    }

    /* While editing inline, the row isn't a tap target */
    html[data-ui="modern"] #playersTable tbody tr.editing-row {
        cursor: default;
    }

    /* ---- Searching: every row is a separate full card ---- */
    html[data-ui="modern"] #playersTable.m-search tbody {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    html[data-ui="modern"] #playersTable.m-search tbody tr.m-open,
    html[data-ui="modern"] #playersTable.m-search tbody tr.m-open:nth-child(odd),
    html[data-ui="modern"] #playersTable.m-search tbody tr.m-open:nth-child(even),
    html[data-ui="modern"][data-theme="dark"] #playersTable.m-search tbody tr.m-open:nth-child(even) {
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        border-radius: var(--m-radius-lg);
        box-shadow: var(--m-shadow-sm);
        cursor: default;
        animation: none;
    }

    html[data-ui="modern"] #playersTable.m-search tbody tr.m-open::before {
        display: none;
    }

    html[data-ui="modern"] #playersTable.m-search td.loading {
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: var(--m-radius-lg);
    }
}

@keyframes m-open-in {
    from { opacity: 0.6; }
    to   { opacity: 1; }
}


/* Division color lookup for dots, swatches and chart segments */
html[data-ui="modern"] .D1, html[data-ui="modern"] .div-D1 { --m-div-color: var(--m-c-D1); }
html[data-ui="modern"] .D2, html[data-ui="modern"] .div-D2 { --m-div-color: var(--m-c-D2); }
html[data-ui="modern"] .D3, html[data-ui="modern"] .div-D3 { --m-div-color: var(--m-c-D3); }
html[data-ui="modern"] .NAIA, html[data-ui="modern"] .div-NAIA { --m-div-color: var(--m-c-NAIA); }
html[data-ui="modern"] .JC, html[data-ui="modern"] .div-JC { --m-div-color: var(--m-c-JC); }
html[data-ui="modern"] .International, html[data-ui="modern"] .div-International { --m-div-color: var(--m-c-International); }

/* ==========================================================================
   Reports (templates/reports_modern.html)
   ========================================================================== */
html[data-ui="modern"] .rp {
    padding-bottom: 24px;
}

html[data-ui="modern"] .rp-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

html[data-ui="modern"] .rp-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--text-primary);
}

html[data-ui="modern"] .rp-sub {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

/* Segmented tabs */
html[data-ui="modern"] .rp-tabs {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--gray-100);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

html[data-ui="modern"] .rp-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s var(--m-ease), color 0.15s var(--m-ease), box-shadow 0.15s var(--m-ease);
}

html[data-ui="modern"] .rp-tab i {
    font-size: 0.82rem;
    opacity: 0.8;
}

html[data-ui="modern"] .rp-tab:hover {
    color: var(--text-primary);
}

html[data-ui="modern"] .rp-tab.active {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--m-shadow-sm), 0 0 0 1px var(--border-color);
}

html[data-ui="modern"] .rp-tab.active i {
    color: var(--primary);
    opacity: 1;
}

/* KPI tiles */
html[data-ui="modern"] .rp-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

html[data-ui="modern"] .rp-kpi {
    min-height: 98px;
    padding: 14px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--m-radius-lg);
    box-shadow: var(--m-shadow-sm);
    min-width: 0;
}

html[data-ui="modern"] .rp-kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

html[data-ui="modern"] .rp-kpi-value {
    margin-top: 4px;
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html[data-ui="modern"] .rp-kpi-value-sm {
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
    padding-top: 8px;
}

html[data-ui="modern"] .rp-kpi-note {
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html[data-ui="modern"] .rp-skel {
    background: linear-gradient(90deg, var(--card-bg) 0%, var(--gray-100) 50%, var(--card-bg) 100%);
    background-size: 200% 100%;
    animation: rp-shimmer 1.2s linear infinite;
}

@keyframes rp-shimmer {
    from { background-position: 100% 0; }
    to   { background-position: -100% 0; }
}

/* Cards */
html[data-ui="modern"] .rp-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--m-radius-lg);
    box-shadow: var(--m-shadow-sm);
    margin-bottom: 16px;
    overflow: clip;
}

html[data-ui="modern"] .rp-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
}

html[data-ui="modern"] .rp-card-head h2 {
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

html[data-ui="modern"] .rp-card-sub {
    margin-top: 2px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

html[data-ui="modern"] .rp-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--m-shadow-sm);
}

html[data-ui="modern"] .rp-btn:hover {
    background: var(--gray-100);
}

html[data-ui="modern"] .rp-btn i {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

html[data-ui="modern"] .rp-loading {
    padding: 48px 18px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

html[data-ui="modern"] .rp-error {
    color: var(--danger);
}

/* Legend */
html[data-ui="modern"] .rp-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 0 18px 12px;
}

html[data-ui="modern"] .rp-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

html[data-ui="modern"] .rp-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--m-div-color, var(--text-secondary));
    flex: 0 0 auto;
}

html[data-ui="modern"] .rp-swatch-track {
    background: var(--gray-200);
}

/* Stacked bars */
html[data-ui="modern"] .rp-bars {
    padding: 4px 18px 16px;
}

html[data-ui="modern"] .rp-bar-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 128px;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
}

html[data-ui="modern"] .rp-bar-year {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    font-size: 0.9rem;
}

html[data-ui="modern"] .rp-bar-track {
    min-width: 0;
}

html[data-ui="modern"] .rp-bar {
    display: flex;
    gap: 2px;              /* surface gap between segments */
    height: 22px;
    min-width: 4px;
}

html[data-ui="modern"] .rp-seg {
    flex-basis: 0;
    min-width: 3px;
    background: var(--m-div-color);
    cursor: default;
    outline: none;
    transition: filter 0.12s var(--m-ease), opacity 0.12s var(--m-ease);
}

html[data-ui="modern"] .rp-seg:first-child {
    border-radius: 4px 0 0 4px;
}

html[data-ui="modern"] .rp-seg:last-child {
    border-radius: 0 4px 4px 0;
}

html[data-ui="modern"] .rp-seg:only-child {
    border-radius: 4px;
}

html[data-ui="modern"] .rp-seg-track {
    background: var(--gray-200);
}

html[data-ui="modern"] .rp-bar:hover .rp-seg {
    opacity: 0.55;
}

html[data-ui="modern"] .rp-bar .rp-seg:hover,
html[data-ui="modern"] .rp-bar .rp-seg:focus-visible {
    opacity: 1;
}

html[data-ui="modern"] .rp-bar-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

html[data-ui="modern"] .rp-bar-meta strong {
    color: var(--text-primary);
    font-weight: 650;
}

/* Tooltip */
html[data-ui="modern"] .rp-tip {
    position: fixed;
    z-index: 3000;
    pointer-events: none;
    max-width: 240px;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--m-tooltip-bg);
    color: var(--card-bg);
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: var(--m-shadow-md);
}

html[data-ui="modern"] .rp-tip strong {
    font-weight: 650;
}

/* Toolbar: search + chips */
html[data-ui="modern"] .rp-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 18px 12px;
}

html[data-ui="modern"] .rp-search {
    position: relative;
    flex: 0 1 280px;
    min-width: 180px;
}

html[data-ui="modern"] .rp-search i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: var(--text-secondary);
    pointer-events: none;
}

html[data-ui="modern"] .rp-search input {
    width: 100%;
    height: 34px;
    padding: 0 10px 0 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.88rem;
}

html[data-ui="modern"] .rp-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--m-ring);
}

html[data-ui="modern"] .rp-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
}

html[data-ui="modern"] .rp-chips::-webkit-scrollbar {
    display: none;
}

html[data-ui="modern"] .rp-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

html[data-ui="modern"] .rp-chip:hover {
    background: var(--gray-100);
}

html[data-ui="modern"] .rp-chip.active {
    background: var(--m-accent-soft);
    border-color: var(--primary);
    color: var(--m-accent-text);
}

/* Tables */
html[data-ui="modern"] .rp-table-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--border-color);
}

html[data-ui="modern"] .rp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
}

html[data-ui="modern"] .rp-table th,
html[data-ui="modern"] .rp-table td {
    padding: 9px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

html[data-ui="modern"] .rp-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

html[data-ui="modern"] .rp-table thead th {
    background: var(--table-header-bg);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
}

html[data-ui="modern"] .rp-table thead th:hover,
html[data-ui="modern"] .rp-table thead th.sorted {
    color: var(--text-primary);
}

html[data-ui="modern"] .rp-table thead th i {
    font-size: 0.65rem;
    margin-left: 3px;
    opacity: 0.35;
}

html[data-ui="modern"] .rp-table thead th.sorted i {
    opacity: 1;
    color: var(--primary);
}

/* First column stays put while scrolling sideways */
html[data-ui="modern"] .rp-table th:first-child,
html[data-ui="modern"] .rp-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--card-bg);
    font-weight: 600;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: inset -1px 0 0 var(--border-color);
}

html[data-ui="modern"] .rp-table thead th:first-child {
    background: var(--table-header-bg);
    z-index: 2;
}

html[data-ui="modern"] .rp-table tbody tr:hover td {
    background-color: var(--table-row-hover);
}

html[data-ui="modern"] .rp-table tbody tr:hover td.heat {
    background-color: color-mix(in srgb, var(--primary) calc(var(--heat) * 100%), var(--table-row-hover));
}

html[data-ui="modern"] .rp-table td.heat {
    background-color: color-mix(in srgb, var(--primary) calc(var(--heat) * 100%), var(--card-bg));
    font-weight: 600;
}

html[data-ui="modern"] .rp-table .rp-zero {
    /* fade the dash with color, not opacity, so the row line stays solid */
    color: color-mix(in srgb, var(--text-secondary) 45%, transparent);
}

html[data-ui="modern"] .rp-table tfoot td {
    background: var(--m-surface-2);
    font-weight: 700;
    border-bottom: none;
    border-top: 1px solid var(--m-border-strong);
}

html[data-ui="modern"] .rp-table tfoot td:first-child {
    background: var(--m-surface-2);
}

html[data-ui="modern"] .rp-table td.rp-empty {
    padding: 36px 12px;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 400;
    position: static;
    box-shadow: none;
}

html[data-ui="modern"] .rp-table .division-badge {
    font-size: 0.68rem;
}

/* Commit-rate meter inside the table */
html[data-ui="modern"] .rp-rate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

html[data-ui="modern"] .rp-rate-bar {
    width: 64px;
    height: 6px;
    border-radius: 999px;
    background: var(--gray-200);
    overflow: hidden;
}

html[data-ui="modern"] .rp-rate-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

@media (max-width: 900px) {
    html[data-ui="modern"] .rp-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    html[data-ui="modern"] .rp-head {
        align-items: stretch;
    }

    html[data-ui="modern"] .rp-title {
        font-size: 1.35rem;
    }

    html[data-ui="modern"] .rp-tabs {
        display: flex;
        width: 100%;
    }

    html[data-ui="modern"] .rp-tab {
        flex: 1 1 0;
        justify-content: center;
        padding: 0 8px;
    }

    html[data-ui="modern"] .rp-kpis {
        gap: 8px;
    }

    html[data-ui="modern"] .rp-kpi {
        min-height: 0;
        padding: 12px;
    }

    html[data-ui="modern"] .rp-kpi-value {
        font-size: 1.5rem;
    }

    html[data-ui="modern"] .rp-kpi-value-sm {
        font-size: 0.98rem;
        padding-top: 6px;
    }

    html[data-ui="modern"] .rp-card-head,
    html[data-ui="modern"] .rp-legend,
    html[data-ui="modern"] .rp-toolbar,
    html[data-ui="modern"] .rp-bars {
        padding-left: 14px;
        padding-right: 14px;
    }

    /* Bar rows: year + numbers on one line, the bar full width below */
    html[data-ui="modern"] .rp-bar-row {
        grid-template-columns: auto 1fr;
        grid-template-areas: "year meta" "bar bar";
        gap: 4px 10px;
        padding: 7px 0;
    }

    html[data-ui="modern"] .rp-bar-year  { grid-area: year; }
    html[data-ui="modern"] .rp-bar-meta  { grid-area: meta; text-align: right; }
    html[data-ui="modern"] .rp-bar-track { grid-area: bar; }

    html[data-ui="modern"] .rp-search {
        flex: 1 1 100%;
    }

    html[data-ui="modern"] .rp-table th:first-child,
    html[data-ui="modern"] .rp-table td:first-child {
        max-width: 150px;
    }
}

/* ==========================================================================
   Admin dashboard (new look): compact tiles, the whole tile is the link.
   Note: class prefix is "dash-", not "ad-". Safari/browser ad blockers hide
   anything named .ad / .ad-* and the dashboard came up blank.
   ========================================================================== */
html[data-ui="modern"] .dash {
    max-width: 1100px;
    padding-top: 4px;
}

html[data-ui="modern"] .dash-head {
    margin-bottom: 18px;
}

html[data-ui="modern"] .dash-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--text-primary);
}

html[data-ui="modern"] .dash-sub {
    margin-top: 2px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

html[data-ui="modern"] .dash-section + .dash-section {
    margin-top: 20px;
}

html[data-ui="modern"] .dash-section-title {
    margin: 0 0 8px 2px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

html[data-ui="modern"] .dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 8px;
}

html[data-ui="modern"] .dash-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 12px 10px 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--m-shadow-sm);
    color: var(--text-primary);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s var(--m-ease), background-color 0.15s var(--m-ease), box-shadow 0.15s var(--m-ease);
}

html[data-ui="modern"] .dash-tile:hover {
    border-color: var(--m-border-strong);
    box-shadow: var(--m-shadow-md);
}

html[data-ui="modern"] .dash-tile:active {
    background: var(--table-row-hover);
}

html[data-ui="modern"] .dash-icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--m-accent-soft);
    color: var(--primary);
    font-size: 0.95rem;
    transition: background-color 0.15s var(--m-ease), color 0.15s var(--m-ease);
}

html[data-ui="modern"] .dash-tile:hover .dash-icon {
    background: var(--primary);
    color: #ffffff;
}

html[data-ui="modern"] .dash-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

html[data-ui="modern"] .dash-name {
    font-size: 0.93rem;
    font-weight: 600;
    line-height: 1.3;
}

html[data-ui="modern"] .dash-desc {
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html[data-ui="modern"] .dash-chevron {
    flex: 0 0 auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    transition: transform 0.15s var(--m-ease), opacity 0.15s var(--m-ease);
}

html[data-ui="modern"] .dash-tile:hover .dash-chevron {
    opacity: 1;
    transform: translateX(2px);
}

/* Suggestions waiting: count pill + highlighted tile */
html[data-ui="modern"] .dash-count {
    flex: 0 0 auto;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

html[data-ui="modern"] .dash-tile.has-pending {
    border-color: color-mix(in srgb, var(--danger) 55%, var(--border-color));
    background: color-mix(in srgb, var(--danger) 5%, var(--card-bg));
}

html[data-ui="modern"] .dash-tile.has-pending .dash-icon {
    background: color-mix(in srgb, var(--danger) 14%, transparent);
    color: var(--danger);
}

html[data-ui="modern"] .dash-tile.has-pending .dash-desc {
    color: var(--danger);
    font-weight: 600;
}

/* Phones: a tight grouped list */
@media (max-width: 640px) {
    html[data-ui="modern"] .dash-title {
        font-size: 1.35rem;
    }

    html[data-ui="modern"] .dash-grid {
        grid-template-columns: 1fr;
        gap: 0;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: var(--m-shadow-sm);
        overflow: clip;
    }

    html[data-ui="modern"] .dash-tile {
        min-height: 56px;
        padding: 9px 14px 9px 12px;
        border: none;
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid var(--border-color);
    }

    html[data-ui="modern"] .dash-tile:last-child {
        border-bottom: none;
    }

    html[data-ui="modern"] .dash-tile:hover {
        box-shadow: none;
    }

    html[data-ui="modern"] .dash-icon {
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 0.88rem;
    }

    html[data-ui="modern"] .dash-tile.has-pending {
        order: -1;
    }
}

/* ==========================================================================
   Admin tables on phones (new look)
   ========================================================================== */
@media (max-width: 768px) {
    /* The desktop wrapper clips to keep its rounded corners; on phones it
       must scroll instead, or wide tables get cut off */
    html[data-ui="modern"] .admin-container .table-wrapper {
        overflow-x: auto;
    }
}

@media (max-width: 640px) {
    /* ---- Tables marked data-mobile-cards: one card per row ---- */
    html[data-ui="modern"] .admin-container .table-wrapper:has(> table[data-mobile-cards]) {
        overflow: visible;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    html[data-ui="modern"] table[data-mobile-cards],
    html[data-ui="modern"] table[data-mobile-cards] tbody {
        display: block;
        width: 100%;
        max-width: none;
        overflow: visible;
    }

    html[data-ui="modern"] table[data-mobile-cards] thead {
        display: none;
    }

    html[data-ui="modern"] table[data-mobile-cards] tbody tr,
    html[data-ui="modern"] table[data-mobile-cards] tbody tr:nth-child(odd),
    html[data-ui="modern"] table[data-mobile-cards] tbody tr:nth-child(even),
    html[data-ui="modern"][data-theme="dark"] table[data-mobile-cards] tbody tr:nth-child(even) {
        display: flex;
        flex-direction: column;
        gap: 2px;
        margin-bottom: 8px;
        padding: 12px 14px;
        background: var(--card-bg) !important;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        box-shadow: var(--m-shadow-sm);
        color: var(--text-primary) !important;
    }

    html[data-ui="modern"] table[data-mobile-cards] tbody tr:hover td {
        color: var(--text-primary) !important;
    }

    html[data-ui="modern"] table[data-mobile-cards] td {
        display: flex;
        align-items: baseline;
        gap: 10px;
        padding: 3px 0 !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        white-space: normal !important;
        overflow: visible;
        text-overflow: clip;
        text-align: left !important;
        font-size: 0.88rem !important;
        overflow-wrap: anywhere;
    }

    html[data-ui="modern"] table[data-mobile-cards] td::before {
        content: attr(data-label);
        flex: 0 0 32%;
        max-width: 120px;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--text-secondary);
        line-height: 1.6;
    }

    html[data-ui="modern"] table[data-mobile-cards] td[data-label=""]::before {
        display: none;
    }

    /* Title cell first, bigger, no label */
    html[data-ui="modern"] table[data-mobile-cards] td.m-title {
        order: -1;
        display: block;
        padding: 0 0 6px !important;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--border-color) !important;
        font-size: 0.98rem !important;
        font-weight: 600;
    }

    html[data-ui="modern"] table[data-mobile-cards] td.m-title::before {
        display: none;
    }

    /* Actions at the bottom, full width */
    html[data-ui="modern"] table[data-mobile-cards] td.m-actions {
        order: 99;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        margin-top: 6px;
        padding-top: 10px !important;
        border-top: 1px solid var(--border-color) !important;
    }

    html[data-ui="modern"] table[data-mobile-cards] td.m-actions::before {
        display: none;
    }

    html[data-ui="modern"] table[data-mobile-cards] td.m-actions > * {
        margin: 0 !important;
    }

    /* Empty-state / colspan rows */
    html[data-ui="modern"] table[data-mobile-cards] td.m-wide {
        display: block;
        text-align: center !important;
        padding: 24px 0 !important;
    }

    html[data-ui="modern"] table[data-mobile-cards] td:empty {
        display: none;
    }
}
