/* =====================================================================================
   assets/css/theme.css — the ISPBILLING look for every page
   Loaded after style.css. Same class names and CSS variables the pages already use
   (--primary, --surface, --text-main, .card, .btn, .table, .badge, .form-control ...),
   restyled: zinc greys, sky-blue brand, flat white cards, Inter / Hind Siliguri.
   Light by default (or the phone/PC setting); dark via html[data-theme="dark"].
   The brand colour is only the --brand-* scale below (+ the rgba() of brand-400/500/600 in a few rings):
   change those to re-colour the whole app.
   ===================================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Hind+Siliguri:wght@400;500;600&display=swap');

:root, :root[data-theme="light"] {
    /* sky */
    --brand-50: #f0f9ff;  --brand-100: #e0f2fe; --brand-200: #bae6fd; --brand-300: #7dd3fc;
    --brand-400: #38bdf8; --brand-500: #0ea5e9; --brand-600: #0284c7; --brand-700: #0369a1; --brand-800: #075985;

    --primary: var(--brand-600);
    --primary-hover: var(--brand-700);
    --primary-gradient: var(--brand-600);
    --primary-soft: var(--brand-50);
    --secondary: #71717a;
    --success: #059669;
    --success-gradient: #059669;
    --danger: #dc2626;
    --danger-gradient: #dc2626;
    --warning: #d97706;
    --warning-gradient: #d97706;
    --info: #4f46e5;

    --background: #f4f4f5;
    --surface: #ffffff;
    --surface-light: #fafafa;
    --surface-sunken: #fafafa;
    --glass-border: #e4e4e7;
    --text-main: #27272a;
    --text-strong: #18181b;
    --text-muted: #71717a;
    --text-faint: #a1a1aa;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --row-line: #f4f4f5;
    --glass-bg: #fafafa;
    --glass-hover: #f4f4f5;
    --glass-border-hover: #d4d4d8;

    --sidebar-bg: #ffffff;
    --sidebar-text: #52525b;
    --sidebar-hover: #f4f4f5;

    --shadow-glow: none;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
    --shadow-glass: none;
    --shadow-xl: 0 20px 40px -12px rgba(0, 0, 0, 0.25);
    --transition: all 0.15s ease;
    --radius-card: 0.75rem;
    --dt-row-hover: #fafafa;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --primary: var(--brand-500);
    --primary-hover: var(--brand-400);
    --primary-gradient: var(--brand-600);
    --primary-soft: rgba(14, 165, 233, 0.1);
    --success: #10b981;
    --success-gradient: #059669;
    --danger: #f43f5e;
    --danger-gradient: #dc2626;
    --warning: #f59e0b;
    --warning-gradient: #d97706;
    --info: #818cf8;

    --background: #09090b;
    --surface: #18181b;
    --surface-light: #1f1f23;
    --surface-sunken: #141417;
    --glass-border: #27272a;
    --text-main: #e4e4e7;
    --text-strong: #ffffff;
    --text-muted: #a1a1aa;
    --text-faint: #71717a;
    --border: #27272a;
    --border-strong: #3f3f46;
    --row-line: rgba(39, 39, 42, 0.7);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-hover: #27272a;
    --glass-border-hover: #3f3f46;

    --sidebar-bg: #18181b;
    --sidebar-text: #a1a1aa;
    --sidebar-hover: #27272a;

    --shadow-sm: none;
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
    --dt-row-hover: rgba(39, 39, 42, 0.4);
    color-scheme: dark;
}

