/* =====================================================================
   IPTV Ops — visual system
   ===================================================================== */

:root {
    /* Ink & surfaces */
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;
    --surface: #f4f6fb;
    --card: #ffffff;
    --border: #e6eaf2;
    --border-strong: #d6dce8;
    --hover: #f6f8fc;

    /* Brand */
    --navy-1: #0b1a33;
    --navy-2: #173a6a;
    --primary: #2a78d6;
    --primary-600: #1f63b8;
    --primary-50: #ebf3fd;
    --accent: #eb6834;

    /* Chart series (validated pair) */
    --series-1: #2a78d6;
    --series-2: #eb6834;

    /* Status (always paired with icon or text) */
    --good: #0ca30c;
    --warning: #fab219;
    --critical: #d03b3b;

    /* Aliases used in page markup */
    --text-primary: var(--ink);
    --text-secondary: var(--ink-2);
    --text-muted: var(--muted);
    --brand: var(--navy-2);
    --brand-light: var(--primary-50);

    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
    --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .18);

    --tabbar-h: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Bootstrap hooks */
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--surface);
    --bs-border-color: var(--border);
    --bs-primary: #2a78d6;
    --bs-primary-rgb: 42, 120, 214;
    --bs-link-color: var(--primary-600);
    --bs-link-color-rgb: 31, 99, 184;
    --bs-link-hover-color: var(--navy-2);
    --bs-border-radius: 10px;
    --bs-border-radius-sm: 8px;
    --bs-border-radius-lg: 14px;
}

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

