* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

a {
    color: #38bdf8;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background-color: #1e293b;
    border-right: 1px solid #334155;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.nav-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #334155;
}

.brand-badge {
    background: #0284c7;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
}

.nav-links {
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: #334155;
    color: #f8fafc;
    text-decoration: none;
}

.nav-item.active {
    background: #0284c7;
    color: #ffffff;
}

.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.admin-header {
    height: 64px;
    background-color: #1e293b;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.page-title-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f1f5f9;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f8fafc;
}

.user-role {
    display: flex;
    gap: 4px;
}

.admin-content {
    flex: 1;
    padding: 24px;
    background-color: #0f172a;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.5rem;
    color: #f8fafc;
}

.subtitle {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-top: 4px;
}

.card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 20px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 16px;
}

.metric-title {
    font-size: 0.85rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #38bdf8;
    margin: 8px 0 4px 0;
}

.metric-desc {
    font-size: 0.8rem;
    color: #64748b;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-primary {
    background: #0284c7;
    color: #ffffff;
}
.btn-primary:hover {
    background: #0369a1;
}

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
}
.btn-secondary:hover {
    background: #475569;
}

.btn-outline {
    background: transparent;
    border: 1px solid #475569;
    color: #cbd5e1;
}
.btn-outline:hover {
    background: #334155;
}

.btn-danger {
    background: #ef4444;
    color: #ffffff;
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: #10b981;
    color: #ffffff;
}
.btn-success:hover {
    background: #059669;
}

.btn-block {
    width: 100%;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #065f46;
    color: #6ee7b7;
}

.badge-danger {
    background: #7f1d1d;
    color: #fca5a5;
}

.badge-warning {
    background: #78350f;
    color: #fcd34d;
}

.badge-info {
    background: #0369a1;
    color: #bae6fd;
}

.role-tag {
    background: #334155;
    color: #94a3b8;
    margin-right: 4px;
}

.role-admin {
    background: #4c1d95;
    color: #c4b5fd;
}

.role-contentmanager {
    background: #075985;
    color: #7dd3fc;
}

.role-student {
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid #475569;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.alert-danger {
    background: #450a0a;
    border: 1px solid #7f1d1d;
    color: #fecaca;
}

.alert-success {
    background: #064e3b;
    border: 1px solid #065f46;
    color: #a7f3d0;
}

.btn-close {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 12px;
    background: #1e293b;
    color: #94a3b8;
    border-bottom: 1px solid #334155;
    font-weight: 600;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #334155;
    color: #cbd5e1;
}

.actions-col {
    text-align: right;
    white-space: nowrap;
    gap: 6px;
}

.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
}