/* ---------- Base ---------- */
html { -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01'; scrollbar-gutter: stable; }
* { font-family: 'Inter', 'Hind Siliguri', ui-sans-serif, system-ui, sans-serif; }
code, pre, kbd, samp, .mono, [style*="monospace"] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
body {
    background: var(--background) !important;
    background-image: none !important;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
}
h1, h2, h3, h4, h5, h6 { color: var(--text-strong); letter-spacing: -0.01em; font-weight: 600; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.1rem; } h4 { font-size: 1rem; } h5 { font-size: .9rem; }
p { color: var(--text-muted); font-size: 0.875rem; }
a { color: var(--primary); }
::selection { background: var(--brand-100); color: var(--brand-800); }
* { scrollbar-width: thin; scrollbar-color: rgba(161, 161, 170, 0.5) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(161, 161, 170, 0.5); border-radius: 999px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow: hidden;
    z-index: 100;
}
.sb-brand {
    display: flex; align-items: center; gap: 10px;
    height: 56px; flex-shrink: 0; padding: 0 16px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}
.sb-brand-mark {
    display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px;
    background: var(--brand-600); color: #fff; font-size: 18px;
}
.sb-brand-name { font-size: 14px; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.sb-brand-sub { font-size: 11px; color: var(--text-muted); line-height: 1.2; }
.sb-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 12px 16px; }
.sb-section {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    padding: 18px 10px 6px; background: none; border: 0; cursor: pointer;
    font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint);
}
.sb-section:hover { color: var(--text-muted); }
.sb-section i { font-size: 14px; transition: transform .15s ease; }
.sb-group.closed .sb-section i { transform: rotate(-90deg); }
.sb-group.closed .sb-items { display: none; }
.sb-items { display: flex; flex-direction: column; gap: 1px; }
.sidebar .nav-link {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 6px; border: 0;
    font-size: 13.5px; font-weight: 500; color: var(--sidebar-text);
    background: none; box-shadow: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background-color .15s, color .15s;
}
.sidebar .nav-link i { font-size: 17px; width: 18px; text-align: center; flex-shrink: 0; color: inherit; transform: none !important; }
.sidebar .nav-link span.sb-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: var(--text-strong); border: 0; box-shadow: none; }
.sidebar .nav-link:hover i { color: inherit; }
.sidebar .nav-link.active {
    background: var(--primary-soft); color: var(--brand-700); font-weight: 500; border: 0; box-shadow: none;
}
:root[data-theme="dark"] .sidebar .nav-link.active { color: var(--brand-300); }
.sidebar .nav-link.active i { color: inherit; }
.sidebar .nav-link.active::before {
    content: ''; position: absolute; top: 6px; bottom: 6px; left: -12px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--brand-600);
}
.sb-count {
    margin-left: auto; min-width: 18px; padding: 0 5px; height: 18px; border-radius: 9px;
    font-size: 10.5px; font-weight: 600; line-height: 18px; text-align: center;
    background: var(--brand-600); color: #fff;
}
.sb-count.amber { background: #f59e0b; }
.sb-user {
    display: flex; align-items: center; gap: 10px; padding: 12px;
    border-top: 1px solid var(--border);
}
.sb-avatar {
    display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%;
    background: var(--glass-hover); color: var(--text-muted); font-size: 11px; font-weight: 600;
}
.sb-user-name { font-size: 13px; font-weight: 500; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.sb-user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; line-height: 1.25; }
.sb-logout { margin-left: auto; padding: 6px; border-radius: 6px; color: var(--text-faint); font-size: 17px; display: inline-flex; }
.sb-logout:hover { background: var(--glass-hover); color: var(--text-main); }

/* ---------- Page frame + top bar ---------- */
.main-content { margin-left: 240px; padding: 0 2rem 2rem; min-width: 0; }
/* Page toolbars that reuse the old "topbar" class (customers, billing, packages ...): a plain row */
.topbar:not(.app-topbar) {
    background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important; padding: 0 !important; margin-bottom: 1.25rem;
}
.app-topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 12px;
    height: 56px; margin: 0 -2rem 1.25rem; padding: 0 2rem;
    background: var(--surface); border: 0; border-bottom: 1px solid var(--border);
    border-radius: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.topbar-title {
    font-size: 15px !important; font-weight: 600; color: var(--text-strong);
    background: none !important; -webkit-text-fill-color: currentColor !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; margin: 0;
}
.tb-search {
    display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; max-width: 28rem; height: 36px;
    padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-light);
    color: var(--text-faint); font-size: 13px; cursor: pointer; transition: border-color .15s;
}
.tb-search:hover { border-color: var(--border-strong); }
.tb-search span:first-of-type { flex: 1; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.kbd { border: 1px solid var(--border-strong); background: var(--surface-light); border-radius: 4px; padding: 1px 6px; font-family: ui-monospace, monospace; font-size: 10px; color: var(--text-muted); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.tb-icon {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 6px;
    background: none; border: 0; color: var(--text-muted); font-size: 18px; cursor: pointer;
}
.tb-icon:hover { background: var(--glass-hover); color: var(--text-main); }
.hamburger { display: none; }

/* Quick customer search (Ctrl K) */
.qs-overlay { position: fixed; inset: 0; z-index: 1100; display: none; align-items: flex-start; justify-content: center; padding: 12vh 1rem 1rem; background: rgba(9, 9, 11, 0.4); }
.qs-overlay.open { display: flex; }
.qs-box { width: 100%; max-width: 36rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-xl); overflow: hidden; }
.qs-head { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--text-faint); }
.qs-head input { flex: 1; height: 48px; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--text-main); }
.qs-list { max-height: 50vh; overflow-y: auto; padding: 6px; margin: 0; list-style: none; }
.qs-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--text-main); }
.qs-item.active, .qs-item:hover { background: var(--glass-hover); }
.qs-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qs-code { margin-left: 4px; font-family: ui-monospace, monospace; font-size: 12px; color: var(--text-faint); }
.qs-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qs-due { width: 84px; text-align: right; font-size: 13px; font-weight: 600; color: var(--text-faint); }
.qs-due.red { color: var(--danger); }
.qs-empty { padding: 28px 12px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
    box-shadow: none; padding: 1.25rem; backdrop-filter: none; -webkit-backdrop-filter: none; transition: none;
}
.card:hover { box-shadow: none; border-color: var(--border); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-strong); margin: 0; }

