/* MantraDesk Mail, in the MantraDesk application design (mant-web semantic tokens), light and dark. */
:root {
  color-scheme: light;
  --text-primary: #21232a; --text-secondary: #6f748c; --text-tertiary: #989eb7;
  --text-action: #0092d6; --text-action-hover: #0078c0; --text-on-fill: #ffffff;
  --border: #dde2f1; --border-hover: #ced3e6;
  --theme: #00b5ff; --theme-hover: #0092d6; --theme-select: #00b5ff26; --theme-light: #e3f6ff;
  --fill-primary: #f8faff; --fill-hover: #1f23290d; --fill-active: #1f23291a;
  --surface: #ffffff; --background: #ffffff; --side: #f8faff;
  --ok: #248569; --ok-light: #ecf9f5; --warn: #db7e21; --warn-light: #fff3d5; --error: #e71d32; --error-light: #ffe6ec;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, Vazirmatn, Tahoma, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r-2: 6px; --r-3: 8px; --r-4: 12px; --r-5: 16px;
  --shadow: 0 1px 2px rgba(31, 35, 41, .06), 0 12px 28px -12px rgba(31, 35, 41, .18);
  --side-w: 248px; --list-w: 380px; --bar-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --text-primary: #e4e8f5; --text-secondary: #989eb7; --text-tertiary: #6f748c;
    --text-action: #00b5ff; --text-action-hover: #4ec1ff;
    --border: #3d404f; --border-hover: #54596e; --theme-light: #00508f;
    --fill-primary: #272930; --fill-hover: #f9fafd0d; --fill-active: #f9fafd1a;
    --surface: #272930; --background: #21232a; --side: #272930;
    --ok: #48a982; --ok-light: #305548; --warn-light: #7a3108; --error: #ff5050; --error-light: #6e0a1e;
  }
}
@font-face { font-family: "Vazirmatn"; src: url("Vazirmatn-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("Vazirmatn-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text-primary); background: var(--background); -webkit-text-size-adjust: 100%; }
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: var(--text-action); text-decoration: none; }
a:hover { color: var(--text-action-hover); }
code { font-family: var(--mono); font-size: .85em; background: var(--fill-primary); border: 1px solid var(--border); border-radius: var(--r-2); padding: .05em .35em; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--theme); outline-offset: 1px; border-radius: var(--r-3); }
::selection { background: var(--theme-select); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic--xl { width: 40px; height: 40px; stroke-width: 1.4; color: var(--text-tertiary); }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }

