/* Mustware Network - graphite + signal red (deliberately unlike PMS's navy/teal) */
:root {
    --ink: #16181D;
    --ink-2: #1E2128;
    --ink-3: #2A2E37;
    --red: #E5243B;
    --red-dark: #C8102E;
    --red-deep: #9E0C24;
    --red-light: #FF5A68;
    --red-soft: #FDECEE;
    --page-bg: #F5F5F4;
    --line: #E7E5E4;
    --muted: #71717A;
    --sidebar-w: 244px;

    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-font-size: .9375rem;
    --bs-body-color: #1C1917;
    --bs-body-bg: var(--page-bg);
    --bs-border-color: var(--line);
    --bs-primary: #E5243B;
    --bs-primary-rgb: 229, 36, 59;
    --bs-link-color: #C8102E;
    --bs-link-color-rgb: 200, 16, 46;
    --bs-link-hover-color: #9E0C24;
    --bs-link-hover-color-rgb: 158, 12, 36;
    --bs-border-radius: .375rem;
    --bs-border-radius-lg: .5rem;
    --bs-focus-ring-color: rgba(229, 36, 59, .22);
}

body { font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; }
h1, .h1, .h2, .h3, .h4, .h5, .page-head h1, .brand-a, .brand-b {
    font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}
h1, .h1, .h2, .h3, .h4, .h5 { font-weight: 600; letter-spacing: -.025em; color: #0C0A09; }

/* ---------- layout ---------- */
.app-sidebar {
    width: var(--sidebar-w);
    background: var(--ink) !important; /* offcanvas-md forces transparent on desktop */
    --bs-offcanvas-width: var(--sidebar-w);
    color: #A1A1AA;
    border-right: 1px solid #000;
}
.app-sidebar::before { /* thin signal-red line on the left edge */
    content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
    background: linear-gradient(180deg, var(--red-light), var(--red-dark) 60%, transparent);
}
@media (min-width: 768px) {
    .app-sidebar { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; }
    .app-main { margin-left: var(--sidebar-w); }
}
.app-sidebar .offcanvas-body { display: flex; flex-direction: column; height: 100%; padding: 0; }
.app-brand { display: flex; align-items: center; gap: .65rem; padding: 1.4rem 1.2rem 1.3rem; text-decoration: none; font-size: 1.08rem; white-space: nowrap; }
.app-brand img { border-radius: 9px; }
.brand-a { font-weight: 700; color: #fff; letter-spacing: -.03em; }
.brand-b { font-weight: 500; color: var(--red-light); letter-spacing: -.02em; }
.nav-section { font-size: .66rem; text-transform: uppercase; letter-spacing: .14em; color: #5B5F6B; padding: 1.1rem 1.35rem .45rem; font-weight: 600; }
.app-nav a {
    position: relative; display: flex; align-items: center; gap: .75rem;
    margin: 1px .7rem; padding: .55rem .8rem; border-radius: .375rem;
    color: #B4B7C0; text-decoration: none; font-weight: 500;
}
.app-nav a i { font-size: 1.05rem; opacity: .75; }
.app-nav a:hover { background: var(--ink-2); color: #fff; }
.app-nav a.active { background: var(--ink-3); color: #fff; }
.app-nav a.active::before { content: ''; position: absolute; left: -.7rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.app-nav a.active i { color: var(--red-light); opacity: 1; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: .1rem .48rem; box-shadow: 0 0 0 3px rgba(229, 36, 59, .25); }
.app-user { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid #23262E; font-size: .85rem; }
.app-user .avatar { flex: none; width: 32px; height: 32px; border-radius: 8px; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; }
.app-user button, .app-user a { color: #8B8F99 !important; }
.app-user button:hover, .app-user a:hover { color: #fff !important; }

.app-topbar { background: var(--ink); padding: .6rem 1rem; border-bottom: 2px solid var(--red); }
.app-content { padding: 2rem 2.4rem 4rem; max-width: 1500px; }
@media (max-width: 767.98px) { .app-content { padding: 1.25rem 1rem 3rem; } }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .75rem; margin-bottom: 1.6rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); position: relative; }
.page-head::after { content: ''; position: absolute; left: 0; bottom: -1px; width: 56px; height: 2px; background: var(--red); }
.page-head h1 { font-size: 1.75rem; margin: 0; font-weight: 600; }
h2.h5 { font-weight: 600; }
.text-muted { color: var(--muted) !important; }

/* ---------- cards ---------- */
.card { --bs-card-bg: #fff; background: #fff; border: 1px solid var(--line); border-radius: .5rem; box-shadow: 0 1px 0 rgba(12, 10, 9, .03) !important; }
.card-header { background: #fff; border-bottom: 1px solid var(--line); padding: .8rem 1.1rem; font-weight: 600; }
.card-header.bg-danger-subtle { background: var(--red-soft) !important; color: #7F0D1F; border-bottom-color: #F8C9CF; }
.card-header.bg-warning-subtle { background: #FFF7E6 !important; color: #8A5A00; }
.card.border-warning { border-color: #F2CF86 !important; }
.card.border-danger { border-color: #F3A9B2 !important; box-shadow: 0 0 0 3px rgba(229, 36, 59, .06) !important; }
.card.border-success { border-color: #A7E3C4 !important; }
.card-body { padding: 1.1rem; }
.card-footer { border-top: 1px solid var(--line); padding: .7rem 1.1rem; }
a.card:hover { border-color: #D6D3D1; }
.card-body > .text-muted.small:first-child { text-transform: uppercase; letter-spacing: .08em; font-size: .68rem !important; font-weight: 600; }
.card-body > .text-muted.small + .fs-3 { font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 600 !important; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.list-group-item { border-color: #F0EEEC; }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { background-color: transparent; }
.table > thead th {
    background: #FAFAF9; color: var(--muted); font-size: .68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); padding: .7rem 1rem; white-space: nowrap;
}
.table > tbody td { padding: .7rem 1rem; border-color: #F0EEEC; }
.table-sm > tbody td, .table-sm > thead th { padding: .5rem .75rem; }
.table > tbody tr:hover > * { background: #FCFBFA; }
.card > .table-responsive:first-child, .card > .table-responsive:first-child .table thead th:first-child { border-top-left-radius: .5rem; border-top-right-radius: .5rem; }
.empty { text-align: center; padding: 3rem 1rem !important; color: var(--muted); }
.empty i { display: block; font-size: 2rem; color: #D6D3D1; margin-bottom: .5rem; }

/* ---------- buttons & forms ---------- */
.btn { font-weight: 500; border-radius: .375rem; padding: .5rem .95rem; }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-primary { --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red); --bs-btn-hover-bg: var(--red-dark); --bs-btn-hover-border-color: var(--red-dark); --bs-btn-active-bg: var(--red-deep); --bs-btn-active-border-color: var(--red-deep); --bs-btn-disabled-bg: var(--red); --bs-btn-disabled-border-color: var(--red); box-shadow: 0 1px 2px rgba(200, 16, 46, .25); }
.btn-outline-secondary { --bs-btn-color: #3F3F46; --bs-btn-border-color: #D6D3D1; --bs-btn-hover-bg: #F5F5F4; --bs-btn-hover-color: #0C0A09; --bs-btn-hover-border-color: #C7C3C0; --bs-btn-active-bg: #EDEBE9; --bs-btn-active-color: #0C0A09; }
.btn-outline-primary { --bs-btn-color: var(--red-dark); --bs-btn-border-color: #F3B3BB; --bs-btn-hover-bg: var(--red); --bs-btn-hover-border-color: var(--red); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--red-dark); }
.btn-outline-danger { --bs-btn-color: #B91C1C; --bs-btn-border-color: #F3B3BB; }
.btn-group .btn-primary { box-shadow: none; }
.form-control, .form-select { border-color: #D6D3D1; border-radius: .375rem; }
.form-control:focus, .form-select:focus { border-color: var(--red); box-shadow: 0 0 0 .2rem rgba(229, 36, 59, .14); }
.form-check-input:checked { background-color: var(--red); border-color: var(--red); }
.form-check-input:focus { border-color: var(--red); box-shadow: 0 0 0 .2rem rgba(229, 36, 59, .14); }
.form-label { font-weight: 500; font-size: .85rem; color: #3F3F46; }
.form-text { color: var(--muted); }
code { color: var(--red-dark); background: var(--red-soft); padding: .05rem .3rem; border-radius: .25rem; }
.secret-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; letter-spacing: .04em; }
td .btn-sm { white-space: nowrap; }

/* ---------- badges & alerts ---------- */
.badge { font-weight: 600; padding: .38em .65em; border-radius: .3rem; letter-spacing: .01em; }
.badge.text-bg-success { background: #DCFCE7 !important; color: #166534 !important; }
.badge.text-bg-warning { background: #FEF3C7 !important; color: #92400E !important; }
.badge.text-bg-danger { background: var(--red) !important; color: #fff !important; }
.badge.text-bg-info { background: #E0F2FE !important; color: #075985 !important; }
.badge.text-bg-primary { background: var(--red-soft) !important; color: var(--red-dark) !important; }
.badge.text-bg-secondary { background: #F4F4F5 !important; color: #52525B !important; }
.badge.text-bg-light { background: #F5F5F4 !important; color: #3F3F46 !important; font-weight: 500; }
.alert { border-radius: .5rem; border-width: 1px; border-left-width: 4px; }
.alert-success { background: #F0FDF4; border-color: #86EFAC; color: #166534; }
.alert-danger { background: var(--red-soft); border-color: #F3A9B2; border-left-color: var(--red); color: #7F0D1F; }
.alert-warning { background: #FFFBEB; border-color: #FCD34D; color: #78350F; }
.pagination { --bs-pagination-active-bg: var(--red); --bs-pagination-active-border-color: var(--red); --bs-pagination-color: var(--red-dark); --bs-pagination-hover-color: var(--red-deep); --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(229, 36, 59, .14); }

/* ---------- status ---------- */
.dot { display: inline-block; width: .58rem; height: .58rem; border-radius: 50%; background: #D6D3D1; vertical-align: middle; }
.dot-ok { background: #16A34A; box-shadow: 0 0 0 3px rgba(22, 163, 74, .16); }
.dot-bad { background: var(--red); box-shadow: 0 0 0 3px rgba(229, 36, 59, .2); animation: pulse 1.6s ease-in-out infinite; }
.dot-off { background: #D6D3D1; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(229, 36, 59, .05); } }
@media (prefers-reduced-motion: reduce) { .dot-bad { animation: none; } }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .38rem 1.1rem; font-size: .9rem; }
dl.kv dt { font-weight: 500; color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.label-input { border-color: transparent; background: transparent; min-width: 11rem; font-weight: 500; }
.label-input:hover, .label-input:focus { border-color: #D6D3D1; background: #fff; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--ink); color: #A1A1AA; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side > * { position: relative; z-index: 1; }
.auth-side h2 { color: #fff; font-size: 2.3rem; font-weight: 600; letter-spacing: -.035em; max-width: 24rem; line-height: 1.12; }
.auth-side .net { position: absolute; right: -60px; bottom: -60px; width: 460px; height: 460px; z-index: 0; }
.auth-form { display: grid; place-items: center; padding: 2rem 1.25rem; background: #fff; }
.auth-form form { width: 100%; max-width: 360px; }
@media (max-width: 767.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ---------- home-screen app (iOS standalone): graphite frame around a light panel, clear of the status-bar fade ---------- */
@media (display-mode: standalone) {
    html, body { background: var(--ink); }
    .app-main { padding-top: calc(env(safe-area-inset-top, 0px) + 26px); }
    .app-content { background: var(--page-bg); min-height: calc(100vh - env(safe-area-inset-top, 0px) - 26px); max-width: none; }
    .app-topbar { padding-top: calc(env(safe-area-inset-top, 0px) + 26px); }
    .app-sidebar .offcanvas-body { padding-top: env(safe-area-inset-top, 0px); }
}
@media (display-mode: standalone) and (min-width: 768px) { .app-content { border-top-left-radius: 14px; } }
@media (display-mode: standalone) and (max-width: 767.98px) {
    .app-sidebar .offcanvas-body { padding-top: calc(env(safe-area-inset-top, 0px) + 26px); }
    .app-main { padding-top: 0; }
    .app-content { min-height: 100vh; }
}

/* ---------- device categories ---------- */
.cat-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.cat-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .32rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #3F3F46; text-decoration: none; font-size: .84rem; font-weight: 500; }
.cat-chip b { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-chip:hover { border-color: #D6D3D1; color: #0C0A09; }
.cat-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.cat-chip.active b { color: var(--red-light); }
.cat-chip.active i { color: var(--red-light); }
.cat-form { display: flex; align-items: center; gap: .45rem; }
.cat-icon { font-size: 1.05rem; color: var(--red-dark); width: 1.1rem; text-align: center; }
.cat-select { width: auto; min-width: 9.5rem; border-color: transparent; background-color: transparent; padding-left: .4rem; font-size: .84rem; }
.cat-select:hover, .cat-select:focus { border-color: #D6D3D1; background-color: #fff; }
.cat-static { display: inline-flex; align-items: center; gap: .45rem; font-size: .86rem; }
.fix-ip { font-size: .76rem; color: var(--muted); text-decoration: none; opacity: 0; }
tr:hover .fix-ip, .fix-ip:focus { opacity: 1; color: var(--red-dark); }
@media (hover: none) { .fix-ip { opacity: 1; } }
.access-btn { color: var(--muted); }
.access-btn:hover { color: var(--red-dark); }
.acc-table td { border: 0; padding: .25rem .3rem; }
.form-switch .form-check-input { width: 2.4em; }
.meter { height: 6px; border-radius: 3px; background: #EEECEA; overflow: hidden; display: inline-block; width: calc(100% - 3rem); vertical-align: middle; margin-right: .4rem; }
.meter > span { display: block; height: 100%; background: #16A34A; }
.meter > span.warn { background: #F59E0B; }
.meter > span.bad { background: var(--red); }
