:root {
    --bg: #f0f2f5;
    --text: #1f2933;
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.08);
    --glass-bar: rgba(255, 255, 255, 0.5);
    --glass-bar-border: rgba(226, 232, 240, 0.65);
    --header-bg: #1f2933;
    --header-text: #e2e8f0;
    --nav-link: #cbd5e1;
    --nav-hover-bg: #334155;
    --nav-hover-text: #f1f5f9;
    --heading: #334155;
    --thead-bg: #f8fafc;
    --thead-text: #475569;
    --border: #e2e8f0;
    --row-hover: #f8fafc;
    --row-alt: #f4f6f9;
    --input-border: #cbd5e1;
    --input-bg: #ffffff;
    --input-text: #1f2933;
    --primary-bg: #0096a6;
    --primary-hover: #007d8c;
    --primary-grad: linear-gradient(to bottom, #00d2e6 0%, #0096a6 30%, #007d8c 100%);
    --glass-soft: linear-gradient(to bottom, #ffffff 0%, #eef1f5 30%, #dde2e9 100%);
    --danger-grad: linear-gradient(to bottom, #f87171 0%, #dc2626 30%, #b91c1c 100%);
    --danger-soft: linear-gradient(to bottom, #fff5f5 0%, #fde8e8 30%, #fbd5d5 100%);
    --danger-bg: #fef2f2;
    --danger-text: #dc2626;
    --danger-hover: #fee2e2;
    --danger: #c0392b;
    --badge-up-bg: #dcfce7;
    --badge-up-text: #166534;
    --muted: #94a3b8;
    --note: #64748b;
    --btn-bg: #ffffff;
    --btn-border: #cbd5e1;
    --btn-edge: #cbd5e1;
    --btn-edge-shadow: #94a3b8;
    --btn-hi: #ffffff;
    --btn-shadow: rgba(15, 23, 42, 0.08);
    --btn-shadow-hover: rgba(15, 23, 42, 0.18);
    --disabled-bg: #e2e8f0;
    --disabled-border: #cbd5e1;
    --disabled-text: #64748b;
    --card-border: #e2e8f0;
    --fs-body: 15px;
    --fs-note: 13px;
    --fs-heading: 17px;
    --fs-small: 12px;
    --fs-table: 14px;
}

html[data-theme="dark"] {
    --bg: #1a2230;
    --text: #d8e0ea;
    --card-bg: #222c3c;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --glass-bar: rgba(26, 34, 48, 0.46);
    --glass-bar-border: rgba(255, 255, 255, 0.09);
    --header-bg: #141b26;
    --header-text: #d8e0ea;
    --nav-link: #aab6c4;
    --nav-hover-bg: #2b3648;
    --nav-hover-text: #eef2f7;
    --heading: #c6d0dc;
    --thead-bg: #202b3a;
    --thead-text: #8a97a8;
    --border: #313d4f;
    --row-hover: #202b3a;
    --row-alt: #253043;
    --input-border: #3b4a5f;
    --input-bg: #1a2230;
    --input-text: #d8e0ea;
    --primary-bg: #12a3b4;
    --primary-hover: #0e8b9b;
    --primary-grad: linear-gradient(to bottom, #1cc0d1 0%, #12a3b4 35%, #0d8494 100%);
    --glass-soft: linear-gradient(to bottom, #2b3648 0%, #253043 40%, #202b3a 100%);
    --danger-grad: linear-gradient(to bottom, #c25a5a 0%, #a83232 40%, #8f2626 100%);
    --danger-soft: linear-gradient(to bottom, #3a2530 0%, #33222c 50%, #2b2025 100%);
    --danger-bg: #2b2025;
    --danger-text: #e08a8a;
    --danger-hover: #3a2a30;
    --danger: #ef9a9a;
    --badge-up-bg: #1d3527;
    --badge-up-text: #7fc48c;
    --muted: #6b7888;
    --note: #8a97a8;
    --btn-bg: #222c3c;
    --btn-border: #3b4a5f;
    --btn-edge: #313d4f;
    --btn-edge-shadow: #1a2230;
    --btn-hi: #2b3648;
    --btn-shadow: rgba(0, 0, 0, 0.25);
    --btn-shadow-hover: rgba(0, 0, 0, 0.4);
    --disabled-bg: #2f3a4d;
    --disabled-border: #46536a;
    --disabled-text: #7c8899;
    --card-border: #2b3648;
}

/* Unified thin, themed scrollbars across the whole app.
   `scrollbar-color` is inherited, but `scrollbar-width` is not — so both are
   set on every element. Covers Chrome 121+/Firefox; the ::-webkit-scrollbar
   rules are a fallback for older Chromium/Edge/Safari. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--muted) transparent;
}
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--heading);
    background-clip: padding-box;
}
::-webkit-scrollbar-corner {
    background: transparent;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    transition: background 0.2s, color 0.2s;
    font-size: var(--fs-body, 15px);
}



/* Avatar slot stays invisible until real settings are applied from
   localStorage — prevents the stock person icon flashing on navigation. */
html.avatar-wait #infobar-avatar {
    visibility: hidden;
}
html.perms-pending [data-perm],
html.perms-pending [data-admin],
html.perms-pending [data-perm-any] {
    display: none !important;
}

/* ---- Top bar: brand + page navigation ---- */
.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid var(--border);
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--thead-text);
    white-space: nowrap;
}

.topbar-brand-img {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: block;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 16px;
}

.topbar-nav a {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: var(--fs-small, 13px);
    font-weight: 600;
    color: var(--thead-text);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.topbar-nav a:hover {
    background: var(--row-hover);
    color: var(--text);
}

.topbar-nav a.active {
    background: var(--primary-bg);
    color: #fff;
}

main {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

/* ---- Top info bar ---- */
.infobar {
    position: sticky;
    top: 0;
    z-index: 60;
    transition: top .25s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 18px;
    box-shadow: 0 2px 8px var(--card-shadow);
}

/* Glassmorphism when backdrop-filter is supported (Chrome/Edge/Safari/Firefox 103+).
   The blur needs something behind the bar, so it's applied together with a
   translucent white-to-clear highlight that gives the "glass" a visible edge. */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .infobar {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18)),
            var(--glass-bar);
        -webkit-backdrop-filter: blur(14px) saturate(160%);
        backdrop-filter: blur(14px) saturate(160%);
        border-color: var(--glass-bar-border);
        box-shadow: 0 4px 16px var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }
    html[data-theme="dark"] .infobar {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
            var(--glass-bar);
        border-color: var(--glass-bar-border);
        box-shadow: 0 4px 16px var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }
}

.infobar-scrolled {
    top: 50px;
}

.infobar-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.stats-mini {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.smini {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: var(--fs-small, 12px);
    color: var(--note);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.12s ease;
}

.smini:hover {
    background: transparent;
    cursor: pointer;
}

.smini b {
    font-size: 16px;
    font-weight: 700;
    color: #16a34a;
    line-height: 1;
}

.smini b.s-off {
    color: #dc2626;
}

.smini b.s-unav {
    color: #94a3b8;
}

.smini b.s-uncfg {
    color: #f59e0b;
}

.sminil {
    white-space: nowrap;
}

.mon-stats {
    display: flex;
    gap: 32px;
    margin: 12px 0 6px;
    flex-wrap: wrap;
}

.mon-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 90px;
}

.mon-stat b {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    color: #16a34a;
}

.mon-stat b.s-off {
    color: #dc2626;
}

.mon-stat b.s-unav {
    color: #94a3b8;
}

.mon-stat span {
    font-size: var(--fs-small, 12px);
    color: var(--note);
    text-align: center;
}

.mon-stats + .form-actions {
    margin-top: 14px;
}

.excluded-box {
    margin-top: 8px;
}

.excluded-group {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.excluded-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--row-alt, #f1f5f9);
    cursor: pointer;
    user-select: none;
}

.excluded-chevron {
    flex: none;
    color: #94a3b8;
    transition: transform 0.15s ease;
    font-size: 12px;
}

.excluded-group:not(.collapsed) .excluded-chevron {
    transform: rotate(90deg);
}

.excluded-group.collapsed .excluded-devices {
    display: none;
}

.excluded-head b {
    font-size: var(--fs-table, 14px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.excluded-count {
    font-size: var(--fs-small, 12px);
    color: var(--note);
    white-space: nowrap;
}

.excluded-enable {
    margin-left: auto;
}

.excluded-devices {
    max-height: 260px;
    overflow: auto;
}

.excluded-devices table {
    width: 100%;
    border-collapse: collapse;
}

.excluded-devices th,
.excluded-devices td {
    padding: 4px 12px;
    text-align: left;
    font-size: var(--fs-table, 14px);
    border-bottom: 1px solid var(--border, #eef1f5);
}

.excluded-devices th {
    background: var(--thead-bg, #f8fafc);
    font-weight: 600;
}

.infobar-alarm-ico {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    z-index: 5;
    cursor: pointer;
}

.infobar-alarm-ico.hidden {
    display: none;
}

.infobar-alarm-ico svg {
    height: 100%;
    width: auto;
    filter: drop-shadow(0 0 6px rgba(229, 57, 53, 0.9));
}

.infobar-alarm-ico.is-night svg {
    animation: alarm-ico-pulse 1.1s ease-in-out infinite;
}

.infobar-alarm-ico.muted svg,
.infobar-alarm-ico:not(.is-night) svg {
    animation: none;
    filter: none;
    opacity: 1;
}

@keyframes alarm-ico-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.infobar-alarm-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #dc2626;
    line-height: 1;
    margin-left: 4px;
}

/* Up to 3 offline central-node rows, stacked from the top to the bottom of
   the infobar, shown instead of the plain counter. */
.infobar-alarm-list {
    position: absolute;
    left: calc(100% + 10px);
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    line-height: 1.25;
    font-size: 20.4px;
    font-weight: 600;
    color: #dc2626;
    max-width: min(320px, 38vw);
}

.infobar-alarm-list.hidden {
    display: none;
}

.infobar-alarm-row {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.infobar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}

.infobar-op {
    position: relative;
    z-index: 70;
    transform: translate(-24px, -26px);
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 4px;
    margin-bottom: -36px;
    color: var(--text);
}

.infobar-op-badge {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--avatar-bg, var(--card-bg));
    border: 2px solid var(--avatar-border, var(--primary-bg));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    color: var(--avatar-color, var(--primary));
    overflow: hidden;
}

.infobar-op-badge svg {
    width: 38px;
    height: 38px;
}

.infobar-op-badge img.avatar-opt-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.infobar-op-badge img.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.infobar-status-dot {
    position: absolute;
    top: 56px;
    left: 50%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    box-sizing: border-box;
    border: 3px solid var(--card-bg);
    background: #a0a8b4;
    transform: translateX(12px);
    pointer-events: none;
    z-index: 6;
    transition: background 0.15s ease;
}
.infobar-status-dot.online { background: #4caf50; }
.infobar-status-dot.away { background: #f0a500; }
.infobar-status-dot.busy { background: #e5533d; }
.infobar-status-dot.dnd { background: #b71c1c; }

.infobar-op-user {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 140px;
}

.infobar-mail-ico {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex: none;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.infobar-mail-ico:hover {
    transform: scale(1.1);
    filter: brightness(1.15);
}

.infobar-mail-ico.hidden {
    display: none;
}

.infobar-mail-ico svg {
    width: 24px;
    height: 24px;
    display: block;
}

.chat-infobar-icons {
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(-27px);
    position: relative;
    flex: none;
}

.infobar-op-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px var(--card-shadow);
    padding: 6px;
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.infobar-op:hover .op-menu,
.infobar-op:focus-within .op-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.op-menu-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.op-menu-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.op-menu-head-row .op-menu-role {
    flex: 1;
    min-width: 0;
}

.op-menu-role {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.op-menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
    white-space: nowrap;
}

.op-menu-link svg {
    flex-shrink: 0;
    color: var(--muted);
}

.op-menu-link:hover {
    background: var(--row-hover);
    color: var(--primary);
}

.op-menu-link:hover svg {
    color: var(--primary);
}

.op-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}

.op-menu-version {
    margin: 6px 4px 2px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    text-align: right;
    font-size: 11px;
    color: #fff;
    letter-spacing: 0.02em;
}

.op-menu-sound {
    padding: 6px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.snd-toggle {
    flex-shrink: 0;
    cursor: pointer;
    color: var(--muted);
    opacity: 0.9;
    transition: opacity 0.15s, color 0.15s;
}
.snd-toggle:hover,
.snd-toggle:focus {
    opacity: 1;
    color: var(--primary-bg);
    outline: none;
}
.snd-toggle.off { color: var(--muted); }
.snd-toggle.off .ico-on { display: none; }
.snd-toggle:not(.off) .ico-off { display: none; }
.op-menu-sound-vol {
    display: flex;
    align-items: center;
    gap: 6px;
}
.op-menu-sound-vol .fs-range { flex: 1; min-width: 80px; height: 4px; }
.op-menu-sound-vol .fs-value { font-size: 11px; color: var(--muted); min-width: 12px; text-align: center; }
.op-menu-sound-vol .fs-test {
    font-size: 10.5px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
}
.op-menu-sound-vol .fs-test:hover { color: var(--heading); border-color: var(--muted); background: var(--row-hover, rgba(127,127,127,0.08)); }

.op-menu-status {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding: 6px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.op-menu-status-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    padding: 0 2px 4px;
}
.op-status-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 8px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.op-status-item:hover { background: var(--row-hover); }
.op-status-item.active { background: var(--row-hover); font-weight: 600; }
.op-menu-status:not(.expanded) { cursor: pointer; }
.op-menu-status:not(.expanded):hover { background: var(--row-hover); border-radius: 7px; }
.op-menu-status:not(.expanded) .op-menu-status-title { display: none; }
.op-menu-status:not(.expanded) .op-status-item {
    display: flex;
    padding: 7px 8px;
    margin: 0;
    border-radius: 7px;
}
.op-menu-status:not(.expanded) .op-status-item:not(.active) { display: none; }
.op-menu-status:not(.expanded) .op-status-item.active { background: transparent; }
.op-menu-status:not(.expanded) .op-status-item.active::after {
    content: "▼";
    margin-left: auto;
    font-size: 10px;
    color: var(--muted);
    opacity: 0.6;
}
.op-status-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #a0a8b4;
}
.op-status-dot.online { background: #4caf50; }
.op-status-dot.away { background: #f0a500; }
.op-status-dot.busy { background: #e5533d; }
.op-status-dot.dnd { background: #b71c1c; }

.op-menu-notes {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding: 8px 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.op-menu-notes-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.op-menu-notes-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
}
.op-menu-notes-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.op-menu-notes-count {
    font-size: 10.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.op-menu-notes-status {
    font-size: 10.5px;
    color: var(--muted);
    min-height: 12px;
}
.op-menu-notes-bar {
    display: flex;
    align-items: center;
    gap: 4px;
}
.op-menu-notes-select {
    flex: 1;
    min-width: 0;
    height: 26px;
    padding: 0 6px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--input-text);
    font-family: inherit;
    font-size: 12px;
    outline: none;
}
.op-menu-notes-select:focus { border-color: var(--primary-bg); }
.op-menu-notes-btn {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}
.op-menu-notes-btn:hover:not(:disabled) {
    color: var(--heading);
    border-color: var(--muted);
    background: var(--row-hover, rgba(127,127,127,0.08));
}
.op-menu-notes-btn:disabled { opacity: 0.4; cursor: default; }
.op-menu-notes-name {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 9px;
    border: 1px solid var(--input-border);
    border-radius: 7px;
    background: var(--input-bg);
    color: var(--input-text);
    font-family: inherit;
    font-size: 12.5px;
    outline: none;
}
.op-menu-notes-name:focus { border-color: var(--primary-bg); }
.op-menu-notes-name::placeholder { color: var(--muted); }
.op-menu-notes-area {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 64px;
    max-height: 220px;
    padding: 7px 9px;
    border: 1px solid var(--input-border);
    border-radius: 7px;
    background: var(--input-bg);
    color: var(--input-text);
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.4;
    outline: none;
}
.op-menu-notes-area:focus { border-color: var(--primary-bg); }
.op-menu-notes-area::placeholder { color: var(--muted); }
.op-menu-notes-editor {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.op-menu-notes-editor[hidden] { display: none; }
.op-menu-notes-prompt {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    padding: 14px 6px;
}
.op-menu-notes-prompt[hidden] { display: none; }

.op-menu-contacts {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding-top: 6px;
}
.op-menu-contacts-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    padding: 4px 10px 6px;
    cursor: pointer;
    user-select: none;
}
.op-menu-contacts-title:hover { color: var(--text); }
.op-menu-contacts-title:focus { outline: none; color: var(--text); }
.op-menu-contacts-caret {
    flex: 0 0 auto;
    transition: transform 0.25s ease;
}
.op-menu-contacts.collapsed .op-menu-contacts-caret { transform: rotate(-90deg); }
.op-menu-contacts-list {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-x: hidden;
    transition: max-height 0.28s ease, opacity 0.22s ease;
}
.op-menu-contacts.collapsed .op-menu-contacts-list {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}
.op-menu-contact {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s ease;
}
.op-menu-contact:hover { background: var(--row-hover); }
.op-menu-contact-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.op-menu-contact-unread {
    background: #d93025;
    color: #fff;
    border-radius: 10px;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
}

.op-menu-danger,
.op-menu-danger svg {
    color: var(--danger-text);
}

.op-menu-danger:hover {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.op-menu-danger:hover svg {
    color: var(--danger-text);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 3px var(--card-shadow);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    user-select: none;
}

.theme-toggle:hover {
    background: var(--row-hover);
}

.theme-toggle .theme-ico {
    font-size: 16px;
    line-height: 1;
}

.card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 3px var(--card-shadow);
    border: 1px solid var(--card-border);
    padding: 20px;
    margin-bottom: 20px;
}

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

.olt-layout .card,
.sw-layout .card {
    margin-bottom: 0;
    min-width: 0;
}

.olt-layout .card-span {
    grid-column: 1 / -1;
}

.sw-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: start;
    width: 100%;
    max-width: 100%;
}

.sw-layout .view-panel {
    min-width: 0;
    width: 100%;
}

.sw-layout .tabs-main {
    display: flex;
    width: 100%;
}

.sw-layout .tabs-main .tab {
    flex: 1 1 0;
    margin-bottom: 0;
    text-align: center;
}

.sw-layout .card {
    margin-bottom: 20px;
    width: 100%;
}

.sw-layout #view-available.hidden,
.sw-layout #view-offline.hidden {
    display: none;
}

@media (max-width: 1200px) {
    .olt-layout,
    .sw-layout {
        grid-template-columns: 1fr;
    }
}

.card h2 {
    font-size: var(--fs-heading, 17px);
    margin-bottom: 16px;
    color: var(--heading);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-head h2 {
    margin-bottom: 0;
}

.card-head h2 .card-title-link {
    cursor: pointer;
}

.card-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    padding: 6px;
    line-height: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, border-color .15s, background-color .15s;
}

.btn-icon:hover {
    color: var(--heading);
    border-color: var(--muted);
    background: var(--row-hover, rgba(127, 127, 127, 0.08));
}

/* Clickable card-head icons styled like the copy/telnet glyphs:
   borderless, muted -> cyan on hover; tooltip (data-tip) pops above the icon. */
.card-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    line-height: 0;
    opacity: 0.9;
    transition: opacity 0.15s, color 0.15s;
}

.card-icon:focus {
    outline: none;
}

.card-icon:hover {
    opacity: 1;
    color: var(--primary-bg);
}

.card-icon::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--header-bg);
    color: var(--header-text);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    width: max-content;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
    pointer-events: none;
    z-index: 100;
}

.card-icon:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Icons at the card top-right: anchor the tooltip to the icon's right edge
   so it grows leftward and never crosses the viewport edge. */
.card-head-actions .card-icon::after {
    left: auto;
    right: 0;
    transform: none;
}

.fs-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}

.fs-row:last-of-type {
    border-bottom: none;
}

.fs-label {
    width: 170px;
    flex-shrink: 0;
    font-size: var(--fs-body, 15px);
    color: var(--text);
}

.fs-range {
    flex: 1;
    min-width: 120px;
    accent-color: var(--primary-bg);
    cursor: pointer;
}

.cc-input {
    width: 44px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    cursor: pointer;
}

.cc-hex {
    min-width: 70px;
    font-family: monospace;
    font-size: var(--fs-small, 12px);
    color: var(--note);
}

.cc-check {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-bg);
    cursor: pointer;
}

.cc-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px 14px;
}

.cc-grid .fs-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 7px 4px;
    margin-bottom: 0;
}

.cc-grid .fs-row:nth-last-child(-n + 3) {
    border-bottom: none;
}

.cc-grid .fs-label {
    width: auto;
    font-size: var(--fs-small, 13px);
    color: var(--note);
}

.cc-grid .cc-input {
    width: 40px;
    height: 30px;
}

.cc-grid .cc-hex {
    min-width: 40px;
    font-size: 12px;
}

.fs-value {
    min-width: 28px;
    text-align: right;
    font-weight: 600;
    color: var(--heading);
}

.fs-unit {
    color: var(--note);
    font-size: var(--fs-small, 12px);
}

.fs-test {
    padding: 4px 10px;
    font-size: var(--fs-small, 12px);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--heading);
    cursor: pointer;
    white-space: nowrap;
}

.fs-test:hover {
    border-color: var(--muted);
    color: var(--heading);
    background: var(--row-hover, rgba(127,127,127,0.08));
}

.fs-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.fs-saved {
    margin-left: auto;
    font-size: var(--fs-small, 12px);
    color: #16a34a;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fs-saved.visible {
    opacity: 1;
}

.avatar-preview-row {
    display: flex;
    justify-content: center;
    padding: 18px 0;
}

.avatar-preview-row .infobar-op {
    transform: none;
    margin-bottom: 0;
}

.avatar-colors,
.avatar-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.avatar-icons {
    max-height: 220px;
    overflow-y: auto;
    align-content: flex-start;
    padding-right: 4px;
}

.avatar-color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    background: transparent;
}

.avatar-color-swatch:hover {
    transform: scale(1.1);
}

.avatar-color-swatch.is-selected {
    box-shadow: 0 0 0 3px var(--primary-bg);
    border-color: #fff;
}

.avatar-icon-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text);
    font-size: var(--fs-small, 12px);
    transition: border-color 0.12s ease;
}

