/* ── LAYOUT ─────────────────────────────── */
html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100%;
}

/* ── SIDEBAR (desktop ≥1024px) ───────────── */
.sidebar {
    width: var(--sidebar-w);
    border-right: 1px solid var(--border);
    background: var(--bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-name {
    font-family: 'Instrument Serif', serif;
    font-size: 1rem;
    color: var(--text);
    line-height: 1.4;
    display: block;
}

.brand-sub {
    font-size: 0.7143rem;
    color: var(--text3);
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 10px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-section-label {
    font-size: 0.7143rem;
    color: var(--text3);
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 10px 8px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text2);
    font-size: 0.9286rem;
    font-weight: 400;
    transition: color .15s, background .15s;
    user-select: none;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--text);
    background: var(--surface)
}

.nav-item.active {
    color: var(--text);
    background: var(--surface2)
}

.nav-item svg {
    width: 15px;
    height: 15px;
    opacity: .5;
    flex-shrink: 0
}

.nav-item.active svg {
    opacity: 1
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar-footer .status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 6px;
    animation: blink 2s infinite
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .3
    }
}

.status-txt {
    font-size: 0.7857rem;
    color: var(--text2)
}

/* ── TOP BAR (tablet 600–1023px) ────────── */
.topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    gap: 15px;
    overflow: hidden;
}

.topbar-brand {
    font-family: 'Instrument Serif', serif;
    font-size: 1.0714rem;
    color: var(--text);
}

.topbar-tabs {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 3px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.topbar-tabs::-webkit-scrollbar {
    display: none;
}

.topbar-tab {
    padding: 5px 12px;
    font-size: 0.8571rem;
    color: var(--text2);
    border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.topbar-tab.active {
    background: var(--surface2);
    color: var(--text)
}

/* ── BOTTOM NAV (mobile <600px) ─────────── */
.bottomnav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottomnav-h);
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottomnav-inner {
    display: flex;
    height: 100%;
}

.bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--text3);
    transition: color .15s;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: .01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bn-item.active {
    color: var(--text)
}

.bn-item svg {
    width: 18px;
    height: 18px
}

/* ── MAIN CONTENT ───────────────────────── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.content {
    flex: 1;
    max-width: 1000px;
    width: 100%;
    padding: 0;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tab-section {
    flex: 1;
    display: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
    position: relative;
    padding-bottom: 80px !important;
}

.tab-section.active {
    display: block !important;
}

/* ── PAGE HEADER ────────────────────────── */
.page-hd {
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-family: 'Instrument Serif', serif;
    font-size: 1.7143rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 4px;
}

.page-desc {
    font-size: 0.9286rem;
    color: var(--text2)
}

/* ════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════ */

