:root {
    color-scheme: light;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #fff;
}

html,
body,
#app {
    width: 100%;
    min-width: 320px;
    height: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: linear-gradient(112deg, #082e69 0%, #152363 45%, #4b0054 100%);
    color: #111;
}

button,
input {
    font: inherit;
}

.terminal-shell {
    height: 100vh;
    min-height: 100vh;
    display: grid;
    grid-template-rows: 135px minmax(0, 1fr) 28px;
    overflow: hidden;
}

.terminal-topbar {
    position: relative;
    display: grid;
    grid-template-columns: 190px 1fr 190px;
    align-items: center;
    padding: 18px 28px 26px;
}

.terminal-logo {
    width: 132px;
    max-height: 104px;
    height: auto;
}

.terminal-time {
    justify-self: center;
    display: inline-grid;
    grid-template-columns: repeat(2, 1ch) 0.7ch repeat(2, 1ch) 0.7ch repeat(2, 1ch);
    width: 7.9ch;
    color: #fff;
    font-size: clamp(2.6rem, 5vw, 4.2rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;
    text-align: center;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.24);
}

.terminal-time-character {
    display: inline-block;
    text-align: center;
}

.terminal-time-separator {
    width: 0.7ch;
}

.terminal-time-digit {
    width: 1ch;
}

.terminal-board {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 27vw);
    gap: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 26px 26px 0 0;
    background-color: #fff;
}

.employee-area,
.history-area,
.configuration-panel,
.feedback-banner,
.feedback-backdrop,
.loading-panel {
    position: relative;
    z-index: 1;
}

.employee-area {
    display: flex;
    flex-wrap: wrap;
    gap: 48px 58px;
    align-items: flex-start;
    align-content: flex-start;
    min-height: 0;
    overflow: auto;
    padding: 44px 30px;
}

.employee-area::before,
.history-area::before {
    content: "";
    position: absolute;
    z-index: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.8)),
        url("../pio-texture.png");
    background-repeat: no-repeat, space;
    background-size: cover, 190px 190px;
    pointer-events: none;
}

.employee-area::before {
    inset: 72px 34px 18px 54px;
}

.history-area::before {
    inset: 72px 24px 18px 30px;
}

.employee-area > *,
.history-area > * {
    position: relative;
    z-index: 1;
}

.employee-group {
    flex: 0 1 auto;
    min-width: min(100%, 150px);
    max-width: 100%;
}

.employee-group h2,
.history-area h2 {
    margin: 0 0 20px;
    color: #7f858d;
    font-size: clamp(2rem, 3vw, 2.45rem);
    font-weight: 300;
    letter-spacing: 0;
}

.employee-list {
    display: flex;
    flex-wrap: wrap;
    gap: 34px 42px;
    max-width: 100%;
}

.employee-card {
    width: 124px;
    display: grid;
    justify-items: center;
    gap: 8px;
    text-align: center;
}

.employee-avatar {
    width: 82px;
    aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover;
}

.employee-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #188f22;
    color: #fff;
}

.employee-avatar-fallback svg {
    width: 100%;
    height: 100%;
    display: block;
}

.employee-avatar-fallback text {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 34px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: uppercase;
    fill: currentColor;
    dominant-baseline: middle;
    text-anchor: middle;
    text-rendering: geometricPrecision;
}

.employee-card p,
.history-item p {
    margin: 0;
    font-size: 1.32rem;
    line-height: 1.25;
}

.history-area {
    position: relative;
    display: flex;
    min-height: 0;
    flex-direction: column;
    background-image: linear-gradient(#9a9a9a, #9a9a9a);
    background-position: left 38px;
    background-repeat: no-repeat;
    background-size: 1px calc(100% - 76px);
    padding: 44px 30px;
    overflow: hidden;
}

.history-area::after {
    content: "";
    position: absolute;
    left: 1px;
    right: 0;
    bottom: 0;
    z-index: 2;
    height: 8.5rem;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.55) 44%,
        rgba(255, 255, 255, 0.82) 72%,
        rgba(255, 255, 255, 0.92)
    );
    pointer-events: none;
}