body {
    background: var(--surface);
    font-family: var(--bs-body-font-family);
    font-size: .9rem;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4, h5, h6, .h4, .h5, .h6 {
    font-weight: 650;
    letter-spacing: -.015em;
    color: var(--ink);
}

a {
    text-decoration: none;
}

.mono {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .8rem;
    letter-spacing: -.01em;
    color: var(--ink-2);
}

.text-muted {
    color: var(--muted) !important;
}

.tnum {
    font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */

.btn {
    font-weight: 550;
    border-radius: var(--radius-sm);
    padding: .5rem .95rem;
    transition: background-color .15s, border-color .15s, box-shadow .15s, transform .05s;
}

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

.btn-sm {
    padding: .3rem .7rem;
    font-size: .8rem;
    border-radius: 8px;
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-600);
    --bs-btn-hover-border-color: var(--primary-600);
    --bs-btn-active-bg: var(--primary-600);
    --bs-btn-active-border-color: var(--primary-600);
    --bs-btn-disabled-bg: #9ec5f4;
    --bs-btn-disabled-border-color: #9ec5f4;
    box-shadow: 0 1px 2px rgba(31, 99, 184, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.btn-success {
    --bs-btn-bg: #12925a;
    --bs-btn-border-color: #12925a;
    --bs-btn-hover-bg: #0e7a4b;
    --bs-btn-hover-border-color: #0e7a4b;
    --bs-btn-active-bg: #0e7a4b;
    box-shadow: 0 1px 2px rgba(14, 122, 75, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.btn-danger {
    --bs-btn-bg: #c8322f;
    --bs-btn-border-color: #c8322f;
    --bs-btn-hover-bg: #a92724;
    --bs-btn-hover-border-color: #a92724;
}

.btn-light,
.btn-outline-secondary {
    --bs-btn-bg: var(--card);
    --bs-btn-color: var(--ink-2);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-bg: var(--hover);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-bg: #eef2f8;
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary-600);
    --bs-btn-border-color: #c6dbf5;
    --bs-btn-bg: var(--card);
    --bs-btn-hover-bg: var(--primary-50);
    --bs-btn-hover-color: var(--primary-600);
    --bs-btn-hover-border-color: #9ec5f4;
    --bs-btn-active-bg: #dceafb;
    --bs-btn-active-color: var(--primary-600);
}

.btn-outline-success {
    --bs-btn-color: #0e7a4b;
    --bs-btn-border-color: #bfe6d1;
    --bs-btn-bg: var(--card);
    --bs-btn-hover-bg: #eaf7f0;
    --bs-btn-hover-color: #0e7a4b;
    --bs-btn-hover-border-color: #8fd3ae;
    --bs-btn-active-bg: #d9f0e4;
    --bs-btn-active-color: #0e7a4b;
}

.btn-outline-warning {
    --bs-btn-color: #8a5a00;
    --bs-btn-border-color: #f6dc9c;
    --bs-btn-bg: var(--card);
    --bs-btn-hover-bg: #fff6df;
    --bs-btn-hover-color: #8a5a00;
    --bs-btn-hover-border-color: #f0c65d;
    --bs-btn-active-bg: #ffefc4;
    --bs-btn-active-color: #8a5a00;
}

.btn-outline-danger {
    --bs-btn-color: #b42318;
    --bs-btn-border-color: #f5c8c4;
    --bs-btn-bg: var(--card);
    --bs-btn-hover-bg: #fdeeed;
    --bs-btn-hover-color: #b42318;
    --bs-btn-hover-border-color: #ee9d96;
    --bs-btn-active-bg: #fbdedb;
    --bs-btn-active-color: #b42318;
}

.btn-link {
    font-weight: 550;
    color: var(--primary-600);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Forms ---------- */

.form-control,
.form-select {
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}

.form-select {
    padding-right: 2.25rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(42, 120, 214, .14);
}

.form-label {
    font-weight: 550;
    color: var(--ink-2);
    font-size: .8rem;
    margin-bottom: .3rem;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* =====================================================================
   Shell
   ===================================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: linear-gradient(135deg, var(--navy-1) 0%, var(--navy-2) 100%);
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: 0 6px 20px -10px rgba(11, 26, 51, .6);
}

.topbar .bar {
    max-width: 1600px;
    margin: 0 auto;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 16px;
}

@media (min-width: 992px) {
    .topbar .bar {
        padding: 0 32px;
        min-height: 64px;
    }
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: -.01em;
    font-size: 1rem;
    white-space: nowrap;
}

.brand:hover {
    color: #fff;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b8ef0 0%, #2a78d6 55%, #1f63b8 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .18) inset, 0 4px 12px rgba(42, 120, 214, .45);
    color: #fff;
    font-size: .95rem;
    position: relative;
}

.brand-mark::after {
    content: "";
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--navy-1);
}

.topnav {
    display: flex;
    gap: .25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.topnav a {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .45rem .8rem;
    border-radius: 9px;
    color: rgba(255, 255, 255, .72);
    font-weight: 550;
    font-size: .875rem;
    transition: background-color .15s, color .15s;
}

.topnav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.topnav a.active {
    color: #fff;
    background: rgba(255, 255, 255, .14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}

.page-title {
    color: #fff;
    font-weight: 650;
    font-size: 1.1rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.page-title a {
    color: #fff;
    width: 32px;
    height: 32px;
    margin-left: -8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: rgba(255, 255, 255, .85);
    font-size: .8rem;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f08a5d, var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .2);
    text-transform: uppercase;
}

.btn-ghost-light {
    color: rgba(255, 255, 255, .8);
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 9px;
}

.btn-ghost-light:hover,
.btn-ghost-light:focus {
    color: #fff;
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .2);
}

/* Bottom tab bar: phones and tablets */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    padding: 6px 8px calc(6px + var(--safe-bottom));
    background: rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid rgba(15, 23, 42, .06);
}

.tabbar a {
    flex: 1 1 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 600;
    position: relative;
    border-radius: 12px;
}

.tabbar a .tab-ico {
    width: 48px;
    height: 28px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background-color .2s, color .2s;
}

.tabbar a.active {
    color: var(--navy-2);
}

.tabbar a.active .tab-ico {
    background: var(--primary-50);
    color: var(--primary-600);
}

.tab-badge {
    position: absolute;
    top: 2px;
    left: calc(50% + 8px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--critical);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

.topnav .tab-badge {
    position: static;
    box-shadow: none;
    margin-left: .1rem;
}

@media (max-width: 991.98px) {
    body.has-tabbar {
        padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
    }
}

@media (min-width: 992px) {
    .tabbar {
        display: none;
    }
}

main.app-main {
    padding: 16px;
    max-width: 1600px;
    margin: 0 auto;
}

@media (min-width: 992px) {
    main.app-main {
        padding: 28px 32px 48px;
    }
}

/* Page heading inside main */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem 1rem;
    margin-bottom: 1.25rem;
}

.page-head h2 {
    font-size: 1.5rem;
    margin: 0;
}

.page-head .sub {
    color: var(--muted);
    margin-top: .2rem;
}

@media (max-width: 991.98px) {
    .page-head {
        margin-bottom: 1rem;
    }

    .page-head h2 {
        font-size: 1.25rem;
    }
}

/* =====================================================================
   Cards
   ===================================================================== */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--card);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: 1rem 1.15rem;
    font-weight: 650;
    font-size: .95rem;
    color: var(--ink);
}

.card-header > span > i.bi:first-child,
.card-header > div > span > i.bi:first-child,
.card-title-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary-50);
    color: var(--primary-600);
    font-size: .9rem;
    margin-right: .55rem !important;
    vertical-align: middle;
}

