* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f6f8;
    color: #222;
    line-height: 1.5;
}

.site-header {
    background: #fff;
    border-bottom: 1px solid #e1e4e8;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo { font-weight: 600; text-decoration: none; color: #222; }
.site-header nav { display: flex; align-items: center; gap: 16px; }
.user-email { color: #555; font-size: 14px; }

.container {
    max-width: 920px;
    margin: 32px auto;
    padding: 0 16px;
}

.card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.card.narrow { max-width: 420px; margin: 80px auto; }

h1 { margin-top: 0; }
h2 { margin-top: 0; font-size: 18px; }

label { display: block; margin: 12px 0; font-size: 14px; color: #444; }
input[type=email], input[type=password], input[type=text], select {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid #cfd4da;
    border-radius: 6px;
    font-size: 15px;
    background: #fff;
}
input:focus { outline: 2px solid #2f7df0; outline-offset: -2px; }

button.primary {
    background: #2f7df0;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
}
button.primary:hover { background: #2466c8; }
button.primary:disabled { background: #9bb6e0; cursor: not-allowed; }

.primary-link {
    display: inline-block;
    background: #2f7df0;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 15px;
    text-decoration: none;
}
.primary-link:hover { background: #2466c8; }

.link-button {
    background: none; border: none; color: #2f7df0; cursor: pointer;
    font-size: 14px; padding: 0;
}
.link-button:hover { text-decoration: underline; }
form.inline { display: inline; }

.error {
    background: #fde8e8;
    color: #9a1f1f;
    padding: 10px 14px;
    border-radius: 6px;
    margin: 8px 0 16px;
    font-size: 14px;
}
.muted { color: #777; font-size: 14px; }
.muted a { color: #2f7df0; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}
.tag-ok { background: #e0f5e9; color: #1f7a3f; }
.tag-warn { background: #fff4cc; color: #7a5a00; }
.tag-err { background: #fde8e8; color: #9a1f1f; cursor: help; }

.connect-block {
    border-top: 1px solid #eee;
    padding-top: 12px;
    margin-top: 12px;
}
.connect-block h3 { font-size: 15px; margin: 0 0 8px; color: #333; }

.webhook-url {
    background: #f5f6f8;
    border: 1px solid #e1e4e8;
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.webhook-url code { flex: 1; word-break: break-all; font-size: 13px; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee; font-size: 14px; }

textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid #cfd4da;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    resize: vertical;
}
textarea:focus { outline: 2px solid #2f7df0; outline-offset: -2px; }

/* Навигационные вкладки */
.nav-tab {
    text-decoration: none;
    color: #555;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 6px;
}
.nav-tab:hover { background: #f0f2f5; }
.nav-tab.active { color: #2f7df0; font-weight: 600; background: #eaf2fe; }

/* Единый список элементов (аккаунты, маппинги) */
.item-list { list-style: none; margin: 8px 0 0; padding: 0; }
.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    background: #fff;
}
.item + .item { margin-top: 8px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 14px; color: #222; word-break: break-word; }
.item-sub { font-size: 12px; color: #888; margin-top: 2px; word-break: break-all; }
.item-sub code { font-size: 12px; }
.item-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.item-toggle { display: flex; align-items: center; }
.link-button.danger { color: #c0392b; }

/* Inline-форма редактирования внутри строки списка */
.inline-form { margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.inline-form input { width: auto; flex: 1; margin-top: 0; }

/* Кнопка-«створка» «+ Добавить» */
.add-toggle { margin-top: 14px; }
.add-toggle > summary {
    display: inline-block;
    cursor: pointer;
    list-style: none;
    background: #2f7df0;
    color: #fff;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 14px;
}
.add-toggle > summary::-webkit-details-marker { display: none; }
.add-toggle > summary:hover { background: #2466c8; }
.add-toggle[open] > summary { background: #2466c8; }
.add-form { margin-top: 12px; }
.add-link {
    display: inline-block;
    background: #2f7df0;
    color: #fff;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
}
.add-link:hover { background: #2466c8; }

/* Переключатель вкл/выкл */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0;
    background: #c4c9d0; border-radius: 22px; transition: .2s;
}
.slider::before {
    content: ""; position: absolute; height: 16px; width: 16px;
    left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: #2fa860; }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Индикаторы статуса системы */
.health-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.health-item {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 12px; border-radius: 20px; font-size: 13px;
    border: 1px solid #e1e4e8; background: #f7f8fa; cursor: help;
}
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; }
.health-ok .health-dot { background: #2fa860; }
.health-fail .health-dot { background: #e04545; }
.health-fail { background: #fdeeee; border-color: #f4caca; }

/* Степпер этапов обработки */
.stepper { display: flex; flex-wrap: wrap; gap: 4px; }
.step {
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    background: #eef0f3; color: #999; border: 1px solid #e1e4e8;
}
.step.done { background: #e0f5e9; color: #1f7a3f; border-color: #bce6cd; }
.step.active { background: #fff4cc; color: #7a5a00; border-color: #f0e0a0; font-weight: 600; }
