/* Почтовый шлюз UMOS — стили веб-панели */
:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --ink: #16212e;
    --ink-soft: #55677c;
    --line: #dfe6ec;
    --accent: #0e6e58;
    --accent-strong: #0a5847;
    --danger: #b3382e;
    --danger-soft: #fbeeec;
    --ok: #1d7a4f;
    --ok-soft: #e9f6ef;
    --warn: #97650d;
    --warn-soft: #fdf3e0;
    --info: #1f5fa8;
    --info-soft: #eaf2fb;
    --violet: #6c4fc4;
    --violet-soft: #f1edfb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(22, 33, 46, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Шапка ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    padding-top: env(safe-area-inset-top);
}
.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 58px;
    flex-wrap: wrap;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand svg { color: var(--accent); }
.mainnav { display: flex; gap: 4px; }
.mainnav a {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 15px;
}
.mainnav a:hover { background: var(--bg); text-decoration: none; }
.mainnav a.active { color: var(--accent); font-weight: 600; background: var(--ok-soft); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user { color: var(--ink-soft); font-size: 14px; }

/* ---------- Каркас ---------- */
.page-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
    min-width: 0;
}

/* ---------- Карточки сводки ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.card-num { font-size: 28px; font-weight: 700; line-height: 1.1; }
.card-label { color: var(--ink-soft); font-size: 13px; }
.card-alert .card-num { color: var(--danger); }
.card-wide { grid-column: span 2; min-width: 260px; }
.rate-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.rate-row > span { width: 62px; color: var(--ink-soft); }
.rate-row b { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.rate-bar {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 99px;
    overflow: hidden;
}
.rate-bar > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease-out; }

/* ---------- Панели ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
    min-width: 0;
    overflow: hidden;
}
.panel h1 { font-size: 20px; margin: 0 0 6px; }
.panel h2 { font-size: 16px; margin: 0 0 10px; }
.panel-sub { color: var(--ink-soft); margin: 0 0 16px; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 9px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease-out, border-color .15s ease-out, transform .1s ease-out;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9c2f26; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 13px; background: var(--ok-soft); color: var(--accent); }
.btn-small:hover { background: #d8efe3; }
.btn-block { width: 100%; }

/* ---------- Фильтры ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.filters input[type="search"] { flex: 1 1 220px; }
.filters select { flex: 0 1 auto; }
input, select, textarea {
    font: inherit;
    font-size: 15px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px 12px;
    min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(14, 110, 88, .15); }

/* ---------- Таблица ---------- */
.table-wrap { overflow-x: auto; }
.queue-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.queue-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    padding: 8px 10px;
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}
.queue-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.queue-table tr:hover td { background: #f8fafb; }
.cell-email { font-weight: 600; }
.cell-subject { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.cell-time { white-space: nowrap; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--ink-soft); padding: 28px 10px !important; }
.hint { color: var(--warn); margin-left: 4px; }

/* ---------- Бейджи ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.b-queued   { background: var(--warn-soft); color: var(--warn); }
.b-sending  { background: var(--info-soft); color: var(--info); }
.b-sent     { background: var(--ok-soft); color: var(--ok); }
.b-failed   { background: var(--danger-soft); color: var(--danger); }
.b-now      { background: var(--danger-soft); color: var(--danger); }
.b-notnow   { background: var(--bg); color: var(--ink-soft); }
.b-yandex   { background: var(--violet-soft); color: var(--violet); }
.b-selectel { background: var(--info-soft); color: var(--info); }

/* ---------- Пагинация ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pg {
    min-width: 40px; min-height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--line);
    color: var(--ink); font-size: 14px;
}
.pg:hover { background: var(--bg); text-decoration: none; }
.pg.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* ---------- Детальная ---------- */
.crumbs { margin-bottom: 12px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-head h1 { margin: 0; }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px 24px;
    margin: 0 0 16px;
}
.meta-grid dt { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.meta-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.body-preview {
    width: 100%;
    min-height: 320px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
}
.body-text {
    margin: 0;
    padding: 14px;
    background: var(--bg);
    border-radius: 9px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 14px;
}

/* ---------- Алерты ---------- */
.alert { padding: 12px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 15px; overflow-wrap: anywhere; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0d2cf; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #cdeadb; }

/* ---------- Формы ---------- */
.send-form { display: flex; flex-direction: column; gap: 6px; max-width: 560px; }
.send-form label { font-weight: 600; font-size: 14px; margin-top: 10px; }
.send-form .btn { margin-top: 18px; }
.prio-field { border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.prio-field legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.radio { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 400; }
.radio input { min-height: auto; width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Авторизация ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.auth-logo { color: var(--accent); margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; margin: 0 0 4px; }
.auth-sub { color: var(--ink-soft); margin: 0 0 22px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.auth-form label { font-weight: 600; font-size: 14px; }
.auth-form .btn { margin-top: 16px; }

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 760px) {
    .topbar-inner { gap: 10px; min-height: 52px; }
    .brand span { display: none; }
    .topbar-right { gap: 8px; }
    .page-wrap { padding-top: 16px; }
    .cards { grid-template-columns: 1fr 1fr; }
    .card-wide { grid-column: span 2; }

    /* Таблица → карточки */
    .queue-table thead { display: none; }
    .queue-table, .queue-table tbody, .queue-table tr, .queue-table td { display: block; width: 100%; }
    .queue-table tr {
        border: 1px solid var(--line);
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 8px 4px;
    }
    .queue-table td { border: none; padding: 6px 12px; display: flex; align-items: center; gap: 10px; }
    .queue-table td::before {
        content: attr(data-th);
        flex: 0 0 96px;
        font-size: 12px;
        color: var(--ink-soft);
        text-transform: uppercase;
        letter-spacing: .03em;
    }
    .queue-table td:empty::before { content: none; }
    .cell-subject { max-width: none; white-space: normal; }
    .cell-actions::before { content: none; }
    .cell-actions .btn { width: 100%; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
