/* =====================================================================
   Yashasavi MLM — Dashboard theme (user / admin / superadmin)
   ===================================================================== */

:root {
    --dash-green: #2e7d32;
    --dash-deep: #16351a;
    --dash-gold: #c99a2e;
    --sky-blue: #6094f3;
    --ink: #000000;
    --ink-soft: #000000;
    --line: #e2e8de;
    --bg: #f2f5f1;
    --card: #ffffff;
    --radius: 12px;
    --shadow: 0 4px 18px rgba(22, 53, 26, .06);
    --sidebar-w: 212px;
    --font: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-head: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* area accents */
body.area-user        { --accent: #2e7d32; --accent-2: #1b5e20; --side: #ffffff; --side-text: #000000; }
body.area-admin       { --accent: #0e7490; --accent-2: #155e75; --side: #ffffff; --side-text: #000000; }
body.area-superadmin  { --accent: #5b3fa8; --accent-2: #432c85; --side: #ffffff; --side-text: #000000; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body.dash-body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.6;
}
a { color: #000; text-decoration: none; }
a:hover { color: #000; text-decoration: underline; }
h1, h2, h3, h4 { color: #000; line-height: 1.3; }
img { max-width: 100%; }

/* ---------- layout ---------- */
.dash { display: flex; min-height: 100vh; }
.sidebar {
    padding-top: env(safe-area-inset-top, 0px);
    width: var(--sidebar-w); background: var(--side); color: var(--side-text);
    position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 400;
    transition: transform .28s ease; display: flex; flex-direction: column;
    border-right: 1px solid var(--line);
}
.side-brand { background: var(--sky-blue); display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.side-brand > div { min-width: 0; }
.side-brand img { height: 30px; width: 30px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.side-brand .sb-name { color: #000; font-weight: 400; font-size: 13.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-brand .sb-sub { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.4px; color: #000; }
.side-nav { padding: 8px 7px 10px; flex: 1; background: var(--bg); border-radius: 12px; margin: 8px 6px 10px; }
.side-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.4px; color: #000; padding: 8px 8px 3px; }
.side-nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 6px 9px; border-radius: 8px; font-size: 13px; font-weight: 400; margin-bottom: 1px; transition: .18s; border-left: 3px solid transparent; }
.side-nav a .s-ico { width: 18px; text-align: center; font-size: 14px; }
.side-nav a:hover { background: #ffffff; color: #000; }
.side-nav a.active { background: #ffffff; color: #000; border-left-color: var(--accent); box-shadow: 0 2px 10px rgba(22, 53, 26, .1); }
.side-nav .side-count { margin-left: auto; background: #ffffff; border: 1px solid var(--line); color: #000; font-size: 10.5px; padding: 1px 8px; border-radius: 12px; }
.side-foot { padding: 8px 12px; border-top: 1px solid var(--line); font-size: 10.5px; color: #000; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { min-width: 0; flex-wrap: nowrap; }
.topbar { background: var(--sky-blue); border-bottom: 1px solid var(--line); padding: 0 18px; padding-top: env(safe-area-inset-top, 0px); height: auto; min-height: 54px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 350; }
.topbar .page-title { font-size: 17px; font-weight:400; flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tb-right { margin-left: auto; flex-shrink: 0; }
.tb-user { flex-shrink: 0; }
.topbar .tb-right { display: flex; align-items: center; gap: 14px; }
.tb-user { display: flex; align-items: center; gap: 10px; }
.tb-user .avatar { width: 34px; height: 34px; border-radius: 50%; background: #e8f3e8; border: 1.5px solid var(--accent); color: #000; display: flex; align-items: center; justify-content: center; font-weight: 400; font-size: 13px; }
.tb-user .tb-name { font-weight:400; font-size: 13.5px; line-height: 1.15; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-user .tb-role { font-size: 11.5px; color: var(--ink-soft); }
.btn-logout { border: 1px solid var(--line); background: #fff; color: var(--ink-soft); padding: 7px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; font-family: var(--font); }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--ink); flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; align-self: center; }

.content { padding: 18px; }
.content-inner { max-width: 1280px; margin: 0 auto; }

/* ---------- cards & stats ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 400; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title .right { margin-left: auto; font-size: 13px; font-weight: 400; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; display: flex; gap: 16px; align-items: center; border-left: 4px solid var(--accent); }
.stat-card.gold { border-left-color: #c99a2e; }
.stat-card.blue { border-left-color: #1976d2; }
.stat-card.red { border-left-color: #d32f2f; }
.stat-card.teal { border-left-color: #00897b; }
.stat-card .st-ico { width: 48px; height: 48px; border-radius: 12px; background: #f0f5ef; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-card b { display: block; font-size: 20px; color: #000; line-height: 1.2; }
.stat-card span { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- tables ---------- */
/* ---------- shop grid ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1180px) { .shop-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

/* ---------- fonts: headings + brand = Poppins, body = Roboto ---------- */
h1, h2, h3, h4, h5, h6, .card-title, .brand-name, .stat-label, .page-title, .nav-label { font-family: var(--font-head); }
.topbar .brand-name, .brand .brand-name { font-family: var(--font-head); }
/* amounts never wrap onto two lines */
span.money { white-space: nowrap; display: inline-block; }

/* ---------- DataTables (table-dt) — zebra styling + controls ---------- */
.table-dt tbody tr.odd td { background: #f3f7f3; }
.table-dt tbody tr.even td { background: #ffffff; }
.table-dt tbody tr:hover td { background: #e9f2e9; }
.table-dt tfoot td { padding: 4px 6px; border-top: 1px solid var(--line); background: #fbfcfa; }
.dt-col-filter { width: 100%; box-sizing: border-box; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; background: #fff; font-family: var(--font); }
.dt-col-filter:focus { outline: none; border-color: var(--accent, #2a7a2a); }
.dataTables_wrapper { margin-top: 4px; font-size: 13px; }
.dataTables_wrapper .dataTables_filter { float: right; text-align: right; margin-bottom: 8px; font-size: 13px; }
.dataTables_wrapper .dataTables_filter input { border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; font-size: 13px; margin-left: 4px; font-family: var(--font); }
.dataTables_wrapper .dataTables_length { float: left; margin-bottom: 8px; font-size: 13px; }
.dataTables_wrapper .dataTables_length select { border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; font-size: 13px; font-family: var(--font); }
.dataTables_wrapper .dataTables_info { clear: both; float: left; margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }
.dataTables_wrapper .dataTables_paginate { float: right; margin-top: 6px; }
.dataTables_wrapper .dataTables_paginate .paginate_button { padding: 5px 11px; margin-left: 3px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #000 !important; cursor: pointer; font-size: 12.5px; }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: #eef5ee; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--brand, #2a7a2a); color: #fff !important; border-color: var(--brand, #2a7a2a); }
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: .45; cursor: default; }
.dataTables_wrapper .dataTables_empty { padding: 18px 0; color: var(--ink-soft); }
table.table-dt thead .sorting, table.table-dt thead .sorting_asc, table.table-dt thead .sorting_desc { cursor: pointer; }
table.table-dt thead .sorting::after { content: " \2195"; opacity: .35; font-size: 10px; }
table.table-dt thead .sorting_asc::after { content: " \2191"; opacity: .7; font-size: 10px; }
table.table-dt thead .sorting_desc::after { content: " \2193"; opacity: .7; font-size: 10px; }
.table th { text-align: left; background: #f6f8f4; color: #000; padding: 11px 14px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; white-space: nowrap; }
.table td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #fafbf9; }
.table .table-img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 44px 20px; color: var(--ink-soft); }
.empty-state .es-ico { font-size: 38px; display: block; margin-bottom: 10px; opacity: .5; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 11.5px; font-weight:400; white-space: nowrap; }
.badge-success { background: #e3f4e4; color: #000; }
.badge-warning { background: #fdf3d7; color: #000; }
.badge-danger  { background: #fdecec; color: #000; }
.badge-info    { background: #e3edf8; color: #000; }
.badge-secondary { background: #eceff1; color: #000; }
.badge-primary { background: #e8f0e6; color: #000; }

/* ---------- buttons ---------- */
.btn { display: inline-block; padding: 8px 18px; border-radius: 9px; font-weight: 400; font-size: 13.5px; cursor: pointer; border: 1px solid transparent; transition: .18s; font-family: var(--font); line-height: 1.4; }
.btn-primary { background: #e8f3e8; color: #000; border-color: var(--accent); }
.btn-primary:hover { background: #d8ead8; color: #000; }
.btn-outline { border-color: #000; color: #000; background: transparent; }
.btn-outline:hover { background: #f0f3ee; color: #000; }
.btn-light { background: #f0f3ee; color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: #e4e9e2; }
.btn-danger { background: #fdecec; color: #000; border-color: #d32f2f; }
.btn-danger:hover { background: #f9d9d9; color: #000; }
.btn-gold { background: #f7ecd2; color: #000; border-color: var(--dash-gold); }
.btn-sm { padding: 4px 11px; font-size: 12px; border-radius: 7px; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---------- forms ---------- */
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 20px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight:400; font-size: 12.5px; margin-bottom: 5px; color: #000; }
.form-group label .req { color: #d32f2f; }
.form-control { width: 100%; padding: 9.5px 13px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-family: var(--font); background: #fcfdfb; transition: .15s; }
.form-control:focus { outline: none; border-color: #000; box-shadow: 0 0 0 3px rgba(46,125,50,.1); background: #fff; }
textarea.form-control { min-height: 110px; resize: vertical; }
select.form-control { appearance: auto; }
.form-hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.inline-form { display: inline; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
/* chip-style filters (shop categories): horizontal swipe row */
.chip-row { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 2px 10px; margin-bottom: 10px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .btn { flex-shrink: 0; white-space: nowrap; }
.filter-form .form-group { margin-bottom: 0; min-width: 150px; }

/* checkbox */
.form-check { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--ink-soft); margin: 10px 0; }
.form-check input { margin-top: 3px; }

/* file upload preview */
.upload-preview { width: 86px; height: 86px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 8px; }

/* ---------- alerts ---------- */
.alert { padding: 12px 38px 12px 15px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; position: relative; border: 1px solid transparent; }
.alert-success { background: #edf7ed; color: #000; border-color: #c8e6c9; }
.alert-danger  { background: #fdecec; color: #000; border-color: #f5c6c6; }
.alert-warning { background: #fff8e6; color: #000; border-color: #f0e0ab; }
.alert .btn-close { position: absolute; right: 8px; top: 8px; background: none; border: 0; font-size: 17px; cursor: pointer; color: inherit; opacity: .55; }

/* ---------- pagination ---------- */
.pagination-nav { display: flex; justify-content: center; margin-top: 22px; }
.pagination { display: flex; gap: 6px; list-style: none; }
.page-item a, .page-item span { min-width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; padding: 0 8px; color: var(--ink-soft); background: #fff; }
.page-item.active a { background: #eef3ec; color: #000; border-color: var(--accent); }
.page-item.disabled { opacity: .4; pointer-events: none; }

/* ---------- login page ---------- */
.dash-login-body { font-family: var(--font); background: linear-gradient(120deg, #14301a, #1f4a26 55%, #2e7d32); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 16px; margin: 0; }
.dash-login { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; box-shadow: 0 26px 70px rgba(0,0,0,.35); padding: 36px; }
.dash-login .dl-logo { text-align: center; margin-bottom: 20px; }
.dash-login .dl-logo img { height: 52px; margin: 0 auto 10px; }
.dash-login h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.dash-login .dl-sub { text-align: center; color: var(--ink-soft); font-size: 13px; margin-bottom: 24px; }

/* ---------- member registration form (panel pages) ---------- */
.member-form .mf-section { font-size: 14px; color: #000; margin: 14px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.member-form .mf-section:first-child { margin-top: 0; }
.member-form .btn { margin-top: 6px; }

/* ---------- genealogy tree (full-page centered chart, ID pills) ---------- */
.content-inner.content-fluid { max-width: none; }

.tree-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.tree-toolbar .tt-label { font-size: 12px; color: var(--ink-soft); }
.tree-toolbar .tt-zoom { display: flex; gap: 6px; margin-left: auto; }
.tree-toolbar .tt-zoom button { border: 1px solid var(--line); background: #fff; color: #000; border-radius: 8px; font-size: 13px; min-width: 38px; min-height: 30px; padding: 3px 12px; cursor: pointer; font-family: var(--font); }
.tree-toolbar .tt-zoom button:hover { background: #f0f3ee; }
.tree-toolbar .tt-level { display: flex; align-items: center; gap: 6px; }
.tree-toolbar .tt-level input { width: 64px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: var(--font); }
.tree-toolbar .tt-level button { border: 1px solid var(--line); background: #fff; color: #000; border-radius: 8px; font-size: 13px; min-height: 30px; padding: 3px 14px; cursor: pointer; font-family: var(--font); }
.tree-toolbar .tt-level button:hover { background: #f0f3ee; }
.tree-toolbar .tt-level .lvl-result { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* the chart uses the complete page width and centers on the root;
   branches are straight SVG lines (drawn by dash.js) */
.tree-wrap { overflow: auto; -webkit-overflow-scrolling: touch; padding: 14px 10px 14px; max-height: calc(100vh - 215px); }
.tree { position: relative; display: flex; justify-content: center; min-width: max-content; margin: 0 auto; }
.tree svg.tree-lines { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 0; overflow: visible; }
.tree svg.tree-lines line, .tree svg.tree-lines path { stroke: #94b098; stroke-width: 2; stroke-linecap: round; }
.tree svg.tree-lines path { fill: none; }
.tree > ul { position: relative; z-index: 1; }
.tree ul { display: flex; justify-content: center; }
.tree li { position: relative; list-style: none; padding: 15px 5px 0; display: flex; flex-direction: column; align-items: center; }
.tree li:only-child { padding-top: 0; }
/* single-child legs render as FLAT sibling lists (one <ul class="chain">):
   the DOM nesting depth stays constant no matter how many levels deep the
   leg goes — browsers cap HTML nesting at ~512 levels, and a 250-level
   nested list broke there, leaking the hidden member info onto the page */
.tree ul.chain { flex-direction: column; align-items: center; }
.tree ul.chain > li:only-child { padding-top: 15px; }
/* a straight-line member's free position floats beside the line, inside the
   member's own <li> (it is absolute, so it never widens the chart) */
.tree .side-slot { position: absolute; top: 75px; z-index: 1; }
.tree .side-slot.L { right: calc(50% + 38px); }
.tree .side-slot.R { left: calc(50% + 38px); }
.tree .side-slot .t-node.empty.add { opacity: .85; }
.tree .deep-note { margin-top: 10px; font-size: 10.5px; color: var(--ink-soft); background: #fff8e6; border: 1px dashed var(--line); border-radius: 8px; padding: 4px 10px; white-space: nowrap; }

/* member node = ID badge only (active green / inactive red); details open in a floating popup */
.tree .t-node { position: relative; display: flex; flex-direction: column; align-items: center; outline: none; }
/* compact member node: small person icon colored by status (green =
   active, red = inactive) with the User ID below it */
.tree .t-pill { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 8px 2px; border-radius: 9px; background: #fff; border: 1px solid var(--line); white-space: nowrap; cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.tree .t-pill:hover { box-shadow: 0 3px 8px rgba(0, 0, 0, .24); }
/* Font Awesome person icon sized to cover the complete User ID below it */
.tree .t-pill .t-ico { display: block; font-size: 30px; line-height: 1; }
.tree .t-pill .t-id { display: block; font-size: 9px; font-weight: 600; line-height: 1.15; color: #2b3a2b; }
.tree .t-pill.on .t-ico { color: #2e7d32; }
.tree .t-pill.off .t-ico { color: #c62828; }
.tree .t-node.root .t-pill { box-shadow: 0 0 0 2px rgba(214, 168, 60, .65), 0 1px 3px rgba(0, 0, 0, .14); }

/* data source for the popup (never rendered inside the tree, so the chart
   layout is never disturbed or clipped) */
.tree .t-tip { display: none; }

/* floating member-info popup (appended to <body>, follows the pill) */
.tree-popup { display: none; position: fixed; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 34px rgba(0, 0, 0, .28); padding: 10px 12px; min-width: 195px; max-width: 260px; text-align: left; z-index: 3000; font-size: 11.5px; line-height: 1.45; }
.tree-popup.show { display: block; }
.tree-popup .t-tip-head { font-size: 12.5px; color: #000; border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 6px; white-space: nowrap; }
.tree-popup dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.tree-popup dt { color: var(--ink-soft); }
.tree-popup dd { margin: 0; color: #000; text-align: right; white-space: nowrap; }
.tree-popup .t-tip-actions { display: flex; gap: 6px; border-top: 1px solid var(--line); margin-top: 7px; padding-top: 7px; flex-wrap: wrap; }
.tree-popup .t-tip-actions a { display: inline-block; font-size: 10.5px; color: #000; background: #eef3ec; border: 1px solid var(--line); border-radius: 10px; padding: 2px 9px; text-decoration: none; white-space: nowrap; }
.tree-popup .t-tip-actions a:hover { background: #e0ebdf; border-color: var(--accent); text-decoration: none; }

/* add-member slot (dashed pill) */
.tree .t-node.empty.add { padding: 0; }
.tree .t-node.empty.add a { display: flex; flex-direction: row; align-items: center; gap: 4px; padding: 3px 9px; color: #000; text-decoration: none; border: 1.5px dashed #a9c3ac; border-radius: 8px; background: #fbfdfb; white-space: nowrap; }
.tree .t-node.empty.add a:hover { background: #e8f3e8; border-color: var(--accent); }
.tree .t-node.empty.add .t-add-plus { font-size: 11px; line-height: 1; }
.tree .t-node.empty.add .t-add-text { font-size: 10px; font-weight: 400; line-height: 1; }
/* level search: dim everything, ring the matching level */
.tree .t-pill.dim { opacity: .3; }
.tree .t-pill.hl { box-shadow: 0 0 0 3px #d6a83c, 0 1px 3px rgba(0, 0, 0, .14); }
.tree .t-pill.dim, .tree .t-pill.hl { transition: opacity .2s; }

.tree-legends { display: flex; gap: 14px; justify-content: center; font-size: 11px; color: var(--ink-soft); margin-bottom: 4px; flex-wrap: wrap; }
.tree-legends .lg { display: flex; align-items: center; gap: 5px; }
.tree-legends .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* mobile: compact chart, roomy touch targets */
@media (max-width: 820px) {
    .tree-wrap { padding: 24px 6px 12px; max-height: calc(100vh - 185px); }
    .tree li { padding: 26px 6px 0; }
    .tree .t-pill .t-ico { font-size: 26px; }
    .tree .t-pill .t-id { font-size: 8px; }
    .tree-popup { left: 50% !important; top: auto !important; bottom: 14px; transform: translateX(-50%); min-width: 240px; max-width: calc(100vw - 24px); }
}

/* ---------- misc components ---------- */
.profile-grid { display: grid; grid-template-columns: 180px 1fr; gap: 26px; }
.avatar-xl { width: 160px; height: 160px; border-radius: 50%; background: #eef3ec; border: 3px solid var(--accent); color: #000; display: flex; align-items: center; justify-content: center; font-size: 52px; font-weight: 400; }
.kv-table td { padding: 8px 6px; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.kv-table td:first-child { color: var(--ink-soft); width: 220px; font-weight: 400; }
.progress { height: 9px; border-radius: 6px; background: #e8ece6; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.chart-bars { display: flex; align-items: flex-end; gap: 5px; height: 150px; padding-top: 10px; }
.chart-bars .cb { flex: 1; background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; opacity: .85; }
.chart-bars .cb:hover { opacity: 1; }
.chart-bars .cb .cb-v { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--ink-soft); white-space: nowrap; }
.chart-bars .cb .cb-l { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 9.5px; color: var(--ink-soft); }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; align-items: start; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.ann-item { border-left: 3px solid var(--dash-gold); background: #fdfaf1; padding: 12px 16px; border-radius: 0 10px 10px 0; margin-bottom: 12px; }
.ann-item b { display: block; font-size: 13.5px; }
.ann-item p { font-size: 13px; color: var(--ink-soft); }
.ann-item .ann-date { font-size: 11px; color: #000; }
.plan-box { background: #f6faf5; border: 1px dashed #bcd6bd; border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; font-size: 13.5px; }
.plan-box b { color: #000; }
.timeline { border-left: 2px solid var(--line); margin-left: 8px; padding-left: 20px; }
.timeline .tl-item { position: relative; padding-bottom: 16px; }
.timeline .tl-item::before { content: ''; position: absolute; left: -27px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); }

/* cart */
.cart-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 22px; align-items: start; }
.qty-input { width: 64px; text-align: center; }
.shop-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: .2s; display: flex; flex-direction: column; }
.shop-card:hover { box-shadow: var(--shadow); border-color: #bcd6bd; }
.shop-card .sc-img { height: 170px; background: #f4f8f3; }
.shop-card .sc-img img { width: 100%; height: 100%; object-fit: cover; }
.shop-card .sc-body { padding: 14px; display: flex; flex-direction: column; flex: 1; }
.shop-card h4 { font-size: 13.5px; margin-bottom: 3px; }
.shop-card .sc-meta { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; }
.shop-card .sc-price { font-weight:400; color: #000; font-size: 15px; }
.shop-card .sc-price small { font-weight: 400; color: var(--ink-soft); }
.shop-card .sc-row { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 10px; }

/* responsive */
@media (max-width: 1200px) {
    :root { --sidebar-w: 196px; }
    .content { padding: 18px 20px; }
}
@media (max-width: 1000px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col, .cart-grid { grid-template-columns: 1fr; }
    .three-col { grid-template-columns: 1fr; }
    .content { padding: 16px; }
}
@media (max-width: 820px) {
    /* sidebar becomes an overlay drawer with a dim backdrop */
    .sidebar { transform: translateX(-100%); box-shadow: 14px 0 40px rgba(0,0,0,.25); z-index: 600; }
    .sidebar.open { transform: translateX(0); }
    .side-overlay { position: fixed; inset: 0; background: rgba(16, 58, 20, .55); z-index: 550;
                    opacity: 0; pointer-events: none; transition: opacity .25s ease; }
    .side-overlay.open { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }
    .menu-toggle { display: block; font-size: 20px; }
    .topbar { height: auto; min-height: 52px; padding: 0 14px; padding-top: env(safe-area-inset-top, 0px); gap: 10px; }
    .topbar .page-title { font-size: 15.5px; }
    .form-grid2, .form-grid3 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    .tb-user .tb-name, .tb-user .tb-role { display: none; }
    .tb-user .avatar { width: 32px; height: 32px; font-size: 12.5px; }
    .btn-logout { padding: 7px 12px; font-size: 12.5px; }
    /* shop cards + product rows stay readable */
    .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .shop-card .sc-img { height: 140px; }
    .shop-card .sc-row { flex-wrap: wrap; gap: 8px; }
    .qty-input { width: 56px; }
}
@media (max-width: 540px) {
    .stat-grid, .stat-grid.cols-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
    .content { padding: 12px; }
    .content-inner { padding: 14px; }
    .topbar { height: auto; min-height: 50px; padding: 0 12px; padding-top: env(safe-area-inset-top, 0px); gap: 8px; }
    .topbar .page-title { font-size: 14.5px; }
    .card { padding: 14px; border-radius: 10px; }
    .card-title { font-size: 14.5px; flex-wrap: wrap; gap: 8px; }
    table.table { font-size: 12.5px; }
    table.table th, table.table td { padding: 8px 8px; }
    .table-actions { flex-wrap: wrap; gap: 6px; }
    .btn { padding: 8px 12px; font-size: 12.5px; }
    .btn-sm { padding: 6px 10px; }
    .form-control { font-size: 13.5px; padding: 9px 11px; }
    /* single-column shop on small phones */
    .shop-grid { grid-template-columns: 1fr; }
    .shop-card .sc-img { height: 170px; }
    .shop-card .sc-row { align-items: stretch; }
    .shop-card .sc-row form { flex: 1; }
    .shop-card .sc-row .btn { flex: 1; }
    .stat-card b { font-size: 17px; }
    .stat-card .st-ico { width: 40px; height: 40px; font-size: 18px; }
    .stat-card { padding: 14px 14px; gap: 10px; }
}

/* ---------- typography: black text, normal weight everywhere ---------- */
h1, h2, h3, h4, h5, h6 { font-weight: 400; }
b, strong { font-weight: 400; }
th { font-weight: 400; }

/* generic status text colors */
.text-ok { color: #1d8a3e; font-weight: 400; }
.text-danger { color: #c62828; font-weight: 400; }

/* ================================================================== */
/*  Mobile UX & device compatibility layer                             */
/* ================================================================== */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.dash-body { overflow-x: hidden; }
* { -webkit-tap-highlight-color: rgba(0,0,0,0); }
a, button, .btn, input, select, textarea { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* iOS: no auto-zoom when focusing inputs */
@media (max-width: 820px) {
    .form-control, input[type=text], input[type=email], input[type=password],
    input[type=number], input[type=tel], input[type=date], input[type=search],
    input[type=url], select, textarea { font-size: 16px !important; }
    /* drawer: wider on phones, clear of the home indicator */
    .sidebar { width: min(280px, 84vw); padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .side-nav a { padding: 9px 10px; font-size: 13.5px; }
    .side-foot { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
    /* tree genealogy: maximum pan area on touch */
    .tree-wrap { max-height: calc(100vh - 205px); }
    .btn { min-height: 40px; }
}

@media (max-width: 540px) {
    .pagination li a, .pagination li span { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
    .table-wrap { -webkit-overflow-scrolling: touch; }
    .alert { font-size: 13px; padding: 11px 36px 11px 13px; }
    .empty-state { padding: 30px 14px; }
    .empty-state .es-ico { font-size: 32px; }
    .kv-table td { padding: 8px 8px; font-size: 12.5px; }
    .kv-table td:first-child { width: 40%; }
    /* card header actions move under the title, aligned left */
    .card-title { flex-wrap: wrap; }
    .card-title .right { margin-left: 0; width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
}

/* press feedback on touch devices */
@media (hover: none) {
    .btn:active { transform: scale(.98); }
    .side-nav a:active { background: #ffffff; }
    .stat-card:active, .shop-card:active { transform: scale(.99); }
}

/* ================================================================== */
/*  2026 mobile app layer — bottom tab bar, clean filters, no overflow */
/* ================================================================== */

html, body.dash-body { overflow-x: hidden; }
table.table td { overflow-wrap: break-word; }

/* form filters become a tidy grid on phones: two columns, one on small screens */
@media (max-width: 820px) {
    .filter-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 8px; align-items: stretch; margin-bottom: 14px; }
    .filter-form > .form-group { min-width: 0; margin-bottom: 0; }
    .filter-form > .btn { width: 100%; }
}
@media (max-width: 540px) {
    .filter-form { grid-template-columns: 1fr; }
}

/* app-style header on phones: nothing can overlap, ever */
@media (max-width: 820px) {
    .topbar { height: auto; min-height: 52px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); gap: 8px; box-shadow: 0 2px 12px rgba(22, 53, 26, .07); }
    .topbar .page-title { line-height: 1.3; }
    .topbar .tb-right { white-space: nowrap; }
    .menu-toggle:active { background: #eef3ec; }
}

/* ---- bottom tab bar: the distributor panel behaves like a native app ---- */
.app-tabbar { display: none; }
@media (max-width: 820px) {
    .app-tabbar {
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 700;
        background: #fff; border-top: 1px solid var(--line);
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -8px 28px rgba(22, 53, 26, .1);
    }
    .app-tabbar a {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-height: 54px; padding: 6px 2px; border-radius: 14px;
        font-size: 10.5px; color: var(--ink-soft); text-decoration: none;
        transition: color .15s ease, background .15s ease;
    }
    .app-tabbar a .t-ico { font-size: 21px; line-height: 1; }
    .app-tabbar a.active { color: var(--accent); background: #f2f7f2; font-weight: 500; }
    .app-tabbar a:active { transform: scale(.95); }
    /* keep page content clear of the bar */
    .content { padding-bottom: 88px; }
}

/* ================================================================== */
/*  Panel drawer fixes — tab bar no longer covers the open sidebar     */
/* ================================================================== */

/* while the sidebar is open it sits above the tab bar; the tab bar hides */
body.side-open .sidebar { z-index: 800; }
body.side-open .side-overlay { z-index: 760; }
body.side-open .app-tabbar { display: none; }

/* close button inside the sidebar header (mobile only) */
.side-close { display: none; }

@media (max-width: 820px) {
    .side-close {
        display: block; margin-left: auto; flex-shrink: 0;
        background: #eef3ec; border: 0; border-radius: 10px;
        width: 38px; height: 38px; font-size: 16px; line-height: 1;
        cursor: pointer; color: var(--ink);
    }
    .side-close:active { background: #dce9dc; }
    .sidebar { transition: transform .32s cubic-bezier(.2, .8, .3, 1); }
    .side-nav a { padding: 10px 10px; font-size: 14px; }
    .side-nav a:active { background: #fff; }
}

@media (max-width: 540px) {
    .side-nav a { padding: 12px 10px; font-size: 14.5px; }
    .side-brand { padding: 12px 10px; }
    .side-brand img { width: 34px; height: 34px; }
}

/* ================================================================== */
/*  PWA standalone: bottom edges for phones with home indicators       */
/* ================================================================== */

/* member popup in the genealogy tree clears the gesture bar */
.tree-popup { margin-bottom: env(safe-area-inset-bottom, 0px); }

/* ================================================================== */
/*  PWA standalone: landscape notches + guaranteed island clearance    */
/* ================================================================== */

/* landscape phones/tablets: notches on the sides */
@media (orientation: landscape) {
    .topbar {
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(14px, env(safe-area-inset-right, 0px));
    }
    .sidebar { padding-left: max(8px, env(safe-area-inset-left, 0px)); }
    .content { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}

/* ultimate guarantee: in installed-app mode nothing of the header may sit
   behind the cutout — applied with maximum specificity at phone widths */
@media (max-width: 820px) {
    .dash .main .topbar { padding-top: calc(8px + env(safe-area-inset-top, 0px)) !important; height: auto; }
    .dash .sidebar { padding-top: env(safe-area-inset-top, 0px) !important; }
    .app-tabbar { padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ================================================================== */
/*  no-data-cuts layer — long values wrap instead of being clipped    */
/* ================================================================== */

/* any cell / label / value can break long tokens (order no, user id,
   email, IFSC, sponsor names, currency amounts) */
table.table td, table.table th,
.kv-table td, .kv-table th { overflow-wrap: anywhere; }
.stat-card b, .stat-card span { overflow-wrap: anywhere; }
.card { min-width: 0; }
.table-wrap { max-width: 100%; }

/* badges inside tables never push past their cell */
.table .badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

/* tree member popup: long names / sponsors wrap, popup stays on screen */
.tree-popup { max-width: min(300px, 92vw); }
.tree-popup .t-tip-head { white-space: normal; overflow-wrap: anywhere; }
.tree-popup dd { white-space: normal; overflow-wrap: anywhere; }

/* summary table above the tree scrolls on its own on phones */
.tree-summary { margin-bottom: 14px; }

/* ---- plan page income diagrams (Direct Sponsor / Matching Bonus / Sponsor Bonus) ---- */
.plan-tree { display: flex; flex-direction: column; align-items: center; margin: 12px 0 4px; }
.pt-node { display: flex; flex-direction: column; align-items: center; gap: 1px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 7px 16px 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); text-align: center; }
.pt-node .pt-ico { font-size: 24px; line-height: 1; color: #2e7d32; }
.pt-node.you .pt-ico { color: #b8860b; }
.pt-node.you { box-shadow: 0 0 0 2px rgba(214, 168, 60, .45), 0 1px 3px rgba(0, 0, 0, .1); }
.pt-node .pt-name { font-size: 11.5px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.pt-node .pt-sub { font-size: 9.5px; color: var(--ink-soft); line-height: 1.3; }
.pt-stem { width: 2px; height: 20px; background: #b9c8b9; }
.pt-branch { position: relative; height: 24px; width: 260px; }
.pt-branch::before { content: ''; position: absolute; top: 0; left: 50%; width: 2px; height: 12px; margin-left: -1px; background: #b9c8b9; }
.pt-branch::after { content: ''; position: absolute; top: 12px; left: 25%; right: 25%; height: 2px; background: #b9c8b9; }
.pt-kids { display: flex; width: 260px; }
.pt-kid { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; }
.pt-kid::before { content: ''; width: 2px; height: 12px; background: #b9c8b9; }
.pt-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 2px; }
.pt-chip { font-size: 11px; background: #eef3ec; border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; color: var(--ink); white-space: nowrap; }
.pt-chip b { color: #103a14; }
.pt-chip.green { background: #edf7ed; border-color: #81c784; }
.pt-chip.gold { background: #fdf6e3; border-color: #d6a83c; }

/* ---- DataTables (sortable / searchable tables: All Distributors, My Team) ---- */
table.dataTable { width: 100% !important; margin: 0; }
table.dataTable thead th { position: relative; cursor: pointer; white-space: nowrap; -webkit-user-select: none; user-select: none; }
table.dataTable thead th:after { content: '\21C5'; opacity: .25; margin-left: 5px; font-size: 10px; }
table.dataTable thead th.sorting_asc:after { content: '\25B2'; opacity: .85; color: var(--accent); }
table.dataTable thead th.sorting_desc:after { content: '\25BC'; opacity: .85; color: var(--accent); }
table.dataTable thead th:hover { background: #eef3ec; }
.dataTables_wrapper { margin-top: 2px; }
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { margin: 10px 0; font-size: 12.5px; color: var(--ink-soft); }
.dataTables_wrapper .dataTables_length select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: #fff; font-size: 12.5px; margin: 0 4px; }
.dataTables_wrapper .dataTables_filter input { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; margin-left: 6px; }
.dataTables_wrapper .dataTables_filter input:focus { outline: 2px solid rgba(16, 58, 20, .25); border-color: var(--accent); }
.dataTables_wrapper .dataTables_info { font-size: 12px; color: var(--ink-soft); margin: 10px 0; }
.dataTables_wrapper .dataTables_paginate { margin: 10px 0; display: flex; gap: 4px; flex-wrap: wrap; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 11px; font-size: 12.5px; color: var(--ink) !important; cursor: pointer; text-decoration: none; }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { border-color: var(--accent); background: #eef3ec; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--accent); border-color: var(--accent); color: #fff !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: .4; cursor: default; }
table.dataTable td.dataTables_empty { text-align: center; padding: 26px; color: var(--ink-soft); }