.pagination-info {
    font-size: 0.85rem;
    color: #94a3b8;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.current-page-num {
    font-weight: 600;
    padding: 0 8px;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    width: 440px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-lg {
    width: 600px;
}

.modal-xl {
    width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.role-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.login-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 400px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 32px;
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h2 {
    font-size: 1.3rem;
    margin-top: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #94a3b8;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #f8fafc;
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: #0284c7;
}

.form-control-sm {
    padding: 4px 8px;
    font-size: 0.85rem;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: #64748b;
}

.empty-state-card {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-text {
    max-width: 500px;
    margin: 12px auto;
    color: #cbd5e1;
    line-height: 1.5;
}

.empty-note {
    font-size: 0.85rem;
    color: #94a3b8;
}

.forbidden-container {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.forbidden-card {
    text-align: center;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 40px;
    max-width: 480px;
}

.forbidden-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.forbidden-card h2 {
    color: #f87171;
    margin-bottom: 12px;
}

.forbidden-card p {
    color: #cbd5e1;
    margin-bottom: 8px;
}

.forbidden-card .hint {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 24px;
}

.forbidden-card .actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.loading-box {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #334155;
    border-top: 3px solid #38bdf8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Banks grid styles */
.bank-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.bank-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bank-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.bank-title {
    font-size: 1.2rem;
    color: #f8fafc;
    margin-top: 4px;
}

.bank-langs {
    display: flex;
    gap: 4px;
}

.bank-metrics-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    background: #0f172a;
    padding: 12px;
    border-radius: 6px;
}

.metric-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.metric-box .metric-num {
    font-size: 1.3rem;
    font-weight: 700;
    color: #38bdf8;
}

.metric-box.metric-ready .metric-num {
    color: #10b981;
}

.metric-box.metric-review .metric-num {
    color: #f59e0b;
}

.metric-box .metric-label {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

.bank-meta {
    font-size: 0.8rem;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bank-card-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid #334155;
}

.filter-bar {
    display: flex;
    gap: 16px;
    background: #0f172a;
    padding: 12px;
    border-radius: 6px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.85rem;
    color: #94a3b8;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.text-muted {
    color: #94a3b8;
}

.text-success {
    color: #10b981;
}

/* ---- ATM-032: import wizard 2.0, import history, content packs ---- */

.hint {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 12px;
}

.alert-block {
    display: block;
}

.alert-info {
    background: #082f49;
    border: 1px solid #0369a1;
    color: #bae6fd;
}

.text-danger {
    color: #f87171;
}

.text-warning {
    color: #fbbf24;
}

.badge-muted {
    background: #334155;
    color: #cbd5e1;
}

.wizard-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    font-size: 0.85rem;
}

.wizard-step-num {
    display: inline-flex;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: #334155;
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.75rem;
}

.wizard-step.active {
    border-color: #0284c7;
    color: #f8fafc;
}

.wizard-step.active .wizard-step-num {
    background: #0284c7;
}

.wizard-step.done {
    color: #6ee7b7;
}

.wizard-step.done .wizard-step-num {
    background: #065f46;
}

.wizard-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wizard-card h3,
.section-title {
    color: #f8fafc;
    font-size: 1.05rem;
}

.section-title {
    margin: 16px 0 8px 0;
}

.wizard-form .form-group {
    margin-bottom: 14px;
}

.wizard-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid #334155;
}

.file-field small {
    display: block;
    margin-top: 4px;
}

.precheck {
    background: #0f172a;
    border: 1px dashed #334155;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.precheck-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #e2e8f0;
}

.precheck-warning {
    margin-top: 6px;
    font-size: 0.85rem;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 6px 16px;
    font-size: 0.85rem;
    word-break: break-word;
}

.run-summary {
    background: #0f172a;
    border-radius: 6px;
    padding: 12px;
}

.report-status {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.report-ok {
    background: #064e3b;
    border: 1px solid #065f46;
    color: #a7f3d0;
}

.report-failed {
    background: #450a0a;
    border: 1px solid #7f1d1d;
    color: #fecaca;
}

.check-title {
    font-weight: 600;
    color: #e2e8f0;
}

.check-summary {
    margin-left: 6px;
    font-size: 0.85rem;
}

.preview-counters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    background: #0f172a;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.metric-box.metric-new .metric-num {
    color: #38bdf8;
}

.metric-box.metric-changed .metric-num {
    color: #a78bfa;
}

.metric-box.metric-conflicts .metric-num {
    color: #f87171;
}

.preview-meta,
.shown-note {
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid #334155;
    margin-bottom: 12px;
}

.tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #94a3b8;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.tab.active {
    color: #f8fafc;
    border-bottom-color: #0284c7;
}

.confirm-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: #052e16;
    border: 1px solid #065f46;
    border-radius: 6px;
    padding: 10px 14px;
}

.table-container {
    overflow-x: auto;
}

.packs-table tr.row-current td {
    background: rgba(16, 185, 129, 0.12);
}

.packs-table tr.row-current td:first-child {
    box-shadow: inset 3px 0 0 #10b981;
}

.packs-table tr.row-new td {
    background: rgba(2, 132, 199, 0.12);
}

.pack-note {
    font-size: 0.8rem;
    margin-top: 2px;
}

.current-packs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.current-pack {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-color: #065f46;
}

.build-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.actions-col .btn + .btn {
    margin-left: 6px;
}

.bank-card-actions {
    gap: 8px;
}

/* ---- ATM-033: questions, question card, key editor, student preview, issues ---- */

.filter-wrap {
    flex-wrap: wrap;
    gap: 10px 16px;
}

.filter-search {
    flex: 1 1 260px;
}

.filter-search input {
    min-width: 200px;
}

.input-narrow {
    width: 90px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.questions-table td,
.issues-table td {
    vertical-align: top;
}

.questions-table .q-text {
    max-width: 420px;
    color: #e2e8f0;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: #38bdf8;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.link-button:hover {
    text-decoration: underline;
}

.shipped-cell small {
    display: block;
    margin-top: 2px;
}

/* question card */
.question-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

a.badge:hover {
    text-decoration: none;
    filter: brightness(1.15);
}

.image-card {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
}

.question-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    background: #0f172a;
    object-fit: contain;
}

.image-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.locale-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
    margin-bottom: 20px;
}

