/* ============================================================
   ШКОЛААНАЛИЗ — Design System
   Font: Inter (Google Fonts)
   Palette: Deep blue (#1a56db), clean white, soft grays
   ============================================================ */

/* ---- TOKENS ---- */
:root {
    --primary:       #1a56db;
    --primary-10:    #e8effe;
    --primary-hover: #1447bf;
    --danger:        #e02424;
    --danger-10:     #fde8e8;
    --success:       #057a55;
    --success-10:    #def7ec;
    --warning:       #c27803;
    --warning-10:    #fdf6b2;

    --bg:            #f4f6fb;
    --surface:       #ffffff;
    --surface-2:     #f9fafb;
    --border:        #e5e7eb;
    --border-strong: #d1d5db;

    --text:          #111827;
    --text-2:        #374151;
    --text-muted:    #6b7280;
    --text-disabled: #9ca3af;

    --sidebar-w:     240px;
    --topbar-h:      60px;
    --radius:        10px;
    --radius-sm:     6px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:     0 4px 12px rgba(0,0,0,.10);
    --shadow-lg:     0 16px 40px rgba(0,0,0,.14);
    --transition:    0.18s ease;
}

[data-theme="dark"] {
    --bg:            #0f1117;
    --surface:       #1a1d27;
    --surface-2:     #232635;
    --border:        #2e3244;
    --border-strong: #404562;
    --text:          #f3f4f6;
    --text-2:        #d1d5db;
    --text-muted:    #9ca3af;
    --text-disabled: #6b7280;
    --primary-10:    rgba(26,86,219,.18);
    --shadow-sm:     0 1px 3px rgba(0,0,0,.4);
    --shadow-md:     0 4px 12px rgba(0,0,0,.5);
    --shadow-lg:     0 16px 40px rgba(0,0,0,.6);
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; height: 100%; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100%;
    transition: background var(--transition), color var(--transition);
}
#app { min-height: 100%; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
p { color: var(--text-2); }


/* ============================
   LOGIN
   ============================ */
#login-container {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 2rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}

.login-logo {
    flex-shrink: 0;
    line-height: 0;
}

.login-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.login-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.72rem;
    color: var(--text-disabled);
    text-align: center;
    line-height: 1.5;
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    min-height: 1.2em;
}

/* ============================
   FORMS
   ============================ */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 1rem;
}
.field-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 9px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
    background: var(--surface);
}
input::placeholder { color: var(--text-disabled); }

input[type="radio"],
input[type="checkbox"] { width: auto; accent-color: var(--primary); }
input[type="file"] { width: auto; font-size: 0.9rem; color: var(--text-muted); }

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

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* File upload custom style */
.file-upload-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.file-upload-label input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}
.file-upload-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.file-upload-label:hover .file-upload-btn { background: var(--border); border-color: var(--border-strong); }
.file-upload-name {
    font-size: 0.88rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ============================
   BUTTONS
   ============================ */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost,
.btn-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--danger-10);
    color: var(--danger);
    border: 1px solid transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-disabled {
    background: var(--surface-2);
    color: var(--text-disabled);
    border: 1px dashed var(--border);
    cursor: default;
    pointer-events: none;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.w-auto { width: auto; }
.flex { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }


/* ============================
   TOP BAR
   ============================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    gap: 1rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
    color: var(--text);
    flex-shrink: 0;
}

.topbar-title { color: var(--text); font-size: 1rem; font-weight: 700; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-2);
}

.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }


/* ============================
   WORKSPACE LAYOUT
   ============================ */
#dashboard { display: none; flex-direction: column; min-height: 100vh; }

.workspace {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--topbar-h));
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-disabled);
    padding: 0.75rem 0.75rem 0.35rem;
    margin-top: 0.5rem;
}

#nav-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#nav-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition), color var(--transition);
}
#nav-menu button:hover {
    background: var(--surface-2);
    color: var(--text);
}
#nav-menu button.active {
    background: var(--primary-10);
    color: var(--primary);
    font-weight: 600;
}


/* ============================
   CONTENT AREA
   ============================ */
.content-area {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
}

.page-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 1.25rem;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-2);
}