/* Stat tiles (dashboard): label + icon on top, number below */
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 1.25rem; }
.stat-card { padding: 14px 16px; gap: 12px; }
.stat-card:hover { border-color: var(--border-strong); }
.stat-icon {
    width: 36px; height: 36px; border-radius: 8px; font-size: 18px; box-shadow: none; border: 0 !important;
}
.stat-icon.blue   { background: var(--primary-soft) !important; color: var(--primary) !important; }
.stat-icon.green  { background: rgba(16, 185, 129, 0.1) !important; color: var(--success) !important; }
.stat-icon.red    { background: rgba(244, 63, 94, 0.1) !important; color: var(--danger) !important; }
.stat-icon.orange { background: rgba(245, 158, 11, 0.12) !important; color: var(--warning) !important; }
.stat-details p { font-size: 12.5px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.stat-details h3 { font-size: 22px; font-weight: 600; margin-top: 2px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--text-strong); }

/* Old AdminLTE colour boxes become flat tiles with a coloured accent */
.small-box {
    background: var(--surface) !important; color: var(--text-main) !important;
    border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: none; backdrop-filter: none;
}
.small-box:hover { transform: none; box-shadow: none; border-color: var(--border-strong); }
.small-box > .inner { padding: 14px 16px; }
.small-box h3 { font-size: 22px; font-weight: 600; color: var(--text-strong) !important; text-shadow: none; margin: 4px 0 0; order: 2; }
.small-box p { font-size: 12.5px; color: var(--text-muted) !important; font-weight: 500; }
.small-box .icon > i { font-size: 44px; top: 12px; right: 14px; color: var(--border) !important; }
.small-box:hover .icon > i { transform: none; }
.small-box > .small-box-footer { background: var(--surface-light); color: var(--text-muted) !important; border-top: 1px solid var(--border); backdrop-filter: none; padding: 8px 0; font-size: 12.5px; }
.small-box > .small-box-footer:hover { background: var(--glass-hover); color: var(--text-main) !important; }
.small-box.bg-info    { border-top: 3px solid var(--info); }
.small-box.bg-success { border-top: 3px solid var(--success); }
.small-box.bg-warning { border-top: 3px solid var(--warning); }
.small-box.bg-danger  { border-top: 3px solid var(--danger); }
.small-box.bg-info .icon > i    { color: rgba(79, 70, 229, 0.18) !important; }
.small-box.bg-success .icon > i { color: rgba(5, 150, 105, 0.18) !important; }
.small-box.bg-warning .icon > i { color: rgba(217, 119, 6, 0.2) !important; }
.small-box.bg-danger .icon > i  { color: rgba(220, 38, 38, 0.18) !important; }
.bg-warning h3, .bg-warning p, .bg-warning .small-box-footer { color: inherit !important; }