/* Buttons and fields (components/ui/button.tsx, input.tsx) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 32px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--r-3); font: inherit; font-size: 14px; font-weight: 500; color: var(--text-primary); background: transparent; cursor: pointer; white-space: nowrap; transition: background-color .2s, border-color .2s, color .2s; }
.btn .ic { width: 16px; height: 16px; }
.btn--lg { height: 40px; padding: 0 16px; border-radius: var(--r-4); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--theme); color: var(--text-on-fill); }
.btn--primary:hover { background: var(--theme-hover); color: var(--text-on-fill); }
.btn--outline { border-color: var(--border); }
.btn--outline:hover { background: var(--fill-hover); border-color: var(--border-hover); color: var(--text-primary); }
.btn--ghost:hover { background: var(--fill-hover); color: var(--text-primary); }
.btn--danger { background: var(--error); color: #fff; }
.btn--danger:hover { filter: brightness(.92); color: #fff; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: var(--r-3); background: transparent; color: var(--text-secondary); cursor: pointer; }
.icon-btn:hover { background: var(--fill-hover); color: var(--text-primary); }
.icon-btn.is-on { color: #f5a623; }
.icon-btn.is-on .ic { fill: currentColor; }
.icon-btn.is-disabled { opacity: .35; pointer-events: none; }
.icon-btn--flip .ic { transform: scaleX(-1); }
input, select, textarea { font: inherit; color: var(--text-primary); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-3); }
input:not([type=checkbox]):not([type=file]), select { height: 36px; padding: 0 10px; }
textarea { padding: 8px 10px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--border-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--theme); box-shadow: 0 0 0 1px var(--theme); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--theme); }
label { display: grid; gap: 4px; font-weight: 500; }
.stack { display: grid; gap: 14px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }

/* App shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; overflow: hidden; }
.nav-toggle, .scrim { display: none; }
.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 12px; background: var(--side); border-right: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px; color: var(--text-primary); }
.brand__mark { width: 24px; height: 24px; flex: none; background: var(--theme); -webkit-mask: url("logo.svg") center / contain no-repeat; mask: url("logo.svg") center / contain no-repeat; }
.brand__word { font-weight: 700; font-size: 16px; color: var(--text-primary); }
.brand__sub { font-size: 13px; color: var(--text-secondary); padding: 0 6px; border: 1px solid var(--border); border-radius: 999px; }
.side__compose { height: 40px; border-radius: var(--r-4); }
.nav { display: grid; gap: 2px; overflow-y: auto; min-height: 0; flex: 1; align-content: start; }
.nav__heading { margin: 14px 8px 4px; font-size: 12px; font-weight: 600; color: var(--text-tertiary); }
.nav__item { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-3); background: transparent; color: var(--text-primary); font: inherit; font-size: 14px; cursor: pointer; text-align: start; }
.nav__item:hover { background: var(--fill-hover); color: var(--text-primary); }
.nav__item.is-active { background: var(--theme-select); color: var(--text-action); font-weight: 600; }
.nav__item .ic { color: var(--text-secondary); }
.nav__item.is-active .ic { color: var(--text-action); }
.nav__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--theme); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.side__foot { display: grid; gap: 2px; padding-top: 8px; border-top: 1px solid var(--border); }
.side__user { padding: 6px 10px 0; font-size: 12px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; position: relative; }
.topbar { display: flex; align-items: center; gap: 12px; height: var(--bar-h); flex: none; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--background); }
.topbar__title { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__extra { margin-inline-start: auto; display: flex; gap: 4px; }
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 520px; margin-inline-start: 12px; }
.search .ic { position: absolute; inset-inline-start: 10px; top: 9px; color: var(--text-tertiary); }
.search input { width: 100%; padding-inline-start: 34px !important; background: var(--fill-primary); border-color: transparent; border-radius: var(--r-4); }
.search input:focus { background: var(--surface); }

.flash { position: absolute; z-index: 20; top: 64px; inset-inline-end: 16px; max-width: min(520px, calc(100% - 32px)); padding: 10px 14px; border-radius: var(--r-4); font-weight: 500; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.flash--ok { background: var(--ok-light); color: var(--ok); }
.flash--error { background: var(--error-light); color: var(--error); }

/* Panes */
.panes { display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr); flex: 1; min-height: 0; }
.list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.listbar { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 4px 8px 4px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.check-all { display: inline-flex; margin-inline-end: 4px; }
.listbar__actions { display: none; align-items: center; gap: 2px; flex-wrap: wrap; }
.listbar__actions select { height: 28px; font-size: 13px; max-width: 120px; }
.listbar.has-selection .listbar__actions { display: flex; }
.listbar__count { margin-inline-start: auto; font-size: 12px; color: var(--text-tertiary); }
.msgs { overflow-y: auto; flex: 1; }
.msg { position: relative; display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--border); }
.msg:hover { background: var(--fill-hover); }
.msg.is-active { background: var(--theme-select); }
.msg__check { margin-top: 3px; }
.msg__link { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; color: var(--text-primary); }
.msg__link:hover { color: var(--text-primary); }
.msg__from, .msg__subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg__from { font-size: 14px; }
.msg__date { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }
.msg__subject { font-size: 13px; color: var(--text-secondary); }
.msg__marks { display: inline-flex; gap: 4px; justify-content: end; }
.msg__marks .ic { width: 14px; height: 14px; color: var(--text-tertiary); }
.ic--star { color: #f5a623 !important; fill: #f5a623; }
.msg.is-unread .msg__from, .msg.is-unread .msg__subject { font-weight: 700; color: var(--text-primary); }
.msg.is-unread::before { content: ""; position: absolute; inset-inline-start: 4px; top: 16px; width: 6px; height: 6px; border-radius: 50%; background: var(--theme); }
.empty, .reader__empty { display: grid; place-items: center; gap: 10px; padding: 48px 16px; text-align: center; color: var(--text-secondary); }
.reader__empty { height: 100%; }

.reader { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.mail { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.mail__bar { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 4px 12px; border-bottom: 1px solid var(--border); }
.mail__back { display: none; }
.mail__tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.mail__tools select { height: 28px; font-size: 13px; max-width: 130px; margin-inline-start: 6px; }
.mail__head { padding: 16px 20px 12px; display: grid; gap: 10px; }
.mail__head h2 { font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.mail__meta { display: grid; gap: 2px; font-size: 13px; }
.mail__meta div { display: flex; gap: 8px; }
.mail__meta dt { width: 44px; flex: none; color: var(--text-tertiary); }
.mail__meta dd { color: var(--text-secondary); overflow-wrap: anywhere; }
.mail__replies { display: flex; gap: 8px; flex-wrap: wrap; }
.notice { display: flex; align-items: center; gap: 8px; margin: 0 20px 10px; padding: 8px 12px; border-radius: var(--r-3); background: var(--theme-light); color: var(--text-primary); font-size: 13px; flex-wrap: wrap; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.att { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-3); color: var(--text-primary); font-size: 13px; }
.att:hover { background: var(--fill-hover); color: var(--text-primary); }
.att__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att__size { color: var(--text-tertiary); font-size: 12px; white-space: nowrap; }
.mail__body { flex: 1; min-height: 240px; width: 100%; border: 0; border-top: 1px solid var(--border); background: #fff; }

/* Compose */
.compose { display: flex; flex-direction: column; gap: 0; flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 20px; max-width: 980px; width: 100%; }
.compose__row { display: flex; align-items: center; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); font-weight: 400; }
.compose__label { width: 64px; flex: none; color: var(--text-secondary); font-size: 13px; }
.compose__row input { flex: 1; border-color: transparent; background: transparent; padding-inline: 0 !important; }
.compose__row input:focus { box-shadow: none; border-color: transparent; }
.compose__from { padding: 8px 0; color: var(--text-secondary); }
.compose__more summary { padding: 8px 0 4px 76px; color: var(--text-action); cursor: pointer; font-size: 13px; list-style: none; }
.compose__more summary::-webkit-details-marker { display: none; }
.compose__body { flex: 1; min-height: 320px; margin-top: 12px; border-radius: var(--r-4); padding: 14px; line-height: 1.6; }
.compose__files { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin-top: 12px; font-weight: 400; color: var(--text-secondary); }
.compose__files input { font-size: 13px; border: 0; }
.compose__actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Settings and admin pages */
.page { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.page > * { max-width: 980px; width: 100%; }
.card { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-5); display: grid; gap: 14px; }
.card h2 { font-size: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.mini { padding: 14px; border: 1px solid var(--border); border-radius: var(--r-4); }
.mini h3 { font-size: 14px; margin-bottom: 4px; }
.list-rows { display: grid; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row__main { flex: 1 1 260px; display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.row__act > summary { list-style: none; }
.row__act > summary::-webkit-details-marker { display: none; }
.row__act[open] { flex-basis: 100%; order: 2; }
.row__act form { margin-top: 8px; }
.tag { padding: 0 8px; border-radius: 999px; background: var(--theme-light); color: var(--text-action); font-size: 12px; font-weight: 600; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.addr { display: flex; }
.addr input { flex: 1; min-width: 0; border-start-end-radius: 0; border-end-end-radius: 0; }
.addr__domain { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border); border-inline-start: 0; border-radius: 0 var(--r-3) var(--r-3) 0; background: var(--fill-primary); color: var(--text-secondary); font-weight: 400; white-space: nowrap; }
.status { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--r-4); background: var(--surface); }
.status--up strong { color: var(--ok); }
.status--down strong { color: var(--error); }
.table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: start; vertical-align: top; padding: 10px; border-top: 1px solid var(--border); }
th { font-size: 12px; color: var(--text-tertiary); font-weight: 600; border-top: 0; }
td p { margin-top: 6px; }
.state { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.state--ok { background: var(--ok-light); color: var(--ok); }
.state--missing { background: var(--error-light); color: var(--error); }
.state--different, .state--unknown { background: var(--warn-light); color: var(--warn); }

/* Sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--fill-primary); }
.auth__main { width: 100%; max-width: 400px; }
.auth__card { display: grid; gap: 16px; padding: 32px 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-5); box-shadow: var(--shadow); }
.auth__brand { justify-self: start; padding: 0; }
.auth__card h1 { font-size: 24px; }
.auth__foot { margin-top: 16px; text-align: center; }
.auth__foot a { color: var(--text-secondary); text-decoration: underline; }

/* Phone and small tablet */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 40; inset-block: 0; inset-inline-start: 0; width: min(280px, 85vw); transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  .nav-toggle:checked ~ .side { transform: none; }
  .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-grid; }
  .search { margin-inline-start: 0; }
  .topbar__title { display: none; }
  .panes { grid-template-columns: minmax(0, 1fr); }
  .panes.has-reader .list { display: none; }
  .panes:not(.has-reader) .reader { display: none; }
  .list { border-right: 0; }
  .mail__back { display: inline-grid; }
  .compose { padding: 8px 14px 16px; }
  .page { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
