:root {
    --bg: #0f0f0f;
    --surface: #161616;
    --surface-2: #1a1a1a;
    --fg: #c8c8c8;
    --muted: #6a6a6a;
    --line: #252525;
    --line-strong: #333333;
    --input: #0b0b0b;
    --btn: #1a1a1a;
    --btn-hover: #222222;
    --error: #c45c5c;
    --ok: #6aa86a;
    --danger: #a85858;
    --overlay: rgba(0, 0, 0, 0.62);
    --font: "Inter", "Segoe UI", system-ui, sans-serif;
}

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

html,
body {
    min-height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.auth-body,
.panel-body {
    min-height: 100vh;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.login-form {
    width: 100%;
    max-width: 360px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    animation: fade 0.35s ease both;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.field span,
.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.field input,
.field select,
.field textarea,
.input,
.select {
    height: 42px;
    padding: 0 12px;
    background: var(--input);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    color: var(--fg);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    width: 100%;
}

.field textarea {
    height: auto;
    min-height: 88px;
    padding: 12px;
    resize: vertical;
}

.field select,
.select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #6a6a6a 50%), linear-gradient(135deg, #6a6a6a 50%, transparent 50%);
    background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.input:hover,
.select:hover {
    border-color: #3d3d3d;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus,
.select:focus {
    border-color: #5a5a5a;
    background: #0a0a0a;
}

.form-error {
    margin-bottom: 16px;
    color: var(--error);
    font-size: 13px;
}

.btn,
.btn-primary,
.btn-ghost,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--btn);
    color: var(--fg);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.btn:hover,
.btn-primary:hover,
.btn-ghost:hover {
    background: var(--btn-hover);
    border-color: #444444;
}

.btn:active,
.btn-primary:active,
.btn-ghost:active,
.btn-danger:active {
    transform: scale(0.985);
}

.btn-primary.wide,
.login-form .btn-primary {
    width: 100%;
    height: 42px;
    margin-top: 6px;
}

.btn-ghost {
    background: transparent;
}

.btn-danger {
    background: transparent;
    border-color: #4a2f2f;
    color: #c98989;
}

.btn-danger:hover {
    background: #1c1212;
    border-color: #6a3d3d;
    color: #df9f9f;
}

.btn-confirm-locked,
.btn-confirm-locked:hover,
.btn-confirm-locked:active {
    background: #efefef;
    border-color: var(--line);
    color: #9a9a9a;
    cursor: not-allowed;
    transform: none;
    opacity: 0.85;
    pointer-events: none;
}

.btn-confirm-ready,
.btn.btn-confirm-ready,
.btn-danger.btn-confirm-ready {
    background: #b43b3b;
    border-color: #9a3030;
    color: #fff;
}

.btn-confirm-ready:hover,
.btn.btn-confirm-ready:hover,
.btn-danger.btn-confirm-ready:hover {
    background: #9a3030;
    border-color: #822828;
    color: #fff;
}

.btn-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    flex-shrink: 0;
}

.btn-icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: 52px 18px;
    column-gap: 20px;
    padding: 4px 40px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-primary {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: stretch;
    gap: 28px;
}

.nav-primary a,
.nav-settings {
    display: inline-flex;
    align-items: center;
    height: 100%;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--muted);
    box-shadow: inset 0 -1px 0 transparent;
    transition: color 0.18s ease, box-shadow 0.18s ease;
}

.nav-primary a:hover,
.nav-settings:hover {
    color: var(--fg);
}

.nav-primary a.active,
.nav-settings.active {
    color: var(--fg);
    box-shadow: inset 0 -1px 0 #8a8a8a;
}

.nav-aside {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: stretch;
    gap: 20px;
}

.nav-settings {
    grid-column: auto;
    grid-row: auto;
}

.logout {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 500;
    color: #a8a8a8;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
}

.logout:hover {
    color: #d0d0d0;
    border-color: #444444;
    background: #1a1a1a;
}

.logout:active {
    transform: scale(0.97);
}

.idle-timer {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
    align-self: start;
    font-size: 10px;
    line-height: 1;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
}

.page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 36px 40px 80px;
    animation: fade 0.3s ease both;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}

.page-head h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--fg);
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.empty-state {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 56px 24px;
    text-align: center;
}

.empty-state p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.empty-state .btn {
    margin-top: 18px;
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}

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

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    vertical-align: middle;
}

