/* Панель Bridge. Свёрстана под телефон, на широком экране просто становится шире. */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #16191d;
    --muted: #6b7280;
    --accent: #1d4ed8;
    --accent-soft: #e8eeff;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --ok: #1b7f3b;
    --warn-bg: #fff7e6;
    --warn-text: #7a5b00;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101215;
        --surface: #191c21;
        --border: #2a2f37;
        --text: #e7e9ee;
        --muted: #9aa2af;
        --accent: #6f96ff;
        --accent-soft: #1c2740;
        --danger: #ff8a80;
        --danger-soft: #351f1d;
        --ok: #6ddc93;
        --warn-bg: #2c2415;
        --warn-text: #e8c877;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
    padding-bottom: env(safe-area-inset-bottom);
}

button, input, textarea, select {
    font: inherit;
    color: inherit;
}

/* Экран входа */

.entry {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.entry form {
    width: 100%;
    max-width: 22rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.entry h1 {
    margin: 0 0 4px;
    font-size: 1.35rem;
}

.entry p.hint {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: .9rem;
}

label {
    display: block;
    margin: 14px 0 6px;
    font-size: .85rem;
    color: var(--muted);
}

input[type="text"], input[type="password"], textarea, select {
    width: 100%;
    padding: 11px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
}

textarea {
    min-height: 9rem;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    touch-action: manipulation;
}

.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    width: 100%;
    margin-top: 20px;
}

.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: .85rem; }

/* Каркас приложения */

header.top {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: calc(12px + env(safe-area-inset-top)) 16px 0;
}

.top-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.state {
    flex: 1;
    min-width: 0;
}

.state h1 {
    margin: 0;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--muted);
    flex: none;
}

.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }

.state p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: .82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

nav.tabs {
    display: flex;
    gap: 4px;
    margin-top: 10px;
    overflow-x: auto;
    scrollbar-width: none;
}

nav.tabs::-webkit-scrollbar { display: none; }

nav.tabs button {
    flex: none;
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

nav.tabs button[aria-selected="true"] {
    color: var(--text);
    border-bottom-color: var(--accent);
}

main {
    padding: 12px 16px 32px;
    max-width: 46rem;
    margin: 0 auto;
}

/* Карточки публикаций */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 10px;
}

.card-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.card-head time {
    color: var(--muted);
    font-size: .8rem;
}

.badge {
    margin-left: auto;
    font-size: .75rem;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    white-space: nowrap;
}

.badge.ok { background: transparent; color: var(--ok); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.mute { background: transparent; color: var(--muted); }

.card p.text {
    margin: 0;
    overflow-wrap: anywhere;
}

.card p.text.empty { color: var(--muted); }

.marks {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mark {
    font-size: .74rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 8px;
}

.card-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

/* Списки людей, устройств и журнала */

.row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.row .grow { flex: 1; min-width: 0; }
.row .grow strong { display: block; }
.row .grow span { color: var(--muted); font-size: .82rem; }

.section-title {
    margin: 20px 0 10px;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.empty-note {
    color: var(--muted);
    text-align: center;
    padding: 32px 16px;
}

/* Всплывающие сообщения и окна */

#toasts {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: grid;
    gap: 8px;
    z-index: 20;
    width: min(92vw, 26rem);
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 11px 14px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    font-size: .9rem;
}

.toast.bad { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

dialog {
    width: min(94vw, 30rem);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 20px;
}

dialog::backdrop { background: rgba(0, 0, 0, .45); }

dialog h2 {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.error {
    color: var(--danger);
    font-size: .88rem;
    margin-top: 12px;
}

.banner {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: .88rem;
    margin-bottom: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.banner button {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.link-box {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .82rem;
    overflow-wrap: anywhere;
}
