* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1f2733;
    --muted: #6b7683;
    --border: #dde3ea;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --green: #16a34a;
    --red: #dc2626;
    --gray: #6b7683;
    --radius: 10px;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

.error {
    color: var(--danger);
    background: #fdeaea;
    border: 1px solid #f5c2c2;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin: 10px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* --- Кнопки --- */
.btn {
    font: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 16px;
    cursor: pointer;
    background: var(--card);
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #eef2f7; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-danger {
    color: var(--danger);
    border-color: #f5c2c2;
}
.btn-danger:hover { background: #fdeaea; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* --- Экран входа --- */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(31, 39, 51, 0.06);
}
.login-card h1 { margin-bottom: 6px; }
.login-card p { margin-bottom: 20px; }
.login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.login-card input {
    font: inherit;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* --- Основной экран --- */
#main-screen {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}
.badge-green { background: var(--green); }
.badge-red { background: var(--red); }
.badge-gray { background: var(--gray); }

/* --- Счётчики --- */
.counters {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.counter-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 28px;
    min-width: 180px;
    flex: 1;
}
.counter-value {
    font-size: 34px;
    font-weight: 700;
    color: var(--primary);
}
.counter-label { color: var(--muted); }

/* --- Список групп --- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.groups-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.group-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.group-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.group-name { font-size: 17px; font-weight: 600; }
.group-actions { display: flex; gap: 8px; }
.group-vacancies {
    margin: 8px 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.vacancy-chip {
    background: #eef2f7;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 13px;
    font-family: Consolas, monospace;
}
.group-message {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--muted);
    max-height: 120px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}
.group-message.expanded { max-height: none; }
.group-message:not(.expanded)::after {
    content: "";
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 40px;
    background: linear-gradient(transparent, #f8fafc);
}

/* --- Модалка --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(31, 39, 51, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
}
.modal {
    background: var(--card);
    border-radius: var(--radius);
    padding: 26px;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { margin-bottom: 16px; }
.modal label {
    display: block;
    margin-bottom: 14px;
    font-weight: 600;
    font-size: 14px;
}
.modal input,
.modal textarea,
.modal select {
    font: inherit;
    font-weight: 400;
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.modal textarea {
    font-family: Consolas, monospace;
    font-size: 13px;
    resize: vertical;
}
.modal select { width: auto; margin-top: 0; padding: 4px 8px; }
.hint {
    display: block;
    font-weight: 400;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}
.presets {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 4px;
}
.presets .hint { margin: 0; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

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

.loading { opacity: 0.5; pointer-events: none; }