@media (max-width: 1100px) {
    .locale-columns {
        grid-template-columns: 1fr;
    }
}

.variant-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.variant-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.variant-header h3 {
    color: #f8fafc;
    font-size: 1.15rem;
    margin-right: 4px;
}

.variant-section .section-title {
    margin-top: 0;
}

.source-question {
    color: #f8fafc;
    font-size: 1rem;
    line-height: 1.45;
    margin-bottom: 10px;
}

.option-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 0.9rem;
}

.option.correct {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}

.option-letter {
    flex: 0 0 auto;
    display: inline-flex;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    background: #334155;
    font-size: 0.75rem;
    font-weight: 700;
}

.option.correct .option-letter {
    background: #065f46;
    color: #6ee7b7;
}

.option-text {
    flex: 1;
}

.source-meta,
.small {
    font-size: 0.8rem;
}

details > summary {
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.85rem;
    margin: 6px 0;
}

.info-text {
    white-space: pre-wrap;
    font-size: 0.85rem;
    color: #cbd5e1;
    background: #0f172a;
    border-radius: 6px;
    padding: 10px;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
}

.history-list li.current {
    color: #e2e8f0;
}

.history-text {
    color: #94a3b8;
}

.kv-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 4px 10px;
    font-size: 0.85rem;
    margin: 8px 0;
}

.kv-list dt {
    color: #94a3b8;
}

.kv-list dd {
    color: #e2e8f0;
    word-break: break-word;
}

.revision-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.key-groups {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}

.key-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.key-group-title {
    color: #94a3b8;
    min-width: 120px;
}

.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #bae6fd;
    font-size: 0.8rem;
}

.issue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.issue-item {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.related-ids a + a {
    margin-left: 4px;
}

.review-note {
    color: #fcd34d;
    font-style: italic;
    margin-top: 2px;
}

.history-table {
    font-size: 0.8rem;
}

.history-table th,
.history-table td {
    padding: 6px 8px;
}

.history-flags .badge {
    margin: 1px;
}

/* key editor */
.editor-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.editor-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
}

.editor-header h3 {
    color: #f8fafc;
    font-size: 1.1rem;
}

.locale-tabs {
    margin-bottom: 0;
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
    gap: 20px;
    align-items: start;
}

@media (max-width: 1200px) {
    .editor-grid {
        grid-template-columns: 1fr;
    }
}

.prepared-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.prepared-form textarea {
    resize: vertical;
    font-family: inherit;
}

.kw-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kw-field-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.kw-field-header .form-label {
    margin-bottom: 0;
}

.kw-hint {
    font-size: 0.8rem;
}

.kw-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kw-row .kw-input {
    flex: 1;
}

.kw-state {
    flex: 0 0 170px;
    font-size: 0.8rem;
}

.kw-ok .kw-state {
    color: #10b981;
}

.kw-bad .kw-state,
.kw-server .kw-state {
    color: #f87171;
}

.kw-bad .kw-input,
.kw-server .kw-input {
    border-color: #ef4444;
}

.kw-empty .kw-state {
    color: #94a3b8;
}

.kw-add {
    align-self: flex-start;
}

.kw-add:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.field-errors {
    list-style: none;
    color: #fca5a5;
    font-size: 0.8rem;
}

.form-warnings {
    list-style: none;
    color: #fcd34d;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-warnings li::before {
    content: "⚠ ";
}

.counter {
    margin-left: 6px;
    color: #64748b;
}

