@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
    --bg: oklch(0.16 0.007 255);
    --bg-elevated: oklch(0.19 0.008 255);
    --surface: oklch(0.19 0.008 255);
    --surface-strong: oklch(0.19 0.008 255);
    --surface-soft: oklch(1 0 0 / 0.03);
    --line: oklch(1 0 0 / 0.08);
    --line-strong: oklch(1 0 0 / 0.18);
    --text: oklch(0.94 0.004 255);
    --muted: oklch(0.68 0.012 255);
    --accent: oklch(0.62 0.08 240);
    --accent-strong: oklch(0.72 0.07 240);
    --danger: #d98c8c;
    --warning: #d9b26b;
    --success: #8fae95;
    --radius-lg: 6px;
    --radius-md: 4px;
    --radius-sm: 3px;
    --content-width: min(1160px, calc(100% - 32px));
}

body.panel.light-mode {
    --bg: #f6f5f2;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --surface-soft: rgba(20, 24, 30, 0.03);
    --line: rgba(20, 24, 30, 0.1);
    --line-strong: rgba(20, 24, 30, 0.18);
    --text: #191c22;
    --muted: #666d76;
    --accent: #45688c;
    --accent-strong: #2e4a66;
}

* { box-sizing: border-box; }

body.panel {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: "IBM Plex Sans", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

a {
    color: inherit;
    text-decoration: none;
}

.panel-header,
.panel-main {
    width: var(--content-width);
    margin-inline: auto;
}

.panel-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 14px 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.panel-brand {
    position: relative;
    display: block;
    align-self: stretch;
    width: 200px;
    min-height: 48px;
    color: var(--text);
    font-size: 0;
}

.panel-brand img {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 167px;
    height: 86.4px;
    object-fit: contain;
    object-position: center;
}

.panel-brand span {
    display: none;
}

.panel-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-width: 0;
    color: var(--muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.78rem;
    text-transform: uppercase;
    flex-wrap: wrap;
    row-gap: 8px;
}

.panel-nav a {
    position: relative;
    color: inherit;
    padding: 0;
    white-space: nowrap;
    transition: color 0.18s ease;
}

.panel-nav a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.22s ease;
}

.panel-nav a:hover,
.panel-nav a.active {
    color: var(--accent);
}

.panel-nav a:hover::after,
.panel-nav a.active::after {
    transform: scaleX(1);
}

.panel-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    color: var(--muted);
    font-size: 0.86rem;
    white-space: nowrap;
}

.panel-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    flex: 0 0 2.35rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    background-image: url("moon-icon.svg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 1.15rem 1.15rem;
    font-size: 0;
    transition: opacity 0.2s ease;
}

body.panel.light-mode .panel-theme-toggle {
    background-image: url("sun-icon.svg");
}

.panel-theme-toggle:hover,
.panel-theme-toggle:focus-visible {
    opacity: 0.7;
}

.panel-user .who b {
    color: var(--text);
    font-weight: 600;
}

.panel-user a.logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-weight: 600;
}

.panel-user a.logout:hover {
    border-color: var(--line-strong);
}

.panel-main {
    padding: 44px 0 64px;
    animation: fade-in-up 0.45s ease;
}

.panel-title {
    margin: 0 0 8px;
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1.15;
    color: var(--text);
}

.panel-subtitle {
    margin: 0 0 26px;
    max-width: 70ch;
    color: var(--muted);
}

