/* Панель владельца: мобильный экран — основной сценарий (Блок 6 плана).
   Кнопки от 44px, шрифт от 16px, никаких мелких целей под пальцем. */
:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #17202a;
    --muted: #6b7480;
    --line: #e3e6ea;
    --accent: #0d6e6e;
    --accent-ink: #ffffff;
    --alert: #b3261e;
    --human: #7a4f01;
    --human-bg: #fdefd0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    min-height: 52px;
}

.topbar nav { margin-left: auto; display: flex; gap: 4px; }

.topbar nav a, .topbar .back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
}

.topbar nav a[aria-current='page'] { background: var(--bg); font-weight: 600; }

.panel { max-width: 720px; margin: 0 auto; padding: 12px 12px 90px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
}

.muted { color: var(--muted); }

.alert {
    background: #fdecea;
    color: var(--alert);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

/* Список диалогов */
.dialog-list { list-style: none; margin: 0; padding: 0; }

.dialog-list a {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    color: inherit;
    min-height: 44px;
}

.dialog-list .row-top { display: flex; justify-content: space-between; gap: 8px; }
.dialog-list .name { font-weight: 600; }
.dialog-list .time { color: var(--muted); font-size: 14px; white-space: nowrap; }
.badges { display: inline-flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.badge {
    display: inline-block;
    font-size: 13px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
}

.badge.alert { background: #fdecea; color: var(--alert); font-weight: 600; }
.badge.human { background: var(--human-bg); color: var(--human); font-weight: 600; }

/* Переписка */
.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    background: var(--card);
    border: 1px solid var(--line);
}

.msg.in { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: #e5f2f2; border-bottom-right-radius: 4px; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg .meta { margin-top: 4px; font-size: 12px; color: var(--muted); }

.notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--human-bg);
    color: var(--human);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
}

/* Формы */
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }

input[type='text'], input[type='email'], input[type='password'],
input:not([type]), textarea, select {
    font: inherit;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    min-height: 44px;
    width: 100%;
}

textarea { resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    font: inherit;
    font-weight: 600;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
}

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.reply-form {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--line);
}

.reply-form textarea { flex: 1; min-height: 44px; max-height: 30vh; }
.reply-form .btn { align-self: flex-end; }

/* Вход */
.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.auth h1 { text-align: center; }

/* База знаний */
details.card summary {
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 600;
}

details.card form { margin-top: 12px; }

@media (min-width: 720px) {
    .reply-form { max-width: 720px; margin: 0 auto; border: 1px solid var(--line); border-radius: 14px 14px 0 0; }
}