.table th {
    color: var(--muted);
    font-weight: 500;
    background: var(--surface-2);
}

.table tr:last-child td {
    border-bottom: none;
}

.table td {
    color: var(--fg);
}

.table .cell-muted {
    color: var(--muted);
}

.table .cell-owner {
    min-width: 108px;
    vertical-align: middle;
}

.table .owner-kicker {
    display: block;
    margin-bottom: 2px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0.85;
}

.table .owner-login {
    display: block;
    font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--fg);
}

.table .cell-owner.is-missing .owner-login {
    color: var(--muted);
    font-style: italic;
}

.table .cell-link {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #b0b0b0;
    word-break: break-all;
}

.table .link-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}

.table a.link-url {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #b0b0b0;
    word-break: break-all;
    line-height: 1.4;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.table a.link-url:hover {
    color: #ececec;
    border-bottom-color: #6a6a6a;
}

.table .cell-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
    vertical-align: middle;
}

.table .row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    overflow: hidden;
    background: var(--input);
    max-width: 100%;
}

.segmented-wrap {
    display: flex;
    width: 100%;
}

.segmented button {
    height: 36px;
    padding: 0 14px;
    border: none;
    border-right: 1px solid var(--line-strong);
    border-bottom: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    flex: 1 1 auto;
    white-space: nowrap;
}

.segmented-wrap button {
    flex: 1 1 calc(33.333% - 1px);
    min-width: 110px;
}

.segmented button:last-child {
    border-right: none;
}

.segmented button:hover {
    color: var(--fg);
}

.segmented button.active {
    background: #222;
    color: var(--fg);
}

.table tr.is-paused .link-url,
.table tr.is-paused .cell-name {
    opacity: 0.55;
}

.preview-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--input);
    padding: 14px;
}

.preview-card .preview-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--fg);
}

.preview-card .preview-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
}

.preview-card .preview-url {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #b0b0b0;
    word-break: break-all;
    line-height: 1.45;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
}

.modal-backdrop.open {
    display: flex;
    animation: fade 0.18s ease both;
}

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    animation: rise 0.2s ease both;
}

.modal-lg {
    max-width: 560px;
}

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

.modal-head h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.modal-close {
    width: 30px;
    height: 30px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--fg);
    border-color: #444;
}

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

.modal-text {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 20px;
}

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
    pointer-events: none;
}

.toast {
    min-width: 220px;
    max-width: 340px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: #171717;
    color: var(--fg);
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    animation: rise 0.2s ease both;
}

.toast.ok {
    border-color: #2f4630;
}

.toast.error {
    border-color: #4a2f2f;
    color: #df9f9f;
}

@keyframes fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* —— Home dashboard —— */
.home-head {
    align-items: center;
}

.home-head-side {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.bots-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid #3a2f2f;
    border-radius: 999px;
    background: #161212;
    color: #b89898;
    font-size: 11px;
    font-weight: 500;
}

.bots-chip em {
    font-style: normal;
    font-weight: 600;
    color: #df9f9f;
    font-variant-numeric: tabular-nums;
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.live-pill.is-tick {
    border-color: #3a4a3a;
    color: #9bbb9b;
}

.live-pill.is-error {
    border-color: #4a2f2f;
    color: #c98989;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6aa86a;
    box-shadow: 0 0 0 0 rgba(106, 168, 106, 0.45);
    animation: live-pulse 1.8s ease infinite;
}

.live-pill.is-error .live-dot {
    background: #c45c5c;
    animation: none;
}

@keyframes live-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(106, 168, 106, 0.45);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(106, 168, 106, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(106, 168, 106, 0);
    }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 28px;
}

.kpi-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.kpi-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 14px 14px 12px;
    min-height: 78px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
}

.kpi-accent {
    border-color: #2a352a;
    background: linear-gradient(180deg, #171b17 0%, var(--surface) 100%);
}

.kpi-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.kpi-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: #e4e4e4;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.kpi-value-sm {
    font-size: 18px;
    letter-spacing: -0.02em;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.dash-section {
    margin-bottom: 28px;
}

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

.section-head h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #d4d4d4;
}

.section-meta {
    font-size: 12px;
    color: var(--muted);
}

.feed-panel,
.links-cut {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
}

.feed-list {
    display: flex;
    flex-direction: column;
}

.feed-list-full {
    max-height: none;
}