.counter.over {
    color: #f87171;
    font-weight: 600;
}

.form-flags {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid #334155;
}

.form-hint {
    margin-bottom: 0;
}

/* student preview («как увидит ученик») */
.preview-column {
    position: sticky;
    top: 16px;
}

.student-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-title {
    font-weight: 600;
    color: #f8fafc;
}

.preview-toggle {
    display: inline-flex;
    border: 1px solid #334155;
    border-radius: 999px;
    overflow: hidden;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px 14px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.toggle-btn.active {
    background: #0284c7;
    color: #ffffff;
}

.preview-note {
    font-size: 0.8rem;
    color: #fcd34d;
}

.phone {
    background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
    border: 1px solid #334155;
    border-radius: 28px;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    max-width: 440px;
}

.pv-image img {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: 18px;
    background: #0f172a;
}

.pv-question {
    color: #f8fafc;
    font-size: 1.02rem;
    line-height: 1.5;
    font-weight: 600;
}

mark.pv-key {
    background: rgba(56, 189, 248, 0.14);
    color: #7dd3fc;
    border-radius: 4px;
    padding: 0 2px;
}

.pv-options {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pv-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid #334155;
    font-size: 0.9rem;
}

.pv-option.correct {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    color: #d1fae5;
}

.pv-option.dimmed {
    opacity: 0.55;
}

.pv-letter {
    flex: 0 0 24px;
    height: 24px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e293b;
    font-weight: 700;
    font-size: 0.75rem;
}

.pv-option.correct .pv-letter {
    background: #10b981;
    color: #052e16;
}

.pv-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.pv-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.pv-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #bae6fd;
    font-size: 0.78rem;
}

.pv-chip-plain {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
}

.pv-chip-missing {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}

.pv-tricky {
    align-self: flex-start;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-weight: 600;
}

.pv-card {
    border-radius: 20px;
    padding: 12px 14px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid #334155;
    font-size: 0.88rem;
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pv-hook {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.35);
}

.pv-hook .pv-eyebrow {
    color: #38bdf8;
}

.pv-card-title {
    font-weight: 700;
    font-size: 0.82rem;
    color: #e2e8f0;
}

.pv-more summary {
    color: #38bdf8;
}

.pv-more p {
    white-space: pre-wrap;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.pv-hidden-info {
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
}

/* issues */
.computed-hints {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.hint-card {
    padding: 14px;
}

.hint-card-title {
    font-weight: 600;
    color: #f8fafc;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.hint-card-text {
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.45;
}

.issue-counters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.issue-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 12px;
    color: #e2e8f0;
    cursor: pointer;
    text-align: left;
}

.issue-tile:hover {
    border-color: #475569;
}

.issue-tile.active {
    border-color: #0284c7;
    background: #082f49;
}

.issue-tile .metric-num {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fbbf24;
}

.issue-tile.all .metric-num {
    color: #38bdf8;
}

.issue-tile .metric-label {
    font-size: 0.8rem;
    font-weight: 600;
}

.tile-title {
    font-size: 0.72rem;
    color: #94a3b8;
}

.status-note {
    flex-basis: 100%;
}

.issue-message {
    max-width: 480px;
}

.issue-legend {
    margin-top: 20px;
}

.legend-list {
    grid-template-columns: 200px 1fr;
}

.alert-warning {
    background: #451a03;
    border: 1px solid #78350f;
    color: #fde68a;
}

.basis-conflict .refresh-basis {
    margin-top: 8px;
}

.empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

/* ---- ATM-034: users and subscriptions, dashboard, config ---- */

/* Chart tokens (dataviz reference palette, dark steps; validated against the card surface #1e293b). */
.dashboard-page,
.user-panel {
    --chart-series-1: #3987e5;
    --chart-series-2: #199e70;
    --chart-grid: #334155;
    --chart-muted: #94a3b8;
    --status-new: #64748b;
    --status-error: #d03b3b;
    --status-unsure: #c98500;
    --status-known: #3987e5;
    --status-learned: #0ca30c;
}

.metrics-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.metrics-grid.compact .metric-value {
    font-size: 1.5rem;
}

.metric-desc a {
    white-space: nowrap;
}

.server-time {
    color: #64748b;
}

.bank-select {
    width: auto;
}

.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

.chart-card h3,
.top-errors-card h3 {
    font-size: 1rem;
    color: #f8fafc;
    margin-bottom: 12px;
}

.top-errors-card {
    margin-top: 16px;
}

.accounts-summary {
    margin-top: 16px;
    font-size: 0.85rem;
}

.compact-table th,
.compact-table td {
    padding: 6px 10px;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table-view {
    margin: 8px 0 12px;
}

.table-view table {
    max-width: 480px;
}

/* Column chart: bars <= 24 px, 4 px rounded data end, square at the baseline, 2 px gap, hairline baseline. */
.bar-chart {
    margin: 0;
}

.bar-chart-plot {
    position: relative;
    height: 160px;
    padding-top: 18px;
    border-bottom: 1px solid var(--chart-grid);
}

.bar-chart-max {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 0.7rem;
    color: var(--chart-muted);
    font-variant-numeric: tabular-nums;
}

.bar-chart-empty {
    position: absolute;
    inset: 18px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--chart-muted);
    pointer-events: none;
}

.bar-chart-bars {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 100%;
}

.bar-slot {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-radius: 4px 4px 0 0;
    outline-offset: 1px;
}

.bar-slot:hover,
.bar-slot:focus-visible {
    background: rgba(148, 163, 184, 0.08);
}

.bar {
    width: 100%;
    max-width: 24px;
    background: var(--chart-series-1);
    border-radius: 4px 4px 0 0;
}

.series-2 .bar {
    background: var(--chart-series-2);
}

.bar-value {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -2px);
    font-size: 0.7rem;
    color: #e2e8f0;
    white-space: nowrap;
    pointer-events: none;
}

