/* BdREN Voltage & Temperature Monitor - layout and polish on top of Bootstrap 3 + w3.css.
   Status colours stay the w3 classes (w3-green / w3-yellow / w3-red); nothing here overrides them. */

:root {
    --brand: #006f2d;
    --brand-teal: #009688;
    --navy: #001a33;
    --head: #607d8b;
    --ink: #1f2933;
    --muted: #6b7785;
    --line: #e3e7ec;
    --bg: #f4f6f8;
    --card: #ffffff;
    --sidebar-w: 230px;
    --header-h: 64px;
}

html, body { background: var(--bg); color: var(--ink); }
body { font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; }
a { color: #1a6fb0; }

/* no slide animation while the saved sidebar state is restored on page load */
.preload * { transition: none !important; }

/* ---------------------------------------------------------------- header */
.app-header {
    position: sticky; top: 0; z-index: 1030;
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 16px;
    background: #fff;
}
.app-header__left, .app-header__right { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.app-burger { padding: 6px 14px !important; font-size: 20px; border-radius: 4px; }
.app-brand img { height: 42px; width: auto; display: block; }
.app-title {
    margin: 0; flex: 1 1 auto; text-align: center;
    color: var(--brand); font-size: clamp(15px, 2.2vw, 28px); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-user { display: flex; align-items: center; gap: 6px; max-width: 220px; }
.app-user__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user__role {
    font-size: 11px; background: rgba(255, 255, 255, .25); border-radius: 8px; padding: 0 6px;
}

/* ---------------------------------------------------------------- sidebar */
.app-sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 1020;
    width: var(--sidebar-w);
    background: aliceblue;
    padding: 12px 10px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .2s ease;
}
.sidebar-open .app-sidebar { transform: none; }
.app-nav {
    display: block; width: 100%; margin-bottom: 6px; padding: 10px 14px;
    border: 0; border-radius: 4px; text-align: left;
    background: #337ab7; color: #fff; font-size: 14px;
}
.app-nav:hover, .app-nav:focus { background: #286090; color: #fff; text-decoration: none; }
.app-nav.active { background: var(--navy); }
.app-nav--action { background: #5cb85c; margin-top: 14px; }
.app-nav--action:hover { background: #449d44; }
.app-backdrop { display: none; }
.sidebar-overlay .app-backdrop {
    display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 1010; background: rgba(0, 0, 0, .35);
}

.app-main { padding: 20px 24px 0; transition: margin-left .2s ease; min-height: calc(100vh - var(--header-h)); }
@media (min-width: 992px) {
    .sidebar-open .app-main { margin-left: var(--sidebar-w); }
}

.app-footer { text-align: right; padding: 24px 0; color: var(--muted); }
.app-footer a { color: green; }

/* ---------------------------------------------------------------- modals */
.app-modal-header { background: var(--navy); color: #fff; border-radius: 5px 5px 0 0; }
.app-modal-header .close { color: #ff6b6b; opacity: .9; text-shadow: none; }
@media (min-width: 768px) { .modal-sm-md { width: 420px; } }
.modal-footer .btn + .btn { margin-left: 6px; }
.btn-group-justified .btn.active { background: var(--brand-teal); border-color: var(--brand-teal); color: #fff; }

/* ---------------------------------------------------------------- toolbar: summary + search */
.vt-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom: 14px;
}
.vt-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.vt-chip {
    display: inline-flex; align-items: baseline; gap: 4px;
    padding: 3px 10px; border-radius: 14px;
    background: #fff; border: 1px solid var(--line); font-size: 12px; color: var(--muted);
    white-space: nowrap;
}
.vt-chip b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.vt-chip--up b { color: #2e7d32; }
.vt-chip--down b { color: #c62828; }
.vt-chip--alert { border-color: #f44336; }
.vt-chip--alert b { color: #f44336; }
.vt-chip--warn { border-color: #e0c200; }
.vt-chip--warn b { color: #9a7d00; }
.vt-chip.is-zero { border-color: var(--line); }
.vt-chip.is-zero b { color: var(--muted); }
.vt-updated { font-size: 12px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.vt-search { display: flex; gap: 6px; align-items: center; }
.vt-search input { width: 220px; }
#muteBtn { display: inline-flex; align-items: center; gap: 4px; }
#muteBtn.is-off { color: var(--muted); }
#muteBtn.is-blocked { border-color: #f0ad4e; }
.sound-level { font-size: 11px; font-variant-numeric: tabular-nums; min-width: 26px; text-align: left; }
.sound-panel { width: 230px; padding: 12px 14px; z-index: 1025; }
.sound-row span { white-space: nowrap; }
.sound-row { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; font-weight: 500; }
.sound-switch { width: 18px; height: 18px; margin: 0 !important; cursor: pointer; }
.sound-panel input[type=range] { width: 100%; margin: 0 0 12px; accent-color: var(--brand-teal); }
.sound-hint { margin: 8px 0 0; font-size: 11px; color: var(--muted); line-height: 1.35; }

/* ---------------------------------------------------------------- tables */
.vt-panel { margin-bottom: 20px; }
.vt-panel__title {
    margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: #1e8449; text-align: center;
}
.vt-count {
    display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 4px; border-radius: 10px;
    background: #e8f5e9; color: #1e8449; font-size: 11px; letter-spacing: 0;
}
.vt-table-wrap, .card-table {
    background: var(--card); border: 1px solid var(--line); border-radius: 6px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    margin-bottom: 0;
}
.vt-table { margin-bottom: 0; }
.vt-table > thead > tr > th, .card-table .table > thead > tr > th {
    padding: 9px 8px; border-bottom: 0; text-align: center; white-space: nowrap;
    font-weight: 600; font-size: 13px;
}
.vt-table > tbody > tr > td {
    padding: 7px 8px; text-align: center; vertical-align: middle;
    border-top: 1px solid rgba(0, 0, 0, .06);
    font-variant-numeric: tabular-nums;
}
.vt-table > tbody > tr:nth-child(even) > td:not([class*="w3-"]) { background: #f8f9fa; }
.vt-table > tbody > tr:hover > td:not([class*="w3-"]) { background: #eef3f7; }
.vt-table td.vt-site, .vt-table th.vt-site { text-align: left; }
.vt-site a { font-weight: 500; }
.vt-time { color: var(--muted); white-space: nowrap; }
.vt-device { display: block; font-size: 11px; color: var(--muted); }
.vt-badge {
    display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 3px;
    font-size: 10px; font-weight: 700; letter-spacing: .04em; vertical-align: middle;
}
.vt-badge--down { background: #c62828; color: #fff; }
.vt-badge--up { background: #2e7d32; color: #fff; }
.vt-badge--alert { background: #fff; color: #d32f2f; box-shadow: inset 0 0 0 1px #f44336; }
.vt-badge--warn { background: #fff8c4; color: #7a6200; box-shadow: inset 0 0 0 1px #e0c200; }
.vt-badge--muted { background: #e0e0e0; color: #555; }

.card-table .table { margin-bottom: 0; }
.card-table .table > tbody > tr > td { vertical-align: middle; }
.page-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom: 14px;
}
.page-head h2 { margin: 0; font-size: 20px; color: var(--brand); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.filters .form-group { margin: 0; }
.filters label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat {
    background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
}
.stat__label { font-size: 12px; color: var(--muted); }
.stat__value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.icon-btn { padding: 4px 8px; }
.icon-btn img { width: 18px; height: 18px; }
.text-nowrap { white-space: nowrap; }
.perm-list label { font-weight: 400; margin-right: 12px; }
.json-diff { font-size: 12px; color: var(--muted); max-width: 420px; word-break: break-word; }
.rules-card { padding: 14px 16px 6px; margin-bottom: 16px; }
.rules-card__title { margin: 0 0 10px; font-size: 16px; font-weight: 600; color: var(--brand); }
.rules-group { margin-bottom: 14px; }
.rules-group__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.rules-group .form-group { margin-bottom: 6px; }
.rules-group label { font-weight: 500; color: var(--ink); min-height: 30px; display: block; line-height: 1.25; }
.rules-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.rules-bar span { display: block; height: 100%; }
.rules-scale { position: relative; height: 16px; font-size: 10px; color: var(--muted); }
.rules-scale i { position: absolute; top: 2px; transform: translateX(-50%); font-style: normal; white-space: nowrap; }
.rules-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.down-now { margin: 8px 0 0; padding: 8px 12px; width: 100%; }
.down-raw { display: block; font-size: 11px; color: var(--muted); font-family: Consolas, monospace; word-break: break-word; }
.down-now .down-raw { color: #a94442; opacity: .8; }
.reasons-box { padding: 10px 14px 4px; margin-bottom: 14px; }
.reasons-box ul { margin: 4px 0 6px; padding-left: 18px; }
.vt-reason { min-width: 220px; font-size: 12px; }
.vt-table tr:has(.js-view) { cursor: pointer; }
.vt-table th.col-action, .vt-table td.col-action { width: 70px; white-space: nowrap; }
.detail-list { margin: 0; }
.detail-list dt { font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 10px; }
.detail-list dd { font-size: 14px; }
.detail-values { display: flex; gap: 6px; margin-top: 4px; }
.detail-values > div { flex: 1; text-align: center; padding: 8px 4px; border-radius: 4px; }
.detail-values small { display: block; font-size: 11px; opacity: .85; }
.detail-values b { font-size: 16px; font-variant-numeric: tabular-nums; }
.detail-reason { margin: 4px 0 0; padding: 8px 10px; }
.pager-bar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0;
}
.pager-bar .pagination { margin: 0; }
.uptime-bar { height: 6px; background: #f44336; border-radius: 3px; overflow: hidden; min-width: 60px; }
.uptime-bar span { display: block; height: 100%; background: #4caf50; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 767px) {
    :root { --header-h: 56px; }
    .app-header { padding: 0 10px; gap: 8px; }
    .app-brand img { height: 32px; }
    .app-user__role, .app-user__name { display: none; }
    .app-main { padding: 12px 10px 0; }
    .vt-toolbar { flex-direction: column; align-items: stretch; }
    .vt-search input { width: 100%; }
    .vt-search { order: -1; }
    .vt-table > thead > tr > th { padding: 7px 4px; font-size: 12px; }
    .vt-table > tbody > tr > td { padding: 6px 4px; font-size: 13px; }
    .vt-table .vt-site { max-width: 120px; overflow-wrap: anywhere; }
    .page-head h2 { font-size: 17px; }
    .filters > * { flex: 1 1 140px; }
}
@media (max-width: 400px) {
    .vt-chip { padding: 2px 7px; }
    .vt-time { font-size: 11px; }
}

/* ---------------------------------------------------------------- icons + NetWatch top-bar entries (pages: css/sw.css) */
.ic { width: 16px; height: 16px; flex: 0 0 auto; vertical-align: -3px; }
.nw-top { display: flex; align-items: center; gap: 6px; }
.nw-top__btn {
    display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
    border: 1px solid #d5dbe3; border-radius: 6px; background: #fff;
    color: #10233a; font-size: 13px; font-weight: 600; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.nw-top__btn .ic { color: #f47b20; }
.nw-top__btn:hover, .nw-top__btn:focus { border-color: #10233a; color: #10233a; text-decoration: none; background: #f5f7fa; }
.nw-top__btn.active { background: #10233a; border-color: #10233a; color: #fff; }
.nw-top__btn.active .ic { color: #ffa45c; }
.nw-top__short { display: none; }

/* ---------------------------------------------------------------- NetWatch down alert popup (js/nw-alerts.js), every page */
.nw-pop-wrap {
    position: fixed; inset: 0; z-index: 2000; display: flex; align-items: flex-start; justify-content: center;
    padding: 80px 16px 16px; background: rgba(15, 23, 42, .45);
}
.nw-pop {
    width: 520px; max-width: 100%; max-height: calc(100vh - 100px); display: flex; flex-direction: column;
    background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
    animation: nw-pop-in .2s ease-out;
}
@keyframes nw-pop-in { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
.nw-pop__head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 18px; background: #c62828; color: #fff; }
.nw-pop__head > .ic { width: 28px; height: 28px; flex: 0 0 auto; }
.nw-pop.is-ringing .nw-pop__head > .ic { animation: nw-pop-shake .5s ease-in-out infinite; }
@keyframes nw-pop-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.nw-pop__head b { display: block; font-size: 17px; line-height: 1.25; }
.nw-pop__head small { display: block; font-size: 12px; opacity: .85; }
.nw-pop__x { margin-left: auto; border: 0; background: rgba(255, 255, 255, .15); color: #fff; width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.nw-pop__x:hover { background: rgba(255, 255, 255, .3); }
.nw-pop__list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.nw-pop__list li { padding: 10px 18px; border-bottom: 1px solid #f1d4d4; background: #fff7f7; }
.nw-pop__name { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.nw-pop__name a { font-size: 16px; font-weight: 700; color: #a11919; }
.nw-pop__ip { font-family: Consolas, monospace; font-size: 12.5px; color: #4b5563; }
.nw-pop__meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12.5px; color: #4b5563; margin-top: 2px; }
.nw-pop__err { margin-top: 4px; font-size: 12px; color: #8a1c1c; font-family: Consolas, monospace; }
.nw-pop__hint:not(:empty) { padding: 8px 18px; font-size: 12.5px; background: #fff6dc; color: #6b4e00; }
.nw-pop__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid #eceef1; }
.nw-pop__spacer { flex: 1 1 auto; }
.nw-pop__btn {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid #d5dbe3; border-radius: 6px;
    background: #fff; color: #10233a; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.nw-pop__btn:hover, .nw-pop__btn:focus { background: #f3f6f9; color: #10233a; text-decoration: none; }
.nw-pop__btn--primary { background: #10233a; border-color: #10233a; color: #fff; }
.nw-pop__btn--primary:hover, .nw-pop__btn--primary:focus { background: #1d3756; color: #fff; }
.nw-pop__mute { margin: 0; font-size: 12.5px; font-weight: 500; color: #4b5563; display: inline-flex; align-items: center; gap: 5px; }
.nw-pop__mute input { margin: 0; }
@media (max-width: 767px) {
    .nw-pop-wrap { padding-top: 66px; }
    .nw-pop__btn span { display: none; }
}

/* ---------------------------------------------------------------- sidebar groups */
.nav-group { margin-bottom: 10px; }
.nav-group__head {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    margin: 0 0 6px; padding: 4px 4px 4px 2px; border: 0; background: none;
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #46607a;
}
.nav-group__head:hover { color: var(--navy); }
.nav-group__caret { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; transition: transform .15s ease; }
.nav-group.is-closed .nav-group__caret { transform: rotate(-90deg); }
.nav-group.is-closed .nav-group__items { display: none; }
.nav-group[data-group="sw"] .app-nav { background: #10233a; }
.nav-group[data-group="sw"] .app-nav:hover, .nav-group[data-group="sw"] .app-nav:focus { background: #1d3756; }
.nav-group[data-group="sw"] .app-nav.active { background: #f47b20; }
.nav-group[data-group="admin"] .app-nav { background: #546e7a; }
.nav-group[data-group="admin"] .app-nav:hover, .nav-group[data-group="admin"] .app-nav:focus { background: #455a64; }
.nav-group[data-group="admin"] .app-nav.active { background: var(--navy); }
.nav-group .app-nav--action { margin-top: 6px; }
.app-nav--plain { background: #fff; color: #1f2933; border: 1px solid var(--line); }
.app-nav--plain:hover, .app-nav--plain:focus { background: #eef3f7; color: #1f2933; }

/* long site title: two lines on tablets / phones instead of cutting it off; the NetWatch entries shrink */
@media (max-width: 1199px) {
    .nw-top__label { display: none; }
    .nw-top__short { display: inline; }
}
@media (max-width: 991px) {
    .app-title {
        white-space: normal; font-size: 16px; line-height: 1.2; min-width: 0;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    }
}
@media (max-width: 767px) {
    .app-title { font-size: 12.5px; }
    .app-header__left, .app-header__right { gap: 6px; }
    .nw-top { gap: 4px; }
    .nw-top__btn { height: 30px; padding: 0 7px; gap: 4px; font-size: 12px; }
    .nw-top__btn .ic { width: 14px; height: 14px; }
}
@media (max-width: 420px) {
    .app-title { font-size: 11.5px; }
    .nw-top__short { display: none; }
    .nw-top__btn { padding: 0 8px; }
    .nw-top__btn .ic { width: 16px; height: 16px; }
}