.feed-item {
    display: grid;
    grid-template-columns: 72px 84px minmax(0, 1fr) minmax(100px, 180px);
    gap: 12px;
    align-items: center;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.feed-panel-full .feed-item {
    grid-template-columns: 148px 84px minmax(0, 1fr) minmax(100px, 180px);
}

.feed-item:last-child {
    border-bottom: none;
}

.feed-item:hover {
    background: #1a1a1a;
}

.feed-item.is-new {
    animation: feed-flash 1.1s ease;
}

.feed-item.is-convert .feed-badge {
    color: #9bbb9b;
    border-color: #2f4630;
    background: #141a14;
}

@keyframes feed-flash {
    from {
        background: #1c221c;
    }
    to {
        background: transparent;
    }
}

.feed-time {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.feed-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    color: #b0b0b0;
    width: fit-content;
}

.feed-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: #b8b8b8;
}

.feed-geo {
    color: #d8d8d8;
    font-weight: 500;
}

.feed-sep {
    color: #3a3a3a;
}

.feed-ip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--muted);
    font-size: 12px;
}

.feed-device {
    color: var(--muted);
    font-size: 12px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-tag {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 6px;
    border-radius: 4px;
    border: 1px solid var(--line-strong);
    font-size: 10px;
    color: var(--muted);
}

.feed-tag-bot {
    border-color: #4a2f2f;
    color: #c98989;
}

.feed-item.is-bot {
    opacity: 0.72;
}

.feed-filter.segmented {
    height: 28px;
}

.feed-filter.segmented a {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-right: 1px solid var(--line-strong);
    color: var(--muted);
    font-size: 12px;
    text-decoration: none;
}

.feed-filter.segmented a:last-child {
    border-right: none;
}

.feed-filter.segmented a:hover {
    color: var(--fg);
}

.feed-filter.segmented a.active {
    background: #222;
    color: var(--fg);
}

.geo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.geo-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 14px;
}

.geo-card h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}

.geo-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.geo-row {
    display: grid;
    grid-template-columns: minmax(72px, 120px) minmax(0, 1fr) 36px;
    gap: 10px;
    align-items: center;
}

.geo-name {
    font-size: 12px;
    color: #c8c8c8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.geo-bar {
    height: 4px;
    border-radius: 999px;
    background: #222;
    overflow: hidden;
}

.geo-bar i {
    display: block;
    height: 100%;
    background: #5a5a5a;
    border-radius: 999px;
}