.card-body {
    padding: 1.15rem;
}

/* KPI tiles */
.stat-card {
    position: relative;
    overflow: hidden;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.stat-card .card-body {
    padding: 1rem 1.1rem;
}

a.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

a.stat-card:active {
    transform: scale(.985);
}

.stat-card .stat-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
}

.stat-card .stat-label {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .01em;
}

.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.1;
    margin-top: .35rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.stat-card .stat-sub {
    color: var(--muted);
    font-size: .76rem;
    margin-top: .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-ico {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.tone-blue .stat-ico { background: #ebf3fd; color: #1f63b8; }
.tone-orange .stat-ico { background: #fdf0ea; color: #c2491b; }
.tone-green .stat-ico { background: #e8f6ee; color: #0e7a4b; }
.tone-violet .stat-ico { background: #f0edfc; color: #5b45d0; }
.tone-amber .stat-ico { background: #fff5dc; color: #9a6400; }
.tone-red .stat-ico { background: #fdecec; color: #b42318; }
.tone-slate .stat-ico { background: #eef1f6; color: #475569; }

.stat-card.attention::before,
.stat-card.danger::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--warning);
}

.stat-card.danger::before {
    background: var(--critical);
}

@media (max-width: 575.98px) {
    .stat-card .stat-value {
        font-size: 1.6rem;
    }

    .stat-card .card-body {
        padding: .85rem .9rem;
    }

    .stat-ico {
        width: 30px;
        height: 30px;
        font-size: .9rem;
    }
}

/* =====================================================================
   Badges (soft pills — the text always carries the meaning)
   ===================================================================== */

.pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .22rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    border: 1px solid transparent;
}

.pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.pill-good { background: #e8f6ee; color: #0e7a4b; border-color: #cdebd9; }
.pill-warn { background: #fff5dc; color: #8a5a00; border-color: #f8e3a9; }
.pill-bad { background: #fdecec; color: #b42318; border-color: #f7d0cd; }
.pill-info { background: #ebf3fd; color: #1c5cab; border-color: #d3e5fa; }
.pill-manual { background: #f0edfc; color: #4c37c0; border-color: #dfd9f8; }
.pill-neutral { background: #eef1f6; color: #475569; border-color: #e1e6ee; }
.pill-dark { background: #e9ebef; color: #374151; border-color: #dcdfe5; }

.pill.pulse .dot {
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 .55rem;
    border-radius: 8px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: .9rem;
}

.count-good { background: #e8f6ee; color: #0e7a4b; }
.count-warn { background: #fff5dc; color: #8a5a00; }
.count-bad { background: #fdecec; color: #b42318; }

/* Calendar-style chip for a renewal date: day on top, month under it. */
.date-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eaf2fc;
    color: #1f63b8;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.1;
}
.date-chip b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.date-chip.soon { background: #fff5dc; color: #8a5a00; }
.date-chip.late { background: #fdecec; color: #b42318; }

.period {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-left: .5rem;
    font-size: .85rem;
    color: var(--muted);
    white-space: nowrap;
}

.badge {
    font-weight: 600;
    border-radius: 999px;
    padding: .3em .65em;
}

/* =====================================================================
   Filter chips & segmented control
   ===================================================================== */

.chips {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px;
    margin: -2px;
}

.chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex: 0 0 auto;
    border: 1px solid var(--border-strong);
    background: var(--card);
    color: var(--ink-2);
    border-radius: 999px;
    padding: .38rem .9rem;
    font-size: .82rem;
    font-weight: 600;
    min-height: 36px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: background-color .15s, color .15s, border-color .15s;
}

.chip:hover {
    border-color: var(--faint);
}

.chip.active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.chip .count:not(:empty) {
    display: inline-block;
    margin-left: .4rem;
    padding: 0 .4rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, .08);
    font-size: .72rem;
}

.chip.active .count:not(:empty) {
    background: rgba(255, 255, 255, .2);
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 11px;
    background: #e9edf4;
    gap: 2px;
}

.segmented .chip {
    border: 0;
    box-shadow: none;
    background: transparent;
    min-height: 32px;
    border-radius: 8px;
    color: var(--muted);
}

.segmented .chip.active {
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

/* =====================================================================
   Tables
   ===================================================================== */

.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--hover);
    --bs-table-color: var(--ink);
    margin-bottom: 0;
}

.table > thead th,
table.dataTable > thead > tr > th {
    font-size: .7rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border) !important;
    padding-top: .65rem;
    padding-bottom: .65rem;
    white-space: nowrap;
}

.table > tbody td {
    border-color: #eef1f6;
    padding-top: .75rem;
    padding-bottom: .75rem;
}

table.dataTable td {
    vertical-align: middle;
}

table.dataTable td a {
    font-weight: 600;
}

.dt-container .dt-layout-table {
    overflow-x: auto;
}

.dt-container .dt-search input {
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    padding: .5rem .8rem .5rem 2.2rem;
    min-width: 260px;
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10'/%3E%3C/svg%3E") no-repeat .75rem center;
    box-shadow: var(--shadow-sm);
}

.dt-container .dt-search input:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(42, 120, 214, .14);
}

.dt-container .dt-length select {
    border-radius: 8px;
}

.dt-container .dt-info {
    color: var(--muted);
    font-size: .8rem;
}

.dt-container .pagination {
    gap: 4px;
}

.dt-container .page-link {
    border-radius: 8px !important;
    border-color: var(--border);
    color: var(--ink-2);
    min-width: 34px;
    text-align: center;
    font-weight: 550;
}

.dt-container .active > .page-link {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.table-actions .btn {
    padding: .28rem .6rem;
    font-size: .78rem;
}

.error-cell {
    max-width: 320px;
    white-space: normal;
    font-size: .8rem;
    color: var(--ink-2);
}

/* Phones: every data table becomes a stack of cards */
@media (max-width: 767.98px) {
    table.table-cards,
    table.table-cards tbody,
    table.table-cards tr,
    table.table-cards td {
        display: block;
        width: 100% !important;
    }

    table.table-cards thead {
        display: none;
    }

    table.table-cards {
        border: 0;
        margin: 0 !important;
    }

    table.table-cards tbody tr {
        background: var(--card) !important;
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: .7rem .95rem;
        margin-bottom: .7rem;
        box-shadow: var(--shadow-sm);
    }

    table.table-cards tbody tr:hover > * {
        --bs-table-bg-state: transparent;
    }

    table.table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        border: 0 !important;
        padding: .32rem 0 !important;
        text-align: right !important;
        min-height: 30px;
        box-shadow: none !important;
        background: transparent !important;
    }

    table.table-cards td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted);
        font-size: .72rem;
        font-weight: 600;
        text-align: left;
    }

    table.table-cards td > .cell-v {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    table.table-cards td:first-child {
        font-size: .98rem;
        font-weight: 650;
        justify-content: flex-start;
        text-align: left !important;
        padding-bottom: .55rem !important;
        border-bottom: 1px solid var(--border) !important;
        margin-bottom: .3rem;
    }

    table.table-cards td:first-child::before,
    table.table-cards td.no-label::before,
    table.table-cards td:empty {
        display: none;
    }

    table.table-cards td.cell-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: stretch;
        gap: .5rem;
        padding-top: .7rem !important;
        margin-top: .3rem;
        border-top: 1px solid var(--border) !important;
    }

    table.table-cards td.cell-actions::before,
    table.table-cards td.cell-actions br {
        display: none;
    }

    table.table-cards td.cell-actions .btn {
        flex: 1 1 calc(50% - .5rem);
        min-height: 42px;
        font-size: .85rem;
    }

    table.table-cards td.error-cell {
        max-width: none;
        flex-direction: column;
        align-items: stretch;
        text-align: left !important;
        gap: .2rem;
    }

    table.table-cards td.error-cell > .cell-v {
        text-align: left;
    }

    table.table-cards td.dt-empty {
        justify-content: center;
        color: var(--muted);
        padding: 1.5rem 0 !important;
        border: 0 !important;
    }

    table.table-cards td.dt-empty::before {
        display: none;
    }

    .dt-container .dt-layout-row:first-child {
        margin-top: 0;
    }

    .dt-container .dt-length {
        display: none;
    }

    .dt-container .dt-search {
        width: 100%;
    }

    .dt-container .dt-search input {
        width: 100% !important;
        min-width: 0;
        margin-left: 0 !important;
    }

    .card-body.table-host {
        padding: .8rem;
        background: var(--surface);
        border-radius: 0 0 var(--radius) var(--radius);
    }
}

/* =====================================================================
   Touch ergonomics
   ===================================================================== */

@media (max-width: 991.98px) {
    /* 16px stops iOS zooming into focused inputs */
    .form-control,
    .form-select,
    .dt-search input,
    .swal2-input,
    .swal2-textarea,
    .swal2-select {
        font-size: 16px !important;
    }

    .btn {
        min-height: 42px;
    }

    .btn-sm {
        min-height: 36px;
    }
}

/* =====================================================================
   Dialogs (SweetAlert2) — buttons are Bootstrap buttons via Swal.mixin
   ===================================================================== */

.swal2-popup {
    border-radius: 20px !important;
    padding: 1.5rem 1.4rem 1.3rem !important;
    font-family: var(--bs-body-font-family) !important;
    box-shadow: var(--shadow-lg) !important;
}

.swal2-popup:not(.swal2-toast) .swal2-title {
    font-size: 1.2rem !important;
    font-weight: 700 !important;
    color: var(--ink) !important;
    letter-spacing: -.015em;
    padding: .25rem 0 0 !important;
}

.swal2-html-container {
    color: var(--ink-2) !important;
    font-size: .9rem !important;
    line-height: 1.55 !important;
}

.swal2-popup .form-label {
    display: block;
    text-align: left;
}

.swal2-popup .form-control,
.swal2-popup .form-select {
    margin-bottom: .85rem;
    font-size: .9rem;
}

.swal2-actions {
    gap: .5rem;
    margin-top: 1.25rem !important;
}

.swal2-actions .btn {
    min-width: 120px;
    min-height: 44px;
}

.swal2-validation-message {
    background: #fdecec !important;
    color: #b42318 !important;
    border-radius: 10px;
    font-size: .85rem !important;
    margin: .75rem 0 0 !important;
}

.swal2-icon {
    transform: scale(.8);
    margin: .5rem auto 0 !important;
}

.swal2-container.swal2-backdrop-show {
    background: rgba(15, 23, 42, .45) !important;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.swal2-popup.swal2-toast {
    border-radius: 14px !important;
    padding: .65rem 1rem !important;
    box-shadow: var(--shadow-md) !important;
    border: 1px solid var(--border);
}

.swal2-popup.swal2-toast .swal2-title {
    font-size: .88rem !important;
    font-weight: 600 !important;
    color: var(--ink) !important;
}

/* Phones: dialogs become bottom sheets (SweetAlert2 lays its container out as a grid) */
@media (max-width: 575.98px) {
    .swal2-container.swal2-center {
        padding: 0 !important;
    }

    .swal2-container.swal2-center > .swal2-popup:not(.swal2-toast) {
        grid-column: 1 / -1;
        grid-row: 1 / -1;
        align-self: end;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 22px 22px 0 0 !important;
        padding: 1.6rem 1.1rem calc(1.1rem + var(--safe-bottom)) !important;
        max-height: 92vh;
        overflow-y: auto;
    }

    .swal2-container.swal2-center > .swal2-popup:not(.swal2-toast)::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: 2px;
        background: var(--border-strong);
    }

    .swal2-popup .swal2-actions {
        width: 100%;
        flex-wrap: nowrap;
    }

    .swal2-popup .swal2-actions .btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 48px;
    }

    .swal2-popup .swal2-html-container {
        margin: .85rem 0 0 !important;
        text-align: left;
    }

    .swal2-container.swal2-top-end {
        padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 0 !important;
    }
}

/* =====================================================================
   Dashboard
   ===================================================================== */

.hello {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
}

.hello-sub {
    color: var(--muted);
    margin-top: .15rem;
}

@media (max-width: 991.98px) {
    .hello {
        font-size: 1.25rem;
    }
}

.chart-box {
    position: relative;
    height: 240px;
}

@media (min-width: 768px) {
    .chart-box {
        height: 300px;
    }
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.75rem;
    font-size: .8rem;
    color: var(--muted);
}

.legend > span {
    display: inline-flex;
    flex-direction: column;
    gap: .15rem;
}

.legend .key {
    display: inline-block;
    width: 14px;
    height: 0;
    border-top: 2px solid currentColor;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: .45rem;
}

.legend b {
    color: var(--ink);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.meter {
    height: 6px;
    border-radius: 3px;
    background: #edf0f5;
    overflow: hidden;
}

.meter > span {
    display: block;
    height: 100%;
    border-radius: 3px;
}

.list-tap {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .8rem 1.15rem;
    color: inherit;
    border-bottom: 1px solid #eef1f6;
    min-height: 60px;
    transition: background-color .12s;
}

.list-tap:last-child {
    border-bottom: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}

a.list-tap:hover,
a.list-tap:active {
    background: var(--hover);
    color: inherit;
}

.list-tap .grow {
    flex: 1 1 auto;
    min-width: 0;
}

.list-tap .truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-tap .chev {
    color: var(--faint);
}

.attention-banner {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    background: linear-gradient(90deg, #fff8e6 0%, #fffaf0 100%);
    border: 1px solid #f8e3a9;
    color: #6b4a00;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s;
}

.attention-banner:hover {
    color: #6b4a00;
    box-shadow: var(--shadow-md);
}

.attention-banner .lead-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fde9b3;
    color: #9a6400;
    font-size: 1.1rem;
}

.feed-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-50);
    color: var(--primary-600);
    flex: 0 0 34px;
}

.feed-icon.f-good { background: #e8f6ee; color: #0e7a4b; }
.feed-icon.f-warn { background: #fff5dc; color: #9a6400; }
.feed-icon.f-bad { background: #fdecec; color: #b42318; }
.feed-icon.f-money { background: #fdf0ea; color: #c2491b; }

.vendor-ico {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    flex: 0 0 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: #fff;
    background: linear-gradient(135deg, #475569, #1e293b);
}

.empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
}

.empty i {
    display: block;
    font-size: 1.6rem;
    color: var(--faint);
    margin-bottom: .4rem;
}

/* =====================================================================
   Client detail
   ===================================================================== */

.profile {
    display: flex;
    align-items: center;
    gap: .9rem;
    min-width: 0;
}

.profile .avatar-lg {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #3b8ef0, #1f63b8);
    box-shadow: 0 6px 16px -6px rgba(31, 99, 184, .6);
    text-transform: uppercase;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}

@media (min-width: 768px) {
    .action-grid {
        display: flex;
        flex-wrap: wrap;
    }
}

.cycle-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: .9rem;
    background: var(--card);
}

.cycle-card:last-child {
    margin-bottom: 0;
}

.cycle-card.open {
    border-color: #c6dbf5;
    background: linear-gradient(180deg, #f5f9ff 0%, #fff 70%);
    box-shadow: 0 0 0 3px rgba(42, 120, 214, .06);
}

.cycle-card table.table-cards tbody tr {
    box-shadow: none;
}

details > summary {
    cursor: pointer;
    font-weight: 550;
    color: var(--primary-600);
}

/* =====================================================================
   Sign-in
   ===================================================================== */

.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px calc(24px + var(--safe-bottom));
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(59, 142, 240, .35), transparent 60%),
        radial-gradient(700px 500px at 110% 110%, rgba(235, 104, 52, .25), transparent 60%),
        linear-gradient(160deg, var(--navy-1) 0%, var(--navy-2) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, .97);
    border-radius: 24px;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
    padding: 2rem 1.75rem 1.75rem;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-brand .brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    font-size: 1.45rem;
}

.auth-brand .brand-mark::after {
    width: 14px;
    height: 14px;
    box-shadow: 0 0 0 3px #fff;
}

.auth-brand h1 {
    font-size: 1.35rem;
    margin: 0;
}

.auth-brand p {
    color: var(--muted);
    margin: 0;
}

.auth-card .btn-primary {
    min-height: 48px;
    font-size: .95rem;
}

.auth-foot {
    color: rgba(255, 255, 255, .55);
    font-size: .78rem;
    text-align: center;
    margin-top: 1.25rem;
}
