/* HomeBack Mail Console — one stylesheet, light theme, HomeBack brand tokens. */
@font-face {
  font-family: "Manrope"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("/static/fonts/manrope-latin-wght.woff2") format("woff2");
}

:root {
  --navy: #0B1F3A; --navy-2: #13294A; --navy-3: #1D3760; --navy-line: rgba(255,255,255,.08);
  --blue: #5A86D6; --blue-600: #3A68BF; --blue-700: #2D56A3; --blue-50: #EEF3FC; --blue-100: #DCE6F8;
  --green: #3FBF7F; --green-700: #1D7A4D; --green-50: #E9F7F0;
  --amber-700: #8A5A00; --amber-50: #FDF4E3;
  --red: #C23A30; --red-700: #A12D24; --red-50: #FCEDEC;
  --bg: #F3F5F9; --surface: #FFFFFF; --line: #E1E6EE; --line-strong: #CBD3DF;
  --text: #0E1A2B; --text-2: #3B4A60; --muted: #5E6B7F;
  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(11,31,58,.06);
  --shadow: 0 1px 2px rgba(11,31,58,.05), 0 6px 20px rgba(11,31,58,.06);
  --shadow-lg: 0 24px 60px rgba(11,31,58,.28);
  --focus: 0 0 0 3px rgba(90,134,214,.45);
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 500 15px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 750; line-height: 1.25; }
h2 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