.bar-chart-reference {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid #cbd5e1;
    pointer-events: none;
    z-index: 1;
}

.bar-chart-reference span {
    position: absolute;
    right: 0;
    bottom: 2px;
    font-size: 0.7rem;
    color: #cbd5e1;
    background: #1e293b;
    padding: 0 4px;
}

.bar-chart-axis {
    display: flex;
    gap: 2px;
    margin-top: 4px;
}

.bar-axis-label {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    font-size: 0.68rem;
    color: var(--chart-muted);
    white-space: nowrap;
    overflow: visible;
    font-variant-numeric: tabular-nums;
}

.bar-chart-caption {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
}

/* Status distribution: stacked bar with 2 px gaps, legend with the numbers. */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

.status-dist-head {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.status-bar {
    display: flex;
    gap: 2px;
    height: 14px;
}

.status-seg {
    min-width: 3px;
    flex-basis: 0;
}

.status-seg:first-child {
    border-radius: 4px 0 0 4px;
}

.status-seg:last-child {
    border-radius: 0 4px 4px 0;
}

.status-seg:only-child {
    border-radius: 4px;
}

.status-new { background: var(--status-new); }
.status-error { background: var(--status-error); }
.status-unsure { background: var(--status-unsure); }
.status-known { background: var(--status-known); }
.status-learned { background: var(--status-learned); }

.status-legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #cbd5e1;
}

.status-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.status-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.status-count {
    font-variant-numeric: tabular-nums;
    color: #f8fafc;
}

/* Users page and user card. */
.users-table td {
    vertical-align: top;
}

.users-table tr.row-inactive td {
    opacity: 0.65;
}

.user-name {
    font-weight: 600;
}

.user-identity {
    word-break: break-all;
}

.provider-badge {
    margin-left: 4px;
}

.filter-group.grow {
    flex: 1 1 320px;
}

.filter-group.grow input {
    min-width: 200px;
}

.user-panel {
    max-height: 90vh;
}

.user-panel h4 {
    font-size: 0.95rem;
    color: #f8fafc;
    margin-bottom: 10px;
}

.user-panel h5 {
    font-size: 0.85rem;
    color: #cbd5e1;
    margin: 12px 0 8px;
}

.user-panel .user-facts {
    margin-bottom: 12px;
}

