* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-title {
    display: flex;
    align-items: baseline;
    gap: 15px;
}

.server-version {
    color: #7f8c8d;
    font-family: monospace;
    font-size: 13px;
    white-space: nowrap;
}

h1 {
    margin: 0;
    color: #2c3e50;
    font-size: 24px;
}

.client-ip {
    font-size: 14px;
    color: #95a5a6;
    margin-left: auto;
}

.client-ip.allowed {
    color: #2ecc71;
}

.client-ip.denied {
    color: #e74c3c;
}

.help-link {
    color: #3498db;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border: 1px solid #3498db;
    border-radius: 4px;
    transition: all 0.2s;
}

.help-link:hover {
    background: #3498db;
    color: #fff;
}

/* Keep the application out of view until the authentication check completes. */
.auth-pending body > :not(#operator-auth),
.auth-required body > :not(#operator-auth) {
    display: none !important;
}

.header {
    flex-wrap: wrap;
    gap: 16px;
}

.operator-auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    color: #52606d;
    font-size: 14px;
}

.operator-auth-card {
    width: min(100%, 340px);
    padding: 28px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.operator-auth[hidden],
.operator-auth-form[hidden],
.operator-auth-form [hidden],
.operator-auth-status[hidden],
.operator-logout[hidden] {
    display: none;
}

.operator-auth-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.operator-auth-form input,
.operator-auth-form select {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font: inherit;
}

.operator-auth-form input {
    margin-bottom: 8px;
}

.operator-auth-form input:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.operator-auth-form button {
    margin-top: 8px;
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    padding: 10px 16px;
    font-size: 14px;
}

.operator-logout {
    padding: 6px 10px;
    font-size: 13px;
}

.operator-auth-status {
    display: block;
    margin-top: 12px;
    overflow-wrap: anywhere;
}

.control-panel {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.server-select, .new-server {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.server-select label, .new-server label {
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

.server-select select, .new-server input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 200px;
}

.server-select select:focus, .new-server input:focus {
    outline: none;
    border-color: #3498db;
}

.actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

button:hover {
    background: #f0f0f0;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc;
    border-color: #aaa;
    color: #666;
}

button:disabled:hover {
    background: #ccc;
}

button.primary {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}

button.primary:hover {
    background: #2980b9;
}

button.danger {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}

button.danger:hover {
    background: #c0392b;
}

button.danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

button.small {
    padding: 4px 10px;
    font-size: 12px;
}

.status-bar {
    flex-wrap: wrap;
    background: #2c3e50;
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: flex;
    align-items: baseline;
    gap: 8px 30px;
    font-size: 14px;
}

.tag-filter-control {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
    margin-left: auto;
    white-space: nowrap;
}

.tag-filter-control input {
    box-sizing: border-box;
    width: 170px;
    height: 26px;
    padding: 3px 7px;
    border: 1px solid #667b8f;
    border-radius: 4px;
    background: #fff;
    color: #243748;
    font-size: 12px;
}

.tag-filter-control input:focus {
    border-color: #5dade2;
    outline: 2px solid rgba(93, 173, 226, 0.25);
}

.clear-tag-filter-btn {
    display: none;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #667b8f;
    border-radius: 4px;
    background: #3e556b;
    color: #fff;
}

body.tile-view-active .clear-tag-filter-btn {
    display: inline-flex;
}

.clear-tag-filter-btn:hover {
    border-color: #5dade2;
    background: #337ea9;
}

.clear-tag-filter-btn:focus-visible {
    outline: 2px solid #5dade2;
    outline-offset: 2px;
}

#connection-status {
    color: #e74c3c;
}

#connection-status.connected {
    color: #2ecc71;
}

.connection-sound-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
}

.connection-sound-hint {
    color: #f5cf80;
    font-size: 11px;
}

.connection-sound-test {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #a9d8f5;
    font-size: inherit;
}

.connection-sound-test:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.connection-sound-test:hover {
    color: #fff;
    background: transparent;
}

.agent-view-toggle {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 2px;
    padding: 2px;
    border: 1px solid #667b8f;
    border-radius: 4px;
    background: #243748;
}

.agent-view-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
    padding: 2px 7px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #c5d0d9;
    font-size: 11px;
    line-height: 1;
}

.agent-view-toggle button:hover,
.agent-view-toggle button.active {
    background: #e5edf3;
    color: #243748;
}

body.tile-view-active .container {
    max-width: 1800px;
}