/* ---------- Buttons ---------- */
.btn {
    gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
    font-size: 13px; font-weight: 600; letter-spacing: 0; white-space: nowrap; line-height: 1.25;
    transition: background-color .15s, border-color .15s, color .15s; box-shadow: none;
}
.btn i { font-size: 16px; }
.btn:hover, .btn:active { transform: none !important; filter: none !important; }
.btn:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: #fff; border: 1px solid var(--brand-600); box-shadow: none; }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); box-shadow: none; color: #fff; }
.btn-success { background: #059669; color: #fff; box-shadow: none; }
.btn-success:hover { background: #047857; box-shadow: none; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; box-shadow: none; }
.btn-danger:hover { background: #b91c1c; box-shadow: none; color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-info { background: #4f46e5; color: #fff; }
.btn-info:hover { background: #4338ca; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-main); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--glass-hover); }
.btn-outline {
    background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-main); backdrop-filter: none;
}
.btn-outline:hover { background: var(--glass-hover); border-color: var(--border-strong); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
.form-label, label.form-label { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.form-control {
    padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--surface); color: var(--text-strong); font-size: 14px; box-shadow: none; transition: border-color .15s, box-shadow .15s;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus { border-color: var(--brand-500); background: var(--surface); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18); }
select.form-control { padding-right: 2.25rem; background-position: right .75rem center; }
select.form-control option { background: var(--surface); color: var(--text-strong); }
:root[data-theme="dark"] .form-control { background: var(--surface); border-color: var(--border-strong); }

/* ---------- Tables ---------- */
.table-responsive { border-radius: 0; }
.table { font-size: 13.5px; margin-top: 0; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 10px 16px; border-bottom: 1px solid var(--row-line); }
.table th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface-light) !important; color: var(--text-muted);
    font-size: 11.5px; font-weight: 600; text-transform: none; letter-spacing: 0; white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.table tbody tr { transition: background-color .15s; }
.table tbody tr:hover { background: var(--dt-row-hover); transform: none; }
.table tbody tr:last-child td { border-bottom: 0; }
.card > .table-responsive:first-child, .card > .table:first-child { margin-top: -0.25rem; }

/* DataTables */
.dataTables_wrapper { font-size: 13px; color: var(--text-main); }
.dataTables_wrapper .top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.dataTables_wrapper .top .dataTables_filter { margin-left: auto; }
.dataTables_wrapper .bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: var(--surface) !important; border: 1px solid var(--border-strong) !important; color: var(--text-strong) !important;
    border-radius: 8px !important; padding: 6px 10px !important; font-size: 13px; outline: 0;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--brand-500) !important; box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18); }
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info { color: var(--text-muted) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important; border: 1px solid transparent !important; color: var(--text-main) !important;
    padding: 4px 10px !important; margin-left: 2px !important; background: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--glass-hover) !important; border-color: var(--border) !important; color: var(--text-strong) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--brand-600) !important; border-color: var(--brand-600) !important; color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: .4; }