.user-section {
    border-top: 1px solid #334155;
    padding-top: 14px;
    margin-top: 14px;
}

.loading-box.compact {
    padding: 16px;
}

.subscription-current {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.subscription-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.subscription-form .form-group {
    margin-bottom: 8px;
}

.subscription-form .form-group.grow {
    flex: 1 1 260px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.user-panel .confirm-box {
    flex-direction: column;
    align-items: flex-start;
    margin-top: 10px;
    background: #450a0a;
    border-color: #7f1d1d;
}

.role-options.inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    margin: 6px 0 10px;
}

.self-hint {
    color: #fcd34d;
}

/* ATM-083: deletion on request, apart from blocking. */
.user-section.user-danger {
    border-top: 1px solid #7f1d1d;
}

.user-danger h4 {
    color: #fca5a5;
}

.user-panel .delete-confirm .form-group {
    width: 100%;
    margin-bottom: 4px;
}

.delete-removes {
    margin: 0 0 4px 18px;
    padding: 0;
}

.delete-error {
    color: #fca5a5;
    margin: 0;
}

/* The operator's rule (CTO 25.10): the channel of the request proves the right to delete. */
.delete-rule {
    color: #fcd34d;
    margin: 0 0 4px;
}

/* Config form. */
.config-meta .kv-grid {
    margin-bottom: 10px;
}

.config-group {
    border: 1px solid #334155;
}

.config-group legend {
    padding: 0 6px;
    font-weight: 600;
    color: #f8fafc;
}

.config-grid {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) minmax(220px, 1.4fr) minmax(160px, 1fr);
    gap: 10px 16px;
    align-items: start;
}

.config-head {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #334155;
    padding-bottom: 4px;
}

.config-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.config-label label {
    color: #e2e8f0;
    font-size: 0.9rem;
}

.config-key {
    font-size: 0.72rem;
    color: #64748b;
}

.config-input {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.config-input .form-control {
    max-width: 180px;
}

.config-input .currency-input {
    max-width: 80px;
    text-transform: uppercase;
}

.config-input.has-error .form-control {
    border-color: #ef4444;
}

.number-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.null-toggle {
    font-size: 0.8rem;
    white-space: nowrap;
}

.config-extra {
    color: #7dd3fc;
}

.config-rule {
    font-size: 0.72rem;
}

.field-error {
    color: #fca5a5;
    font-size: 0.8rem;
}

.config-default {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.config-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
}

.changes-summary {
    margin-right: auto;
    font-size: 0.85rem;
}

.config-general-errors ul {
    margin-left: 18px;
}

@media (max-width: 900px) {
    .config-grid {
        grid-template-columns: 1fr;
    }

    .config-head {
        display: none;
    }
}

/* ---- ATM-027 r2: payments (orders, transactions, account by code), manual Pro in the user card ---- */
.billing-page > .card {
    margin-bottom: 16px;
}

.billing-page .card h4 {
    margin-bottom: 8px;
}

.back-link {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.account-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.code-input {
    max-width: 14rem;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.audit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
}

.audit-entry + .audit-entry {
    margin-top: 4px;
}

.pro-until {
    margin: 4px 0 8px;
    font-size: 0.9rem;
}

.pro-form .hint {
    margin: 0 0 8px;
}

.external-id {
    word-break: break-all;
}

/* ATM-059: asynchronous import 1.0 (status page /import/v1/{importId}) */
.import-status-card .run-summary {
    margin-bottom: 12px;
}

.import-progress {
    margin: 10px 0;
}

.import-progress-label {
    display: flex;
    gap: 6px;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.import-progress .progress-text {
    font-weight: 600;
}

.progress-track {
    height: 10px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #38bdf8;
    transition: width 0.4s ease;
}

.import-status-card[data-status="Applied"] .progress-fill {
    background: #34d399;
}

.import-status-card[data-status="Failed"] .progress-fill {
    background: #f87171;
}

.start-failure .server-detail,
.import-failed .error-code {
    display: block;
    margin-top: 6px;
    opacity: 0.85;
}

.start-failure .btn {
    margin: 8px 8px 0 0;
}

.import-failed .error-message {
    margin-top: 4px;
}