body.tile-view-active #agent-view-root {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tile-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 16px; margin: 12px 0; min-width: 0; }
.tile-filters[hidden], .tile-filter-empty[hidden] { display: none; }
.tile-filter-field { display: flex; flex-direction: column; gap: 4px; flex: 0 1 250px; min-width: 0; max-width: 100%; }
.tile-filter-field label { color: #2c3e50; font-size: 12px; font-weight: 600; }
.tile-filter-field input { width: 100%; min-width: 0; padding: 7px; border: 1px solid #cbd6df; border-radius: 4px; }
.tile-filter-field input:focus { outline: 2px solid #3498db; outline-offset: 1px; }
.tile-filter-summary { color: #657987; font-size: 12px; padding: 8px 0; font-variant-numeric: tabular-nums; }
.tile-filter-empty { color: #657987; padding: 12px 0; }

body.tile-view-active .terminal-tiles {
    order: 1;
}

body.tile-view-active #agents-table {
    order: 2;
    margin-top: 12px;
}

body.tile-view-active #agents-table .filter-row {
    display: none;
}

.terminal-tiles {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
    gap: 8px;
    width: 100%;
}

.terminal-tiles.visible {
    display: grid;
}

.terminal-tile {
    --terminal-tile-background: #fff;
    --terminal-tile-online-flash: #6be5a1;
    --terminal-tile-offline-flash: #ff908a;
    min-width: 0;
    padding: 8px 9px 7px;
    overflow: hidden;
    border: 1px solid #cbd6df;
    border-left: 4px solid #b8c2ca;
    border-radius: 5px;
    background: var(--terminal-tile-background);
    box-shadow: 0 1px 3px rgba(35, 52, 68, 0.12);
    font-size: 11px;
    line-height: 1.25;
    cursor: pointer;
}

.terminal-tile:hover {
    border-color: #839eb3;
    box-shadow: 0 2px 6px rgba(35, 52, 68, 0.2);
}

.terminal-tile.selected {
    border-color: #337ea9;
    box-shadow: 0 0 0 2px rgba(51, 126, 169, 0.24);
}

.terminal-tile.online {
    border-left-color: #2ca25f;
}

.terminal-tile.offline {
    border-left-color: #c95850;
    --terminal-tile-background: #fafafa;
}

.terminal-tile.reserved {
    border-color: #d99a2b;
    border-left-color: #d99a2b;
    --terminal-tile-background: #fff9ed;
}

.terminal-tile-heading,
.terminal-tile-line {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 6px;
    white-space: nowrap;
}

.terminal-tile-tags,
.terminal-group-tags {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 3px;
    overflow: hidden;
}

.terminal-tile-tags {
    min-height: 20px;
    margin-top: 3px;
}

.terminal-group-tags {
    flex: 0 1 260px;
    max-width: 260px;
    height: 24px;
}

.terminal-tag {
    display: inline-block;
    min-width: 0;
    max-width: 120px;
    padding: 1px 5px;
    overflow: hidden;
    border: 1px solid #9fb8ca;
    border-radius: 9px;
    background: #eef5f9;
    color: #315b73;
    font-size: 10px;
    line-height: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.terminal-tag-edit {
    flex: 0 0 auto;
    height: 20px;
    min-width: 25px;
    padding: 0 4px;
    border-color: #8fa6b8;
    background: #f7fafc;
    color: #385b70;
    font-size: 10px;
    line-height: 1;
}

.terminal-tag-edit.compact {
    margin-left: auto;
}

.terminal-tag-edit:hover:not(:disabled) {
    border-color: #337ea9;
    background: #337ea9;
    color: #fff;
}

.terminal-tag-edit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.terminal-tile-heading {
    margin-bottom: 5px;
}

.terminal-tile-heading strong {
    min-width: 0;
    overflow: hidden;
    color: #263b4d;
    font-size: 12px;
    text-overflow: ellipsis;
}

.terminal-poor-connection {
    display: inline-flex;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    align-items: center;
    color: #b86a00;
    cursor: help;
}

.terminal-tile-state-dot {
    width: 7px;
    min-width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b8c2ca;
}

.terminal-tile.online .terminal-tile-state-dot {
    background: #2ca25f;
    box-shadow: 0 0 0 2px #e2f3e9;
}

.terminal-tile.offline .terminal-tile-state-dot {
    background: #c95850;
    box-shadow: 0 0 0 2px #f7e5e3;
}

.terminal-sound-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    padding: 2px;
    border: 0;
    border-radius: 0;
    color: #667784;
    background: transparent;
    transition: color 0.2s;
}

.terminal-sound-toggle[data-sound-enabled="true"] {
    color: #186c3a;
}

.terminal-sound-toggle[data-sound-mode="on"],
.terminal-sound-toggle[data-sound-mode="off"] {
    border: 1px solid currentColor;
    border-radius: 3px;
}

.terminal-sound-toggle:hover {
    color: #337ea9;
    background: transparent;
}

.terminal-sound-toggle:focus-visible {
    outline: 1px dashed #337ea9;
    outline-offset: 3px;
}

.terminal-tile-mode {
    color: #287a3f;
    font-size: 10px;
    font-weight: 800;
}

.terminal-tile.offline .terminal-tile-mode {
    color: #a54b45;
}

.terminal-tile-remote {
    margin-left: auto;
    color: #667784;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 10px;
}

.terminal-tile-line {
    justify-content: space-between;
    margin-top: 3px;
    color: #64727d;
}

.terminal-tile-line > span,
.terminal-tile-line > strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.terminal-tile-identity span:first-child {
    color: #293f52;
    font-weight: 700;
}

.terminal-tile-atm strong {
    color: #315b73;
    font-weight: 700;
}

.terminal-tile-atm span:last-child {
    color: #667784;
}

.terminal-tile-health {
    justify-content: flex-start;
    gap: 9px;
}

.terminal-tile-health span:last-child {
    margin-left: auto;
}

.terminal-tile-presence {
    margin: 6px -9px -7px;
    padding: 5px 9px;
    border-top: 1px solid #e3e9ee;
    background: #f4f7f9;
    font-size: 10px;
}

.terminal-tile.online .terminal-tile-presence strong {
    color: #247a45;
}

.terminal-tile.offline .terminal-tile-presence strong {
    color: #a94e48;
}

.terminal-tile-lock {
    flex: 0 0 auto;
}

table {
    --terminal-group-accent: #8fa6b8;
    width: 100%;
    table-layout: auto;
    background: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

thead {
    background: #34495e;
    color: #fff;
}

th, td {
    padding: 8px 6px;
    text-align: left;
}

th {
    font-weight: 500;
    font-size: 14px;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
}

th.sortable:hover {
    background: #3d566e;
}

th.sortable::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    opacity: 0.3;
}

th.sortable:hover::after {
    opacity: 0.6;
    border-top-color: #fff;
    border-bottom: none;
}

th.sortable.sort-asc::after {
    opacity: 1;
    border-top: none;
    border-bottom: 5px solid #fff;
}

th.sortable.sort-desc::after {
    opacity: 1;
    border-top: 5px solid #fff;
    border-bottom: none;
}

/* Filter row in table header */
.filter-row th {
    padding: 4px 6px;
    background: #3d566e;
}

.filter-row .filter-status-cell {
    width: 112px;
    min-width: 112px;
    max-width: 112px;
}

.filter-status-slot {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22px;
    align-items: center;
    gap: 4px;
    width: 100%;
    height: 24px;
    min-height: 24px;
    white-space: nowrap;
}

.filter-status-slot > * {
    visibility: hidden;
}

.filter-status-slot.active > * {
    visibility: visible;
}

.filter-row select,
.filter-row input[type="text"] {
    width: 100%;
    padding: 3px 6px;
    border: 1px solid #7f8c8d;
    border-radius: 3px;
    font-size: 12px;
    background: #fff;
    color: #333;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #ccc;
    cursor: pointer;
    white-space: nowrap;
    font-weight: normal;
}

.filter-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.filter-count {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
    color: #aaa;
    line-height: 1;
    white-space: nowrap;
}

.reset-filters-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 20px;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    padding: 0;
    cursor: pointer;
    line-height: 1;
}
.reset-filters-btn:hover {
    background: #c0392b;
}

tbody tr {
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background: #e8e8e8;
}

tbody tr.row-selected {
    background: #d4e6f9;
}

tbody tr.row-selected:hover {
    background: #b8d4f0;
}
.filter-status-slot .reset-filters-btn:disabled {
    opacity: 1;
    background: #e74c3c;
    border-color: transparent;
    color: #fff;
}

tbody tr.terminal-group-row {
    border-bottom: 0;
}

tbody tr.terminal-group-row td {
    padding: 7px 10px;
    vertical-align: middle;
    border-top: 3px solid var(--terminal-group-accent);
    border-bottom: 0;
    background: #e5edf3;
}

tbody tr.terminal-group-row:hover td {
    background: #d9e5ed;
}

tbody tr.terminal-group-row.row-selected td {
    background: #d4e6f9;
}

tbody tr.terminal-group-row.reserved td {
    background: #fff4dd;
    border-top-color: #d99a2b;
}

tbody tr.agent-program-row.reserved td {
    background: #fffaf0;
}

.terminal-group-summary {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    height: 24px;
    min-height: 24px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.terminal-group-summary > * {
    align-self: center;
    margin: 0;
}

.terminal-group-summary > span {
    display: inline-flex;
    align-items: center;
    height: 24px;
    min-height: 24px;
    line-height: 1;
}

.terminal-group-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    min-width: 22px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #34495e;
    font-size: 16px;
    line-height: 1;
}

.terminal-group-toggle:hover {
    background: #d5e1e9;
}

.terminal-group-hostname {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 700;
}

.terminal-screenshot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    min-width: 25px;
    height: 24px;
    padding: 0;
    border-color: #3498db;
    color: #2471a3;
    background: #f8fbfd;
    font-size: 13px;
    line-height: 1;
}

.terminal-screenshot-btn:hover:not(:disabled) {
    color: #fff;
    background: #3498db;
}

.terminal-screenshot-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.terminal-group-remote {
    color: #52606d;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

.terminal-group-agent-id {
    flex: 1 1 180px;
    min-width: 80px;
    max-width: 360px;
    color: #52606d;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.terminal-group-mode {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 700;
}

.terminal-group-mode-indicator.online {
    color: #198b43;
}

.terminal-group-mode-indicator.offline {
    color: #c0392b;
}

.terminal-group-mode-separator {
    color: #7f8c8d;
}

.terminal-group-os,
.terminal-group-atm,
.terminal-group-count,
.terminal-group-health {
    color: #66727c;
    font-size: 12px;
}

.terminal-group-atm {
    max-width: 220px;
    overflow: hidden;
    color: #315b73;
    font-weight: 700;
    text-overflow: ellipsis;
}

.terminal-group-health {
    color: #287a3f;
    font-weight: 600;
}

.terminal-group-update-policy {
    border: 1px solid #b45309;
    border-radius: 3px;
    padding: 1px 4px;
    color: #9a3412;
    background: #ffedd5;
    font-size: 9px;
    font-weight: 700;
    line-height: 13px;
}

.terminal-group-reservation {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid #c47d12;
    border-radius: 3px;
    padding: 1px 5px;
    color: #804d08;
    background: #ffedc2;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.terminal-reservation-btn {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    padding: 0;
    border: 1px solid #b87510;
    border-radius: 4px;
    color: #704207;
    background: #fff7df;
    font-size: 12px;
    line-height: 20px;
    cursor: pointer;
}

.terminal-reservation-btn:hover {
    background: #ffe7a6;
}

.terminal-reservation-btn.release {
    border-color: #b74b3f;
    color: #8e2f25;
    background: #fff0ee;
}

.terminal-group-transports {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 3px;
    margin-left: auto;
}

tbody tr.stale {
    opacity: 0.5;
}

.col-checkbox {
    width: 30px;
    text-align: center;
}

.col-terminal,
.col-source,
.col-program,
.col-current,
.col-status,
.col-action {
    white-space: nowrap;
    width: 1%;
}

.col-new {
    width: auto;
}

.col-source {
    border-left: 3px solid var(--terminal-group-accent);
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

td input[type="text"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

td input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

.status-running {
    color: #27ae60;
    font-weight: 500;
}

.status-stopped {
    color: #e74c3c;
    font-weight: 500;
}

.status-unknown {
    color: #95a5a6;
}

.transport-indicator {
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    line-height: 13px;
    padding: 0 3px;
}

.status-degraded {
    color: #b45309;
    font-weight: 600;
}

.program-components {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1rem;
    margin-top: 0.12rem;
    color: #526579;
    font-size: 0.68rem;
    line-height: 1.15;
}

.program-component.running { color: #16814b; }
.program-component.stopped { color: #7b8794; }
.program-component.degraded { color: #b45309; }
.program-component-separator { color: #9aa9b7; }

.transport-indicator.online {
    color: #238636;
    background: #eaf7ed;
}

.transport-indicator.transport-http.online {
    color: #b45309;
    background: #fff4d6;
}

.transport-indicator.partial {
    color: #9a6700;
    background: #fff4d6;
}

.transport-indicator.offline {
    color: #a94442;
    background: #faeeee;
}

/* Prevent text wrapping in table cells */
#agents-body td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-table-tooltip-key]:focus:not(.terminal-sound-toggle) {
    outline: 2px solid #3498db;
    outline-offset: -2px;
}

.table-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: min(420px, calc(100vw - 16px));
    padding: 7px 9px;
    border-radius: 4px;
    background: #243342;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
    font-size: 12px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    pointer-events: none;
    white-space: pre-line;
}

.table-tooltip[hidden] {
    display: none;
}

.screenshot-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 29, 38, 0.76);
    cursor: pointer;
}

.screenshot-overlay[hidden] {
    display: none;
}

.screenshot-preview {
    max-width: min(860px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    overflow: hidden;
    border: 1px solid #52697d;
    border-radius: 6px;
    background: #18232d;
    color: #fff;
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.48);
}

.screenshot-preview-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    padding: 9px 12px;
    color: #dce8f2;
    font-size: 13px;
}

.screenshot-preview-header span {
    color: #91a4b5;
    font-size: 11px;
}

.screenshot-status {
    min-width: 280px;
    padding: 28px;
    color: #dce8f2;
    text-align: center;
}

.screenshot-status.error {
    color: #ffb3ad;
}

.screenshot-preview img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 100px);
    margin: 0 auto;
    background: #000;
    object-fit: contain;
}

.screenshot-preview img[hidden],
.screenshot-status[hidden] {
    display: none;
}

/* Service control buttons */
.service-controls {
    display: flex;
    gap: 4px;
}

button.service-btn {
    padding: 3px 8px;
    font-size: 11px;
    min-width: 24px;
}

button.service-btn.start {
    color: #27ae60;
    border-color: #27ae60;
}

button.service-btn.start:hover {
    background: #27ae60;
    color: #fff;
}

button.service-btn.stop {
    color: #e74c3c;
    border-color: #e74c3c;
}

button.service-btn.stop:hover {
    background: #e74c3c;
    color: #fff;
}

button.service-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

button.service-btn.info {
    color: #3498db;
    border-color: #3498db;
    font-size: 12px;
    padding: 2px 6px;
    min-width: 20px;
}

button.service-btn.info:hover {
    background: #3498db;
    color: #fff;
}

button.service-btn.info i {
    font-style: italic;
    font-weight: bold;
}

.result-ok {
    color: #27ae60;
}

.result-error {
    color: #e74c3c;
}

/* Time drift indicators */
.time-drift-warn {
    color: #e67e22;
    font-size: 11px;
    font-weight: 500;
}
.time-drift-bad {
    color: #e74c3c;
    font-size: 11px;
    font-weight: bold;
}

.service-version-value {
    display: block;
    min-height: 13px;
    margin-top: 2px;
    color: #52606d;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.service-version-value.missing {
    color: #a0a8b0;
    font-weight: 400;
}

.service-update-pending {
    display: inline-block;
    margin-left: 5px;
    padding: 0 3px;
    border: 1px solid #d17b00;
    border-radius: 3px;
    color: #a85f00;
    font-size: 9px;
    line-height: 11px;
    vertical-align: 1px;
}

/* Duplicate terminal ID warning */
tr.duplicate-terminal td.col-terminal {
    background: #fff3cd;
    color: #c0392b;
    font-weight: bold;
}

/* Missing service version warning - version not received */
tr.missing-service-version td.col-program {
    color: #c0392b;
}

/* Exec panel */
.exec-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.exec-panel label {
    font-size: 14px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.exec-panel input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.exec-panel input:focus {
    outline: none;
    border-color: #3498db;
}

.exec-panel input[type="text"] {
    flex: 1;
}

.exec-panel input[type="checkbox"] {
    flex: none;
    width: auto;
    margin-right: 5px;
}

.exec-panel select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    min-width: 150px;
}

.exec-panel .checkbox-label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
}