.dataTables_wrapper .dataTables_processing {
    background: var(--surface) !important; color: var(--text-main) !important; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-md);
}
table.dataTable thead th, table.dataTable thead td { border-bottom: 1px solid var(--border) !important; }
table.dataTable.no-footer { border-bottom: 1px solid var(--border) !important; }
table.dataTable tbody tr { background: transparent !important; }
table.dataTable tbody tr:hover { background: var(--dt-row-hover) !important; }
.dt-buttons { margin-bottom: 0 !important; gap: 6px !important; }
button.dt-button, div.dt-button, a.dt-button, .dt-buttons .dt-button {
    background: var(--surface) !important; border: 1px solid var(--border-strong) !important; color: var(--text-main) !important;
    border-radius: 8px !important; padding: 6px 12px !important; font-size: 12.5px !important; font-weight: 600 !important; box-shadow: none !important;
}
button.dt-button:hover, div.dt-button:hover, a.dt-button:hover, .dt-buttons .dt-button:hover {
    background: var(--glass-hover) !important; color: var(--text-strong) !important; box-shadow: none !important;
}
/* DataTables "show more" arrow (when columns are folded away): a small grey arrow above the row checkbox, not a box on top of it */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control { padding-top: 30px !important; vertical-align: top; }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    top: 10px !important; margin-top: 0 !important; left: 6px !important;
    background: none !important; color: var(--text-muted) !important; border: 0 !important; box-shadow: none !important;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before { color: var(--primary) !important; }

