:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e0ea;
    --accent: #1594d2;
    --accent-dark: #0b5f8f;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth {
    display: grid;
    place-items: center;
    padding: 24px;
}

header {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

a {
    color: var(--accent-dark);
    text-decoration: none;
}

main {
    width: min(1120px, calc(100% - 40px));
    margin: 32px auto;
}

h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.login-panel {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 12px 30px rgb(16 24 40 / 8%);
}

label {
    display: grid;
    gap: 8px;
    margin: 18px 0;
    font-weight: 600;
}

input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    font: inherit;
}

button {
    height: 40px;
    border: 1px solid #0e74a8;
    border-radius: 6px;
    padding: 0 16px;
    color: white;
    background: var(--accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

nav form {
    margin: 0;
}

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

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

.notice {
    color: var(--accent-dark);
}

.empty-state {
    margin-top: 24px;
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.tile {
    display: flex;
    min-height: 84px;
    align-items: center;
    justify-content: space-between;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font-weight: 700;
}

.tile span {
    color: var(--accent-dark);
}

body.rdp-session-page { min-height: 100vh; overflow: hidden; }
body.rdp-session-page main.rdp-session-main {
    width: calc(100vw - 24px);
    max-width: none;
    margin: 12px auto;
    padding: 0;
    height: calc(100vh - 58px - 24px);
    overflow: hidden;
}
.rdp-shell { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.rdp-viewport {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #111;
    border: 1px solid #333;
}
.rdp-display-wrapper {
    position: relative;
    flex: 0 0 auto;
    width: 0;
    height: 0;
    overflow: hidden;
    transform-origin: top left;
}
.rdp-display {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent;
}
.rdp-display canvas { display: block; }
.rdp-display-wrapper,
.rdp-display,
.rdp-display > div,
.rdp-display canvas {
    cursor: none;
}
.row-card form.tile, form.tile { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }


select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    background: white;
    color: var(--ink);
    font: inherit;
}

textarea {
    min-height: 88px;
    padding: 10px 12px;
}

header strong {
    white-space: nowrap;
}

header nav a {
    font-weight: 700;
}

header nav {
    flex-wrap: wrap;
    justify-content: flex-end;
}

form.grid {
    align-items: end;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

form.grid label {
    margin: 0;
}

.table-list {
    display: grid;
    gap: 14px;
    margin-top: 24px;
}

.row-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgb(16 24 40 / 5%);
}

.row-card form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: end;
    margin: 0;
}

.row-card form + form {
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.row-card span,
.row-card small {
    align-self: center;
    color: var(--muted);
}

.machine-tile {
    gap: 8px;
}

.machine-tile span {
    font-size: 17px;
}

.machine-tile small {
    color: var(--muted);
    font-weight: 600;
}

.admin-grid .tile {
    min-height: 96px;
}

@media (max-width: 760px) {
    header {
        height: auto;
        min-height: 58px;
        gap: 12px;
        align-items: flex-start;
        padding: 14px 18px;
        flex-direction: column;
    }

    header nav {
        justify-content: flex-start;
    }

    main {
        width: min(100% - 24px, 1120px);
        margin: 22px auto;
    }
}


.checkline {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.checkline input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.actions-row form {
    display: block;
}

.danger-button {
    background: var(--danger);
}

.session-status {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.session-status p {
    margin: 0;
    color: var(--muted);
}

.session-status.error {
    border-color: #fecdca;
    background: #fff5f5;
}

.session-status.warning {
    border-color: #fedf89;
    background: #fffaeb;
}

.session-status.connected {
    border-color: #91b9d8;
    background: #e8f3fb;
}

.session-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.rdp-display.is-pending::before,
.rdp-display.is-error::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(135deg, #151515, #242424);
}

.rdp-display.is-error {
    opacity: 0.35;
}


.diag-line {
    margin: 2px 0 0;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

#rdp-session:fullscreen {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 12px;
    background: var(--bg);
}

#rdp-session:fullscreen .rdp-viewport {
    min-height: 0;
}

.rdp-display > div {
    position: relative;
    z-index: 1;
    transform-origin: 0 0;
}

.rdp-display canvas {
    max-width: none;
}

.resolution-picker {
    width: 100%;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.resolution-picker select {
    margin-top: 6px;
}

.custom-resolution {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.custom-resolution[hidden] {
    display: none;
}

/* Fase 2A: compact RDP session chrome */
.rdp-session-page .rdp-toolbar {
    height: 52px;
    min-height: 52px;
    padding: 0 14px;
    gap: 12px;
    background: #f8fbfe;
    border-bottom: 1px solid #c8d8e8;
}

.rdp-toolbar-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rdp-machine-name {
    max-width: 36vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #102a43;
}

.rdp-state-pill {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid #91b9d8;
    border-radius: 999px;
    background: #e8f3fb;
    color: #0b5f8f;
    font-weight: 700;
    font-size: 13px;
}

.rdp-session-summary {
    color: #52677a;
    font-size: 13px;
    white-space: nowrap;
}

.rdp-toolbar-actions {
    flex-wrap: nowrap;
    gap: 8px;
}

.btn,
button.btn,
a.btn {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0 13px;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary,
button.btn-primary {
    border-color: #0e74a8;
    background: #1594d2;
    color: #fff;
}

.btn-primary:hover,
button.btn-primary:hover {
    background: #0e7fb6;
}

.btn-secondary,
a.btn-secondary,
button.btn-secondary {
    border-color: #9bb0c2;
    background: #eef4f8;
    color: #17364d;
}

.btn-ghost,
button.btn-ghost {
    border-color: #91b9d8;
    background: #f7fbff;
    color: #0b5f8f;
}

.btn-danger,
button.btn-danger {
    border-color: #d98b86;
    background: #c8463f;
    color: #fff;
}

.btn-danger:hover,
button.btn-danger:hover {
    background: #a9342e;
}

.btn:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #9ed8f5;
    outline-offset: 2px;
}

button:disabled,
.btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.58;
}

body.rdp-session-page main.rdp-session-main {
    margin: 8px auto;
    height: calc(100vh - 52px - 16px);
}

.rdp-session-main .session-status.compact {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.rdp-session-main .session-status.compact > p {
    display: none;
}

.rdp-diagnostic-panel {
    padding: 8px 10px;
    border: 1px solid #c8d8e8;
    border-radius: 6px;
    background: #f8fbfe;
}

#rdp-session:fullscreen {
    padding: 8px;
}

.rdp-session-page:has(#rdp-session:fullscreen) .rdp-toolbar {
    position: fixed;
    z-index: 5;
    top: 8px;
    left: 50%;
    width: min(760px, calc(100vw - 24px));
    transform: translateX(-50%);
    border: 1px solid #c8d8e8;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgb(16 42 67 / 16%);
}

/* Fase 2A: unified portal/admin navigation */
.app-header {
    background: #f8fbfe;
    border-bottom: 1px solid #c8d8e8;
}

.app-header strong {
    color: #102a43;
}

.app-header nav a {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0 10px;
    color: #17364d;
}

.app-header nav a:hover,
.app-header nav a.active {
    border-color: #91b9d8;
    background: #e8f3fb;
    color: #0b5f8f;
}

.admin-main {
    width: min(1280px, calc(100% - 40px));
}

.admin-titlebar {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #d9e0ea;
}

.admin-titlebar h1 {
    margin: 0 0 4px;
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-tab {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    border: 1px solid #d0dce7;
    border-radius: 6px;
    padding: 0 12px;
    color: #52677a;
    background: #fff;
    font-weight: 700;
}

.admin-tab:hover,
.admin-tab.active {
    border-color: #91b9d8;
    background: #e8f3fb;
    color: #0b5f8f;
}

.admin-page main > h1:first-of-type {
    font-size: 22px;
}

.danger-button,
button.danger-button {
    border-color: #d98b86;
    background: #c8463f;
}

@media (max-width: 760px) {
    .admin-main {
        width: min(100% - 24px, 1280px);
    }

    .admin-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .admin-tab {
        white-space: nowrap;
    }
}

.session-row {
    grid-template-columns: 1fr;
}

.session-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    color: #52677a;
}

.session-meta.technical code {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