/* ============================
   CARD
   ============================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}


/* ============================
   TABLES
   ============================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); margin-top: 1rem; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead tr {
    background: var(--surface-2);
}

th {
    padding: 11px 14px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 11px 14px;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background var(--transition);
}
tbody tr:hover { background: var(--surface-2); }


/* ============================
   BADGES / STATUS
   ============================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-blue    { background: var(--primary-10); color: var(--primary); }
.badge-green   { background: var(--success-10); color: var(--success); }
.badge-yellow  { background: var(--warning-10); color: var(--warning); }
.badge-gray    { background: var(--surface-2);  color: var(--text-muted); border: 1px solid var(--border); }
.badge-red     { background: var(--danger-10);  color: var(--danger); }


/* ============================
   DIAGNOSTIC / QUESTION CARDS
   ============================ */
.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    transition: border-color var(--transition);
}
.question-card:hover { border-color: var(--border-strong); }
.question-card.error { border-color: var(--danger); background: var(--danger-10); }

.question-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.opt-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-2);
    font-size: 0.92rem;
    transition: background var(--transition);
    margin-top: 4px;
}
.opt-label:hover { background: var(--primary-10); color: var(--primary); }
.opt-label input[type="radio"] { width: 16px; height: 16px; flex-shrink: 0; }

.block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2rem 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--primary-10);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary);
}
.block-header h3 {
    color: var(--primary);
    margin: 0;
    font-size: 1rem;
}

.sub-block-header {
    margin: 1.25rem 0 0.75rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--border-strong);
}
.sub-block-header h4 {
    color: var(--text-2);
    font-size: 0.9rem;
}


/* ============================
   RESULT VIEW
   ============================ */
.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.result-meta-item { display: flex; flex-direction: column; gap: 2px; }
.result-meta-item .label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.result-meta-item .value { font-size: 0.92rem; font-weight: 600; color: var(--text); }

.answer-row {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.answer-row:last-child { border-bottom: none; }

.answer-question { font-size: 0.88rem; font-weight: 600; color: var(--text-2); }
.answer-value    { font-size: 0.92rem; color: var(--text); }
.answer-score    { display: inline-flex; align-items: center; padding: 1px 8px; background: var(--primary-10); color: var(--primary); border-radius: 4px; font-size: 0.78rem; font-weight: 600; margin-left: 6px; }

.expert-comment {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--surface-2);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.88rem;
    color: var(--text-2);
}
.expert-comment em { color: var(--text-muted); font-style: normal; font-weight: 600; }


/* ============================
   MODALS
   ============================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 1rem;
}

.modal {
    background: var(--surface);
    width: 100%;
    max-width: 520px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-in 0.18s ease;
}

@keyframes modal-in {
    from { transform: scale(0.95) translateY(-10px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
    padding: 1.5rem;
}


/* ============================
   QUILL EDITOR OVERRIDES
   ============================ */
.ql-toolbar.ql-snow {
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--surface-2);
}
.ql-container.ql-snow {
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    min-height: 300px;
    background: var(--surface);
    color: var(--text);
}
.ql-editor { min-height: 300px; }


/* ============================
   UTILITIES
   ============================ */
.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: 0.5rem; }
.mb-2  { margin-bottom: 1rem; }
.text-muted   { color: var(--text-muted); font-size: 0.88rem; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.info-tile {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
}
.info-tile .tile-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 2px; }
.info-tile .tile-value { font-size: 1rem; font-weight: 600; color: var(--text); }

.action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.25rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    gap: 0.5rem;
}

/* ============================
   TABLE SORT & FILTER
   ============================ */
.th-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.th-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.th-label:hover { color: var(--text); }
.sort-icon { opacity: 0.35; transition: opacity var(--transition), transform var(--transition); }
.sort-icon.asc  { opacity: 1; transform: rotate(0deg); }
.sort-icon.desc { opacity: 1; transform: rotate(180deg); }

/* Table filter select: same look as text inputs, no white box */
.th-filter[type="text"],
.th-filter {
    width: 100%;
    padding: 4px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    transition: border-color var(--transition);
    margin-bottom: 0;
    -webkit-appearance: none;
    appearance: none;
}
select.th-filter {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}
.th-filter:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,86,219,.1); }

/* ============================
   CARD TITLE
   ============================ */
.card-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0;
}

/* ============================
   SCHOOL CARD — USER ROWS
   ============================ */
.sc-users-list { display: flex; flex-direction: column; }
.sc-user-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.sc-user-row:last-child { border-bottom: none; }
.sc-user-row:hover { background: var(--surface-2); }
.sc-col { display: flex; align-items: center; }
.sc-col-grow { flex: 1; flex-direction: column; align-items: flex-start; gap: 1px; }
.sc-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light, #dbeafe);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}
.sc-user-name { font-size: 0.92rem; font-weight: 600; color: var(--text); }
.sc-user-login { font-size: 0.8rem; color: var(--text-muted); }