.history-list {
    display: grid;
    align-content: start;
    gap: 14px;
    grid-auto-rows: max-content;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.history-item {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.history-icon {
    position: relative;
    width: 50px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #188f22;
    color: #fff;
}

.history-icon-end {
    background: #a51624;
}

.history-door {
    position: absolute;
    top: 12px;
    bottom: 12px;
    width: 12px;
    border-right: 3px solid currentColor;
    border-radius: 0 2px 2px 0;
}

.history-door::after {
    content: "";
    position: absolute;
    right: -1px;
    bottom: 0;
    width: 13px;
    height: 3px;
    border-radius: 2px 0 0 2px;
    background: currentColor;
}

.history-door::before {
    content: "";
    position: absolute;
    right: -1px;
    top: 0;
    width: 13px;
    height: 3px;
    border-radius: 2px 0 0 2px;
    background: currentColor;
}

.history-arrow {
    position: absolute;
    top: 24px;
    width: 16px;
    height: 3px;
    border-radius: 999px;
    background: currentColor;
}

.history-arrow::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    transform: translateY(-50%);
}

.history-icon-start .history-door {
    right: 10px;
}

.history-icon-start .history-arrow {
    left: 9px;
}

.history-icon-start .history-arrow::after {
    right: -6px;
    border-left: 8px solid currentColor;
}

.history-icon-end .history-door {
    left: 10px;
    transform: scaleX(-1);
}

.history-icon-end .history-arrow {
    right: 9px;
}

.history-icon-end .history-arrow::after {
    left: -6px;
    border-right: 8px solid currentColor;
}

.history-item strong {
    display: block;
    margin-top: 2px;
    font-size: 1rem;
}

.history-empty,
.empty-state p {
    margin: 0;
    color: #7f858d;
    font-size: 1.2rem;
}

.empty-state {
    max-width: 38rem;
}

.empty-state h1 {
    margin: 0 0 12px;
    color: #7f858d;
    font-size: clamp(2.4rem, 4vw, 4rem);
    font-weight: 300;
    letter-spacing: 0;
}

.scanner-form {
    position: fixed;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.scanner-input {
    width: 1px;
    height: 1px;
    opacity: 0;
}

.configuration-panel,
.feedback-banner,
.loading-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(620px, calc(100% - 48px));
    transform: translate(-50%, -50%);
    border: 1px solid rgba(8, 46, 105, 0.18);
    border-radius: 8px;
    padding: 28px 32px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.feedback-backdrop {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: rgba(8, 13, 22, 0.58);
    pointer-events: none;
}

.feedback-banner {
    z-index: 6;
}

.configuration-panel h1,
.feedback-banner h1,
.loading-panel h1 {
    margin: 0 0 8px;
    color: #7f858d;
    font-size: clamp(2rem, 3vw, 2.8rem);
    font-weight: 300;
    letter-spacing: 0;
}

.configuration-panel p,
.feedback-banner p,
.feedback-banner small,
.loading-panel p {
    color: #222;
    font-size: 1.15rem;
}

.loading-panel {
    display: grid;
    justify-items: center;
    text-align: center;
    border-left: 8px solid #d9a21b;
}

.loading-spinner {
    width: 54px;
    aspect-ratio: 1;
    margin-bottom: 16px;
    border: 5px solid rgba(127, 133, 141, 0.24);
    border-top-color: #188f22;
    border-radius: 50%;
    animation: terminal-loading-spin 0.9s linear infinite;
}

@keyframes terminal-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.configuration-form {
    display: grid;
    gap: 0.9rem;
    margin-top: 18px;
}

.configuration-form label {
    color: #7f858d;
    font-size: 1rem;
}

.configuration-input {
    width: 100%;
    min-height: 3.2rem;
    box-sizing: border-box;
    border: 1px solid #b8bec5;
    border-radius: 4px;
    padding: 0.75rem 0.9rem;
    background: #fff;
    color: #111;
    outline: none;
}

.configuration-input:focus {
    border-color: #082e69;
    box-shadow: 0 0 0 3px rgba(8, 46, 105, 0.12);
}

.configuration-button {
    justify-self: start;
    min-height: 3rem;
    border: 0;
    border-radius: 4px;
    padding: 0.75rem 1.1rem;
    background: #188f22;
    color: #fff;
    font-weight: 700;
}

.terminal-state-success .feedback-banner {
    border-left: 8px solid #188f22;
}

.terminal-state-warning .feedback-banner,
.terminal-state-pending .feedback-banner {
    border-left: 8px solid #d9a21b;
    box-shadow: 0 12px 30px rgba(97, 65, 0, 0.24);
}

.terminal-state-error .feedback-banner,
.terminal-state-offline .feedback-banner {
    border-left: 8px solid #d61023;
}

.terminal-footer {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0 18px;
    border-top: 1px solid #dcdcdc;
    background: #fff;
    color: #000;
    font-size: 1rem;
}

.terminal-footer span:first-child {
    justify-self: center;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 1rem;
    background: #d61023;
    color: #fff;
}

#blazor-error-ui .reload {
    color: #fff;
    font-weight: 700;
}

@media (max-width: 860px) {
    body {
        overflow: auto;
    }

    .terminal-shell {
        height: auto;
        min-height: 100vh;
        grid-template-rows: auto minmax(0, 1fr) auto;
        overflow: visible;
    }

    .terminal-topbar {
        grid-template-columns: 84px 1fr;
        gap: 1rem;
        padding: 16px;
    }

    .terminal-logo {
        width: 74px;
    }

    .terminal-time {
        justify-self: end;
        font-size: 2.35rem;
    }

    .terminal-board {
        grid-template-columns: 1fr;
        border-radius: 0;
        overflow: visible;
    }

    .employee-area {
        min-height: 440px;
        padding: 26px 18px;
    }

    .employee-area::before,
    .history-area::before {
        inset: 54px 18px 18px;
    }

    .history-area {
        border-left: 0;
        border-top: 1px solid #d5d5d5;
        background-image: none;
        padding: 26px 18px;
        overflow: visible;
    }

    .history-area::after {
        display: none;
    }

    .history-list {
        max-height: none;
        overflow: visible;
    }

    .terminal-footer {
        grid-template-columns: 1fr;
        padding: 8px 14px;
        text-align: center;
    }
}