/* ── MOBILE (max-width: 480px) ─────────── */
@media(max-width:480px) {

    .sidebar,
    .topbar {
        display: none !important;
    }

    .bottomnav {
        display: block;
    }

    .bn-item span {
        display: none;
    }

    .bn-item svg {
        width: 24px;
        height: 24px;
        margin-bottom: 0;
    }

    .main {
        margin-left: 0;
        height: auto;
        overflow: visible;
        padding-top: 0;
        padding-bottom: var(--bottomnav-h);
    }

    .content {
        padding: 0;
        max-width: 100%;
        height: auto;
        overflow: visible;
    }

    .tab-section {
        padding: 12px 12px 20px !important;
        font-size: 0.9rem;
        height: auto;
        overflow: visible;
        position: relative;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .metrics {
        grid-template-columns: 1fr;
        gap: 8px;
        border: none;
    }

    .metric {
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    .block-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px;
    }

    .block-head>div {
        width: 100%;
        justify-content: space-between;
    }

    .block-body {
        padding: 12px;
    }

    .contacts-grid,
    .users-grid,
    .broadcast-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .cost-strip {
        flex-direction: column;
        gap: 6px;
    }

    input[type=text],
    input[type=password],
    textarea,
    select {
        font-size: 1rem;
        padding: 10px;
        width: 100%;
    }

    .btn {
        min-height: 44px;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .row-item {
        flex-wrap: wrap;
    }

    .table-wrap {
        overflow-x: auto;
    }
}

/* ── TABLET (481px - 768px) ────────────── */
@media(min-width:481px) and (max-width:768px) {

    .sidebar,
    .topbar {
        display: none !important;
    }

    .bottomnav {
        display: block;
    }

    .main {
        margin-left: 0;
        height: auto;
        overflow: visible;
        padding-bottom: var(--bottomnav-h);
    }

    .content {
        padding: 0;
        max-width: 100%;
        height: auto;
        overflow: visible;
    }

    .tab-section {
        padding: 16px 16px 20px !important;
        height: auto;
        overflow: visible;
        position: relative;
    }

    .metrics {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        border: none;
    }

    .metric {
        padding: 16px;
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    .metric:last-child {
        grid-column: span 2;
    }

    .bn-item span {
        display: none !important;
    }

    .contacts-grid,
    .users-grid,
    .broadcast-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .btn {
        min-height: 44px;
    }

    .table-wrap {
        overflow-x: auto;
    }
}

/* ── SMALL LAPTOP (769px - 1024px) ─────── */
@media(min-width:769px) and (max-width:1024px) {

    .topbar,
    .bottomnav {
        display: none !important;
    }

    .sidebar {
        width: var(--sidebar-w-collapsed);
        display: flex;
    }

    .sidebar-brand {
        padding: 18px 0;
        text-align: center;
        justify-content: center;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .brand-name,
    .brand-sub,
    .nav-section-label,
    .sidebar-footer .status-row,
    .sidebar-footer button span {
        display: none !important;
    }
    .sidebar-footer {
        padding: 15px 0;
        align-items: center;
    }
    .sidebar-footer button {
        width: 40px !important;
        height: 40px;
        padding: 0 !important;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-brand::after {
        content: "📞";
        font-size: 1.5rem;
        display: block;
    }

    .nav-item {
        justify-content: center;
        padding: 12px 0;
        font-size: 0;
        gap: 0;
    }

    .nav-item svg {
        width: 22px;
        height: 22px;
        margin: 0;
    }

    .sidebar-footer {
        padding: 20px 0;
        display: flex;
        justify-content: center;
    }

    .dot {
        margin: 0;
    }

    .main {
        margin-left: var(--sidebar-w-collapsed);
    }

    .content {
        padding: 0;
        max-width: 100%;
    }

    .tab-section {
        padding: 20px !important;
    }

    .contacts-grid,
    .users-grid {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: 20px;
    }

    .broadcast-grid {
        display: grid;
        grid-template-columns: 1fr 320px;
        gap: 20px;
        align-items: start;
    }

    .broadcast-side {
        position: sticky;
        top: 0;
    }

    .broadcast-side .controls-row>* {
        min-width: 130px;
    }

    .btn {
        min-height: 44px;
    }

    .table-wrap {
        overflow-x: auto;
    }
}

/* ── DESKTOP (1025px and above) ────────── */
@media(min-width:1025px) {

    .topbar,
    .bottomnav {
        display: none !important;
    }

    .sidebar {
        width: var(--sidebar-w);
        display: flex;
    }

    .main {
        margin-left: var(--sidebar-w);
    }

    .content {
        max-width: 1200px;
    }

    .tab-section {
        padding: 24px !important;
    }

    .contacts-grid,
    .users-grid {
        display: grid;
        grid-template-columns: 320px 1fr;
        gap: 20px;
    }

    .broadcast-grid {
        display: grid;
        grid-template-columns: 1fr 340px;
        gap: 20px;
        align-items: start;
    }

    .broadcast-side {
        position: sticky;
        top: 0;
    }

    .btn {
        min-height: 44px;
    }

    .table-wrap {
        overflow-x: auto;
    }
}

/* Extra large: cap content width nicely */
@media(min-width:1400px) {
    .tab-section {
        padding-left: 40px !important;
        padding-right: 40px !important;
    }
}

.dir-block {
    display: flex;
    flex-direction: column;
}

.dir-block .table-wrap {
    overflow-y: auto;
    max-height: 55vh;
}

@media(min-width: 2560px) {
    .content {
        max-width: 1400px !important;
        margin: 0 auto;
    }
}

/* ── MOBILE / TABLET OVERRIDES (enable browser chrome hiding) ── */
@media(max-width: 768px) {
    html, body {
        height: auto !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .app {
        height: auto !important;
        display: block !important;
    }
    .bn-item span {
        display: none !important;
    }
}
/* ── WALLET VISIBILITY ───────────────────── */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }
}
