/* ─── Design tokens ───────────────────────────────────────────────────────── */
:root {
    --bg: #f0f3f7;
    --panel: #ffffff;
    --border: #dde4ed;
    --text: #1a2536;
    --muted: #5a6a80;
    --primary: #c35f1d;
    --primary-hover: #a34d17;
    --ok: #187a45;
    --ok-bg: rgba(24, 122, 69, 0.09);
    --error: #b52b22;
    --error-bg: rgba(181, 43, 34, 0.09);
    --nav: #1a2536;
    --nav-text: #e8ecf2;
    --nav-muted: #7a8fa8;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 2px 8px rgba(0, 0, 0, 0.04);
    font-family: system-ui, "Segoe UI", "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

h1,
h2,
h3,
p {
    margin: 0;
}

/* ─── App nav (sticky dark topbar) ───────────────────────────────────────── */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 50px;
    background: var(--nav);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--nav-text);
    font-weight: 700;
    font-size: 0.9rem;
}

.nav-sep {
    color: var(--nav-muted);
    font-size: 0.8rem;
    opacity: 0.6;
}

.nav-sep-v {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
    margin: 0 4px;
}

.nav-spacer {
    flex: 1;
}

/* ─── Account menu ────────────────────────────────────────────────────────── */
.account-menu {
    position: relative;
}

.account-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    color: var(--nav-text);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 100ms;
}

.account-trigger:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: none;
}

.account-trigger-subtitle {
    font-size: 0.88rem;
    line-height: 1.1;
    font-weight: 700;
}

.account-trigger-chevron {
    font-size: 0.8rem;
    opacity: 0.55;
}

.account-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    z-index: 60;
    display: grid;
    gap: 2px;
}

.account-dropdown-head {
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
    display: grid;
    gap: 2px;
}

.account-dropdown-head strong {
    font-size: 0.9rem;
    color: var(--text);
}

.account-dropdown-head span {
    font-size: 0.8rem;
    color: var(--muted);
}

.account-link {
    display: flex;
    align-items: center;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    transition: background 80ms;
    width: 100%;
    text-align: left;
}

.account-link:hover {
    background: var(--bg);
    transform: none;
}

.account-link-active {
    color: var(--primary);
}

/* ─── Page wrappers ───────────────────────────────────────────────────────── */
.page-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 20px 60px;
}

.page-wrap-medium {
    max-width: 860px;
}

/* ─── Login layout ────────────────────────────────────────────────────────── */
.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 20px;
}

.login-panel {
    width: 100%;
    max-width: 400px;
}

.login-logo {
    margin-bottom: 24px;
    text-align: center;
}

.login-logo-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.login-logo-sub {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 3px;
}

/* ─── Session status bar ─────────────────────────────────────────────────── */
.session-bar {
    display: flex;
    align-items: center;
    gap: 4px 12px;
    padding: 9px 0 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.session-bar-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.session-bar-label {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.session-bar-item strong {
    color: var(--text);
    font-size: 0.86rem;
}

.session-bar-item code {
    font-family: "Consolas", monospace;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text);
}

.session-bar-item span:not(.session-bar-label) {
    font-size: 0.86rem;
    color: var(--text);
}

.session-bar-sep {
    color: var(--border);
    user-select: none;
    font-size: 1rem;
}

.session-bar-spacer {
    flex: 1;
    min-width: 12px;
}

/* ─── Panels ─────────────────────────────────────────────────────────────── */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 16px;
}

.panel-header {
    margin-bottom: 16px;
}

.panel-header p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.panel-header .panel-title {
    margin-bottom: 0;
}

/* ─── Layouts ────────────────────────────────────────────────────────────── */
.scan-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr);
    gap: 14px;
    align-items: start;
}

.page-grid {
    display: grid;
    gap: 14px;
}