.exec-panel .preset-comment {
    flex: 0 0 150px;
    max-width: 150px;
    font-family: inherit;
}

.deploy-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.deploy-panel label {
    font-size: 14px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.deploy-panel select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    min-width: 200px;
}

button.small {
    padding: 6px 10px;
    font-size: 12px;
}

.no-agents {
    text-align: center;
    padding: 40px;
    background: #fff;
    border-radius: 8px;
    color: #95a5a6;
    font-size: 18px;
    display: none;
}

.no-agents.visible {
    display: block;
}

#agents-table.hidden {
    display: none;
}

@media (max-width: 1200px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .actions {
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* PowerShell editor uses the existing command panel and authentication controls. */
.exec-panel { flex-wrap: wrap; }
.exec-panel [hidden] { display: none !important; }
#powershell-fields { flex: 1 1 100%; min-width: 0; }
#exec-script { display: block; width: 100%; box-sizing: border-box; resize: vertical; margin: 8px 0; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font: 14px Consolas, Monaco, monospace; }
#exec-session { width: 110px; }
#exec-timeout { width: 90px; }

.terminal-activate-btn { padding: 2px 6px; font-size: 11px; border-radius: 3px; background: #2476a8; color: #fff; cursor: pointer; }
.terminal-activate-btn:disabled { opacity: .5; cursor: default; }