.geo-count {
    font-size: 12px;
    color: var(--muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.geo-empty {
    font-size: 12px;
    color: var(--muted);
}

.link-row.is-fat {
    background: linear-gradient(90deg, rgba(20, 26, 20, 0.55), transparent 55%);
}

.link-row.is-fat .link-cr em {
    color: #9bbb9b;
}

.link-cr em {
    font-variant-numeric: tabular-nums;
}

.device-full {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    max-width: 240px;
}

.row-bot td {
    opacity: 0.7;
}

.table tr.is-new-row {
    animation: feed-flash 1.1s ease;
}

.feed-link {
    justify-self: end;
    font-size: 12px;
    font-weight: 500;
    color: #a8a8a8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.link-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    transition: background 0.15s ease;
}

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

.link-row:hover {
    background: #1a1a1a;
}

.link-row-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.link-row-name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #e0e0e0;
}

.link-row-url {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.link-stat {
    font-size: 12px;
    color: var(--muted);
}

.link-stat em {
    font-style: normal;
    font-weight: 600;
    color: #d0d0d0;
    font-variant-numeric: tabular-nums;
    margin-right: 3px;
}

.link-geo {
    font-size: 12px;
    color: #a8a8a8;
    min-width: 72px;
    text-align: right;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 5px;
    border: 1px solid var(--line-strong);
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

.status-chip.status-active {
    color: #9bbb9b;
    border-color: #2f4630;
    background: #141a14;
}

.status-chip.status-idle {
    color: #8a8a8a;
}

.dash-empty {
    padding: 36px 20px;
    text-align: center;
}

.dash-empty p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.dash-empty .btn {
    margin-top: 14px;
}

.page-head-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.back-link {
    font-size: 12px;
    color: var(--muted);
    width: fit-content;
    transition: color 0.15s ease;
}

.back-link:hover {
    color: var(--fg);
}

.page-sub {
    font-size: 13px;
    color: var(--muted);
}

.detail-url-bar {
    margin: -12px 0 24px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--input);
    font-size: 12px;
    color: #a8a8a8;
    word-break: break-all;
}

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

.detail-table {
    min-width: 860px;
}

.event-chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 5px;
    border: 1px solid var(--line-strong);
    font-size: 11px;
    font-weight: 500;
}

.event-chip.event-click {
    color: #b0b0b0;
}

.event-chip.event-convert {
    color: #9bbb9b;
    border-color: #2f4630;
    background: #141a14;
}

.row-convert td {
    background: rgba(20, 26, 20, 0.35);
}

.geo-full {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
}

.cell-ref {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .kpi-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-grid-5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .kpi-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .topbar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 14px;
        padding: 8px 16px 10px;
        grid-template-columns: none;
        grid-template-rows: none;
    }

    .nav-primary {
        display: contents;
    }

    .nav-primary a,
    .nav-settings {
        grid-column: auto;
        grid-row: auto;
        height: auto;
        padding: 4px 0;
        font-size: 13px;
    }

    .nav-aside {
        display: contents;
    }

    .logout {
        grid-column: auto;
        grid-row: auto;
        margin-left: auto;
        justify-self: auto;
        align-self: center;
    }

    .idle-timer {
        grid-column: auto;
        grid-row: auto;
        flex: 1 0 100%;
        justify-self: auto;
        text-align: right;
        order: 10;
    }

    .page {
        padding: 28px 20px 64px;
    }

    .page-head {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .table {
        min-width: 720px;
    }

    .kpi-grid,
    .kpi-grid-4,
    .kpi-grid-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .geo-grid {
        grid-template-columns: 1fr;
    }

    .home-head-side {
        width: 100%;
        justify-content: flex-start;
    }

    .feed-item,
    .feed-panel-full .feed-item {
        grid-template-columns: 60px 72px minmax(0, 1fr);
        grid-template-rows: auto auto;
    }

    .feed-panel-full .feed-item .feed-time {
        grid-column: 1 / -1;
    }

    .feed-link {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .link-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .link-row-meta {
        justify-content: flex-start;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-card-head {
        flex-direction: column;
    }

    .modal {
        max-width: none;
    }
}

/* —— Heatmap —— */
.page:has(.heat-page) {
    max-width: none;
    padding: 12px 20px 20px;
}

.heat-page {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: auto;
}

.heat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.heat-toolbar-left,
.heat-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
}

.heat-toolbar h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: #e0e0e0;
}

.heat-toolbar-sep {
    width: 1px;
    height: 16px;
    background: var(--line-strong);
}

.heat-inline-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: var(--muted);
}

.heat-inline-stats em {
    font-style: normal;
    font-weight: 600;
    color: #d8d8d8;
    font-variant-numeric: tabular-nums;
    margin-right: 3px;
}

.heat-tip {
    font-size: 11px;
    color: var(--muted);
    padding: 0 2px;
    margin: 0;
}

.heat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 10px;
    align-items: stretch;
}

.heat-map-card,
.heat-side {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.heat-map-card {
    height: 70vh;
    min-height: 420px;
    flex-shrink: 0;
    position: relative;
}

.heat-map-card.is-crosshair {
    cursor: none !important;
}

.heat-map-card.is-crosshair,
.heat-map-card.is-crosshair * {
    cursor: none !important;
}

.heat-map-card.is-crosshair .jvm-zoom-btn,
.heat-map-card.is-crosshair .jvm-zoom-btn * {
    cursor: pointer !important;
}

.heat-crosshair {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.heat-crosshair-v,
.heat-crosshair-h {
    position: absolute;
    background: rgba(200, 210, 200, 0.45);
    pointer-events: none;
}

.heat-crosshair-v {
    top: 0;
    bottom: 0;
    width: 1px;
    left: 0;
    transform: translateX(-50%);
    box-shadow: 0 0 0 0.5px rgba(143, 175, 143, 0.25);
}

.heat-crosshair-h {
    left: 0;
    right: 0;
    height: 1px;
    top: 0;
    transform: translateY(-50%);
    box-shadow: 0 0 0 0.5px rgba(143, 175, 143, 0.25);
}

.heat-side {
    height: 70vh;
    min-height: 420px;
    flex-shrink: 0;
}

.heat-side-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 8px;
    flex-shrink: 0;
}

.heat-side-head h2 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #d4d4d4;
}

.heat-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
}

.heat-legend i {
    width: 14px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
}