/* ---------- Badges (ISPBILLING pills: soft colour + thin ring) ---------- */
.badge {
    gap: 5px; padding: 2px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 500; letter-spacing: 0;
    border: 0; box-shadow: inset 0 0 0 1px rgba(113, 113, 122, 0.15);
}
.badge-success   { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px rgba(5, 150, 105, 0.15); }
.badge-danger    { background: #fff1f2; color: #be123c; box-shadow: inset 0 0 0 1px rgba(225, 29, 72, 0.15); }
.badge-warning   { background: #fffbeb; color: #92400e; box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.2); }
.badge-secondary { background: #f4f4f5; color: #3f3f46; }
.badge-primary   { background: var(--brand-50); color: var(--brand-700); box-shadow: inset 0 0 0 1px rgba(2, 132, 199, 0.15); }
.badge-info      { background: #eef2ff; color: #4338ca; box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.15); }
[data-theme='light'] .badge-success   { background: #ecfdf5; color: #047857; border-color: transparent; }
[data-theme='light'] .badge-danger    { background: #fff1f2; color: #be123c; border-color: transparent; }
[data-theme='light'] .badge-warning   { background: #fffbeb; color: #92400e; border-color: transparent; }
[data-theme='light'] .badge-secondary { background: #f4f4f5; color: #3f3f46; border-color: transparent; }
[data-theme='light'] .badge-primary   { background: var(--brand-50); color: var(--brand-700); border-color: transparent; }
:root[data-theme="dark"] .badge-success   { background: rgba(16, 185, 129, 0.1); color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.2); }
:root[data-theme="dark"] .badge-danger    { background: rgba(244, 63, 94, 0.1); color: #fda4af; box-shadow: inset 0 0 0 1px rgba(251, 113, 133, 0.2); }
:root[data-theme="dark"] .badge-warning   { background: rgba(245, 158, 11, 0.1); color: #fcd34d; box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.2); }
:root[data-theme="dark"] .badge-secondary { background: #27272a; color: #d4d4d8; box-shadow: inset 0 0 0 1px rgba(161, 161, 170, 0.2); }
:root[data-theme="dark"] .badge-primary   { background: rgba(14, 165, 233, 0.1); color: var(--brand-300); box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.2); }
:root[data-theme="dark"] .badge-info      { background: rgba(99, 102, 241, 0.12); color: #a5b4fc; box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.2); }

/* Flash messages: alert boxes like ISPBILLING */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius-card); border: 1px solid; font-size: 14px; font-weight: 500; margin-bottom: 1.25rem; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger, .alert-error { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-800); }
:root[data-theme="dark"] .alert-success { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
:root[data-theme="dark"] .alert-danger, :root[data-theme="dark"] .alert-error { background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.2); color: #fda4af; }
:root[data-theme="dark"] .alert-warning { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); color: #fcd34d; }
:root[data-theme="dark"] .alert-info { background: rgba(14, 165, 233, 0.1); border-color: rgba(14, 165, 233, 0.2); color: var(--brand-300); }

/* ---------- Modals ---------- */
.modal-overlay { background: rgba(9, 9, 11, 0.6); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); transition: opacity .15s; }
.modal-content {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
    box-shadow: var(--shadow-xl); padding: 1.5rem; transition: transform .15s ease;
    transform: translateY(8px);
}
.modal-overlay.active .modal-content { transform: none; }
.modal-header { margin: -0.25rem 0 1.25rem; padding-bottom: .9rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text-strong); }
.btn-close {
    width: 30px; height: 30px; border-radius: 8px; background: none; border: 0; font-size: 20px; color: var(--text-faint);
}
.btn-close:hover { background: var(--glass-hover); color: var(--text-main); border: 0; transform: none; }

/* ---------- Login ---------- */
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-md); backdrop-filter: none; padding: 2.25rem 2rem; }
.login-header h2 { background: none; -webkit-text-fill-color: currentColor; color: var(--text-strong); font-size: 1.35rem; }
.login-header i {
    display: inline-grid !important; place-items: center; width: 48px; height: 48px; border-radius: 12px;
    background: var(--brand-600); color: #fff !important; font-size: 26px !important; margin-bottom: 12px !important;
}
.login-body { background: var(--background) !important; }

/* A <div class="badge"> is used as a notice box on some pages: let its text wrap */
div.badge { white-space: normal; line-height: 1.5; }

/* ---------- Customer list rows ---------- */
.cl-avatar {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
    background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: .95rem;
    box-shadow: inset 0 0 0 1px rgba(2, 132, 199, 0.15);
}
:root[data-theme="dark"] .cl-avatar { background: rgba(14, 165, 233, 0.12); color: var(--brand-300); }
.cl-date { font-size: .78rem; color: var(--text-muted); white-space: nowrap; line-height: 1.6; }
.cl-date small { font-size: .7rem; font-weight: 600; }
.cl-actions { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.cl-actions .btn, .cl-actions .btn-sm { padding: 0 !important; width: 30px; height: 30px; min-width: 30px; display: inline-grid !important; place-items: center; font-size: 15px; border-radius: 8px; }

/* ⋯ row menu (opened by the script in header.php; placed with position: fixed so tables do not clip it) */
.row-menu { position: relative; display: inline-block; }
.rm-list {
    display: none; position: fixed; z-index: 1200; min-width: 210px; padding: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-xl);
}
.row-menu.open .rm-list { display: block; }
.rm-list form { margin: 0; display: block; }
.rm-item {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px;
    background: none; color: var(--text-main); font-size: .82rem; text-align: left; cursor: pointer; white-space: nowrap;
}
.rm-item i { font-size: 16px; color: var(--text-muted); }
.rm-item:hover { background: var(--glass-hover); color: var(--text-strong); }
.rm-item.warn, .rm-item.warn i { color: var(--warning); }
.rm-item.ok, .rm-item.ok i { color: var(--success); }
.rm-item.danger, .rm-item.danger i { color: var(--danger); }
.rm-sep { height: 1px; margin: 4px 2px; background: var(--border); }

/* ---------- Small phones / tablets ---------- */
.sidebar-overlay { background: rgba(9, 9, 11, 0.4); backdrop-filter: none; }
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: none; box-shadow: var(--shadow-xl); }
    .main-content { margin-left: 0; padding: 0 1.25rem 1.25rem; }
    .app-topbar { margin: 0 -1.25rem 1rem; padding: 0 1.25rem; }
    .hamburger { display: inline-grid !important; }
}
@media (max-width: 768px) {
    .main-content { padding: 0 .75rem .75rem !important; }
    .app-topbar {
        flex-direction: row !important; flex-wrap: nowrap !important; align-items: center !important;
        height: 56px !important; margin: 0 -.75rem .75rem !important; padding: 0 .75rem !important; gap: 8px !important;
    }
    .app-topbar > div { width: auto !important; flex-wrap: nowrap !important; }
    /* phone: the page name stays (so you know where you are); the search becomes an icon button */
    .topbar-title { display: block; flex: 1 1 auto; min-width: 0; max-width: none; font-size: 14px !important; }
    .tb-search { flex: 0 0 34px !important; width: 34px !important; height: 34px; padding: 0; justify-content: center; border-color: transparent; background: none; color: var(--text-muted); }
    .tb-search span, .tb-search .kbd, .tb-cron { display: none !important; }
    .tb-right { margin-left: 0; }
    .app-topbar .tb-icon { min-height: 0 !important; }
    .card { padding: 1rem; }
    .stat-card { flex-direction: row; align-items: center; text-align: left; }
    .rs-renew-group, .rs-fund-pill { width: 100%; }
    .rs-renew-group { flex-direction: column !important; flex-wrap: nowrap !important; }
    .rs-renew-group > * { flex: 0 0 auto !important; width: 100% !important; min-width: 0 !important; }
    .cl-avatar { display: none; }  /* customer lists: room for the name on a phone */
}

/* ---------- One size for controls and tiles ----------
   Pages set their own heights inline (35, 37, 42, 45, 48px), so a filter row mixed a 35px select with a 45px
   button and boxes looked big and small side by side. Every single-line control is now --ctl-h tall
   (44px on phones, the touch size), small buttons --ctl-h-sm. Table cells and the big amount field keep theirs. */
:root { --ctl-h: 40px; --ctl-h-sm: 32px; }
@media (max-width: 768px) { :root { --ctl-h: 44px; --ctl-h-sm: 36px; } }

:is(.main-content, .modal-overlay, .modal) .form-control:not(textarea):not([multiple]):not([size]):not([type="file"]):not([type="color"]):not(table *):not(.ac-amount *),
:is(.main-content, .modal-overlay, .modal) select:not([multiple]):not([size]):not(table *),
.dataTables_wrapper .dataTables_length select, .dataTables_wrapper .dataTables_filter input {
    height: var(--ctl-h) !important; min-height: var(--ctl-h) !important; padding-top: 0 !important; padding-bottom: 0 !important;
    box-sizing: border-box !important;
}
.dataTables_wrapper .dataTables_filter input { padding: 0 12px !important; border-radius: 8px; }
.dataTables_wrapper .dataTables_length select { padding: 0 28px 0 10px !important; border-radius: 8px; }

:is(.main-content, .modal-overlay, .modal) .btn:not(.btn-sm):not(.btn-xs):not(.btn-lg):not(.btn-block):not(.ac-submit):not(.btn-close):not(table *):not(.rm-btn),
:is(.main-content, .modal-overlay, .modal) .dt-buttons .btn {
    min-height: var(--ctl-h) !important; height: auto !important; padding-top: 0 !important; padding-bottom: 0 !important;
    display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
}
:is(.main-content, .modal-overlay, .modal) .btn.btn-sm:not(table *):not(.rm-btn):not(.cl-actions *) {
    min-height: var(--ctl-h-sm) !important; height: auto !important; padding-top: 0 !important; padding-bottom: 0 !important;
    display: inline-flex; align-items: center; justify-content: center;
}
/* a label / checkbox standing in a row of controls lines up with them */
:is(.main-content, .modal-overlay) form label:has(> input[type="checkbox"]:only-of-type) { display: inline-flex; align-items: center; gap: 6px; min-height: var(--ctl-h); margin-bottom: 0; }

/* Select2 (searchable customer pickers) the same height as the other fields */
body .select2-container--default .select2-selection--single {
    height: var(--ctl-h) !important; padding: 0 !important; display: flex !important; align-items: center;
    border: 1px solid var(--border-strong) !important; border-radius: 8px !important; background-color: var(--surface) !important;
}
body .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: normal !important; padding-left: 12px !important; padding-right: 32px !important; color: var(--text-strong) !important; }
body .main-content .select2-container--default .select2-selection--single .select2-selection__arrow,
body .select2-container--default .select2-selection--single .select2-selection__arrow { height: calc(var(--ctl-h) - 2px) !important; top: 0 !important; }

/* Stat tiles: the number never breaks onto two lines (৳ on one line, digits on the next made one tile taller
   than its neighbours); it gets smaller instead when the tile is narrow */
.stat-card { min-width: 0; }
.stat-details { flex: 1 1 auto; min-width: 0; container-type: inline-size; }
.stat-details p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-details h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: clamp(15px, 14cqi, 22px); line-height: 1.25; }

/* Tiles that use .stat-card without an icon (label, number, note stacked): style.css lays .stat-card out in a row,
   which squeezed "TOTAL COLLECTED", the amount and "0 payments" side by side */
.stat-card:not(:has(> .stat-icon)) { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px; min-height: 110px; }
.stat-card:not(:has(> .stat-icon)) > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0 !important; }

