:root {
    color-scheme: light dark;
    --bg: #0f1115;
    --panel: #1a1d23;
    --text: #e6e8eb;
    --muted: #9aa0a6;
    --accent: #2f81f7;
    --error: #f85149;
}

* {
    box-sizing: border-box;
}

/* The hidden attribute must win over any display rule below (e.g. display: flex),
   otherwise script-toggled panels show on page load. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: system-ui, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--panel);
    border-bottom: 1px solid #2a2e35;
}

header .brand {
    font-weight: 600;
}

header nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

main {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1.25rem;
}

a {
    color: var(--accent);
}

form.inline {
    display: inline;
}

button.link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.card {
    background: var(--panel);
    border: 1px solid #2a2e35;
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 360px;
    margin: 4rem auto;
}

/* Release label at the foot of the sign-in card. */
.card .version {
    margin: 1rem 0 0;
    text-align: right;
    font-size: 0.8rem;
    color: var(--muted);
}

label {
    display: block;
    margin-bottom: 0.85rem;
    color: var(--muted);
}

/* The "keep me signed in" tick sits beside its text instead of above it. */
label.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.3;
}

label.checkbox input[type="checkbox"] {
    display: inline-block;
    width: auto;
    margin-top: 0;
    flex: none;
}

input {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.55rem 0.65rem;
    border-radius: 6px;
    border: 1px solid #3a3f47;
    background: #0d0f13;
    color: var(--text);
}

button,
.button {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}

.error {
    color: var(--error);
}

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

th,
td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #2a2e35;
}

td.code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
}

.card-wide {
    max-width: 640px;
}

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

.qr-row {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.qr {
    background: #fff;
    padding: 6px;
    border-radius: 6px;
    flex: 0 0 auto;
}

.qr-row > div {
    flex: 1 1 260px;
}

.qr-row p {
    margin: 0 0 0.6rem;
}

.manual-key {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    background: #0d0f13;
    border: 1px solid #3a3f47;
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    user-select: all;
}

/* ---- Session viewer -------------------------------------------------------- */

body.session-page {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.session-page header {
    display: none; /* the toolbar replaces it; every pixel goes to the remote screen */
}

body.session-page main {
    max-width: none;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.viewer {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #000;
}

.viewer:fullscreen {
    width: 100vw;
    height: 100vh;
}

.toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.75rem;
    background: var(--panel);
    border-bottom: 1px solid #2a2e35;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.tb-link {
    color: var(--muted);
    text-decoration: none;
}

.tb-link:hover {
    color: var(--text);
}

.tb-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1rem;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.tb-status {
    color: var(--muted);
}

/* Toolbar chip while a Windows security prompt has the customer's screen. */
.tb-warn {
    color: #f0b429;
    border: 1px solid #6b5316;
    border-radius: 6px;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* A slim banner over the top of the picture. It never takes clicks, so even a wrong
   report cannot get between the technician and the screen. */
.secure-desktop {
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 1rem);
    padding: 0.35rem 0.8rem;
    border: 1px solid #6b5316;
    border-radius: 6px;
    background: rgba(13, 15, 19, 0.85);
    color: #f0b429;
    font-size: 0.85rem;
    text-align: center;
    pointer-events: none;
    z-index: 5;
}

.tb-spacer {
    flex: 1 1 auto;
}

.tb-group {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.tb-btn {
    background: #2a2e35;
    color: var(--text);
    border: 1px solid #3a3f47;
    border-radius: 5px;
    padding: 0.3rem 0.6rem;
    font: inherit;
    cursor: pointer;
    line-height: 1.2;
}

.tb-btn:hover {
    background: #343a43;
}

.tb-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.tb-btn.tb-danger {
    border-color: #a83a3a;
    color: #f0a0a0;
}

.tb-btn.tb-danger:hover {
    background: #b93c3c;
    border-color: #b93c3c;
    color: #fff;
}

.tb-zoom {
    min-width: 3.2em;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.tb-info {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.stage-row {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

/* Holds the scrolling stage and anchors the secure-desktop banner, which must not scroll
   with the picture. */
.stage-wrap {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    position: relative;
}

/* The scrollable area the remote screen lives in. Smaller-than-stage images are centred;
   larger ones scroll. */
.stage {
    flex: 1 1 auto;
    min-width: 0;
    overflow: auto;
    display: grid;
    place-items: center;
    background: #000;
}

#screen {
    display: block;
    background: #000;
    outline: none;
    cursor: crosshair;
    image-rendering: auto;
}

/* ---- Tools drawer ----------------------------------------------------------- */

.tools {
    flex: 0 0 320px;
    overflow-y: auto;
    background: var(--panel);
    border-left: 1px solid #2a2e35;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.tools section + section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #2a2e35;
}

.tools h2 {
    font-size: 0.95rem;
    margin: 0 0 0.5rem;
}

.tools .hint {
    color: var(--muted);
    font-size: 0.8rem;
    margin: 0 0 0.5rem;
}

.tools textarea {
    display: block;
    width: 100%;
    resize: vertical;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid #3a3f47;
    background: #0d0f13;
    color: var(--text);
    font: inherit;
}

.tools input[type="text"] {
    margin-top: 0;
}

.tools input[type="file"] {
    padding: 0.3rem 0;
    border: none;
    background: none;
}

.tools .row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.tools button.secondary {
    background: #2a2e35;
}

.tools progress {
    width: 100%;
    margin-top: 0.5rem;
}

.tools ul {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
    color: var(--muted);
    font-size: 0.8rem;
}

.tools ul li {
    padding: 0.15rem 0;
    word-break: break-word;
}

@media (max-width: 900px) {
    .stage-row {
        flex-direction: column;
    }

    .tools {
        flex: 0 0 auto;
        max-height: 45vh;
        border-left: none;
        border-top: 1px solid #2a2e35;
    }
}

.tb-select {
    background: #2a2e35;
    color: var(--text);
    border: 1px solid #3a3f47;
    border-radius: 5px;
    padding: 0.3rem 0.5rem;
    font: inherit;
    line-height: 1.2;
    max-width: 16rem;
}