.heat-legend i:nth-child(2) { background: #2f7a38; }
.heat-legend i:nth-child(3) { background: #45b34f; }
.heat-legend i:nth-child(4) { background: #6ee06a; }
.heat-legend i:nth-child(5) { background: #9cff7a; }
.heat-legend i:nth-child(6) { background: #c8ff9a; }

.heat-map {
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.heat-map .jvm-container {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    overflow: hidden !important;
}

.heat-map .jvm-container svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.jvm-tooltip {
    border: 1px solid var(--line-strong) !important;
    background: #171717 !important;
    color: #d0d0d0 !important;
    border-radius: 7px !important;
    font-size: 12px !important;
    padding: 8px 10px !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35) !important;
}

.jvm-zoom-btn {
    width: 36px !important;
    height: 36px !important;
    left: 14px !important;
    border: 1px solid #444 !important;
    border-radius: 8px !important;
    background: #1a1a1a !important;
    color: #e8e8e8 !important;
    font-size: 22px !important;
    font-weight: 500 !important;
    line-height: 34px !important;
    padding: 0 !important;
    text-align: center !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35) !important;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}

.jvm-zoom-btn.jvm-zoomin {
    top: 14px !important;
}

.jvm-zoom-btn.jvm-zoomout {
    top: 58px !important;
}

.jvm-zoom-btn:hover {
    background: #242424 !important;
    border-color: #666 !important;
    color: #fff !important;
}

.heat-list {
    padding: 4px 14px 14px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.heat-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1.1fr) minmax(0, 1fr) 36px;
    gap: 8px;
    align-items: center;
}

.heat-rank {
    font-size: 11px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.heat-name {
    font-size: 12px;
    color: #d0d0d0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.heat-name em {
    font-style: normal;
    color: var(--muted);
    margin-left: 4px;
    font-size: 10px;
}

.heat-bar {
    height: 4px;
    border-radius: 999px;
    background: #222;
    overflow: hidden;
}

.heat-bar i {
    display: block;
    height: 100%;
    background: #6a8a6a;
    border-radius: 999px;
}

.heat-count {
    font-size: 12px;
    color: var(--muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* —— Settings —— */
.settings-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 12px;
}

.settings-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: 20px;
}

.settings-card-muted {
    background: var(--surface-2);
}

.settings-card h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

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

.settings-card-head .settings-desc {
    margin-bottom: 0;
}

.settings-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
    margin-bottom: 18px;
}

.host-input {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.host-input .input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.host-suffix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-left: none;
    border-radius: 0 7px 7px 0;
    background: var(--surface-2);
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    white-space: nowrap;
}

.tg-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--input);
    min-width: 160px;
}

.tg-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6a6a6a;
    flex-shrink: 0;
}

.tg-status[data-status="running"] .tg-status-dot {
    background: #6aa86a;
    box-shadow: 0 0 0 0 rgba(106, 168, 106, 0.4);
    animation: live-pulse 1.8s ease infinite;
}

.tg-status[data-status="starting"] .tg-status-dot {
    background: #c2a35a;
}

.tg-status[data-status="error"] .tg-status-dot {
    background: #c45c5c;
}

.tg-status[data-status="stopped"] .tg-status-dot {
    background: #6a6a6a;
}

.tg-status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tg-status-text strong {
    font-size: 12px;
    font-weight: 600;
    color: #d8d8d8;
}

.tg-status-text span {
    font-size: 12px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tg-error {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #4a2f2f;
    border-radius: 8px;
    background: #161212;
    color: #df9f9f;
    font-size: 12px;
    line-height: 1.4;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    cursor: pointer;
}

.toggle-row strong {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #d4d4d4;
    margin-bottom: 4px;
}

.toggle-row small {
    font-size: 12px;
    color: var(--muted);
}

.toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #6a8a6a;
    cursor: pointer;
    flex-shrink: 0;
}

.settings-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.settings-status {
    font-size: 12px;
    color: var(--muted);
}

.settings-status.is-ok {
    color: #9bbb9b;
}

.settings-status.is-err {
    color: #c98989;
}

.settings-kv {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    font-size: 13px;
}

.settings-kv:first-of-type {
    border-top: none;
    padding-top: 4px;
}

.settings-kv span {
    color: var(--muted);
}

.settings-kv strong {
    font-weight: 500;
    color: #d0d0d0;
    text-align: right;
}

.settings-danger {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 12px;
}

.settings-danger .settings-desc {
    margin: 4px 0 0;
}