.split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* ─── Step indicator ─────────────────────────────────────────────────────── */
.step-indicator {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
    padding: 10px 14px;
    background: rgba(195, 95, 29, 0.07);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.step-num {
    min-width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.step-num-ok {
    background: var(--ok);
}

.step-indicator strong {
    display: block;
    font-size: 0.9rem;
}

.step-hint {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 2px;
    line-height: 1.4;
}

.input-has-active-zone {
    border-color: rgba(24, 122, 69, 0.5);
    box-shadow: inset 0 0 0 1px rgba(24, 122, 69, 0.18);
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.scan-form,
.stack-form {
    display: grid;
    gap: 14px;
}

.field-block {
    display: grid;
    gap: 5px;
}

.field-block > span {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-transform: none;
    letter-spacing: normal;
}

.field-label-row > span:first-child {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-state-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.field-state-active {
    border-color: rgba(24, 122, 69, 0.18);
    background: rgba(24, 122, 69, 0.08);
    color: var(--ok);
}

.field-state-empty {
    border-color: rgba(195, 95, 29, 0.14);
    background: rgba(195, 95, 29, 0.07);
    color: var(--primary);
}

.field-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.field-row > .field-block {
    flex: 1;
    min-width: 0;
}

.field-row > .field-block.field-narrow {
    flex: 0 0 140px;
}

input,
select {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font-size: 0.94rem;
    font-family: inherit;
    transition: border-color 120ms, box-shadow 120ms;
}

input::placeholder,
select::placeholder {
    font: inherit;
    color: #7a8fa8;
    opacity: 1;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(195, 95, 29, 0.12);
}

.field-scan input {
    font-family: "Consolas", "SFMono-Regular", monospace;
    font-size: 1rem;
    padding: 12px 13px;
    border-width: 2px;
}

.field-scan input:focus {
    box-shadow: 0 0 0 4px rgba(195, 95, 29, 0.14);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
button {
    border: 0;
    border-radius: 7px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    font-weight: 600;
    transition: background 100ms, transform 80ms;
    white-space: nowrap;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-ghost {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: #e4eaf2;
}

.btn-sm {
    padding: 6px 11px;
    font-size: 0.82rem;
    border-radius: 6px;
}

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(181, 43, 34, 0.18);
}

.btn-danger:hover {
    background: rgba(181, 43, 34, 0.16);
    transform: none;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ─── Feedback ───────────────────────────────────────────────────────────── */

/* ─── History ────────────────────────────────────────────────────────────── */
.history-list {
    display: grid;
    gap: 7px;
}

.history-empty {
    color: var(--muted);
    font-size: 0.86rem;
    padding: 8px 0;
}

.history-item {
    padding: 10px 12px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: #fafbfc;
}

.history-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.history-item strong {
    font-family: "Consolas", monospace;
    font-size: 0.88rem;
    display: block;
}

.history-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.8rem;
}

/* ─── Status pill ────────────────────────────────────────────────────────── */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 0.77rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-pill.active {
    background: var(--ok-bg);
    color: var(--ok);
}

.status-pill.inactive {
    background: var(--error-bg);
    color: var(--error);
}

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    background: var(--bg);
    padding: 3px;
    border-radius: 8px;
    width: fit-content;
}

.tab-btn {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 600;
    background: transparent;
    color: var(--muted);
    border: 0;
    cursor: pointer;
    transition: background 100ms, color 100ms;
}

.tab-btn:hover {
    color: var(--text);
    transform: none;
}

.tab-btn:active {
    transform: none;
}

.tab-btn.active {
    background: #fff;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ─── Users list ─────────────────────────────────────────────────────────── */
.users-list {
    display: grid;
    gap: 8px;
}

.user-item {
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fafbfc;
    display: grid;
    gap: 10px;
}

.user-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.user-topline strong {
    font-size: 0.94rem;
}

.user-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.8rem;
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.user-password-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    padding: 0 8px;
    overflow: hidden;
}

.site-nav-link {
    display: flex;
    align-items: center;
    height: 34px;
    padding: 0 11px;
    border-radius: 6px;
    color: var(--nav-muted);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 600;
    transition: background 100ms, color 100ms;
    white-space: nowrap;
}

.site-nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--nav-text);
}

.site-nav-link.active {
    background: rgba(255, 255, 255, 0.11);
    color: #fff;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 840px) {
    .site-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-shrink: 1;
    }

    .site-nav::-webkit-scrollbar {
        display: none;
    }

    .scan-layout {
        grid-template-columns: 1fr;
    }

    .field-row {
        flex-direction: column;
        align-items: stretch;
    }

    .field-row > .field-block.field-narrow {
        flex: none;
    }

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

    .history-topline {
        flex-direction: column;
        align-items: stretch;
    }

    .session-bar-spacer {
        flex-basis: 100%;
    }

    .page-wrap {
        padding: 12px 14px 40px;
    }

    .app-nav {
        padding: 0 14px;
    }
}

.toast-stack {
    position: fixed;
    top: 62px;
    right: 16px;
    z-index: 200;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.14);
    color: var(--text);
    pointer-events: auto;
    animation: toast-in 140ms ease-out;
}

.toast-success {
    border-left-color: var(--ok);
    background: #f6fcf8;
}

.toast-error {
    border-left-color: var(--error);
    background: #fff7f6;
}

.toast-info {
    border-left-color: var(--primary);
    background: #fffaf5;
}

.toast-content {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.45;
}

.toast-close {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.toast-close:hover {
    color: var(--text);
}

.toast-leave {
    animation: toast-out 160ms ease-in forwards;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(15, 23, 42, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-card {
    width: min(460px, 100%);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
    padding: 20px 20px 16px;
}

.modal-head {
    margin-bottom: 10px;
}

.modal-title {
    font-size: 1.06rem;
    font-weight: 800;
    color: var(--text);
}

.modal-body {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 18px;
}

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

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

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-6px);
    }
}
