:root {
    color-scheme: dark;
    --bg: #101416;
    --surface: #181e21;
    --surface-2: #20282c;
    --line: #334046;
    --text: #edf4f6;
    --muted: #9fb0b6;
    --accent: #22c7a9;
    --accent-dark: #118570;
    --blue: #4da3ff;
    --danger: #ff6b6b;
    --warning: #f3c969;
    --success: #54d68b;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}
a { color: var(--blue); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 58px;
    padding: 10px max(20px, calc((100vw - 1180px) / 2));
    background: #14191c;
    border-bottom: 1px solid var(--line);
}
.brand {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}
.nav a {
    padding: 7px 9px;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 60px;
}
.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}
.page-heading h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: 0; }
.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr);
    gap: 20px;
    align-items: start;
}
.panel {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.panel + .panel { margin-top: 18px; }
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.panel-header h2 { margin: 0; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}
.field { min-width: 0; }
.field-full { grid-column: 1 / -1; }
label, .field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
input, select, textarea {
    width: 100%;
    padding: 10px 11px;
    color: var(--text);
    background: #111719;
    border: 1px solid var(--line);
    border-radius: 5px;
    font: inherit;
}
textarea { min-height: 170px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(34, 199, 169, .25);
    border-color: var(--accent);
}
.help { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: var(--accent);
    color: #071411;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: #43d6bb; }
.button-secondary {
    background: var(--surface-2);
    border-color: var(--line);
    color: var(--text);
}
.button-danger { background: #7e2f35; color: #fff; }
.button-small { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.icon-button {
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 5px;
    font-size: 24px;
    cursor: pointer;
}
.check-list { display: grid; gap: 7px; max-height: 420px; overflow: auto; }
.check-item {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 9px;
    background: #13191b;
    border: 1px solid #293338;
    border-radius: 5px;
}
.check-item input { width: 16px; height: 16px; margin: 0; }
.check-item label { margin: 0; color: var(--text); font-weight: 400; }
.badge {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
}
.badge-success { color: var(--success); }
.badge-admin { color: var(--success); }
.badge-member { color: var(--warning); }
.badge-failed, .badge-danger { color: var(--danger); }
.badge-warning, .badge-partial, .badge-processing { color: var(--warning); }
.alert {
    margin-bottom: 16px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-left-width: 4px;
    background: var(--surface);
    border-radius: 4px;
}
.alert-success { border-left-color: var(--success); }
.alert-error { border-left-color: var(--danger); }
.alert-warning { border-left-color: var(--warning); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 13px; }
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.metric { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.metric strong { display: block; margin-top: 4px; font-size: 25px; }
.empty { padding: 26px; color: var(--muted); text-align: center; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, .68);
}
.modal[hidden] { display: none; }
.modal-dialog {
    width: min(560px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.modal-header, .modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-actions { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.telegram-preview { min-height: 220px; padding: 24px; background: #0e252d; }
.telegram-bubble {
    width: min(420px, 90%);
    padding: 11px 13px;
    color: #122018;
    background: #d7f7c5;
    border-radius: 6px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login-box { width: min(420px, 100%); }
.login-box h1 { margin-top: 0; }
.inline-form { display: inline; }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.toolbar .field { min-width: 150px; }

@media (max-width: 860px) {
    .topbar { align-items: flex-start; flex-direction: column; gap: 6px; }
    .nav { width: 100%; }
    .layout, .form-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    .page { width: min(100% - 20px, 1180px); padding-top: 18px; }
    .panel { padding: 14px; }
    .metric-grid { grid-template-columns: 1fr; }
    .button { width: 100%; }
    .inline-form .button, td .button { width: auto; }
}