/* Phones: page toolbars stack, so their buttons and forms take the full width like the fields above them
   (a full-width Search next to a half-width "Add Custom Bill" looked like boxes of random sizes) */
@media (max-width: 768px) {
    html { scrollbar-gutter: auto; }
    /* stat tiles two per row, icon above the number: ten full-width tiles meant scrolling past a screen of numbers */
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
    .stat-grid .stat-card { flex-direction: column !important; align-items: flex-start !important; gap: 8px; padding: 12px !important; }
    .stat-grid .stat-details { width: 100%; }
    .stat-grid .stat-details h3 { font-size: clamp(14px, 13cqi, 20px); }
    /* fields and main buttons are full width, so stacked boxes line up instead of 97px / 181px / 332px at random */
    .main-content .form-control:not(table *):not([type="checkbox"]):not([type="radio"]),
    .main-content select:not(table *):not(.dataTables_length select) { width: 100% !important; max-width: 100% !important; }
    .main-content .btn:not(.btn-sm):not(.btn-xs):not(table *):not(.dt-buttons *):not(.rm-btn):not(.btn-close):not(.btn-group *):not(.nav-tabs *):not(:is(h1, h2, h3, h4, h5) *):not(.cl-actions *):not(.stat-card *) {
        width: 100%; flex: 1 1 100%;
    }
    .main-content form:not(table *):not(.rm-list *):not(.cl-actions *):not(.btn-group *) { width: 100%; max-width: 100%; flex: 1 1 100%; }
    /* cards placed side by side on a computer each take the full width (one came out narrower than the rest) */
    .main-content [style*="display: flex"] > .card, .main-content .dash-pair > .card { flex: 1 1 100% !important; width: 100%; }
    .main-content [style*="flex-wrap: wrap"]:not(table *):not(.card-header):not(h1):not(h2):not(h3):not(h4) > .btn:not(.btn-sm),
    .main-content [style*="flex-wrap: wrap"]:not(table *) > form,
    .main-content [style*="flex-wrap: wrap"]:not(table *) > form > .btn:not(.btn-sm) { flex: 1 1 100%; width: 100%; }
}

/* Table cells holding a date, an amount, a phone number or an ID stay on one line (marked by includes/header.php),
   so rows don't grow when "20 Oct / 2026" or "৳ / 1,000.00" wrapped */
.table th { white-space: nowrap; }
.table td.nx-nw, .table td .nx-nw { white-space: nowrap !important; }

@media print {
    .sidebar, .app-topbar, .sidebar-overlay, .qs-overlay, .no-print { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; }
}