.skip { position: absolute; left: 12px; top: -48px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip:focus { top: 12px; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 650 .92rem/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn:hover { text-decoration: none; background: #F7F9FC; border-color: #B9C3D2; }
.btn-primary { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn-primary:hover { background: #244A8F; border-color: #244A8F; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-700); border-color: var(--red-700); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .75; cursor: progress; }
.btn.is-loading .icon { display: none; }
.btn.is-loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--blue-50); color: var(--blue-700); text-decoration: none; }
.icon-btn.danger { color: var(--red); } .icon-btn.danger:hover { background: var(--red-50); color: var(--red-700); }
.icon-btn.on-dark { color: #C9D4E6; } .icon-btn.on-dark:hover { background: var(--navy-3); color: #fff; }
.link { font-weight: 650; font-size: .88rem; }

/* ---------------------------------------------------------------- forms */
.field { display: block; margin: 0 0 16px; }
.field > span, .field-label { display: block; margin-bottom: 6px; font-weight: 650; font-size: .88rem; color: var(--text-2); }
input, textarea, select { width: 100%; font: 500 .95rem/1.4 var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; transition: border-color .15s, box-shadow .15s; }
input:hover, textarea:hover { border-color: #AEB9C9; }
input:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
textarea { resize: vertical; min-height: 200px; }
input[type=file] { padding: 8px; background: #FAFBFD; border-style: dashed; }
input[type=file]::file-selector-button { font: 650 .85rem var(--font); margin-right: 12px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; flex: 1 1 240px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 600; font-size: .92rem; }
.alert .icon { margin-top: 2px; }
.alert-error { background: var(--red-50); color: var(--red-700); border: 1px solid #F3C9C5; }
.alert-ok { background: var(--green-50); color: var(--green-700); border: 1px solid #BFE8D2; }

/* ---------------------------------------------------------------- sign-in */
body.auth { min-height: 100vh; background: var(--navy); background-image:
  radial-gradient(1200px 600px at 50% -10%, #1A3563 0%, rgba(26,53,99,0) 60%); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-logo { width: 176px; height: auto; margin-bottom: 28px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-card > .muted { margin-bottom: 22px; }
.auth-card .btn-block { margin-top: 8px; min-height: 44px; }
.auth-alt { display: block; text-align: center; margin-top: 16px; font-size: .88rem; font-weight: 600; }
.auth-foot { margin-top: 24px; color: #9FB0C9; font-size: .82rem; text-align: center; }
.code-input { font: 700 1.4rem/1 var(--mono); letter-spacing: .4em; text-align: center; }

/* ---------------------------------------------------------------- app shell */
body.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--navy); color: #DDE5F2; padding: 20px 14px; }
.brand { display: flex; flex-direction: column; gap: 6px; padding: 4px 10px 22px; border-bottom: 1px solid var(--navy-line); margin-bottom: 14px; }
.brand:hover { text-decoration: none; }
.brand img { width: 132px; height: auto; }
.brand-sub { color: #93A6C4; font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: #C3CFE2; font-weight: 600; font-size: .93rem; }
.nav-item:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--navy-3); color: #fff; }
.nav-item.is-active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--green); }
.nav-item.is-active .icon { color: var(--blue); }
.account { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--navy-line); }
.account-name { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; font-weight: 700; color: #fff; }
.account-name small { color: #93A6C4; font-weight: 600; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 750; font-size: .9rem; flex: none; }
.avatar-sm { width: 32px; height: 32px; font-size: .82rem; background: var(--blue-100); color: var(--blue-700); }

.content { min-width: 0; padding: 28px 36px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 auto 24px; max-width: 1200px; }
.subtitle { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: .86rem; margin-bottom: 8px; color: var(--muted); }
main { max-width: 1200px; margin: 0 auto; outline: none; }

/* progress bar shown while the next page loads */
.progress { position: fixed; left: 0; top: 0; height: 3px; width: 0; background: var(--green); z-index: 60; opacity: 0; transition: width .3s ease, opacity .2s; }
body.is-busy .progress { opacity: 1; width: 80%; transition: width 6s cubic-bezier(.1,.7,.2,1), opacity .1s; }

/* ---------------------------------------------------------------- surfaces */
.card, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card { padding: 22px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.narrow { max-width: 560px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > .card { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "icon label" "value value" "note note"; align-items: center; column-gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
a.stat:hover { text-decoration: none; border-color: var(--blue-100); box-shadow: var(--shadow); }
.stat-icon { grid-area: icon; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--blue-50); color: var(--blue-700); }
.stat-label { grid-area: label; font-weight: 650; color: var(--text-2); font-size: .88rem; }
.stat-value { grid-area: value; display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 1.75rem; font-weight: 780; letter-spacing: -.02em; }
.stat-note { grid-area: note; color: var(--muted); font-size: .84rem; }
.tone-ok .stat-icon { background: var(--green-50); color: var(--green-700); }
.tone-warn .stat-icon { background: var(--amber-50); color: var(--amber-700); }
.tone-bad .stat-icon { background: var(--red-50); color: var(--red); }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-ok { background: var(--green); box-shadow: 0 0 0 4px rgba(63,191,127,.18); }
.dot-bad { background: var(--red); box-shadow: 0 0 0 4px rgba(194,58,48,.15); }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.activity li:last-child { border-bottom: 0; }
.activity-who { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .activity-when { margin-left: auto; font-size: .82rem; white-space: nowrap; }

/* ---------------------------------------------------------------- tables */
.table-card { margin-bottom: 20px; }
.table thead th:first-child { border-top-left-radius: var(--radius); } .table thead th:last-child { border-top-right-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; padding: 12px 18px; background: #F8FAFC; color: var(--muted); font-size: .76rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFD; }
.table th.right, .table td.right { text-align: right; }
.identity { display: flex; align-items: center; gap: 12px; color: var(--text); }
.identity:hover { text-decoration: none; } .identity:hover strong { color: var(--blue-700); }
.identity-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; word-break: break-all; }
.row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
.row-actions form { display: inline; margin: 0; }
.details { max-width: 420px; }
.kv { display: inline-block; margin: 0 12px 2px 0; font-size: .82rem; word-break: break-all; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--blue-50); color: var(--blue-700); font-size: .74rem; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--green-50); color: var(--green-700); }
.badge-warn { background: var(--amber-50); color: var(--amber-700); }
.badge-bad { background: var(--red-50); color: var(--red-700); }
.chip { display: inline-block; padding: 2px 8px; margin: 2px 0; border-radius: 6px; background: #F1F4F8; border: 1px solid var(--line); font-size: .8rem; font-weight: 600; }

.empty { text-align: center; padding: 36px 16px; }
.empty-icon { width: 40px; height: 40px; color: var(--blue); padding: 8px; border-radius: 12px; background: var(--blue-50); box-sizing: content-box; }
.empty-title { font-weight: 750; font-size: 1.02rem; margin: 14px 0 4px; }

/* ---------------------------------------------------------------- mail */
.mail-layout > * { min-width: 0; }
.mail-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.folders { padding: 10px; margin: 0; }
.folders ul { list-style: none; margin: 0; padding: 0; }
.folder { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; font-size: .92rem; }
.folder:hover { background: #F4F7FB; text-decoration: none; }
.folder.is-active { background: var(--blue-50); color: var(--blue-700); }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.count { font-size: .76rem; color: var(--muted); font-weight: 700; }
.count-strong { background: var(--blue-700); color: #fff; padding: 1px 7px; border-radius: 999px; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); color: var(--text); }
.msg-list li:last-child .msg { border-bottom: 0; }
.msg:hover { background: #FAFBFD; text-decoration: none; }
.msg-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg-from { font-size: .86rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-date { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.msg.is-unseen .msg-subject, .msg.is-unseen .msg-from { font-weight: 780; color: var(--text); }
.msg.is-unseen::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-left: -12px; margin-right: -4px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); }

.message .meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.meta-row { display: contents; } .meta dt { color: var(--muted); font-weight: 650; font-size: .88rem; } .meta dd { margin: 0; word-break: break-word; }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.attachment { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #FAFBFD; color: var(--text); font-size: .88rem; font-weight: 600; }
.attachment:hover { border-color: var(--blue); text-decoration: none; }
.attachment-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-html { width: 100%; min-height: 60vh; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.mail-text { white-space: pre-wrap; word-break: break-word; font: 500 .92rem/1.6 var(--font); margin: 0; }
.plain { margin-top: 14px; } .plain summary { cursor: pointer; font-weight: 650; color: var(--text-2); }
.compose { max-width: 820px; }
.compose-from { padding: 10px 14px; margin-bottom: 18px; background: #F6F8FB; border-radius: var(--radius-sm); font-size: .9rem; }

.secret-box { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 14px; margin-bottom: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: #F8FAFC; }
.secret-box code { font-size: 1.05rem; font-weight: 700; word-break: break-all; user-select: all; }
.danger-card { border-color: #F0C7C3; }
.error-card { text-align: center; } .error-card .form-actions { justify-content: center; }
.error-icon .icon { width: 36px; height: 36px; color: var(--red); margin-bottom: 8px; }

.log-card { padding: 0; overflow: hidden; }
.search-field { position: relative; margin: 0; padding: 14px; border-bottom: 1px solid var(--line); }
.search-field .icon { position: absolute; left: 26px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-field input { padding-left: 40px; }
.log { list-style: none; margin: 0; padding: 12px 0; max-height: 70vh; overflow: auto; background: #0D1B30; color: #C9D4E6; font: 500 .8rem/1.6 var(--mono); counter-reset: line; }
.log li { padding: 1px 16px; white-space: pre-wrap; word-break: break-all; }
.log li:hover { background: #142745; }
.log li.log-ok { color: #8FE0B6; } .log li.log-bad { color: #FFB4AC; }
.log li[hidden] { display: none; }

/* ---------------------------------------------------------------- toasts, dialog, skeleton */
.toasts { position: fixed; right: 20px; top: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); border-left: 4px solid var(--green); animation: toast-in .25s ease-out; font-weight: 600; font-size: .92rem; }
.toast p { margin: 0; flex: 1; word-break: break-word; }
.toast-ok .toast-icon { color: var(--green-700); }
.toast-error { border-left-color: var(--red); } .toast-error .toast-icon { color: var(--red); }
.toast-icon { margin-top: 1px; }
.toast-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }

dialog.confirm { border: 0; border-radius: 16px; padding: 28px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--text); }
dialog.confirm::backdrop { background: rgba(11,31,58,.55); }
.confirm-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--red-50); color: var(--red); margin-bottom: 14px; }
.confirm h2 { font-size: 1.15rem; margin-bottom: 8px; }
.confirm-text { color: var(--text-2); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.skeleton { display: grid; gap: 14px; }
.sk { border-radius: var(--radius-sm); background: linear-gradient(90deg, #E7EBF1 0%, #F2F4F8 50%, #E7EBF1 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-row { height: 56px; } .sk-head { height: 22px; width: 32%; } .sk-card { height: 110px; }
.sk-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------------------------------------------------------------- round 2: controls */
.js-only { display: none !important; }
.js .js-only { display: inline-grid !important; }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; font: 600 .74rem/1.3 var(--font); padding: 6px 9px; border-radius: 6px;
  white-space: nowrap; z-index: 70; pointer-events: none; box-shadow: var(--shadow); }
[data-tip]:hover::before, [data-tip]:focus-visible::before {
  content: ""; position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--navy); border-bottom: 0; z-index: 70; pointer-events: none; }
[data-tip].tip-left:hover::after, [data-tip].tip-left:focus-visible::after { left: auto; right: 0; transform: none; }
.on-dark[data-tip]:hover::after, .on-dark[data-tip]:focus-visible::after { background: #fff; color: var(--navy); }
.on-dark[data-tip]:hover::before, .on-dark[data-tip]:focus-visible::before { border-top-color: #fff; }

.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; }
.pw-toggle .when-shown { display: none; }
.pw-toggle[aria-pressed="true"] .when-shown { display: block; }
.pw-toggle[aria-pressed="true"] .when-hidden { display: none; }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 4px; font-weight: 650; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue-700); }
.hint { display: block; color: var(--muted); font-size: .8rem; margin: 2px 0 14px; }
.req { color: var(--red); } .optional { color: var(--muted); font-weight: 500; }
.field-error { display: none; color: var(--red-700); font-size: .8rem; font-weight: 600; margin-top: 5px; }
input.touched:invalid, input:user-invalid, textarea.touched:invalid { border-color: var(--red); }
input.touched:invalid ~ .field-error, input:user-invalid ~ .field-error { display: block; }

.lang-switch { display: flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 650; }
.lang-switch .icon { width: 16px; height: 16px; margin-right: 4px; }
.lang-switch a { padding: 4px 8px; border-radius: 6px; color: var(--text-2); }
.lang-switch a.is-active { background: var(--blue-50); color: var(--blue-700); }
.lang-switch.on-dark { color: #93A6C4; } .lang-switch.on-dark a { color: #C3CFE2; }
.lang-switch.on-dark a:hover { background: var(--navy-2); text-decoration: none; }
.lang-switch.on-dark a.is-active { background: var(--navy-3); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.sidebar-foot .lang-switch { padding: 0 8px; }
.sidebar-foot .account { margin-top: 0; }
.auth-lang { margin-top: 12px; justify-content: center; }

/* avatars */
.avatar-brand { background: var(--navy); padding: 0; overflow: hidden; }
.avatar-brand img { width: 100%; height: 100%; display: block; }
.avatar-lg { width: 44px; height: 44px; font-size: 1.05rem; }

/* dashboard */
.stat { grid-template-areas: "icon label" "value value" "note note" "spark spark"; }
.stat .spark { grid-area: spark; margin-top: 10px; width: 100%; height: 32px; }
.spark-sent { color: var(--blue-700); } .spark-recv { color: var(--green-700); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.grid-3 > .card, .grid-2 > .card { margin: 0; }
.grid-2-wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); margin-bottom: 20px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--blue-700); }
a.card-link { color: var(--text); display: block; transition: border-color .15s, box-shadow .15s; }
a.card-link:hover { text-decoration: none; border-color: var(--blue-100); box-shadow: var(--shadow); }
.big-number { font-size: 1.9rem; font-weight: 780; letter-spacing: -.02em; margin: 0 0 8px; }
.small-number { font-size: 1.05rem; }
.kv-list, .status-list { list-style: none; margin: 0; padding: 0; }
.kv-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.status-list li { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; font-weight: 650; }
.status-list li:first-child, .kv-list li:first-child { border-top: 0; }
.status-value { grid-column: 2; color: var(--muted); font-weight: 500; font-size: .84rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.status-dot.ok { background: var(--green); } .status-dot.bad { background: var(--red); }
.text-ok { color: var(--green-700); } .text-bad { color: var(--red-700); }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar-sent { fill: var(--blue-700); } .chart .bar-recv { fill: var(--green); }
.chart .bar-label { fill: var(--muted); font: 600 11px var(--font); }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); font-weight: 650; margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key-sent { background: var(--blue-700); } .key-recv { background: var(--green); }
.inline-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.inline-card-text { flex: 1 1 320px; } .inline-card-text p { margin: 4px 0 0; }
.inline-card .inline-form { flex: 1 1 360px; }
.sk-grid-3 { grid-template-columns: repeat(3, 1fr); } .sk-chart { height: 220px; }
.fragment { min-height: 120px; }

/* search bar and message rows */
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.searchbar .search-field { flex: 1 1 280px; padding: 0; border: 0; margin: 0; }
.searchbar .search-field .icon { left: 12px; }
.select-field { margin: 0; }
select { width: auto; padding: 9px 34px 9px 12px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235E6B7F' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; cursor: pointer; }
select:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.msg-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.msg-list li:last-child.msg-row { border-bottom: 0; }
.msg-row .msg { flex: 1; min-width: 0; border-bottom: 0; }
.msg-action { padding-right: 10px; }
.msg-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.msg-size { font-size: .74rem; color: var(--muted); }
.msg-row.is-unseen .msg-subject, .msg-row.is-unseen .msg-from { font-weight: 780; color: var(--text); }
.msg-row.is-unseen .msg::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-left: -12px; margin-right: -4px; flex: none; }
.message-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.message-title { flex: 1 1 260px; min-width: 0; } .message-title h2 { font-size: 1.2rem; word-break: break-word; }
.message-title p { margin: 2px 0 0; word-break: break-word; }
.message-actions { display: flex; align-items: center; gap: 6px; }
.message-actions form { margin: 0; }

/* compose */
.compose-from { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
details.copies { margin: -4px 0 12px; }
details.copies > summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--blue-700); font-weight: 650; font-size: .88rem; list-style: none; padding: 4px 0; }
details.copies > summary::-webkit-details-marker { display: none; }
details.copies[open] > summary { margin-bottom: 12px; }
details.copies[open] > summary .icon { transform: rotate(45deg); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2, .grid-2-wide { grid-template-columns: minmax(0, 1fr); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  body.app { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 40; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px 10px; }
  .brand { flex-direction: row; align-items: center; padding: 0; margin: 0; border: 0; gap: 10px; }
  .brand img { width: 108px; } .brand-sub { display: none; }
  .account { margin: 0 0 0 auto; padding: 0; border: 0; } .account .avatar, .account-name { display: none; }
  .nav { order: 3; flex: 1 0 100%; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 32px; }
  .nav-item { flex: none; padding: 8px 12px; font-size: .88rem; }
  .nav-item.is-active::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .content { padding: 20px 16px 40px; }
  .mail-layout { grid-template-columns: minmax(0, 1fr); }
  .folders { overflow: hidden; }
  .folders ul { display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; } .folder { white-space: nowrap; }
  .sk-grid, .sk-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 8px; }
  .sidebar-foot .lang-switch { padding: 0; } .sidebar-foot .lang-switch .icon { display: none; }
  .sidebar-foot .lang-switch a { padding: 4px 6px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .page-head { align-items: flex-start; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .stat { padding: 14px; } .stat-value { font-size: 1.4rem; margin-top: 10px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 4px 0; text-align: left; }
  .table td.right { text-align: left; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
  .table td[data-label="Mailbox"]::before, .table td[data-label="Actions"]::before { display: none; }
  .row-actions { justify-content: flex-start; margin-left: -8px; }
  .card { padding: 18px; } .auth-card { padding: 24px; }
  .form-actions .btn { flex: 1; }
  .chart .bar-label { font-size: 22px; }
  .searchbar .select-field, .searchbar .btn { flex: 1 1 auto; } .searchbar select { width: 100%; }
  .msg { padding: 12px 12px; gap: 10px; } .msg-action { padding-right: 4px; }
  .msg-size { display: none; }
  .message-actions { width: 100%; } .message-actions .btn { flex: 1; }
  .inline-card .inline-form .btn { width: 100%; }
  [data-tip]:hover::after, [data-tip]:hover::before { display: none; }
  [data-tip]:focus-visible::after { left: auto; right: 0; transform: none; }
  .message .meta { grid-template-columns: 1fr; gap: 0; } .meta dd { margin-bottom: 8px; }
}