.avatar-icon-opt svg {
    width: 52px;
    height: 52px;
    color: var(--avatar-color, var(--primary));
}

.avatar-icon-opt img.avatar-opt-img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.avatar-icon-opt.is-selected {
    border-color: var(--primary-bg);
}

.avatar-upload {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.note {
    font-size: var(--fs-note, 13px);
    color: var(--note);
    margin-bottom: 16px;
}

.modal #onu-history-confirm-text {
    font-size: 21px;
    color: #e5484d;
    text-align: center;
}

#onu-history-confirm-modal .modal {
    width: auto;
    min-width: 320px;
    max-width: 420px;
    padding-bottom: 16px;
}

#onu-history-confirm-modal .modal-head {
    justify-content: flex-end;
}

#onu-history-confirm-ok {
    padding: 8px 22px;
    font-size: 21px;
}

.onu-actions-btns.center {
    justify-content: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-table, 14px);
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--thead-bg);
    color: var(--thead-text);
    font-weight: 600;
    white-space: nowrap;
}

tbody > tr:not(.folder-row):not(.tree-toggle):not(.folder-header):not(.sched-row):not(.sched-section-row):not(.tnet-detail):nth-child(even) td {
    background: var(--row-alt);
}

tbody > tr:not(.sched-row):not(.sched-section-row):hover td {
    background: var(--row-hover);
}

tr:not(.sched-row):not(.sched-section-row):hover td {
    background: var(--row-hover);
}

.folder-row td {
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    padding: 4px 12px;
    border-bottom: 1px solid var(--border);
}

.folder-row:hover td {
    background: var(--row-hover);
}

.tree-folder-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.tree-chevron {
    flex: none;
    color: #94a3b8;
    transition: transform 0.15s ease;
}

.tree-chevron.is-open {
    transform: rotate(90deg);
}

.folder-ico {
    flex: none;
    color: #f59e0b;
}

.folder-name {
    font-weight: 500;
    color: var(--text);
}

.folder-count {
    font-weight: 400;
    color: #94a3b8;
    font-size: 12px;
}

.folder-header th {
    background: var(--thead-bg);
    color: var(--thead-text);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    padding: 6px 12px;
}

.folder-count {
    font-weight: 400;
    color: var(--note);
    font-size: 12px;
}

.folder-copy-btn {
    background: none;
    border: none;
    padding: 0;
    margin-left: 6px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
    vertical-align: middle;
    opacity: 0.9;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: none;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    font-size: inherit;
}

.folder-copy-btn:hover {
    opacity: 1;
    color: var(--primary-bg);
    filter: none;
    box-shadow: none;
}

.folder-copy-btn:active {
    transform: none;
    box-shadow: none;
}

.folder-copy-btn:focus-visible {
    outline: 1px solid var(--primary-bg);
    outline-offset: 2px;
}

.folder-copy-btn.copied {
    color: var(--badge-up-text);
}

.folder-edit-btn {
    background: none;
    border: none;
    padding: 0 2px;
    margin-left: 6px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
    vertical-align: middle;
    opacity: 0.9;
    font-size: 14px;
    transition: opacity 0.15s, color 0.15s;
}

.folder-edit-btn:hover {
    opacity: 1;
    color: var(--primary-bg);
}

.folder-district-dot {
    display: inline-block;
    width: 12px;
    height: 14px;
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
}

.folder-check {
    width: 16px;
    height: 16px;
    margin-left: 8px;
    cursor: pointer;
    accent-color: var(--primary-bg);
    vertical-align: middle;
}

.tree-toggle {
    cursor: pointer;
}

.tree-toggle:hover td {
    background: var(--row-hover);
}

.tree-hidden {
    display: none;
}

.folder-check {
    margin-left: 6px;
}

.folder-poll-off {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #94a3b8;
    cursor: pointer;
    user-select: none;
    margin-left: 8px;
}

.folder-poll-off input {
    width: 13px;
    height: 13px;
    cursor: pointer;
    accent-color: #dc2626;
    margin: 0;
}

.folder-poll-off input:checked {
    color: #dc2626;
}

.folder-poll-off input:disabled {
    cursor: default;
    opacity: 0.55;
}

.device-poll-off {
    display: inline-flex;
    align-items: center;
    margin-right: 2px;
    cursor: pointer;
    user-select: none;
}

.device-poll-off input {
    width: 13px;
    height: 13px;
    cursor: pointer;
    accent-color: #dc2626;
    margin: 0;
}

.device-poll-off input:checked {
    color: #dc2626;
}

.device-poll-off input:disabled {
    cursor: default;
    opacity: 0.55;
}

.folder-ico.is-open {
    color: #f59e0b;
}

.folder-ico:not(.is-open) {
    color: #f59e0b;
}



.mono {
    font-family: Consolas, monospace;
    font-size: 16px;
}

.mac-cell {
    color: #fff;
}

.serial-num {
    font-family: var(--serial-font, inherit);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    white-space: nowrap;
}

.serial-link {
    cursor: pointer;
}

.serial-num .serial-hex {
    color: var(--serial-hex-color, var(--primary-bg));
}

html[data-theme="dark"] .serial-num .serial-hex,
html[data-theme="dark"] .uncfg-row .serial-num {
    color: var(--serial-hex-color, #3b82f6);
}

/* Serial display preview on the profile page */
.sd-preview {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.sd-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin: 8px 0;
}

.sd-opt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.sd-example {
    color: var(--muted);
    font-size: 13px;
}

.uncfg-row td {
    font-size: 15px;
    padding-top: 8px;
    padding-bottom: 8px;
}

table.uncfg-table {
    border-collapse: separate;
    border-spacing: 0 5px;
}

table.uncfg-table th {
    border-bottom-width: 2px;
}

table.uncfg-table td {
    border-bottom: none;
    background: var(--card-bg);
}

table.uncfg-table tbody tr td:first-child {
    border-left: 1px solid var(--border);
    border-radius: 6px 0 0 6px;
}

table.uncfg-table tbody tr td:last-child {
    border-right: 1px solid var(--border);
    border-radius: 0 6px 6px 0;
}

#uncfg-status {
    display: none;
    margin-left: 10px;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    vertical-align: middle;
    border: 1px solid transparent;
    white-space: nowrap;
}

#uncfg-status.is-ok,
#uncfg-status.is-err {
    display: inline-block;
}

#uncfg-status.is-ok::before {
    content: "✓";
    margin-right: 6px;
}

#uncfg-status.is-err::before {
    content: "✗";
    margin-right: 6px;
}

