/* Веб-клиент почты. Оформление намеренно не совпадает с админкой:
   там синий акцент и таблицы, здесь — тёмная колонка папок и зелёный акцент,
   чтобы две панели не путались в соседних вкладках. */

:root {
  /* Интерфейс светлый; без этой строки браузер в тёмной теме системы
     перекрашивает поля ввода и полосы прокрутки по своему усмотрению. */
  color-scheme: light;

  --bg: #f2f4f6;
  --pane: #ffffff;
  --line: #e2e6ea;
  --line-soft: #eef1f4;
  --ink: #1a1d21;
  --ink-soft: #626b75;
  --ink-faint: #8b939c;
  --accent: #1f7a6f;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2f0;
  --danger: #b5322c;
  --side: #232a31;
  --side-ink: #cfd6dd;
  --side-ink-strong: #ffffff;
  --side-hover: #2e3740;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,22,28,.06), 0 6px 18px rgba(16,22,28,.08);
}

* { box-sizing: border-box; }
/* Атрибут hidden обязан побеждать любой display из правил ниже.
   Иначе невидимое модальное окно продолжает ловить клики по всему экрану. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- вход ---------- */
.login-page {
  display: grid; place-items: center; min-height: 100vh;
  background: linear-gradient(160deg, #eef1f4 0%, #e3e9ee 100%);
}
.login-card {
  width: min(370px, calc(100vw - 32px));
  background: var(--pane); border-radius: 14px; padding: 32px 30px 26px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.login-mark {
  width: 42px; height: 42px; border-radius: 11px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 600;
  margin-bottom: 10px;
}
.login-card h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
.login-sub { margin: 2px 0 18px; color: var(--ink-faint); font-size: 13px; }
.login-card label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--ink-soft); margin-bottom: 13px;
}
.login-card input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; font-size: 15px;
}
.login-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-card button {
  margin-top: 4px; padding: 11px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: #1a6a60; }
.login-error {
  background: #fdeceb; border: 1px solid #f3c9c6; color: #8c2620;
  padding: 9px 11px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px;
}
.login-note { margin: 14px 0 0; font-size: 12px; color: var(--ink-faint); text-align: center; }

/* ---------- каркас ---------- */
.shell {
  display: grid;
  grid-template-columns: 232px minmax(320px, 400px) 1fr;
  height: 100vh; overflow: hidden;
}
.pane { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.pane-folders { background: var(--side); color: var(--side-ink); }
.pane-list { background: var(--pane); border-right: 1px solid var(--line); }
.pane-read { background: var(--pane); }

/* ---------- папки ---------- */
.brand { display: flex; align-items: center; gap: 9px; padding: 14px 16px 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; flex: none;
}
.brand-user {
  font-size: 12.5px; color: var(--side-ink); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.btn-compose {
  margin: 4px 12px 12px; padding: 10px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.btn-compose:hover { background: #24897c; }
.folders { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.folder {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--side-ink); cursor: pointer; text-align: left; margin-bottom: 1px;
}
.folder:hover { background: var(--side-hover); color: var(--side-ink-strong); }
.folder.active { background: var(--accent); color: #fff; }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count {
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.14); padding: 1px 6px; border-radius: 9px; flex: none;
}
.folder.active .folder-count { background: rgba(255,255,255,.25); }
.folder-count.zero { display: none; }
.folder-del {
  opacity: 0; border: 0; background: none; color: inherit; cursor: pointer;
  padding: 0 2px; font-size: 15px; line-height: 1;
}
.folder:hover .folder-del { opacity: .55; }
.folder-del:hover { opacity: 1; }
.sidebar-foot {
  padding: 10px 16px 14px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; justify-content: space-between; align-items: center;
}
.logout-form { margin: 0; }
.link-btn {
  border: 0; background: none; color: var(--side-ink); cursor: pointer;
  font-size: 12.5px; padding: 2px 0; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,.25);
}
.link-btn:hover { color: #fff; }

/* ---------- список писем ---------- */
.list-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); flex: none;
}
.search-wrap { flex: 1; position: relative; display: flex; align-items: center; }
.search-wrap input {
  width: 100%; padding: 8px 30px 8px 11px; border: 1px solid var(--line);
  border-radius: 20px; background: #f7f9fa; font-size: 13px;
}
.search-wrap input:focus {
  outline: none; background: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#btn-search-clear { position: absolute; right: 4px; }
.icon-btn {
  border: 0; background: none; color: var(--ink-soft); cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px; font-size: 16px; line-height: 1;
  display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.list-tools {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; flex: none;
}
.chk { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-soft); }
.sel-count { font-size: 12.5px; color: var(--ink-faint); margin-right: auto; }
.tool-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 4px 9px; font-size: 12.5px; cursor: pointer; color: var(--ink-soft);
}
.tool-btn:hover { border-color: #c9d0d7; color: var(--ink); }
.tool-btn.danger { color: var(--danger); }
.tool-btn.danger:hover { background: #fdeceb; border-color: #f0c4c1; }
.msg-list { flex: 1; overflow-y: auto; }
.msg {
  display: grid; grid-template-columns: auto 1fr; gap: 9px;
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.msg:hover { background: #f7f9fa; }
.msg.active { background: var(--accent-soft); }
.msg.unseen .msg-from, .msg.unseen .msg-subject { font-weight: 650; color: var(--ink); }
.msg-check { padding-top: 2px; }
.msg-body { min-width: 0; }
.msg-top { display: flex; align-items: baseline; gap: 8px; }
.msg-from {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--ink-soft); font-size: 13px;
}
.msg-date { font-size: 11.5px; color: var(--ink-faint); flex: none; }
.msg-subject {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13.5px; color: var(--ink-soft); margin-top: 1px;
}
.msg-marks { display: flex; gap: 5px; align-items: center; font-size: 11.5px; color: var(--ink-faint); }
.dot-unseen {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  display: inline-block; flex: none;
}
.star { color: #d8a33a; }
.list-foot {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 9px; border-top: 1px solid var(--line); font-size: 12.5px;
  color: var(--ink-soft); flex: none;
}
.list-empty { padding: 40px 20px; text-align: center; color: var(--ink-faint); }

/* ---------- чтение ---------- */
.empty { flex: 1; display: grid; place-items: center; color: var(--ink-faint); }
.reader { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.reader-head { padding: 16px 22px 10px; border-bottom: 1px solid var(--line); flex: none; }
.reader-subject { margin: 0 0 8px; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.reader-meta { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.r-from { font-size: 13.5px; }
.r-from .nm { font-weight: 600; }
.r-from .em { color: var(--ink-faint); }
.r-date { font-size: 12.5px; color: var(--ink-faint); margin-left: auto; }
.reader-to { font-size: 12.5px; color: var(--ink-faint); margin-top: 3px; }
.reader-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.act {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 5px 10px; font-size: 12.5px; cursor: pointer; color: var(--ink-soft);
  text-decoration: none; display: inline-block;
}
.act:hover { border-color: #c9d0d7; color: var(--ink); }
.act.on { background: var(--accent-soft); border-color: #b9dcd6; color: #176057; }
.act.danger { color: var(--danger); }
.act.danger:hover { background: #fdeceb; border-color: #f0c4c1; }
.images-bar, .attach-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 22px; border-bottom: 1px solid var(--line); flex: none;
  font-size: 12.5px;
}
.images-bar { background: #fff8e8; color: #7a5b12; }
.attach {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 10px; background: #fff; color: var(--ink-soft);
  text-decoration: none;
}
.attach:hover { border-color: #c9d0d7; color: var(--ink); }
.attach .sz { color: var(--ink-faint); font-size: 11.5px; }
.body-frame { width: 100%; border: 0; padding: 6px 22px 30px; background: #fff; min-height: 240px; }

/* ---------- окна ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(20,26,32,.42);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal-card {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  width: min(720px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column;
}
.picker-card { width: min(360px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.compose-form { display: flex; flex-direction: column; min-height: 0; }
.field {
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
}
.field label { width: 62px; flex: none; font-size: 12.5px; color: var(--ink-faint); }
.field input { flex: 1; border: 0; padding: 10px 0; background: none; }
.field input:focus { outline: none; }
#c-body {
  flex: 1; min-height: 240px; border: 0; padding: 14px 16px; resize: vertical;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#c-body:focus { outline: none; }
.attach-list { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 8px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; background: #f2f5f7;
  border-radius: 14px; padding: 3px 6px 3px 11px; font-size: 12.5px; color: var(--ink-soft);
}
.attach-chip button { border: 0; background: none; cursor: pointer; color: var(--ink-faint); }
.compose-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 16px; border-top: 1px solid var(--line);
}
.btn-primary {
  border: 0; background: var(--accent); color: #fff; border-radius: var(--radius);
  padding: 8px 18px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: #1a6a60; }
.btn-primary:disabled { opacity: .55; cursor: default; }
.file-btn { cursor: pointer; }
.compose-from { margin-left: auto; font-size: 12px; color: var(--ink-faint); }
/* .link-btn рассчитана на тёмную колонку; на белом фоне ей нужен свой цвет */
.compose-foot .link-btn { color: var(--ink-soft); text-decoration-color: #c2cad2; }
.compose-foot .link-btn:hover { color: var(--ink); }
.picker-list { overflow-y: auto; padding: 6px; }
.picker-item {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: 8px 12px; border-radius: 6px; cursor: pointer;
}
.picker-item:hover { background: var(--line-soft); }

/* ---------- тосты ---------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; display: flex;
  flex-direction: column; gap: 8px; z-index: 80; max-width: min(380px, 90vw);
}
.toast {
  background: #232a31; color: #fff; padding: 10px 13px; border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 13px; cursor: pointer;
}
.toast.err { background: #8c2620; }

/* ---------- узкий экран ---------- */
.only-narrow { display: none; }
@media (max-width: 1080px) {
  .shell { grid-template-columns: 200px 1fr; }
  .pane-read { display: none; }
  .shell.reading .pane-list { display: none; }
  .shell.reading .pane-read { display: flex; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .pane-folders { display: none; }
  .shell.folders-open .pane-folders { display: flex; }
  .shell.folders-open .pane-list { display: none; }
  .only-narrow { display: grid; }
  .reader-head { padding: 12px 14px 10px; }
  .body-frame { padding: 6px 14px 30px; }
  .images-bar, .attach-bar { padding: 9px 14px; }
}