.panel-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.panel-title-row .panel-subtitle {
    margin-bottom: 0;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 14px;
    font-weight: 600;
    line-height: 1.15;
    color: var(--text);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    box-shadow: none;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.card:hover {
    border-color: var(--line-strong);
}

.card + .card {
    margin-top: 18px;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 1rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

label.field {
    display: block;
    margin-bottom: 14px;
}

label.field > span,
.items-table th,
table.list th {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--muted);
}

label.field > span {
    display: block;
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid oklch(1 0 0 / 0.12);
    background: rgba(6, 18, 29, 0.78);
    color: var(--text);
    font: inherit;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

body.panel.light-mode input,
body.panel.light-mode select,
body.panel.light-mode textarea {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(11, 31, 51, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--surface-soft);
}

textarea {
    min-height: 84px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}

.btn-ghost:hover {
    border-color: var(--line-strong);
}

.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
    border-color: var(--line);
    padding: 8px 12px;
}

.btn-danger-ghost:hover {
    border-color: var(--line-strong);
}

.items-table,
table.list {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    text-align: left;
    padding: 6px 8px;
}

.items-table td {
    padding: 6px 8px;
    vertical-align: top;
}

.items-table input {
    padding: 9px 10px;
}

table.list input,
table.list select,
table.list textarea {
    padding: 9px 10px;
}

.col-num { width: 110px; }
.col-qty { width: 90px; }

.line-total {
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding-top: 18px;
    color: var(--accent);
    font-weight: 600;
}

.totals {
    margin-left: auto;
    max-width: 360px;
    margin-top: 18px;
}

.totals .row {
    display: flex;
    justify-content: space-between;
    padding: 7px 0;
    color: var(--muted);
}

.totals .row.grand {
    border-top: 1px solid var(--line);
    margin-top: 6px;
    padding-top: 14px;
    font-size: 1.15rem;
    color: var(--text);
    font-weight: 700;
}

.totals .row.grand span:last-child {
    color: var(--accent);
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.alert {
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid;
    background: var(--surface);
}

.alert-error {
    border-color: color-mix(in srgb, var(--danger) 45%, transparent);
    color: var(--danger);
}

.alert-success {
    border-color: color-mix(in srgb, var(--success) 45%, transparent);
    color: var(--success);
}

.alert ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

table.list th,
table.list td {
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

table.list tbody tr:hover {
    background: var(--surface-soft);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    font-weight: 500;
}

.badge.draft { color: var(--warning); }
.badge.sent { color: var(--accent); }
.badge.accepted { color: var(--success); }
.badge.rejected { color: var(--danger); }

.metric-number {
    display: block;
    font-size: 2.1rem;
    line-height: 1.1;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.training-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.training-card .btn {
    margin-top: auto;
}

.training-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.progress-track span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
}

.choice-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    cursor: pointer;
}

.choice-row input {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    accent-color: var(--accent);
}

.training-result {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.training-result > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.training-bars {
    display: flex;
    align-items: end;
    gap: 10px;
    min-height: 180px;
    padding-top: 12px;
}

.training-bar {
    display: flex;
    flex: 1 1 28px;
    min-width: 24px;
    height: 150px;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    text-align: center;
    color: var(--muted);
}

.training-bar span {
    display: block;
    min-height: 10px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--accent);
}

.training-bar small {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
}

.training-detail {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}

.training-detail summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    color: var(--text);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 48px 0;
}

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

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    margin: 0 0 18px;
}

.check-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.inline-form {
    margin: 0;
}

.twofa-setup {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.qr-frame {
    width: 200px;
    height: 200px;
    aspect-ratio: 1;
    margin-bottom: 14px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fff;
}

.qr-code {
    display: block;
    width: 100%;
    height: 100%;
}

.users-list details {
    position: relative;
}

.users-list summary {
    list-style: none;
    width: fit-content;
}

.users-list summary::-webkit-details-marker {
    display: none;
}

.user-form .btn,
.user-edit-form .btn {
    margin-top: 4px;
}

.user-edit-form {
    margin-top: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    min-width: 280px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.action-row form {
    margin: 0;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(400px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: none;
    animation: fade-in-up 0.45s ease;
}

.login-card .brand {
    text-align: center;
    margin-bottom: 20px;
}

.login-card .brand img {
    width: 167px;
    height: 86.4px;
    object-fit: contain;
}

.login-card h1 {
    text-align: center;
    font-size: 1.2rem;
    margin: 0 0 6px;
}

.login-card p.sub {
    text-align: center;
    color: var(--muted);
    margin: 0 0 24px;
    font-size: 0.92rem;
}

.login-card .btn {
    width: 100%;
    margin-top: 6px;
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 960px) {
    .panel-header {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .panel-brand {
        width: 167px;
        min-height: 58px;
    }

    .panel-user {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 760px) {
    .panel-header,
    .panel-main {
        width: min(100vw - 16px, var(--content-width));
    }

    .panel-nav {
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

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

    .grid-2,
    .grid-3,
    .training-result,
    .twofa-setup {
        grid-template-columns: 1fr;
    }

    .panel-title-row {
        flex-direction: column;
    }

    .form-actions,
    .action-row {
        align-items: stretch;
    }

    .form-actions .btn,
    .action-row .btn,
    .action-row form {
        width: 100%;
    }

    table.list {
        display: block;
        overflow-x: auto;
    }
}