#uncfg-status.is-ok {
    color: var(--badge-up-text, #166534);
    background: var(--badge-up-bg, #dcfce7);
    border-color: var(--badge-up-text, #16a34a);
}

#uncfg-status.is-err {
    color: var(--danger-text, #dc2626);
    background: var(--danger-bg, #fef2f2);
    border-color: var(--danger-text, #dc2626);
}

#uncfg-status.is-pop {
    animation: uncfg-status-pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes uncfg-status-pop {
    from { transform: scale(0.82); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.auto-run-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 9px;
    margin-left: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    line-height: 18px;
    border-radius: 6px;
    background: var(--thead-bg);
    border: 1px solid var(--border);
    color: var(--thead-text);
    cursor: pointer;
    user-select: none;
    vertical-align: middle;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.auto-run-btn:focus {
    outline: none;
}

.auto-run-btn:hover {
    border-color: var(--muted);
    color: var(--heading);
    background: var(--row-hover, rgba(127,127,127,0.08));
}

.auto-run-btn.busy {
    background: #dcfce7;
    border-color: var(--badge-up-text, #16a34a);
    color: var(--badge-up-text, #16a34a);
    opacity: 0.45;
    cursor: wait;
    animation: auto-blink 1s infinite alternate;
}

.auto-run-btn.done {
    background: #dcfce7;
    border-color: var(--badge-up-text, #16a34a);
    color: var(--badge-up-text, #16a34a);
}

.auto-run-btn.disabled {
    cursor: not-allowed;
    pointer-events: none;
    background: var(--disabled-bg, #e2e8f0);
    background-color: var(--disabled-bg, #e2e8f0);
    color: var(--disabled-text, #64748b);
    border: 1px solid var(--disabled-border, #cbd5e1);
    box-shadow: none;
    filter: none;
}

.uncfg-row-status {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    font-weight: 600;
    color: var(--note);
    white-space: normal;
    max-width: 280px;
}

.uncfg-row-status.is-ok {
    color: var(--badge-up-text, #16a34a);
}

.uncfg-row-status.is-err {
    color: var(--danger-text, #dc2626);
}

@keyframes auto-blink {
    from { opacity: 0.35; }
    to { opacity: 0.8; }
}

.uncfg-ban {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--muted, #64748b);
    cursor: default;
    margin-right: 9px;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
}

.uncfg-ban input {
    cursor: pointer;
}

.uncfg-row .serial-num {
    cursor: pointer;
    color: var(--primary-bg);
}

.uncfg-row .serial-num:hover {
    text-decoration: underline;
}

.uncfg-row .dev-name {
    font-size: 15px;
}

.copy-btn {
    background: none;
    border: none;
    padding: 0;
    margin-left: 3px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
    vertical-align: middle;
    opacity: 0.9;
    transition: opacity 0.15s;
}

.copy-btn:focus {
    outline: none;
}

.copy-btn:hover {
    opacity: 1;
    color: var(--primary-bg);
}

.copy-btn.copied {
    color: var(--badge-up-text);
}

.copy-icon {
    width: 18px;
    height: 18px;
}

/* Kubalink search magnifier and district pencil: same hover/cursor
   behavior as the copy icon (muted/0.9 -> cyan/1). The magnifier follows
   the copy icon with the same 3px offset -> uniform icon rhythm. */
.kuba-search-btn,
.dev-district-btn,
.topo-share-btn {
    cursor: pointer;
    color: var(--muted);
    opacity: 0.9;
    transition: opacity 0.15s, color 0.15s;
}

.kuba-search-btn:hover,
.dev-district-btn:hover,
.topo-share-btn:hover {
    opacity: 1;
    color: var(--primary-bg);
}

.topo-share-btn {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    margin-left: 3px; /* mirrors .copy-btn margin: equal IP->search->shared gaps */
}

.kuba-search-btn {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    margin-left: 3px; /* mirrors .copy-btn margin: IP->copy->search gaps */
}

/* "i" icon of the outage note (offline rows only): same rhythm/hover as the
   copy/search icons. .has-note = the node currently carries an active note,
   the icon stays permanently tinted and gets a filled badge. */
.outage-note-btn {
    cursor: pointer;
    color: var(--muted);
    opacity: 0.9;
    transition: opacity 0.15s, color 0.15s;
}

.outage-note-btn:hover {
    opacity: 1;
    color: var(--primary-bg);
}

.outage-note-btn {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    margin-left: 3px;
}

.outage-note-btn.has-note {
    color: var(--warn, #f59e0b);
    opacity: 1;
}

.outage-note-btn.has-note circle {
    fill: rgba(245, 158, 11, 0.16);
}

/* The note text under the IP of an offline row. */
.dev-note {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    font-size: 11px;
    line-height: 1.3;
    padding: 1px 12px 4px 16px;
    max-width: 620px;
    color: var(--warn, #f59e0b);
}

.dev-note-reason {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.25;
}

.dev-note-text {
    color: var(--muted, #64748b);
    font-size: 17px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Outage note modal: node line, reason select, text, archive history ----
   Flat, label-above-field layout: every input has a visible caption, so the
   modal reads top-down as "which node -> why -> what happened -> history". */
.note-node {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 14px;
}

.note-node-label {
    flex-shrink: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted, #64748b);
}

.note-node-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text, #e2e8f0);
    word-break: break-word;
}

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

.note-label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted, #94a3b8);
}

.note-label + .note-select,
.note-label + .note-custom,
.note-select + .note-label {
    margin-bottom: 12px;
}

.note-select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border, #334155);
    background: var(--input-bg, rgba(15, 23, 42, 0.6));
    color: var(--text, #e2e8f0);
    font-family: inherit;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
}

.note-select:focus {
    border-color: var(--primary-bg, #22d3ee);
}

#outage-note-reason-custom {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
}

.note-counter {
    margin-top: 4px;
    font-size: 11px;
    color: var(--muted, #64748b);
    text-align: right;
}

#outage-note-text {
    width: 100%;
    min-height: 96px;
    resize: vertical;
    font-family: inherit;
    font-size: 20px;
    line-height: 1.45;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border, #334155);
    background: var(--input-bg, rgba(15, 23, 42, 0.6));
    color: var(--text, #e2e8f0);
}

#outage-note-meta {
    margin: 8px 0 0;
    line-height: 1.45;
}

.note-history {
    margin-top: 18px;
    border-top: 1px solid var(--border, #334155);
    padding-top: 12px;
}

.note-history-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted, #94a3b8);
    margin-bottom: 4px;
}

.note-history-list {
    max-height: 220px;
    overflow-y: auto;
    margin-top: 6px;
}

.note-history-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    font-size: 13px;
}

.note-history-row:last-child {
    border-bottom: none;
}

.note-history-when {
    color: var(--muted, #64748b);
    font-size: 12px;
}

.note-history-what {
    color: var(--text, #e2e8f0);
    line-height: 1.4;
    word-break: break-word;
}

.note-readonly {
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid var(--border, #334155);
    background: rgba(148, 163, 184, 0.08);
    font-size: 14px;
    line-height: 1.5;
}

.note-readonly-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted, #64748b);
    margin-bottom: 2px;
}

.note-readonly-label + .note-readonly-reason {
    margin-bottom: 10px;
}

.note-readonly-reason {
    font-weight: 600;
    font-size: 20px;
    line-height: 1.25;
    color: var(--warn, #f59e0b);
}

.note-readonly-text {
    color: var(--text, #e2e8f0);
    font-size: 20px;
    white-space: pre-wrap;
    word-break: break-word;
}

.district-edit-ico {
    width: 1em;
    height: 1em;
}

/* District pencil matches the folder/table title font (and scales with
   the user font-size setting). */
.district-edit-ico.folder-edit-btn {
    width: calc(var(--fs-table, 15px) * 1.4);
    height: calc(var(--fs-table, 15px) * 1.4);
}

.dev-name {
    font-size: 16px;
    color: var(--muted, #888);
    margin-top: 2px;
}

/* IP cell: the TD stays a real table-cell (zebra background / row border /
   height stretch work natively); the inner DIV carries the flex icon row.
   height:100% on a div resolves reliably against the stretched td. */
td.ip-cell-wrap {
    padding: 0;
}

/* Folder name under the IP in unified-search results (status present). */
.dev-folder {
    display: block;
    font-size: 11px;
    color: var(--note, #64748b);
    line-height: 1.2;
    padding: 0 12px 6px 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.ip-cell {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    box-sizing: border-box;
    height: 100%;
    padding: 10px 12px;
}

.ip-cell[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    top: 100%;
    z-index: 20;
    min-width: 160px;
    padding: 8px 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--card-shadow);
    color: var(--text);
    font-family: Consolas, monospace;
    font-size: 12px;
    white-space: pre;
    pointer-events: none;
}

.oper.is-up {
    color: #16a34a;
    font-weight: 600;
}

.uplink-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--primary-bg);
    color: #fff;
    font-size: 11px;
    line-height: 1.4;
    cursor: help;
}

.uplink-act {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid #c5c5c5;
    color: #999;
    font-size: 11px;
    line-height: 1.4;
    cursor: pointer;
}

.uplink-act:hover {
    color: var(--primary-bg);
    border-color: var(--primary-bg);
}

.onu-choose {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 4px;
}

/* Кнопки выбора действия в едином окне ONU (TODO 165): базовый стиль —
   общий .btn-outline, активное действие выглядит как .btn-primary. */
.onu-choose-btn.active {
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    color: #fff;
    border-color: var(--primary-bg);
}

.onu-choose-btn.active:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.onu-choose-btn.hidden {
    display: none;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 860px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

/* Same glassmorphism applied to every modal window: translucent body
   + backdrop blur of the overlay behind it. Falls back to opaque card. */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .modal {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18)),
            var(--glass-bar);
        -webkit-backdrop-filter: blur(14px) saturate(160%);
        backdrop-filter: blur(14px) saturate(160%);
        border: 1px solid var(--glass-bar-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }
    html[data-theme="dark"] .modal {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
            var(--glass-bar);
        border-color: var(--glass-bar-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    /* Head must never shrink so the body below takes the remaining height
       and scrolls internally instead of spilling out of the modal frame. */
    flex-shrink: 0;
}

.modal-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 12px;
}

.btn-outline.modal-resnmp {
    font-size: var(--fs-small, 12px);
    padding: 5px 12px;
    border-radius: 14px;
    white-space: nowrap;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--heading);
    display: flex;
    align-items: baseline;
    flex: 1;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
    text-align: left;
}

.onu-register-serial-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 4px 0 12px;
    flex-wrap: wrap;
}

.onu-register-serial-label {
    color: var(--muted, #64748b);
    font-size: 16px;
    font-weight: 600;
}

.onu-register-serial-line {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-family: var(--serial-font, var(--mono, monospace));
    font-size: 22px;
    font-weight: 600;
    color: var(--text, #1e293b);
}

.onu-register-serial-line .serial-hex {
    color: var(--serial-hex-color, var(--text, #1e293b));
}

.onu-register-serial-row .copy-icon {
    flex: 0 0 auto;
}

.modal-title .copy-icon {
    flex: 0 0 auto;
}

.btn-close {
    background: rgba(0, 0, 0, 0.05);
    background-color: rgba(0, 0, 0, 0.05);
    color: #dc2626;
    font-size: 16px;
    padding: 4px 10px;
    box-shadow: none;
    border: none;
    border-bottom: none;
}

.btn-close:hover {
    background-color: rgba(220, 38, 38, 0.15);
    color: #dc2626;
    filter: none;
}

.scroll-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 90;
    width: 60px;
    height: 60px;
    padding: 0;
    border-radius: 4px;
    background: var(--primary-bg);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.scroll-top:hover {
    background: var(--primary-hover);
}

.modal-body {
    overflow: auto;
    padding: 0 20px 20px;
    /* Occupy the remaining modal height and scroll internally instead of
       spilling past the frame on long content (permissions list, etc.). */
    flex: 1 1 auto;
    min-height: 0;
}

.alarm-mute-modal-box {
    max-width: 300px;
}

.alarm-sound-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--heading);
    cursor: pointer;
    padding: 14px 0;
    border-radius: 8px;
    transition: color 0.15s ease, background 0.15s ease;
}

.alarm-sound-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #dc2626;
}

.alarm-sound-btn svg {
    width: 56px;
    height: 56px;
}

.alarm-sound-btn .alarm-sound-off {
    display: none;
}

.alarm-sound-btn.muted .alarm-sound-on {
    display: none;
}

.alarm-sound-btn.muted .alarm-sound-off {
    display: block;
}

.alarm-sound-btn.muted {
    color: #dc2626;
}





.device-model {
    font-size: var(--fs-small, 12px);
    color: var(--note);
    font-family: monospace;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.mtab {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px 14px;
    font-size: var(--fs-small, 12px);
    color: var(--note);
    cursor: pointer;
}

.mtab:not(.active):hover {
    background: var(--row-hover);
    color: var(--text);
    border-color: var(--muted);
}

.mtab.active {
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    border-color: var(--primary-bg);
    color: #fff;
}

.mtab-pane { display: none; }
.mtab-pane.active { display: block; }

.macs-hint {
    font-size: var(--fs-small, 12px);
    color: var(--note);
    padding: 6px 2px 8px;
}

.macs-none { color: var(--note); }
.detail-loading {
    color: var(--primary);
    font-weight: 600;
    animation: detail-pulse 1.2s ease-in-out infinite;
}

@keyframes detail-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.macs-more {
    color: var(--primary);
    cursor: help;
    font-weight: 600;
}
.mac-list-cell { max-width: 460px; }

.crc-err { color: #dc2626; font-weight: 700; }

.crc-delta {
    color: #ea580c;
    font-weight: 700;
    font-size: var(--fs-small, 12px);
}

.row-clickable {
    cursor: pointer;
}

.row-clickable:hover {
    background: rgba(59, 130, 246, 0.06);
}

.row-clickable .col-name {
    text-decoration: underline dotted rgba(59, 130, 246, 0.4);
    text-underline-offset: 2px;
}

.log-time { white-space: nowrap; }
.log-text { white-space: pre-wrap; word-break: break-word; max-width: 520px; }
.log-sev { text-align: center; }
.sev-emerg, .sev-alert, .sev-crit { color: #dc2626; font-weight: 700; }
.sev-error { color: #ea580c; font-weight: 600; }
.sev-warn { color: #d97706; }
.sev-notice, .sev-info, .sev-debug { color: var(--note); }

.col-model {
    padding-left: 40px;
    white-space: nowrap;
}

/* Switches offline 36+ hours: yellow highlight across the whole row. */
tr.stale-offline {
    background: rgba(250, 204, 21, 0.22);
}
tr.stale-offline:hover {
    background: rgba(250, 204, 21, 0.3);
}
tr.stale-offline td {
    border-color: rgba(250, 204, 21, 0.4);
}

.col-name {
    font-size: 16px;
    font-weight: 500;
    min-width: 380px;
    max-width: 640px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Time column absorbs the leftover horizontal space. The value sits with a
   moderate gap after the model (not flush next to it, not at the far edge)
   so every device row stays on a single line. */
.col-time {
    width: 100%;
    white-space: nowrap;
    padding-left: 64px;
}

/* «Отключено уже» — живая длительность отключения на вкладке «Отключённые». */
.col-down-for {
    white-space: nowrap;
}

/* Keep the time column header (4th in both views — «Время отключения» on the
   offline tab, «Обновлено» on the available tab) aligned with the values
   below it. The 5th offline column («Отключено уже») keeps default padding. */
.folder-header th:nth-child(4) {
    padding-left: 64px;
}

button {
    border: none;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    font-size: 16px;
    padding: 10px 22px;
    color: #fff;
    border-radius: 8px;
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.1s ease;
}

button:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

button:active {
    background-color: var(--primary-hover);
    transform: translateY(1px);
}

button:focus-visible {
    outline: 2px solid var(--primary-hover);
    outline-offset: 2px;
}

/* Disabled/inactive buttons: solid gray fill + border + muted text so they
   stay clearly visible against the background (no transparency/opacity fade). */
button:disabled,
button[disabled] {
    cursor: not-allowed;
    opacity: 1;
    filter: none;
    text-shadow: none;
    background: var(--disabled-bg, #e2e8f0);
    background-color: var(--disabled-bg, #e2e8f0);
    color: var(--disabled-text, #64748b);
    border: 1px solid var(--disabled-border, #cbd5e1);
    border-top-color: var(--disabled-border, #cbd5e1);
    border-bottom: 1px solid var(--disabled-border, #cbd5e1);
    box-shadow: none;
    transform: none;
}
button:disabled:hover {
    filter: none;
    box-shadow: none;
}
button:disabled:active {
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-primary:active {
    background-color: var(--primary-hover);
    transform: translateY(1px);
}

.btn-outline {
    background: var(--btn-bg);
    background-color: var(--btn-bg);
    color: var(--text);
    border: 1px solid var(--input-border);
    padding: 7px 18px;
    font-size: 13px;
}

.btn-outline:hover {
    background-color: var(--row-hover);
    border-color: var(--muted);
}

.user-dis-tog { padding: 2px 10px; font-size: 12px; }
.user-dis-tog[data-on="0"] { border-color: #16a34a; color: #16a34a; }
.user-dis-tog[data-on="0"]:hover { background: rgba(22,163,74,.1); border-color: #16a34a; color: #16a34a; }
.user-dis-tog[data-on="1"] { border-color: #ca8a04; color: #ca8a04; }
.user-dis-tog[data-on="1"]:hover { background: rgba(202,138,4,.1); border-color: #ca8a04; color: #ca8a04; }

/* Draggable modal headers (modal-drag.js) */
.modal-head,
.term-modal-head {
    cursor: move;
    user-select: none;
}

.modal-head .btn-close,
.term-modal-head .term-close {
    cursor: pointer;
}

.onu-action-btns {
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
    box-sizing: border-box;
    height: 100%;
    padding: 10px 12px;
}

/* The TD wrapper is a real table-cell: it paints zebra/borders at full row
   height while the inner flex div centers the buttons. */
td.onu-action-btns-wrap {
    padding: 0;
}

.btn-mini {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--input-border);
    cursor: pointer;
    line-height: 1.6;
}

/* ONU row action buttons: readable labels instead of cryptic REB/RST/DEL */
td.onu-action-btns .btn-mini {
    font-size: 12px;
    padding: 4px 11px;
    border-radius: 7px;
    line-height: 1.4;
}

.onu-actions-locked {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.btn-reboot {
    background: var(--btn-bg);
    background-color: var(--btn-bg);
    color: var(--text);
}

.btn-reboot:hover {
    background-color: var(--row-hover);
}

.btn-reset {
    background: var(--btn-bg);
    background-color: var(--btn-bg);
    color: var(--danger, #c0392b);
    border-color: var(--danger, #c0392b);
}

.btn-reset:hover {
    background-color: var(--danger-bg);
    border-color: var(--danger, #c0392b);
    color: var(--danger, #c0392b);
}

.btn-delete {
    background: var(--danger-bg);
    background-color: var(--danger-bg);
    color: var(--danger, #c0392b);
    border-color: var(--danger, #c0392b);
}

.btn-delete:hover {
    background-color: var(--danger, #c0392b);
    color: #fff;
    border-color: var(--danger, #c0392b);
}

.area-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.area-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--heading);
}

.area-chip {
    padding: 5px 14px;
    border-radius: 0;
    font-size: 13px;
    font-weight: 600;
    background: var(--thead-bg);
    color: var(--thead-text);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.area-chip:hover {
    background: var(--row-hover);
    color: var(--heading);
}

.area-chip.active {
    background: var(--primary-bg) !important;
    background-color: var(--primary-bg) !important;
    color: #fff !important;
    border-color: var(--primary-bg);
}



.modal-narrow {
    max-width: 420px;
}

.mini-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
}

.note.is-err {
    color: #dc2626;
}

.district-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 14px;
    margin: 6px 0;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 8px;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s;
}

.district-item:hover {
    filter: brightness(0.93);
}

.district-item:active {
    transform: scale(0.99);
}

/* Central node dot: red square shown on device rows for the main (central)
   communication nodes, mirroring the district square. */
.central-dot {
    display: inline-block;
    width: 12px;
    height: 14px;
    border-radius: 2px;
    margin-right: 1px;
    vertical-align: middle;
    background: #b91c1c;
    box-shadow: inset 0 0 0 1px rgba(127, 29, 29, 0.4);
}

/* Unified-search status badge: small colored dot before the IP in search results. */
.sw-status {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.sw-status.up { background: #16a34a; }
.sw-status.down { background: #dc2626; }
.sw-status.never { background: #9ca3af; }
.sw-status.unknown { background: #d97706; }
/* «Нестабильно»: flapping up<->down — hollow yellow dot with a red ring so it
   stays distinguishable from the solid amber "unknown" dot. */
.sw-status.unstable {
    background: #facc15;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.55);
}

/* Topology-tab rows: central nodes get a subtle highlight + the central dot. */
#view-topology tr.central-row td.name-cell,
#view-topology tr.central-row .col-name {
    font-weight: 600;
}

/* Central-node indicator in the district modal (device rows only).
   Shown as a red strip like the other district items. */
.central-indicator-row {
    margin: 12px 0;
}
.central-indicator-row.hidden { display: none; }
.central-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: #dc2626;
    background-color: #dc2626;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}
.central-indicator:hover {
    background-color: #b91c1c;
}
.central-indicator.active::before {
    content: "✓";
    font-weight: 800;
}
.central-indicator.disabled-btn {
    cursor: default;
    opacity: 0.6;
    background: #b91c1c;
    color: #fff;
}
.central-indicator-row .note {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.tree-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    justify-content: flex-end;
}

.tree-toolbar .btn-outline {
    padding: 4px 12px;
    font-size: 12px;
    background: var(--primary-bg);
    border-color: var(--primary-bg);
    color: #fff;
}

.tree-toolbar .btn-outline:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.flat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 6px;
}

.flat-toggle input {
    cursor: pointer;
    accent-color: var(--primary-bg);
}

.btn-danger {
    background: #dc2626;
    background-color: #dc2626;
    color: #fff;
    padding: 5px 14px;
    font-size: 13px;
}

/* Delete-mode swap in a search row must not change row proportions:
   same box metrics as .btn-primary and a fixed width for both labels. */
.search-row .btn-danger {
    padding: 10px 22px;
    /* match the .btn-primary state exactly (base button font is 16px,
       while .btn-danger forces 13px -> the button looked smaller) */
    font-size: 16px;
}

#refresh-btn-offline {
    min-width: 118px;
    text-align: center;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

input[type="text"], input[type="search"], input[type="password"] {
    border: 1px solid var(--input-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    width: 100%;
    background: var(--input-bg);
    color: var(--input-text);
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-textfield-decoration-container {
    visibility: hidden;
    display: none !important;
}

input:focus {
    border-color: var(--primary-bg);
}

input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23dc2626" stroke-width="3" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>') center/contain no-repeat;
    cursor: pointer;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    justify-content: flex-end;
}

.search-row input {
    width: 240px;
    flex: none;
}











.pwd-toggle {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--tx-1, #888);
    opacity: 0.7;
    line-height: 1;
    padding: 4px;
}

.pwd-toggle:hover {
    opacity: 1;
}





.poll-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.poll-row label {
    font-weight: 600;
}

.poll-row input {
    width: 160px;
}

.poll-hint {
    margin: 0;
    font-size: var(--fs-note, 13px);
    color: var(--note);
    line-height: 1.45;
}

.poll-group-title {
    margin: 22px 0 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border, #e2e8f0);
    font-size: var(--fs-note, 13px);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--muted, #94a3b8);
}

.poll-group-title:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.msg {
    margin-top: 10px;
    font-size: 13px;
}

.msg.error { color: #dc2626; }
.msg.ok { color: #16a34a; }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 30px 0;
}

.stat {
    display: inline-flex;
    flex-direction: column;
    margin-right: 30px;
}

/* Activation count in the card head (right edge, next to the action icons):
   keep the .stat look but hug the icons and align the label to the right. */
.stat.stat-head {
    margin-right: 0;
    text-align: right;
    line-height: 1.15;
}

.stat-link {
    cursor: pointer;
    padding: 6px 14px;
    margin: -6px 0 -6px -14px;
    border-radius: 8px;
    transition: background 0.15s;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.stat-link:hover {
    background: var(--row-hover);
}

.stats-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-grow {
    flex: 1;
}

.report-text {
    width: 100%;
    min-height: 320px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    font-family: Consolas, monospace;
    font-size: 13px;
    background: var(--input-bg);
    color: var(--input-text);
    outline: none;
}

.report-format {
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text);
}

.report-format label {
    margin-right: 16px;
    cursor: pointer;
}

.report-format input {
    margin-right: 5px;
}

.report-format-hint {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--note);
}

.report-count {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.report-count span {
    color: var(--primary-bg);
}

.onu-register-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
}

.onu-register-head .note {
    margin: 0;
}

.onu-register-prev {
    flex-basis: 100%;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
}

.onu-register-prev-title {
    font-size: 13px;
    font-weight: 700;
    color: #c2410c;
    margin-bottom: 6px;
}

.onu-register-prev-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    padding: 3px 0;
}

.onu-register-router-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    margin-left: auto;
}

.onu-register-opts {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-bottom: 10px;
}

.onu-register-toprow {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    margin-bottom: 10px;
}

.onu-register-toprow .onu-register-opts {
    margin-bottom: 0;
    flex-shrink: 0;
}

.onu-register-toprow .onu-vlan-check {
    margin-left: 0;
}

.onu-register-toprow #onu-register-info {
    margin: 0;
}

.onu-register-opts .onu-vlan-check {
    margin-left: auto;
    margin-right: -18px;
}

.onu-register-opts .onu-vlan-input {
    margin-left: 0;
}

.onu-vlan-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

.onu-vlan-input {
    width: 70px !important;
    padding: 4px 8px !important;
    font-size: 13px !important;
}

.onu-register-result {
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.onu-register-result-msg {
    font-size: 14px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.onu-register-result-msg.is-ok {
    background: var(--badge-up-bg);
    color: var(--badge-up-text);
}

.onu-register-result-msg.is-err {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.onu-register-result-btns {
    text-align: right;
}

.report-actions {
    margin-top: 12px;
    text-align: right;
}

.stat .num {
    font-size: 24px;
    font-weight: 700;
}
.num.up { color: #16a34a; }

.num.los { color: #dc2626; }

.num.offline { color: #dc2626; }

.num.warn { color: #f59e0b; }

.num.dying { color: #f59e0b; }
.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
}

.status-dot.is-up { background: #16a34a; }
.status-dot.is-down { background: #dc2626; }
.status-dot.is-unavail { background: #94a3b8; }

.stat .label {
    font-size: var(--fs-small, 12px);
    color: var(--note);
}

.stat .stat-updated {
    font-size: 11px;
    color: var(--note);
    white-space: nowrap;
    margin-top: 2px;
}

.last-refresh {
    font-size: var(--fs-small, 12px);
    color: var(--note);
    margin-bottom: 8px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.users-subtabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.usubtab {
    background: transparent;
    color: var(--note);
    font-size: 15px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 6px;
}

.usubtab:hover {
    color: var(--text);
    background: var(--row-hover);
}

.usubtab.active {
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    color: #fff;
}

.users-filter-row {
    justify-content: flex-start;
    margin-bottom: 10px;
    gap: 10px;
}

.users-filter-row select {
    width: 220px;
    flex: none;
}

.users-filter-label {
    font-size: 14px;
    color: var(--heading, #1e293b);
    font-weight: 600;
    white-space: nowrap;
}

/* Settings → «Ресурсы»: resource consumption monitor (main.py /api/resources). */
.res-stats {
    gap: 24px;
}

.res-stats .mon-stat b {
    color: var(--text, #1f2933);
}

.res-chart-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 20px 0 6px;
}

.res-chart-head h3 {
    margin: 0;
    font-size: 15px;
    color: var(--heading, #1e293b);
}

.res-chart-wrap {
    position: relative;
    width: 100%;
}

.res-chart-wrap canvas {
    display: block;
    width: 100%;
    cursor: crosshair;
}

.res-tip {
    position: absolute;
    z-index: 6;
    display: none;
    pointer-events: none;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    padding: 6px 9px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text, #1f2933);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
}

.res-tip-time {
    color: var(--note, #64748b);
    margin-bottom: 3px;
}

.res-tip-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.res-tip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}

.users-filter-count {
    margin: auto;
    white-space: nowrap;
}

.tab {
    background: transparent;
    color: var(--note);
    font-size: 15px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 6px;
}

.tab:hover {
    color: var(--text);
    background: var(--row-hover);
}

.tab.active {
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    color: #fff;
}







.hidden { display: none; }







.switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 26px;
    cursor: pointer;
    transition: background 0.2s;
}

.switch .slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch input:checked + .slider {
    background: var(--primary-bg);
}

.switch input:checked + .slider::before {
     transform: translateX(22px);
 }

 /* ---- App settings rows (Настройки OLT) ---- */
 .settings-row {
     display: flex;
     align-items: center;
     gap: 12px;
     margin: 10px 0;
 }
 .settings-label {
     font-size: 13px;
     color: var(--text);
     white-space: nowrap;
 }
 .settings-input {
     max-width: 220px;
     padding: 6px 10px;
     border: 1px solid var(--border, #cbd5e1);
     border-radius: 6px;
     background: var(--card-bg, #fff);
     color: var(--text);
 }
 .settings-input:focus {
     outline: none;
     border-color: var(--primary-bg);
 }
 /* ---- ONU history status badges ---- */
 .status-badge {
     display: inline-block;
     padding: 3px 8px;
     border-radius: 4px;
     font-size: 12px;
     line-height: 1.4;
     font-weight: 600;
 }
 .status-badge.info {
     background: #eff6ff;
     color: #1d4ed8;
     border: 1px solid #bfdbfe;
 }
 .status-badge.warn {
     background: #fff7ed;
     color: #c2410c;
     border: 1px solid #fed7aa;
 }
 .onu-badge.ok {
     display: inline-block;
     padding: 3px 8px;
     border-radius: 4px;
     font-size: 12px;
     font-weight: 600;
     background: #ecfdf5;
     color: #047857;
     border: 1px solid #a7f3d0;
 }
 .onu-status-ok {
     color: var(--text-dim, #64748b);
     font-size: 12px;
 }
 .onu-login-box {
     display: flex;
     gap: 6px;
     margin-top: 6px;
     align-items: center;
 }
 .onu-login-input {
     width: 140px;
     padding: 4px 8px;
     border: 1px solid var(--border, #cbd5e1);
     border-radius: 6px;
     background: var(--card-bg, #fff);
     color: var(--text);
 }
 .onu-login-val {
     margin-top: 4px;
     font-size: 12px;
     color: #047857;
 }

 .onu-history-actions {
     text-align: center;
     white-space: nowrap;
 }

 .onu-history-del {
     border: none;
     background: transparent;
     color: var(--muted);
     padding: 4px;
     border-radius: 6px;
     line-height: 0;
     cursor: pointer;
     display: inline-flex;
     align-items: center;
 }

 .onu-history-del:hover {
     color: #dc2626;
     background: rgba(220, 38, 38, 0.12);
 }

/* ---- Login page ---- */
.login-main {
    flex: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 28px;
}

.login-brand {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo {
    width: 128px;
    height: 128px;
    border-radius: 24px;
    object-fit: cover;
    margin-bottom: 8px;
}

.login-brand h1 {
    font-size: 22px;
    color: var(--heading);
    margin: 4px 0;
}

.login-field {
    display: block;
    margin-bottom: 14px;
    text-align: center;
}

.login-field span {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--note);
    margin-bottom: 6px;
}

.login-field input {
    width: 50%;
    box-sizing: border-box;
}

.login-submit {
    display: block;
    width: 50%;
    margin: 6px auto 0;
}

.login-error {
    min-height: 22px;
    margin: 12px 0 0;
    font-size: 17px;
    font-weight: 600;
    color: #dc2626;
    text-align: center;
}

.login-version {
    margin: 14px 0 0;
    font-size: 12px;
    color: #fff;
    text-align: right;
    letter-spacing: 0.02em;
}

.login-pwd {
    position: relative;
    display: inline-block;
    width: 50%;
    vertical-align: middle;
}

.login-pwd input {
    width: 100%;
    box-sizing: border-box;
    padding-right: 34px;
}

.login-pwd-eye {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    opacity: 0.55;
    line-height: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.login-pwd-eye:focus,
.login-pwd-eye:focus-visible {
    outline: none;
}

.login-pwd-eye svg {
    display: block;
}

.login-pwd-eye .ico-open {
    display: none;
}

.login-pwd-eye.is-visible .ico-closed {
    display: none;
}

.login-pwd-eye.is-visible .ico-open {
    display: block;
}



.onu-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}



.onu-field input,
.onu-field select {
    width: 100%;
    box-sizing: border-box;
}

.onu-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid var(--input-border, #94a3b8);
    border-radius: 6px;
    background: var(--input-bg, #fff);
    color: var(--text);
}



.onu-actions-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

/* «Автоактивация» — в левой части строки кнопок формы регистрации;
   «Авто (бокс)» и «Зарегистрировать» остаются справа (решение 26.10). */
#onu-action-auto {
    margin-right: auto;
}

/* Запасное окно «Данные активации» (браузер без Document PiP): тот же
   компактный макет, что и в плавающем окне (26.10). */
#onu-pip-fallback-modal .modal {
    padding: 14px 16px;
}

/* Подсказка «История активаций хранится 4 недели…» под «История пуста»:
   текст по центру, пространство плашки увеличено вдвое, растянута вниз. */
#onu-history-tbody .note {
    text-align: center;
    margin: 0;
    padding: 16px 16px 40px;
    background: rgba(127, 127, 127, 0.07);
    border-radius: 8px;
}
#onu-pip-fallback-modal .pip-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}
#onu-pip-fallback-modal .pip-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 2px 6px;
    font-size: 14px;
    border-radius: 4px;
}
#onu-pip-fallback-modal .pip-alt {
    background: rgba(127, 127, 127, 0.10);
}
#onu-pip-fallback-modal .pip-row .k {
    color: var(--muted);
    min-width: 92px;
}
#onu-pip-fallback-modal .pip-row .v {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    word-break: break-all;
}
#onu-pip-fallback-modal .pip-extra {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}
#onu-pip-fallback-modal .pip-copy {
    margin-left: 8px;
    padding: 1px 7px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: transparent;
    color: inherit;
}
#onu-pip-fallback-modal .pip-copy:hover {
    border-color: var(--primary-bg);
    color: var(--primary-bg);
}
#onu-pip-fallback-modal .pip-login-input {
    width: 150px;
    padding: 2px 8px;
    font-size: 13px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: inherit;
    font-family: inherit;
}
#onu-pip-fallback-modal .pip-login-btn {
    margin-left: 6px;
    padding: 1px 9px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: transparent;
    color: inherit;
}
#onu-pip-fallback-modal .pip-login-btn:hover {
    border-color: var(--primary-bg);
    color: var(--primary-bg);
}

.onu-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.onu-target {
    font-size: 16px;
    font-weight: 600;
    color: var(--heading);
}





.telnet-btn {
    background: none;
    border: none;
    padding: 0;
    margin-right: 8px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
    vertical-align: middle;
    width: 19px;
    height: 19px;
    opacity: 0.9;
    transition: opacity 0.15s;
}

.telnet-btn:focus {
    outline: none;
}

.telnet-btn:hover {
    opacity: 1;
    color: var(--primary-bg);
}

/* Theme switch: a compact segmented control that matches the app's pill
   tabs (.mtab / .usubtab). Two segments — sun (light) and moon (dark);
   the segment of the active theme is filled with the primary colour. */
.theme-switch-wrap {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    transition: border-color 0.15s ease;
}

.theme-switch-wrap:hover .theme-switch {
    border-color: var(--muted);
}

.theme-switch-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 22px;
    border-radius: 999px;
    flex-shrink: 0;
    color: var(--muted);
    transition: background 0.18s ease, color 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.theme-switch-icon svg { display: block; }

/* Sun (light) is warm amber, moon (dark) is indigo. */
.theme-switch-icon.light { order: -1; color: #f59e0b; }
.theme-switch-icon.dark { order: 1; color: #6366f1; }

/* The icon of the inactive theme stays coloured but dimmed. */
html:not([data-theme="dark"]) .theme-switch-icon.dark { opacity: 0.4; }
html[data-theme="dark"] .theme-switch-icon.light { opacity: 0.4; }

.theme-switch-icon:hover {
    background: var(--row-hover);
}

/* The active segment is filled and ringed in its own colour so the
   current theme is clearly readable in both light and dark. */
html:not([data-theme="dark"]) .theme-switch-icon.light {
    background: rgba(245, 158, 11, 0.2);
    box-shadow: inset 0 0 0 1.5px rgba(245, 158, 11, 0.95);
}

html[data-theme="dark"] .theme-switch-icon.dark {
    background: rgba(99, 102, 241, 0.28);
    box-shadow: inset 0 0 0 1.5px rgba(99, 102, 241, 0.95);
}

/* The old sliding knob is no longer used. */
.theme-switch-track { display: none; }

.term-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.term-modal.open {
    display: flex;
}

.term-modal-box {
    width: min(860px, 94vw);
    height: min(560px, 82vh);
    background: var(--bg, #0f172a);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.term-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-soft, #1e293b);
    border-bottom: 1px solid var(--border, #334155);
}

.term-title {
    font-weight: 600;
    font-size: 14px;
}

.term-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.term-close:hover {
    color: var(--fg, #fff);
}

.term-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.term-container {
    flex: 1;
    padding: 8px;
    overflow: hidden;
}

.term-container .xterm {
    height: 100%;
}

.term-status {
    color: var(--muted);
    font-size: 13px;
    padding: 20px 14px;
}

.term-status.term-error {
    color: var(--badge-down-text, #ef4444);
}

.term-actions {
    padding: 10px 14px;
    border-top: 1px solid var(--border, #334155);
}

.user-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.user-modal.open {
    display: flex;
}

.user-modal-box {
    width: min(860px, 92vw);
    height: 72vh;
    max-height: 80vh;
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Same glassmorphism applied to every modal window: translucent body
   + backdrop blur of the overlay behind it. Falls back to opaque card. */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .user-modal-box {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18)),
            var(--glass-bar);
        -webkit-backdrop-filter: blur(14px) saturate(160%);
        backdrop-filter: blur(14px) saturate(160%);
        border: 1px solid var(--glass-bar-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }
    html[data-theme="dark"] .user-modal-box {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
            var(--glass-bar);
        border-color: var(--glass-bar-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }
}

.user-modal-tabs {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 20px 8px;
    border-bottom: 1px solid var(--border);
}

.user-modal-tabs .um-tab {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px 14px;
    font-size: var(--fs-small, 12px);
    color: var(--note);
    cursor: pointer;
}

.user-modal-tabs .um-tab:not(.active):hover {
    background: var(--row-hover);
    color: var(--text);
    border-color: var(--muted);
}

.user-modal-tabs .um-tab.active {
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    border-color: var(--primary-bg);
    color: #fff;
}

/* Head save button + hidden per-pane save buttons (triggered by it) */
.um-head-save {
    padding: 4px 12px;
    font-size: var(--fs-small, 12px);
}

/* «Сохранено» feedback, centered in the window header */
.user-modal-box .modal-head {
    position: relative;
}

.user-modal-box .modal-head .um-saved {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    pointer-events: none;
    /* match the modal title size */
    font-size: 20px;
}

#user-modal-save,
#avatar-save,
#cc-save,
#cf-save {
    display: none;
}

.user-modal-body .um-pane {
    display: none;
}

.user-modal-body .um-pane.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
}

.user-modal-body .um-pane .avatar-section:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.user-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    /* Panes scroll internally; the preview stays pinned via sticky */
    overflow: hidden;
    padding: 16px 20px 20px;
}

.user-modal-body .note {
    margin-top: 0;
}

.user-modal-body .fs-row {
    margin-bottom: 10px;
}

.user-modal-body .fs-actions {
    margin-top: 14px;
}

.avatar-section {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.avatar-section h3 {
    font-size: var(--fs-body, 15px);
    margin: 0 0 8px;
    color: var(--heading);
}

.avatar-section .avatar-preview-row {
    padding: 6px 0 14px;
}

.fs-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text, #e2e8f0);
    margin: 4px 0 6px;
}



.tn-input {
    width: 100%;
    max-width: 220px;
    box-sizing: border-box;
}

.tn-input-num {
    max-width: 100px;
}

.fs-row .tn-input {
    flex: 0 1 auto;
}

html[data-theme="dark"] #fs-reset,
html[data-theme="dark"] #user-modal-reset {
    background: linear-gradient(to bottom, #2b4368 0%, #22324c 100%);
    background-color: #2b4368;
    color: #e2e8f0;
    border: none;
    box-shadow:
        inset 0 4px 6px rgba(255, 255, 255, 0.08),
        inset 0 -4px 10px rgba(0, 0, 0, 0.12),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] #fs-reset:hover,
html[data-theme="dark"] #user-modal-reset:hover {
    filter: brightness(1.15);
    color: var(--nav-hover-text);
    background: linear-gradient(to bottom, #34527a 0%, #29405e 100%);
    background-color: #34527a;
    box-shadow:
        inset 0 4px 6px rgba(255, 255, 255, 0.5),
        inset 0 -4px 10px rgba(0, 0, 0, 0.1),
        0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Drill «роль → пользователь → права» (Настройки → Пользователи → Права ролей) */
.role-drill {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

.role-drill-step {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.role-drill-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--heading, #334155);
    min-width: 168px;
}

.role-drill-ctl {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.role-drill-ctl select {
    min-width: 280px;
    padding: 7px 12px;
    font-size: 15px;
    border-radius: 6px;
    border: 1px solid var(--input-border, #cbd5e1);
    background: var(--input-bg, #fff);
    color: var(--input-text, #1f2933);
}

.role-drill .note {
    flex-basis: 100%;
    margin: 0;
}

.role-drill-panel {
    margin-top: 4px;
}

.drill-userbox {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    padding: 14px 16px;
}

.drill-user-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.drill-user-head b {
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #1f2933);
}

.drill-role-badge {
    background: var(--accent-soft, rgba(0, 150, 166, 0.1));
    color: var(--accent, #0096a6);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.drill-custom-toggle {
    font-size: 15px;
    font-weight: 600;
    color: var(--heading, #334155);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.drill-custom-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-bg, #0284c7);
    margin: 0;
}

.drill-custom-toggle .note {
    font-weight: 400;
    color: var(--note, #64748b);
}

.drill-userbox .perm-group-head {
    font-size: 13px;
    font-weight: 600;
    color: var(--heading, #334155);
}

.drill-userbox .report-actions {
    margin-top: 12px;
}

.drill-userbox .btn-outline:disabled,
.drill-userbox .btn-primary:disabled {
    cursor: not-allowed;
}

/* Grouped permissions (Страницы / Действия) */
.perm-group {
    border: 1px dashed var(--border, #e2e8f0);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 10px;
}

.perm-group:last-child {
    margin-bottom: 0;
}

.perm-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--note, #475569);
}

.perm-group .perm-grid {
    margin-top: 2px;
}

.user-role-select {
    padding: 3px 6px;
    font-size: 13px;
}

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px 16px;
}

.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.perm-item span {
    line-height: 1.35;
}

.perm-item input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 0 0 auto;
    width: 40px;
    height: 22px;
    margin: 0;
    border: 1px solid #000;
    box-sizing: border-box;
    border-radius: 999px;
    background-color: #dc2626;
    background-image: radial-gradient(circle, #fff 0 7.9px, transparent 8px);
    background-repeat: no-repeat;
    background-size: 16px 16px;
    background-position: 3px center;
    transition: background-color 0.2s ease, background-position 0.2s ease;
    vertical-align: middle;
}

.perm-item input[type="checkbox"]:checked {
    background-color: #16a34a;
    background-position: 21px center;
}

.perm-item input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--primary-bg, #0096a6);
    outline-offset: 2px;
}

.perm-item input:disabled {
    cursor: default;
    opacity: 0.55;
}

.perm-item input:disabled + span {
    color: var(--note, #64748b);
}

.perm-item input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Links panel mirrors the top district-filter panel geometry */
.report-links-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.report-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* While a district filter is active only the matching link is clickable */
.report-links a.link-disabled,
.report-links a.link-disabled:hover {
    opacity: 0.45;
    pointer-events: none;
    filter: none;
}

.report-links a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--primary-bg);
    background-color: var(--primary-bg);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.report-links a:hover {
    background-color: var(--primary-hover);
}

/* User-management windows share one standard size regardless of content */
#user-perm-modal .modal,
#user-pass-modal .modal {
    height: 72vh;
}

/* Chat preview stays pinned while settings rows scroll under it */
.user-modal-body .chat-preview {
    position: sticky;
    top: -2px;
    z-index: 2;
    flex-shrink: 0;
    background: var(--bg, #0f172a);
}

/* ---- chat (Mail.ru Агент) ---- */
.chat-root { display: contents; z-index: 1500; }

.chat-avatar-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
    border: 2px solid var(--card-bg, #fff);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 5;
}
.chat-avatar-badge.hidden { display: none !important; }

.chat-panel.chat-panel.hidden { display: none !important; }
.chat-conv.chat-conv.hidden { display: none !important; }
.chat-list.chat-list.hidden { display: none !important; }

.chat-modal-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    display: none;
    z-index: 1550;
    pointer-events: none;
}
.chat-modal-overlay.hidden { display: none !important; }
.chat-modal-overlay:not(.hidden) { display: block; }

.chat-window-row {
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    align-items: stretch;
    gap: 1px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    user-select: none;
    pointer-events: auto;
}

.chat-modal-box {
    background: #eef2f7;
    border: 1px solid #aab9c9;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.chat-modal-box.hidden { display: none !important; }
.chat-contacts-box { width: min(400px, 56vw); height: min(420px, 66vh); }
.chat-conv-box { width: min(640px, 75vw); height: min(420px, 66vh); }

.tg-contacts-search { padding: 8px; flex: none; border-bottom: 1px solid #dfe4ea; background: #ffffff; }
.tg-contacts-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 12px;
    border: 1px solid #dfe4ea;
    border-radius: 18px;
    font-size: 13px;
    background: #f0f2f5;
    color: #17212b;
    outline: none;
}
.tg-contacts-search input:focus { border-color: #4da3e2; background: #ffffff; }

.tg-contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #ffffff;
}
.chat-person {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}
.chat-person:hover { background: #f0f4f8; }
.chat-person.active { background: #e3ecf7; }
.chat-avatar-wrap { position: relative; flex: none; }
.chat-status-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: #a0a8b4;
}
.chat-status-dot.online { background: #4caf50; }
.chat-status-dot.away { background: #f0a500; }
.chat-status-dot.busy { background: #e5533d; }
.chat-status-dot.dnd { background: #b71c1c; }

.chat-person-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-person-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #17212b; }
.chat-person-status { font-size: 11px; color: #4caf50; }
.chat-person-status.offline { color: #a0a8b4; }
.chat-person-status.away { color: #f0a500; }
.chat-person-status.busy { color: #e5533d; }
.chat-person-status.dnd { color: #b71c1c; }
.chat-person-last { font-size: 12px; color: #7a8699; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.chat-person-unread { background: #d93025; color: #fff; border-radius: 10px; min-width: 20px; height: 20px; line-height: 20px; text-align: center; padding: 0 6px; font-size: 11px; font-weight: 700; }

.chat-avatar {
    border-radius: 50%;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.chat-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-conv { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #eef2f7; }

.chat-conv-user-status.offline { color: #e8eef4; }


.chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; }

.chat-msg.mine { align-self: flex-end; }
.chat-msg.mine .chat-msg-wrap { background: #d8e8f8; color: #1c2b3d; border-top-right-radius: 4px; }
.chat-msg.other { align-self: flex-start; }
.chat-msg.other .chat-msg-wrap { background: #fff; color: #22303f; border-top-left-radius: 4px; }

.chat-emoji-btn {
    background: none;
    border: none;
    color: #7a8699;
    font-size: 20px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
}
.chat-emoji-btn:hover { color: #3a6ea5; }
.chat-emoji-panel {
    position: fixed;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 10px;
    border: 1px solid #d5deea;
    background: #fff;
    max-height: 280px;
    overflow-y: auto;
    width: min(340px, 92vw);
    z-index: 3000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.chat-emoji-panel button {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    border-radius: 6px;
}
.chat-emoji-panel button:hover { background: #e3ecf7; }
.chat-emoji-3d { width: 32px; height: 32px; display: block; }
.chat-emoji-msg { width: 1.6em; height: 1.6em; vertical-align: -0.3em; }
.chat-empty { color: #7a8699; font-size: 13px; padding: 16px; text-align: center; }

.chat-toast {
    position: fixed;
    right: 18px;
    bottom: 66px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(320px, 90vw);
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #c3d1e3;
    border-left: 3px solid #3a6ea5;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    z-index: 1600;
    animation: chat-toast-in 0.25s ease;
}
.chat-toast-body { min-width: 0; flex: 1; }
.chat-toast-name { font-weight: 700; font-size: 13px; color: #22303f; }
.chat-toast-text { font-size: 12px; color: #7a8699; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes chat-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Telegram-style chat window ---- */
.chat-conv-box {
    width: min(640px, 75vw);
    height: min(420px, 66vh);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #e7ebf0;
    border: none;
    font-family: "Segoe UI", "Roboto", Arial, sans-serif;
}

.tg-window { display: flex; flex-direction: column; }

.tg-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 9px 10px;
    background: linear-gradient(180deg, var(--chat-header-start, #ffffff) 0%, var(--chat-header-end, #e8eff7) 55%, var(--chat-header-end, #d6e2ee) 100%);
    border-bottom: 1px solid #aebfce;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -2px 0 rgba(255, 255, 255, 0.5),
        0 4px 12px rgba(30, 55, 90, 0.18),
        0 1px 0 rgba(255, 255, 255, 0.6);
    flex: none;
    user-select: none;
    cursor: grab;
    position: relative;
    z-index: 2;
}
.tg-header::before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    top: 0;
    height: 40%;
    border-radius: 0 0 10px 10px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0));
    pointer-events: none;
}
.tg-header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding: 0 4px;
}
.tg-avatar-wrap { flex: none; position: relative; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.tg-avatar-wrap .chat-status-dot { width: 14px; height: 14px; border-width: 2.5px; right: 1px; bottom: 1px; }
.tg-header-info { min-width: 0; display: flex; flex-direction: column; }
.tg-title {
    font-weight: 700;
    font-size: var(--chat-fs-title, 15px);
    color: #17212b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.tg-title:hover { color: #168acd; text-decoration: underline; }
.tg-subtitle { font-size: var(--chat-fs-subtitle, 12px); color: #6b7686; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-header-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.tg-icon {
    background: none;
    border: none;
    color: #e53e3e;
    cursor: pointer;
    line-height: 0;
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tg-icon:hover { color: #c53030; }

.tg-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--chat-body-bg, #d7e0ea);
}

.tg-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 14px;
    display: flex;
    flex-direction: column;
    background-image: var(--chat-msgs-bg-img, url("/static/img-chat-bg.jpg?v=2"));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--chat-msgs-bg, #eef2f8);
}

.tg-date {
    align-self: center;
    background: #ffffff;
    color: #7b8694;
    font-size: var(--chat-fs-date, 12px);
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin: 8px 0;
}

.tg-msg {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    margin-bottom: 5px;
    max-width: 78%;
}
.tg-msg.mine { align-self: flex-end; }
.tg-msg-avatar { flex: none; }
.tg-msg-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    max-width: 100%;
    min-width: 0;
}
.tg-msg-name {
    font-size: var(--chat-fs-name, 12px);
    font-weight: 700;
    color: var(--chat-name-color, #1f66c2);
    padding: 0 4px;
    user-select: none;
}
.tg-bubble {
    position: relative;
    background: var(--chat-bubble-other-bg, #ffffff);
    color: #111926;
    border-radius: 12px;
    border-top-left-radius: 3px;
    border: 1px solid var(--chat-bubble-other-border, #e6ebf1);
    padding: 7px 10px 6px 10px;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--chat-fs-msg, 15px);
    line-height: 1.45;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    max-width: 100%;
}
.tg-msg.mine .tg-bubble {
    background: var(--chat-bubble-mine-bg, #eaf4ff);
    border-color: var(--chat-bubble-mine-border, #d3e6f8);
    border-radius: 12px;
    border-top-right-radius: 3px;
}
.tg-msg.mine { margin-left: auto; }
.tg-text { display: block; white-space: pre-wrap; overflow-wrap: break-word; padding-right: 2px; }
.tg-meta {
    float: right;
    margin: 3px 0 -2px 8px;
    font-size: var(--chat-fs-meta, 11px);
    color: #67727e;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    user-select: none;
}
.tg-msg.mine .tg-meta { color: #6aa8e0; }
.tg-msg.mine .tg-msg-name { color: var(--chat-my-name-color, #4da3e2); }
.tg-check { display: inline-flex; align-items: center; gap: 1px; color: #a3adb8; margin-left: 2px; }
.tg-check svg { display: block; }
.tg-check-svg { color: #a3adb8; }
.tg-check-svg.read { color: #4da3e2; }
.tg-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 4px;
    border: 0;
    background: transparent;
    color: #a3adb8;
    cursor: pointer;
    line-height: 1;
}
.tg-edit svg { display: block; }
.tg-edit:hover { color: #4da3e2; }
.tg-msg.mine .tg-meta .tg-edit { color: #6aa8e0; }
.tg-msg.mine .tg-meta .tg-edit:hover { color: #2f80c4; }
.tg-edited { margin-right: 4px; font-style: italic; opacity: 0.85; }
.tg-edit-input {
    display: block;
    width: 100%;
    min-width: 180px;
    box-sizing: border-box;
    resize: none;
    border: 1px solid var(--chat-bubble-mine-border, #d3e6f8);
    border-radius: 8px;
    padding: 5px 7px;
    font: inherit;
    color: inherit;
    background: #fff;
    outline: none;
    overflow: hidden;
}
.tg-edit-input:focus { border-color: #4da3e2; }
.tg-edit-actions {
    display: inline-flex;
    gap: 6px;
    margin-top: 5px;
}
.tg-edit-actions button {
    border: 1px solid var(--chat-bubble-mine-border, #d3e6f8);
    background: #f2f8ff;
    color: #2f80c4;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 4px 8px;
}
.tg-edit-actions button:hover { background: #e2eefc; }

.tg-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--chat-input-bg, #f4f7fb);
    border-top: 2px solid #b8c7d8;
    box-shadow: 0 -4px 10px rgba(30, 55, 90, 0.10);
    flex: none;
    z-index: 2;
}
.tg-input-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: stretch;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #cdd8e4;
    border-radius: 22px;
    padding: 3px 3px 3px 12px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}
.tg-input-field:focus-within {
    border-color: #3a6ea5;
    box-shadow: 0 0 0 3px rgba(58, 110, 165, 0.15);
}
.tg-input-field textarea {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    outline: none;
    font-size: var(--chat-fs-input, 14px);
    color: #17212b;
    padding: 7px 6px;
    resize: none;
    font-family: inherit;
    line-height: 1.35;
    min-height: 66px;
    max-height: 120px;
    overflow-y: auto;
    display: block;
}
.tg-toolbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 10px;
    background: var(--chat-toolbar-bg, #eef2f7);
    border-top: 2px solid #c9d6e4;
    border-bottom: 2px solid #c9d6e4;
    flex: none;
}
.tg-toolbar-btn {
    background: none;
    border: none;
    font-size: 17px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7b8694;
    flex: none;
}
.tg-toolbar-btn:hover { background: #e8eef5; color: #3a6ea5; }
.chat-emoji-btn-img { width: 24px; height: 24px; display: block; border-radius: 4px; }
.tg-toolbar-hint {
    font-size: 11px;
    color: #9aa5b1;
    user-select: none;
}

.tg-send {
    background: #22c55e;
    border: none;
    cursor: pointer;
    width: 38px;
    align-self: stretch;
    border-radius: 18px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.tg-send:hover { background: #16a34a; }
.tg-send svg { display: block; }

/* chat settings preview */
.chat-preview {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.cp-header {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 12px;
    background: linear-gradient(180deg, var(--chat-header-start, #ffffff) 0%, var(--chat-header-end, #d6e2ee) 100%);
    border-bottom: 1px solid #aebfce;
}
.cp-title {
    font-size: var(--chat-fs-title, 15px);
    font-weight: 700;
    color: #17212b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cp-subtitle {
    font-size: var(--chat-fs-subtitle, 12px);
    color: #6b7686;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cp-body {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 10px 12px;
    background-image: var(--chat-msgs-bg-img, url("/static/img-chat-bg.jpg?v=2"));
    background-size: cover;
    background-position: center;
    background-color: var(--chat-msgs-bg, #eef2f8);
}
.cp-msg {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    max-width: 85%;
}
.cp-msg.cp-mine { align-self: flex-end; align-items: flex-end; }
.cp-name {
    font-size: var(--chat-fs-name, 12px);
    font-weight: 700;
    color: var(--chat-name-color, #1f66c2);
    padding: 0 4px;
    user-select: none;
}
.cp-msg.cp-mine .cp-name { color: var(--chat-my-name-color, #4da3e2); }
.cp-bubble {
    font-size: var(--chat-fs-msg, 14px);
    line-height: 1.3;
    padding: 6px 9px 5px;
    border-radius: 12px;
    background: var(--chat-bubble-other-bg, #ffffff);
    border: 1px solid var(--chat-bubble-other-border, #e6ebf1);
    color: #17212b;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.cp-msg.cp-mine .cp-bubble {
    background: var(--chat-bubble-mine-bg, #eaf4ff);
    border-color: var(--chat-bubble-mine-border, #d3e6f8);
    border-radius: 12px;
    border-top-right-radius: 3px;
}
.cp-meta {
    font-size: var(--chat-fs-meta, 11px);
    color: #67727e;
    padding: 0 4px;
}
.cp-msg.cp-mine .cp-meta { color: #6aa8e0; }
.cp-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;  /* кнопки всегда рядом (28.10) */
    gap: 8px;
    padding: 4px 10px;
    background: var(--chat-toolbar-bg, #2b394b);  /* тёмная полоска — иконки видно (28.10) */
    color: #ffffff;
    border-top: 2px solid #1e2833;
    border-bottom: 2px solid #1e2833;
}
/* Кнопка-чип: тёмный квадрат с белой иконкой — видна на ЛЮБОМ фоне
   полоски (28.10, «значки так и не видны» — исправлено окончательно). */
.cp-toolbar-smile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    flex: none;
    background: #22303e;
    color: #ffffff;
    border: 1px solid #16202b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.cp-toolbar-smile:hover { background: #3b4f66; }
.cp-toolbar-smile:active { background: #16202b; }
/* Подсказка — светлый текст на тёмной плашке: читается на любом фоне */
.cp-toolbar-hint {
    margin-left: auto;
    font-size: 11px;
    color: #dce6f0;
    background: rgba(10, 18, 28, 0.55);
    padding: 3px 9px;
    border-radius: 8px;
    user-select: none;
}
.cp-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--chat-input-bg, #f4f7fb);
    border-top: 2px solid #b8c7d8;
    box-shadow: 0 -4px 10px rgba(30, 55, 90, 0.10);
}
.cp-input-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #cdd8e4;
    border-radius: 22px;
    padding: 7px 12px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}
.cp-input-placeholder {
    font-size: var(--chat-fs-input, 14px);
    color: #9aa5b1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cp-send {
    background: #22c55e;
    border: none;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 19px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.cp-send svg { display: block; }

.chat-emoji-panel.hidden { display: none; }
.chat-emoji-panel {
    position: fixed;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 10px;
    border: 1px solid #dfe4ea;
    background: #ffffff;
    max-height: 280px;
    overflow-y: auto;
    width: min(340px, 92vw);
    z-index: 3000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.chat-emoji-panel button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    border-radius: 6px;
}
.chat-emoji-panel button:hover { background: #f0f4f8; }

/* ---- Games modal ---- */

.chat-game-modal.hidden { display: none; }

.tg-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    color: #8494a6;
}
.tg-icon:hover { background: #e8eef5; color: #3a6ea5; }

.tg-game-btn.ok { background: #2f88d0; color: #fff; }
.tg-game-btn.ok:hover { background: #3a95dc; }
.tg-game-btn.no { background: #eef1f5; color: #4a5a6d; }
.tg-game-btn.no:hover { background: #e2e7ee; }


/* checkers */

.tg-chk-cell.dark { background: #b0815a; }

.tg-chk-cell.sel { background: rgba(47, 136, 208, 0.45); }

.tg-chk-p.white { background: #f4f0e8; }


/* battleship */

.tg-bs-cell.hit { background: #f5c6c6; }


/* backgammon */

.tg-bg-row.top .tg-bg-pt { border-bottom: 1px dashed rgba(0,0,0,0.15); }
.tg-bg-row.bottom .tg-bg-pt { border-top: 1px dashed rgba(0,0,0,0.15); }

.tg-bg-pt.sel { outline: 2px solid rgba(47,136,208,0.6); outline-offset: -2px; background: rgba(47,136,208,0.18); }

.tg-bg-row.top .tg-bg-pt:nth-child(odd) { background: #d8b87e; }
.tg-bg-row.top .tg-bg-pt:nth-child(even) { background: #c9a463; }
.tg-bg-row.bottom .tg-bg-pt:nth-child(odd) { background: #c9a463; }
.tg-bg-row.bottom .tg-bg-pt:nth-child(even) { background: #d8b87e; }
.tg-bg-pt.home { background: #f0d9a6; }

.tg-bg-row.bottom .tg-bg-tri {
    border-left: 22px solid transparent;
    border-right: 22px solid transparent;
    border-bottom: none;
    border-top: 30px solid #fff;
    top: auto;
    bottom: 4px;
}
.tg-bg-tri.w { border-bottom: 30px solid #f4efe4; }
.tg-bg-tri.b { border-bottom: 30px solid #3a3a3a; }
.tg-bg-row.bottom .tg-bg-tri.w { border-top: 30px solid #f4efe4; }
.tg-bg-row.bottom .tg-bg-tri.b { border-top: 30px solid #3a3a3a; }

.tg-bg-row.bottom .tg-bg-stack { justify-content: flex-end; padding-top: 0; padding-bottom: 10px; height: 100%; }

.tg-bg-chk.w { background: #f4efe4; }
.tg-bg-chk.b { background: #3a3a3a; }

.tg-bg-row.top .tg-bg-cnt { bottom: 3px; }
.tg-bg-row.bottom .tg-bg-cnt { top: 3px; }


/* ---- ONU status modal ---- */
.modal-wide { max-width: 1080px; }

/* ONU activation history (last 30 days): widen so all columns fit one row. */
#range-history-modal .modal { max-width: 1500px; width: 96vw; }
#range-history-modal .serials-table { white-space: nowrap; }
#range-history-modal .serials-scroll { overflow-x: auto; }

.modal-register .modal-body {
    display: flex;
    flex-direction: column;
}

.modal-register .onu-register-spacer {
    display: none;
}

.modal-register .onu-actions-btns {
    margin-top: 1.5cm;
}

.modal-register {
    max-width: 90vw;
    width: 560px;
    height: auto;
    position: fixed;
}

.modal-register .onu-field select,
.modal-register .onu-field .onu-input {
    width: 100%;
}

.modal-register .modal-head {
    cursor: move;
    user-select: none;
    padding: 8px 20px;
}

.modal-register .modal-body {
    padding: 14px 1cm 20px;
}

.modal-register #onu-register-id {
    margin-top: 0;
}

.onu-port-info {
    margin: 14px 0 4px;
    border-top: 2px solid var(--border);
    padding-top: 10px;
    font-family: "Segoe UI", Arial, sans-serif;
}

.onu-port-info-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--head);
    margin-bottom: 10px;
}

.onu-port-info-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 10px;
    font-size: 17px;
    line-height: 1.5;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.onu-port-info-row:nth-child(odd) {
    background: rgba(0,0,0,0.03);
}

.onu-port-info-row.is-err {
    color: #d33;
    font-weight: 500;
}

.onu-port-info-row.is-err pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow: auto;
    color: #d33;
    font-size: 15px;
}

.onu-port-info-label {
    color: var(--head);
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    min-width: 140px;
}

.onu-port-info-value {
    font-weight: 600;
    color: var(--text);
    text-align: right;
    word-break: break-word;
    font-size: 16px;
}

.onu-port-info-row.dg-loading {
    color: var(--note);
    font-weight: 500;
    border-bottom: none;
}

.onu-sticky {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--card-bg);
    padding-top: 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.onu-port-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 4px;
}

.onu-port-row label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
}

.onu-port-select {
    min-width: 148px;
    max-width: 220px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 17px;
}


.onu-port-select optgroup {
    font-weight: 600;
    color: var(--note);
}

.onu-port-select option {
    font-weight: 400;
    color: var(--input-text);
    font-variant-numeric: tabular-nums;
    font-size: 17px;
}

input.onu-id-input {
    width: 72px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 17px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.onu-id-input::-webkit-outer-spin-button,
.onu-id-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.onu-id-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}





.onu-search {
    min-width: 220px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 13px;
}

.onu-stats-row {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 10px 0;
}

/* ---- VLAN-ы плат на OLT: three-column port view ---- */
.vlan-view-box {
    border: 1px dashed var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 4px 16px 10px;
    max-height: 46vh;
    overflow-y: auto;
    font-size: 15px;
}

.vlan-view-box .vlan-row {
    display: grid;
    grid-template-columns: max-content max-content 1fr;
    gap: 10px 32px; /* row-gap | column-gap */
    align-items: center;
    padding: 4px 6px;
}

.vlan-view-box .vlan-row:not(.vlan-head-row):nth-child(even) {
    background: rgba(100, 116, 139, 0.16);
    border-radius: 7px;
}

html[data-theme="dark"] .vlan-view-box .vlan-row:not(.vlan-head-row):nth-child(even) {
    background: rgba(148, 163, 184, 0.10);
}

.vlan-head-row {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card-bg, #fff);
    padding: 9px 6px 7px;
    margin-bottom: 3px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--note, #475569);
}

.vlan-port,
.vlan-std {
    color: var(--text);
}

.vlan-std {
    font-weight: 600;
}

.vlan-std.vlan-none {
    font-weight: 400;
    color: var(--note, #64748b);
    opacity: 0.75;
}

.vlan-custom {
    color: var(--primary-bg, #0096a6);
    font-weight: 700;
    font-size: 16px;
}

.vlan-own {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.vlan-edit-btn,
.vlan-save {
    cursor: pointer;
    color: var(--muted);
    opacity: 0.9;
    background: none;
    border: none;
    padding: 0 2px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    transition: opacity 0.15s, color 0.15s;
}

.vlan-edit-btn:hover,
.vlan-save:hover {
    opacity: 1;
    color: var(--primary-bg);
}

.vlan-ico {
    width: 1em;
    height: 1em;
}

/* Add-own-VLAN button for ports without a standard VLAN. */
.vlan-add-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid var(--primary-bg, #0096a6);
    background: rgba(0, 150, 166, 0.10);
    color: var(--primary-bg, #0096a6);
    transition: background 0.15s, border-color 0.15s;
}

.vlan-add-btn:hover {
    background: rgba(0, 150, 166, 0.22);
    border-color: var(--primary-bg, #0096a6);
}

/* Custom OLT picker (trigger + popup list) */

.vlan-own {
    white-space: nowrap;
}

.vlan-edit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vlan-by {
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
    font-size: 12.5px;
    color: var(--note, #475569);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vlan-input {
    width: 112px;
    box-sizing: border-box;
    padding: 8px 12px;
    font-size: 15px;
    border-radius: 8px;
    border: 1px solid var(--input-border, #94a3b8);
    background: var(--input-bg, #fff);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.vlan-input:focus {
    outline: none;
    border-color: var(--primary-bg, #0096a6);
    box-shadow: 0 0 0 3px rgba(0, 150, 166, 0.16);
}

.vlan-input.vlan-invalid {
    border-color: var(--danger, #dc2626) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.vlan-save {
    color: var(--primary-bg);
    opacity: 1;
}

.vlan-save:disabled {
    cursor: not-allowed;
}

.vlan-clear {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 7px;
    border: 1px solid var(--border, #e2e8f0);
    background: transparent;
    color: var(--muted, #94a3b8);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}

.vlan-row:hover .vlan-clear {
    opacity: 1;
}

.vlan-clear:hover {
    color: var(--danger, #dc2626);
    border-color: var(--danger, #dc2626);
}

.vlan-cancel {
    width: 24px;
    height: 24px;
    margin-left: -4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted, #94a3b8);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.vlan-cancel:hover {
    color: var(--danger, #dc2626);
    background: transparent;
}

#vlan-olt-select,
#vlan-card-select {
    max-width: none;
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 8px;
}

.vlan-summary {
    font-size: 13.5px;
    color: var(--note, #475569);
    margin: -4px 0 12px;
}

/* Status counters are clickable: click sorts matching ONUs to the top. */
.onu-stats-row .stat {
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
}

.onu-stats-row .stat:hover {
    background: var(--row-hover);
}

.onu-stats-row .stat.sort-active {
    background: var(--row-hover);
    border-color: var(--primary-bg, #0096a6);
}

.olt-row { cursor: pointer; }
.olt-row:hover { background: var(--row-hover); }

.onu-row.onu-highlight {
    background: rgba(250, 204, 21, 0.18) !important;
    outline: 2px solid #facc15;
}

.status-dot.is-warn { background: #f59e0b; }

.onu-port-row .last-refresh { margin: 0; }

/* ---- Registry of ONU serials (olt page) ---- */
.serials-scroll {
    max-height: 60vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.serials-table {
    width: 100%;
    border-collapse: collapse;
}

.serials-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--thead-bg);
    color: var(--thead-text);
    text-align: left;
    padding: 9px 12px;
    font-size: 12px;
}

.serials-table td {
    padding: 7px 12px;
    border-top: 1px solid var(--border);
    font-size: var(--fs-table, 14px);
}

.serials-table tbody tr:hover {
    background: var(--row-hover);
}

.serial-arrow-cell {
    text-align: center;
    white-space: nowrap;
}

.serial-arrow {
    color: var(--primary-bg, #2563eb);
    font-weight: 700;
    font-size: 16px;
    width: 30px;
    height: 30px;
    padding: 0;
    border-color: var(--border);
}

.serial-arrow:hover {
    color: #fff;
    background: var(--primary-bg, #2563eb);
    border-color: var(--primary-bg, #2563eb);
}

/* ---- Inner scrolling for the ONU subscribers table ---- */
.onu-table-wrap {
    max-height: 58vh;
    overflow: auto;
}

/* The Actions column exists only when it is needed (an interface number
   is pinned); otherwise the whole column is hidden. */
.onu-table-wrap.hide-actions th:last-child,
.onu-table-wrap.hide-actions td.onu-action-btns-wrap {
    display: none;
}

.onu-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--thead-bg);
}

/* Extra status badges for the serial registry */
.status-badge.ok {
    background: var(--badge-up-bg);
    color: var(--badge-up-text);
    border: 1px solid transparent;
}

.status-badge.online {
    background: rgba(0, 150, 166, 0.14);
    color: #007d8c;
    border: 1px solid rgba(0, 150, 166, 0.35);
}

html[data-theme="dark"] .status-badge.online {
    background: rgba(18, 163, 180, 0.16);
    color: #4dd0e1;
    border-color: rgba(77, 208, 225, 0.35);
}

.status-badge.gone {
    background: var(--thead-bg);
    color: var(--muted);
    border: 1px solid var(--border);
}

/* Defensive: long custom dropdowns get their own scroll */
.perm-dropdown {
    max-height: 60vh;
    overflow-y: auto;
}

/* ---- «Терминал уже активировался ранее» readability ---- */
.onu-register-prev {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-left: 4px solid #ea580c;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
}

.onu-register-prev-title {
    font-size: 15px;
    font-weight: 700;
    color: #c2410c;
    margin-bottom: 8px;
}

.onu-register-prev-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 14px;
    padding: 6px 0;
}

.onu-register-prev-row + .onu-register-prev-row {
    border-top: 1px dashed #fed7aa;
}

.onu-register-prev-row .btn-prev-del {
    margin-left: auto;
    font-size: 12px;
    padding: 3px 10px;
}

html[data-theme="dark"] .onu-register-prev {
    background: #33240f;
    border-color: #7c5a2e;
    border-left-color: #f59e0b;
}

html[data-theme="dark"] .onu-register-prev-title {
    color: #fdba74;
}

html[data-theme="dark"] .onu-register-prev-row + .onu-register-prev-row {
    border-top-color: #57431f;
}

/* ====================================================================
   Overflow fix — широкие таблицы и тулбары не вылезают за карточку.
   Таблицы с nowrap-ячейками шире карточки прокручиваются внутри неё
   по горизонтали; когда всё влезает — вид не меняется. Тулбары и
   строки поиска переносятся вместо переполнения.
   ==================================================================== */

.card {
    overflow-x: auto;
}

.search-row,
.tree-toolbar,
.db-toolbar {
    flex-wrap: wrap;
}

/* ---- Topology tab: interactive SVG tree (5 levels up + 5 levels down) ---- */
.topo-svg-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    background: var(--panel-bg, #fff);
}

.topo-svg-legend {
    font-size: 12px;
    color: var(--note, #64748b);
}

.topo-svg-zoom {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
}

.topo-zoom-btn {
    min-width: 30px;
    padding: 3px 9px;
    line-height: 1.2;
}

.topo-search-input {
    width: 260px;
    font-size: 14px;
    padding: 8px 12px;
    border: 1px solid var(--input-border, #cbd5e1);
    border-radius: 6px;
    background: var(--input-bg, #fff);
    color: var(--input-text, #1e293b);
}

.topo-search-input:focus {
    outline: none;
    border-color: var(--primary-bg, #2563eb);
}

.topo-focus-label {
    font-size: 12px;
    color: var(--accent, #2563eb);
    font-variant-numeric: tabular-nums;
}

/* The search box lives in the always-visible toolbar (this tab starts
   empty — the graph is only built after an IP is entered). */
#view-topology .tree-toolbar {
    justify-content: flex-start;
    align-items: center;
}

#view-topology .tree-toolbar .topo-focus-label {
    margin-left: auto;
}

#topo-svg-canvas {
    overflow: auto;
    max-height: calc(100vh - 250px);
    cursor: grab;
    background: var(--panel-bg, #fff);
}

#topo-svg-canvas.topo-panning {
    cursor: grabbing;
}

.topo-svg {
    display: block;
    transform-origin: 0 0;
    will-change: transform;
    width: 100%;
    height: auto;
}

#topo-svg-wrap {
    position: relative;
    width: 100%;
    background: var(--panel-bg, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
}





.topo-node {
    cursor: pointer;
}

/* Node markers: a status dot with the IP and name underneath (no box). */
.topo-node-hit {
    fill: transparent;
}

.topo-node:hover .topo-status-dot,
.topo-node.focus .topo-status-dot,
.topo-node.hit .topo-status-dot {
    filter: drop-shadow(0 0 2px var(--accent-soft, rgba(37, 99, 235, 0.5)));
}

.topo-node.focus .topo-status-dot,
.topo-node.hit .topo-status-dot {
    stroke-width: 2;
}

.topo-node-ring {
    fill: none;
    stroke: #020617;
    stroke-width: 1.5;
}

.topo-status-dot {
    fill: currentColor;
}

.topo-status-dot.up {
    color: #16a34a;
}

.topo-status-dot.down {
    color: #dc2626;
}

.topo-status-dot.never {
    color: #94a3b8;
}

.topo-status-dot.unstable {
    color: #facc15;
    stroke: #dc2626;
    stroke-width: 1.5;
}

.topo-central-ring {
    fill: #16a34a;
}

.topo-central-star {
    fill: #fff;
}

.topo-node-ip {
    fill: var(--note, #64748b);
}

.topo-node-ip.mono {
    font-family: var(--mono, ui-monospace, Consolas, monospace);
    font-size: 11px;
}

.topo-node-name {
    fill: var(--text, #0f172a);
    font-weight: 600;
}

.topo-node-name.mono {
    font-family: var(--mono, ui-monospace, Consolas, monospace);
    font-size: 12px;
}

.topo-edge {
    fill: none;
    stroke: var(--border, #e2e8f0);
    stroke-width: 1.5;
}

.topo-arrow-head {
    fill: #020617;
    stroke: none;
}



/* ---- Shift schedule (/schedule) ---- */
:root {
    --sched-day-bg: #c5e0b4;
    --sched-day-fg: #1f3b12;
    --sched-night-bg: #b4c7e7;
    --sched-night-fg: #1f2f4f;
    --sched-off-bg: #f2b8b5;
    --sched-off-fg: #7f1d1d;
    --sched-absent-bg: #facc15;
    --sched-absent-fg: #422006;
    --sched-x2-bg: #a78bfa;
    --sched-x2-fg: #2e1065;
    --sched-section-shift-bg: #e3ebf6;
    --sched-section-shift-fg: #1f3864;
    --sched-section-shift-mark: #b4c7e7;
    --sched-team-bg: #f1f5f9;
    --sched-user-bg: #f6f8fb;
    --sched-weekend-head-bg: #c97b7b;
    --sched-weekend-fg: #3b0d0d;
    --sched-today-bg: rgba(0, 150, 166, 0.10);
    --sched-grid-line: #b9c5d4;
}

html[data-theme="dark"] {
    --sched-off-bg: #7f2d33;
    --sched-off-fg: #fecaca;
    --sched-absent-bg: #a16207;
    --sched-absent-fg: #fef9c3;
    --sched-x2-bg: #6d28d9;
    --sched-x2-fg: #f5f3ff;
    --sched-section-shift-bg: #24344d;
    --sched-section-shift-fg: #dbe5f1;
    --sched-section-shift-mark: #b4c7e7;
    --sched-team-bg: #253043;
    --sched-user-bg: #202b3a;
    --sched-weekend-head-bg: #8f4a4f;
    --sched-weekend-fg: #ffe4e6;
    --sched-today-bg: rgba(18, 163, 180, 0.10);
    --sched-grid-line: #46536a;
}

.sched-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.sched-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sched-nav .btn-outline {
    padding: 5px 12px;
    font-size: 15px;
    line-height: 1.2;
    border-radius: 8px;
}

#sched-today {
    font-size: var(--fs-small, 13px);
}

.sched-month {
    min-width: 140px;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
}

.sched-legend {
    margin: 4px 0 8px;
    line-height: 1.7;
}

.sched-sw {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    vertical-align: -2px;
    margin: 0 3px;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.sched-sw-day {
    background: var(--sched-day-bg);
}

.sched-sw-night {
    background: var(--sched-night-bg);
}

.sched-sw-off {
    background: var(--sched-off-bg);
}

.sched-sw-absent {
    background: var(--sched-absent-bg);
}

.sched-sw-x2 {
    background: var(--sched-x2-bg);
}

.sched-sw-empty {
    background: transparent;
    border: 1px dashed var(--muted);
}

.sched-status.sched-status-error {
    color: #dc2626;
}

.sched-wrap {
    overflow-x: auto;
    margin-top: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.sched-grid {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    font-size: var(--fs-small, 13px);
    color: var(--text);
    background: var(--card-bg);
}

.sched-grid th,
.sched-grid td {
    border: 2px solid var(--sched-grid-line);
    text-align: center;
}

.sched-grid thead th {
    background: var(--thead-bg);
    color: var(--thead-text);
    position: sticky;
    top: 0;
    z-index: 2;
}

.sched-user-col {
    width: 190px;
    min-width: 190px;
    max-width: 210px;
    box-sizing: border-box;
    text-align: left !important;
    padding: 6px 10px;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--sched-user-bg);
    color: var(--text);
    font-weight: 600;
    font-size: 15px;
}

.sched-grid thead .sched-user-col {
    z-index: 5;
    background: var(--thead-bg);
}

.sched-user-name {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.sched-team-chip {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--sched-team-bg);
    color: var(--note);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.5;
    vertical-align: 1px;
}

.sched-section-row td {
    padding: 9px 12px 9px 14px;
    border: 0;
    border-bottom: 3px solid var(--sched-section-shift-mark);
    background: var(--sched-section-shift-bg);
    box-shadow: inset 5px 0 0 var(--sched-section-shift-mark);
    color: var(--sched-section-shift-fg);
    font-size: var(--fs-small, 12px);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
}

/* Thicker line between adjacent night-shift teams (not above the first one). */
.sched-row.sched-team-start td {
    border-top: 4px solid var(--note);
}

.sched-flag {
    font-weight: 400;
    font-size: 13px;
    color: var(--note);
}

.sched-day-head {
    width: 24px;
    min-width: 24px;
    padding: 4px 1px;
    font-weight: 600;
}

.sched-day-num {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.15;
}

.sched-day-head .sched-dw {
    display: block;
    margin-top: 1px;
    color: var(--heading);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
}

.sched-day-head.weekend {
    background: var(--sched-weekend-head-bg);
    color: var(--sched-weekend-fg);
}

.sched-day-head.weekend .sched-dw {
    color: inherit;
    opacity: 0.95;
}

.sched-day-head.today {
    background: var(--primary-bg);
    color: #ffffff;
}

.sched-day-head.today .sched-dw {
    color: #ffffff;
    opacity: 0.9;
    font-weight: 600;
}

.sched-cell {
    width: 24px;
    min-width: 24px;
    height: 32px;
    padding: 0;
    font-weight: 700;
    font-size: 8px;
    cursor: pointer;
    user-select: none;
    text-align: center;
}

.sched-cell[data-edit="0"] {
    cursor: default;
}

.sched-cell.is-day {
    background: var(--sched-day-bg);
    color: var(--sched-day-fg);
}

.sched-cell.is-night {
    background: var(--sched-night-bg);
    color: var(--sched-night-fg);
}

.sched-cell.is-off {
    background: var(--sched-off-bg);
    color: var(--sched-off-fg);
}

.sched-cell.is-absent {
    background: var(--sched-absent-bg);
    color: var(--sched-absent-fg);
}

.sched-cell.is-x2 {
    background: var(--sched-x2-bg);
    color: var(--sched-x2-fg);
}

/* today column: translucent fill only where no shift is set, so the
   indicator never hides an actual shift; rails mark the column on every cell. */
.sched-cell.today:not(.is-day):not(.is-night):not(.is-off):not(.is-absent):not(.is-x2) {
    background: var(--sched-today-bg);
}

.sched-cell.today {
    box-shadow: inset 4px 0 0 0 var(--primary-bg), inset -4px 0 0 0 var(--primary-bg);
}

.sched-cell[data-edit="1"]:hover {
    box-shadow: inset 0 0 0 2px var(--primary-bg);
}

.sched-row.sched-me .sched-user-col {
    box-shadow: inset 3px 0 0 var(--primary-bg);
}

.sched-row.sched-off-row .sched-user-col {
    opacity: 0.6;
}

/* Hover: light feedback on the sticky name cell only (the global
   tr:hover rule must NOT paint rows of this grid — in the dark theme
   --row-hover is near-black and it covered the employee name). */
.sched-row:hover .sched-user-col {
    background: var(--row-hover);
}

/* Clicked row is lifted above the grid while its menu is open.
   NB: no position/z-index here — it would override the sticky
   name cell; a transformed element already paints above siblings. */
.sched-row.sched-lift td {
    transform: translateY(-2px);
}

.sched-row.sched-lift .sched-user-col {
    z-index: 7;
    background: var(--card-bg);
    box-shadow: 0 -5px 12px rgba(15, 23, 42, 0.22), 0 5px 12px rgba(15, 23, 42, 0.22);
}

.sched-menu {
    position: fixed;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    min-width: 150px;
    padding: 4px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.sched-menu.hidden {
    display: none !important;
}

.sched-menu-item {
    appearance: none;
    background: none;
    border: 0;
    border-radius: 6px;
    padding: 8px 12px;
    text-align: left;
    font-size: 13px;
    color: var(--text, #1f2933);
    cursor: pointer;
}

.sched-menu-item:hover {
    background: rgba(0, 150, 166, 0.14);
}

.sched-menu-item.active {
    font-weight: 700;
    color: var(--primary-bg, #0096a6);
    background: rgba(0, 150, 166, 0.16);
}

.sched-menu-clear {
    color: #dc2626;
    border-top: 1px solid var(--border, #e2e8f0);
    border-radius: 0 0 6px 6px;
}

/* ---- admin: fill / clear modal ------------------------------------- */

.sched-clear-label {
    display: block;
    margin-top: 12px;
}

.sched-clear-select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 6px 8px;
    font-size: 14px;
    color: var(--text, #1f2933);
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
}

.sched-clear-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.sched-fill-team {
    margin: 10px 0 2px;
    padding-top: 6px;
    border-top: 1px solid var(--border, #e2e8f0);
    color: var(--heading, #334155);
    font-size: var(--fs-small, 12px);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sched-fill-team.sched-fill-day {
    border-top-style: dashed;
    color: var(--note, #64748b);
    text-transform: none;
    letter-spacing: 0;
}

.sched-fill-team:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.sched-fill-users {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.sched-fill-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text, #1f2933);
}

.sched-fill-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sched-fill-pattern {
    flex: 0 0 auto;
    max-width: 60%;
    padding: 4px 6px;
    font-size: 13px;
    color: var(--text, #1f2933);
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
}

.sched-clear-actions .btn-outline:disabled {
    cursor: not-allowed;
}

/* Ghost/icon buttons must never pick up the flat primary fill that the base
   `button` rule applies on hover/active — they manage their own background. */
.pwd-toggle:hover,
.pwd-toggle:active,
.term-close:hover,
.term-close:active,
.folder-copy-btn:hover,
.folder-copy-btn:active,
.vlan-edit-btn:hover,
.vlan-edit-btn:active,
.vlan-save:hover,
.vlan-save:active,
.vlan-clear:hover,
.vlan-clear:active,
.btn-icon:hover,
.btn-icon:active {
    background: none;
    background-color: transparent;
}

/* ...but icon buttons get a soft slate wash that matches the flat theme. */
.btn-icon:hover {
    background: var(--row-hover, rgba(127, 127, 127, 0.08));
    background-color: var(--row-hover, rgba(127, 127, 127, 0.08));
}

/* ================= Import tab (Импорт структуры) ================= */

.imp-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}

.imp-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg, var(--card-bg));
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
}

.imp-chip b {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.imp-chip.ok b { color: #16a34a; }
.imp-chip.warn b { color: #c2410c; }

.imp-note {
    font-size: 12px;
    color: var(--muted);
    margin-left: 4px;
}

.imp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

@media (max-width: 900px) {
    .imp-grid { grid-template-columns: 1fr; }
}

.imp-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.imp-col-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px;
    background: var(--thead-bg);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.imp-count {
    display: inline-block;
    min-width: 22px;
    padding: 1px 8px;
    border-radius: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    background: var(--thead-bg);
    color: var(--muted);
    border: 1px solid var(--border);
}

.imp-count.warn {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}

html[data-theme="dark"] .imp-count.warn {
    background: rgba(234, 88, 12, 0.18);
    color: #fdba74;
    border-color: rgba(234, 88, 12, 0.4);
}

.imp-scroll {
    max-height: 320px;
    overflow: auto;
}

.imp-table {
    font-size: 13px;
}

.imp-table th,
.imp-table td {
    padding: 6px 12px;
}

.imp-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.imp-table td.imp-ip {
    font-family: Consolas, monospace;
    white-space: nowrap;
}

.imp-table td.imp-new {
    color: #16a34a;
}

.imp-dash {
    color: var(--muted);
}

.imp-resolve {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg, var(--card-bg));
}

.imp-resolve-label {
    font-size: 13px;
    color: var(--muted);
}

.imp-resolve .perm-item {
    margin: 0;
}

.imp-resolve .btn-primary {
    margin-left: auto;
}

.imp-result-head {
    margin-top: 14px;
    font-size: 14px;
    font-weight: 600;
    color: #16a34a;
}

.imp-sep {
    height: 1px;
    background: var(--border);
    margin: 22px 0 18px;
}

.imp-hint {
    margin: 10px 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg, var(--card-bg));
    font-size: 13px;
}

.imp-hint > summary {
    cursor: pointer;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}

.imp-hint[open] > summary {
    border-bottom: 1px solid var(--border);
}

.imp-hint p {
    margin: 8px 12px;
    color: var(--muted);
}

.imp-hint pre {
    margin: 8px 12px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--thead-bg);
    border: 1px solid var(--border);
    overflow: auto;
    font-family: Consolas, monospace;
    font-size: 12.5px;
    color: var(--text);
}

.imp-hint-list {
    margin: 8px 12px 12px;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.5;
}

.imp-hint code {
    font-family: Consolas, monospace;
    background: var(--thead-bg);
    padding: 0 4px;
    border-radius: 4px;
}

#import-folders {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.imp-ok-text {
    color: #16a34a;
}

.imp-folder-select {
    width: 100%;
    max-width: 440px;
}

.tnet-toggle {
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.tnet-toggle:hover {
    background: var(--row-hover);
}

.tnet-detail > td {
    background: var(--card-bg);
    padding: 0;
}

.tnet-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
}

.tnet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: var(--fs-table);
    padding: 4px 10px 4px 30px;
}

/* Чередование строк IP внутри раскрытой подсети — как в остальных таблицах. */
.tnet-item:nth-child(even) {
    background: var(--row-alt);
}

/* Чередование самих строк-подсетей: пары «строка + раскрытие», поэтому 4n+3. */
#targets-tbody > tr.tnet:nth-child(4n+3) > td {
    background: var(--row-alt);
}

.tnet .imp-ip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
}

.tnet-item .imp-ip {
    min-width: 130px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tnet-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.tnet-date {
    color: var(--note);
    font-size: var(--fs-small);
    white-space: nowrap;
}

.tnet-item .btn-danger {
    padding: 2px 8px;
    font-size: var(--fs-small);
}



/* === «Операции ONU»: журнал заданий очереди (TODO 112, 24.10.2026) === */
.modal-jobs {
    width: min(940px, 94vw);
    max-height: 86vh;
    overflow: auto;
}
.onu-jobs-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}
.onu-jobs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.onu-jobs-table th,
.onu-jobs-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.onu-jobs-table thead th {
    position: sticky;
    top: 0;
    background: var(--thead-bg);
    color: var(--thead-text);
}
.onu-jobs-empty {
    text-align: center;
    color: var(--thead-text);
    padding: 18px 0;
}
.onu-jobs-status {
    white-space: nowrap;
    font-weight: 600;
}
.onu-jobs-row.st-ok .onu-jobs-status,
.onu-jobs-row.st-done .onu-jobs-status {
    color: #1a7f37;
}
.onu-jobs-row.st-error .onu-jobs-status,
.onu-jobs-row.st-timeout .onu-jobs-status {
    color: #c62828;
}
.onu-jobs-row.st-pending .onu-jobs-status,
.onu-jobs-row.st-running .onu-jobs-status {
    color: #b26a00;
}
.onu-jobs-detail {
    color: var(--thead-text);
    max-width: 280px;
    overflow-wrap: anywhere;
}
#onu-jobs-toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.onu-jobs-toast-item {
    padding: 10px 14px;
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    font-size: 13px;
    max-width: 380px;
}
.onu-jobs-toast-item.ok {
    border-left: 4px solid #1a7f37;
}
.onu-jobs-toast-item.err {
    border-left: 4px solid #c62828;
}

/* Необходимые номера (TODO 147, 26.10) */
.numbers-actions {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}
.numbers-table {
    width: 100%;
    border-collapse: collapse;
}
.numbers-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(127, 127, 127, 0.25);
}
.numbers-table td {
    padding: 8px;
    font-size: 15px;
    border-bottom: 1px solid rgba(127, 127, 127, 0.12);
}
.numbers-table .numbers-phone {
    font-family: var(--serial-font, ui-monospace, SFMono-Regular, Consolas, monospace);
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.numbers-table .numbers-phone a {
    color: inherit;
    text-decoration: none;
}
.numbers-table .numbers-phone a:hover {
    color: var(--primary-bg);
}
.numbers-table .numbers-acts {
    width: 150px;
    white-space: nowrap;
    text-align: right;
}
.numbers-table input.numbers-input {
    width: 100%;
    padding: 4px 8px;
    font-size: 14px;
    border: 1px solid rgba(127, 127, 127, 0.35);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-family: inherit;
}

/* Выпадающие пункты верхнего меню («Информация», 26.10) */
.nav-drop {
    position: relative;
    display: inline-flex;
}
.nav-drop-btn {
    display: inline-flex;
    align-items: center;
    line-height: inherit;  /* кнопка не наследует line-height — «плыла» по высоте */
    gap: 4px;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: none;
    font-family: inherit;
    font-size: var(--fs-small, 13px);
    font-weight: 600;
    color: var(--thead-text);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-drop-btn:hover,
.nav-drop.open .nav-drop-btn {
    background: var(--row-hover);
    color: var(--text);
}
.nav-drop-btn.active {
    background: var(--primary-bg);
    color: #fff;
}
.nav-drop-menu {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    padding: 4px;
    min-width: 190px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, rgba(127, 127, 127, 0.25));
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0s linear 2s, visibility 0s linear 2s;
}
.nav-drop:hover .nav-drop-menu,
.nav-drop.open .nav-drop-menu {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s, 0s;
}
.nav-drop-menu a {
    display: block;
}

/* Плавающие окна пунктов меню «Информация» (26.10). Вид — стандартная модалка
   приложения (.modal-head/.modal-title/.btn-close + стекло), но БЕЗ затемнения
   и ниже обычных модалок: страница и другие окна остаются доступны. Открываются
   по центру, двигаются за шапку (класс .modal намеренно не используется —
   иначе их перехватит modal-drag.js). */
.info-win {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(860px, 92vw);
    height: min(620px, 80vh);
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 95;
    overflow: hidden;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .info-win {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18)),
            var(--glass-bar);
        -webkit-backdrop-filter: blur(14px) saturate(160%);
        backdrop-filter: blur(14px) saturate(160%);
        border: 1px solid var(--glass-bar-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }
    html[data-theme="dark"] .info-win {
        background:
            linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
            var(--glass-bar);
        border-color: var(--glass-bar-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }
}
.info-win .modal-head {
    padding: 16px 20px;
    cursor: move;
    user-select: none;
}
.info-win .modal-title {
    font-size: 18px;
}
.info-win-frame {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    border: 0;
    background: transparent;
}

/* «Потолки по трафикам»: список и графики (26.10) */
.tcap-actions {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}
.tcap-table td.numbers-phone {
    text-align: right;
}
.tcap-charts {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.tcap-chart-box {
    border: 1px solid var(--border, rgba(127, 127, 127, 0.25));
    border-radius: 10px;
    padding: 14px 16px;
}
.tcap-chart-title {
    font-size: var(--fs-small, 13px);
    font-weight: 700;
    margin-bottom: 10px;
}
.tcap-svg {
    width: 100%;
    height: auto;
    display: block;
}
.tcap-grid {
    stroke: rgba(127, 127, 127, 0.22);
    stroke-width: 1;
}
.tcap-axis,
.tcap-name {
    fill: var(--thead-text);
    font-size: 12px;
}
.tcap-name {
    font-weight: 600;
}
.tcap-val {
    fill: var(--text);
    font-size: 13px;
    font-weight: 700;
}
.tcap-bar {
    transform: scaleY(0);
    transform-box: fill-box;
    transform-origin: bottom;
    transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.tcap-bar.shown {
    transform: scaleY(1);
}
.tcap-seg {
    opacity: 0;
    transition: opacity 0.5s ease;
}
.tcap-seg.shown {
    opacity: 1;
}
.tcap-donut-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
#tcap-donut {
    width: 240px;
    max-width: 100%;
}
.tcap-donut-val {
    fill: var(--text);
    font-size: 28px;
    font-weight: 700;
}
.tcap-donut-cap {
    fill: var(--thead-text);
    font-size: 13px;
}
.tcap-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
}
.tcap-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-small, 13px);
}
.tcap-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.tcap-legend-val {
    margin-left: auto;
    font-weight: 600;
    white-space: nowrap;
}

/* Поиск и фильтр в «История найденных ONU» — отступ от разделительной
   полосы шапки окна (26.10). */
#found-history-modal .search-row {
    margin-top: 18px;
}

/* Фильтр по статусу в «История найденных ONU» (26.10) */
.found-history-status {
    padding: 8px 10px;
    border: 1px solid var(--border, rgba(127, 127, 127, 0.35));
    border-radius: 8px;
    background: var(--card-bg, #fff);
    color: var(--text);
    font-family: inherit;
    font-size: var(--fs-small, 13px);
    cursor: pointer;
    white-space: nowrap;
}

/* ===== Страница «Настройки» (26.10): вкладки по логике, оформление ===== */
.settings-body .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 18px;
    padding: 6px;
    background: var(--row-hover, rgba(127, 127, 127, 0.08));
    border-radius: 12px;
}

.settings-body .tab {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--thead-text);
    font-family: inherit;
    font-size: var(--fs-small, 13px);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.settings-body .tab:hover {
    background: var(--card-bg);
    color: var(--text);
}

.settings-body .tab.active {
    background: var(--primary-bg);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.settings-body .tab-panel .card + .card {
    margin-top: 16px;
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.about-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border, rgba(127, 127, 127, 0.25));
    border-radius: 8px;
    font-size: var(--fs-small, 13px);
}

.about-row span {
    color: var(--thead-text);
}


/* ===== Чат в стиле Telegram (26.10): сайдбар чатов + переписка ===== */
.chat-tg {
    display: flex;
    flex-direction: row !important;  /* старые .tg-window/.chat-modal-box задают column */
    /* Размеры окна меняет пользователь (ручка справа внизу), дефолт как раньше */
    width: var(--chat-win-w, auto) !important;
    max-width: 96vw;
    height: var(--chat-win-h, min(360px, 52vh)) !important;
    min-width: 320px;
    min-height: 220px;
    position: relative;
    overflow: hidden;
    background: var(--card-bg);
    border: 1px solid var(--border, #aab9c9);
}

/* Ручка изменения размера окна чата (27.10) */
.chat-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    z-index: 30;
    background: linear-gradient(135deg, transparent 0 55%, var(--border, #aab9c9) 55% 65%, transparent 65% 75%, var(--border, #aab9c9) 75% 85%, transparent 85%);
    border-bottom-right-radius: 12px;
}
.chat-resize-handle:hover {
    background: linear-gradient(135deg, transparent 0 55%, var(--primary-bg, #2563eb) 55% 65%, transparent 65% 75%, var(--primary-bg, #2563eb) 75% 85%, transparent 85%);
}

.tg-side.hidden {
    display: none !important;
}

.tg-side {
    display: flex;
    flex-direction: column;
    order: 2;                        /* список контактов — СПРАВА от чата */
    width: 300px;
    flex: none;
    border-left: 1px solid var(--border, rgba(127, 127, 127, 0.25));
    background: var(--row-hover, rgba(127, 127, 127, 0.05));
}

.tg-side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, rgba(127, 127, 127, 0.2));
}

.tg-side .tg-contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.tg-main {
    display: flex;
    flex-direction: column;
    width: min(620px, 70vw);  /* постоянная ширина чата — контакты её не отнимают */
    flex: none;
    min-width: 0;
}

.tg-main .tg-body {
    flex: 1;
    min-height: 0;
}

/* Строка диалога: имя + время в первой строке, превью + счётчик — во второй */
.chat-person {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-person:hover {
    background: var(--card-bg);
}

.chat-person.active {
    background: var(--primary-bg);
}

.chat-person.active .chat-person-name,
.chat-person.active .chat-person-time,
.chat-person.active .chat-person-last,
.chat-person.active .chat-person-status {
    color: #fff;
}

.chat-person-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-person-row1,
.chat-person-row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.chat-person-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-person-time {
    font-size: 11px;
    color: var(--thead-text);
    white-space: nowrap;
}

.chat-person-row2 .chat-person-last,
.chat-person-row2 .chat-person-status {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-person-unread {
    flex: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--primary-bg);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-person.active .chat-person-unread {
    background: #fff;
    color: var(--primary-bg);
}

/* Панель заметок-«магнитиков» */
.chat-notes-panel {
    position: fixed;      /* как панель смайликов: вниз под кнопкой (28.10) */
    z-index: 3000;
    width: min(360px, 70vw);
    padding: 10px;
    border: 1px solid var(--border, rgba(127, 127, 127, 0.3));
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.chat-notes-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--thead-text);
    margin: 4px 2px 8px;
}

.chat-notes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.chat-note {
    padding: 12px 10px;
    border: none;
    border-radius: 6px;
    color: #2b2b2b;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
    transform: rotate(-1deg);
    transition: transform 0.12s ease;
}

.chat-note:nth-child(2n) {
    transform: rotate(1deg);
}

.chat-note:hover {
    transform: rotate(0deg) scale(1.04);
}

.chat-notes-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-note-swatch {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 0.12s ease;
}

.chat-note-swatch:hover {
    transform: scale(1.12);
}

/* Заметка в ленте сообщений */
.cp-bubble.note {
    transform: rotate(-1deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: none;
}

.cp-bubble.note .tg-text {
    color: #2b2b2b;
    font-weight: 600;
}

.cp-bubble.note .tg-meta {
    color: rgba(0, 0, 0, 0.55);
}


/* «Контакты» в верхней панели → модальное окно (26.10). Кнопка повторяет
   стиль ссылок .topbar-nav a — надписи в одной линии. */
.topbar-nav .nav-contacts-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: none;
    font-family: inherit;
    font-size: var(--fs-small, 13px);
    font-weight: 600;
    line-height: inherit;
    color: var(--thead-text);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.topbar-nav .nav-contacts-btn:hover {
    background: var(--row-hover);
    color: var(--text);
}

/* Окно «Контакты» уже стандартного на 65% (26.10) */
#contacts-modal .modal {
    max-width: 300px;
}

#contacts-modal .op-menu-contacts-list {
    max-height: 55vh;
    overflow-y: auto;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Реальный чат — вид 1в1 с предпросмотром «Цвета окна чата» (27.10).
   Элементы чата используют те же классы cp-*, что и предпросмотр в
   настройках пользователя: шапка, пузыри, тулбар, строка ввода. */
.chat-tg {
    border: 1px solid var(--border, #aab9c9);
    border-radius: 12px;
    overflow: hidden;
    background: var(--chat-body-bg, var(--card-bg));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Шапка: как cp-header, но в строку (слева заголовок, справа действия) */
.chat-tg .tg-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(180deg, var(--chat-header-start, #ffffff) 0%, var(--chat-header-end, #d6e2ee) 100%);
    border-bottom: 1px solid #aebfce;
}

.chat-tg .tg-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.chat-tg .tg-header .cp-title { cursor: pointer; }

/* Панель сообщений прокручивается */
.chat-tg .tg-msgs.cp-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.chat-tg .cp-bubble .tg-text {
    display: block;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* Кнопки-кружки в тулбаре (смайлики, заметки) */
.chat-tg .cp-toolbar-smile {
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

.chat-tg .cp-toolbar-smile:hover { background: #3b4f66; }

/* Поле ввода: в предпросмотре — плашка с плейсхолдером, в чате — textarea */
.chat-tg .cp-input-field textarea {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: var(--chat-fs-input, 14px);
    line-height: 1.3;
    color: var(--text, #17212b);
    max-height: 120px;
    padding: 0;
}

.chat-tg .cp-send:hover { background: #16a34a; }

/* Галочки/кнопка правки в метке времени — как в старом чате */
.cp-msg.cp-mine .cp-meta .tg-edit { color: #6aa8e0; }
.cp-msg.cp-mine .cp-meta .tg-edit:hover { color: #2f80c4; }

/* Окно чата уже — пропорции ближе к предпросмотру (27.10, по требованию) */
.chat-tg .tg-main {
    flex: 1 1 auto;
    min-width: 0;
    width: min(644px, 90vw);  /* +40% ширины (27.10) */
}

/* Кнопка «Отправить» — 1в1 с предпросмотром. В предпросмотре это span,
   а тут button — гасим глобальные стили button (padding, фон, скругление). */
.chat-tg .cp-send {
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
    font-size: inherit;
    line-height: 1;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: #22c55e;
    background-color: #22c55e;
}

.chat-tg .cp-send:hover,
.chat-tg button.cp-send:hover {
    /* как в предпросмотре: цвет не меняется */
    background: #22c55e;
    background-color: #22c55e;
    transform: none;
}


/* --- Мини-панель «Сервисы» (28.10): подсказка по наведению и окно --- */
.svc-list { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; min-width: 240px; }
.svc-pop {
    position: fixed;
    z-index: 110;
    min-width: 240px;
    padding: 5px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border, #c3cfdb);
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(20, 35, 55, 0.22);
}
.svc-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text, #1c2733);
}
.svc-row:hover { background: rgba(127, 148, 173, 0.12); }
.svc-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
    background: #b6c0cc;
}
.svc-dot.on { background: #2fa84f; box-shadow: 0 0 5px rgba(47, 168, 79, 0.55); }
.svc-dot.off { background: #d24949; box-shadow: 0 0 5px rgba(210, 73, 73, 0.45); }
.svc-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-state { color: var(--muted, #7a8794); font-size: 11.5px; }
.svc-empty { color: var(--muted, #7a8794); font-size: 13px; padding: 12px; }