.settings-danger .btn {
    justify-self: start;
}

/* Heatmap / tablet+phone — after base heat rules so cascade wins */
@media (max-width: 960px) {
    .page:has(.heat-page) {
        padding: 10px 14px 16px;
    }

    .heat-layout {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .heat-map-card {
        height: 52vh;
        min-height: 280px;
        max-height: 560px;
    }

    .heat-side {
        height: auto;
        min-height: 0;
        max-height: none;
    }

    .heat-map {
        height: 100%;
        min-height: 0;
    }

    .heat-list {
        max-height: 42vh;
    }

    .heat-toolbar {
        align-items: flex-start;
    }

    .heat-toolbar-sep {
        display: none;
    }

    .heat-toolbar-right .section-meta {
        display: none;
    }
}

@media (max-width: 720px) {
    .heat-inline-stats {
        gap: 10px;
        flex-wrap: wrap;
    }

    .heat-map-card {
        height: 48vh;
        min-height: 240px;
    }

    .heat-row {
        grid-template-columns: 18px minmax(0, 1fr) 28px;
        grid-template-areas:
            "rank name count"
            "bar bar bar";
        gap: 6px 8px;
    }

    .heat-rank {
        grid-area: rank;
    }

    .heat-name {
        grid-area: name;
    }

    .heat-bar {
        grid-area: bar;
    }

    .heat-count {
        grid-area: count;
        text-align: right;
    }
}

.access-denied {
    max-width: 420px;
    margin: 64px auto 0;
    text-align: center;
}

.access-denied h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
}

.access-denied p {
    color: var(--muted);
    margin-bottom: 24px;
    line-height: 1.45;
}

.input-with-action {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-action .input {
    flex: 1;
    min-width: 0;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--line-strong);
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    vertical-align: middle;
}

.dev-credit {
    position: fixed;
    left: 18px;
    bottom: 14px;
    z-index: 40;
    margin: 0;
    font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 300;
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--fg, #111);
    opacity: 0.22;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

.journal-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.4fr) auto;
    gap: 10px 12px;
    align-items: end;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.journal-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.journal-filter-field > span {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.journal-filter-grow {
    min-width: 0;
}

.journal-filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.offers-filters {
    display: flex;
    align-items: center;
    gap: 10px;
}

.offers-owner-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.offers-owner-filter .input {
    min-width: 140px;
    height: 34px;
}

.scope-tabs {
    display: inline-flex;
    gap: 6px;
}

.scope-tab {
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.scope-tab:hover {
    color: var(--fg);
    border-color: var(--line-strong);
}

.scope-tab.active {
    color: var(--fg);
    border-color: var(--line-strong);
    box-shadow: inset 0 -1px 0 #8a8a8a;
}

.owners-cut {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.owner-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.owner-row-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.owner-row-login {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.owner-row-sub {
    font-size: 12px;
    color: var(--muted);
}

.owner-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: center;
    justify-content: flex-end;
}

@media (max-width: 1100px) {
    .journal-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .journal-filter-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .journal-filters {
        grid-template-columns: 1fr;
    }

    .owner-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .owner-row-meta {
        justify-content: flex-start;
    }

    .page-head-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

.journal-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

.journal-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.journal-tab em {
    font-style: normal;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
    opacity: 0.8;
}

.journal-tab:hover {
    color: var(--fg);
    border-color: var(--line-strong);
}

.journal-tab.active {
    color: var(--fg);
    border-color: var(--line-strong);
    background: #f7f7f7;
    box-shadow: inset 0 -1px 0 #8a8a8a;
}

.journal-table .journal-actor {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.journal-table .journal-actor strong {
    font-weight: 600;
    font-size: 13px;
}

.journal-role {
    font-size: 11px;
    color: var(--muted);
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.journal-action {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 180px;
}

.journal-action-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
}

.journal-message {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}

.journal-details {
    max-width: 320px;
}

.journal-detail-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    margin: 0 6px 4px 0;
    font-size: 11px;
    line-height: 1.3;
}

.journal-detail-chip em {
    font-style: normal;
    color: var(--muted);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.journal-table tr.is-fail .journal-action-label {
    color: #b43b3b;
}

.mono {
    font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

@media (max-width: 720px) {
    .journal-tabs {
        gap: 8px;
    }

    .journal-tab {
        height: 30px;
        padding: 0 10px;
        font-size: 12px;
    }
}
