/* FATUSA Mail — design system
   Blue, white, black, neutral gray. Light and dark are both first-class:
   every colour is a token defined on :root and redefined for dark. */

:root {
  color-scheme: light;

  --blue-50:  #eef4ff;
  --blue-100: #dce8ff;
  --blue-200: #bcd3ff;
  --blue-300: #8fb5ff;
  --blue-500: #2563eb;
  --blue-600: #1d4ed8;
  --blue-700: #1e40af;

  --bg:            #f7f8fa;
  --bg-raised:     #ffffff;
  --bg-sunken:     #eff1f5;
  --bg-hover:      #f2f4f7;
  --bg-active:     var(--blue-50);
  --bg-inverse:    #0b0d12;

  --text:          #10131a;
  --text-muted:    #5b6472;
  --text-subtle:   #838d9c;
  --text-inverse:  #ffffff;
  --text-accent:   var(--blue-600);

  --border:        #e2e6ec;
  --border-strong: #cdd3dc;
  --border-focus:  var(--blue-500);

  --accent:        var(--blue-600);
  --accent-hover:  var(--blue-700);
  --accent-soft:   var(--blue-50);
  --on-accent:     #ffffff;

  --success: #087443;  --success-soft: #e4f6ec;
  --warning: #8a5400;  --warning-soft: #fdf2dd;
  --danger:  #b02231;  --danger-soft:  #fdeaec;
  --info:    #1d4ed8;  --info-soft:    #e8efff;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(16, 19, 26, .06);
  --shadow:    0 2px 8px rgba(16, 19, 26, .07), 0 1px 2px rgba(16, 19, 26, .05);
  --shadow-lg: 0 12px 32px rgba(16, 19, 26, .12), 0 2px 8px rgba(16, 19, 26, .06);

  --sidebar-w: 248px;
  --list-w: 400px;
  --header-h: 58px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:            #0d1017;
    --bg-raised:     #151a23;
    --bg-sunken:     #0a0d13;
    --bg-hover:      #1b2230;
    --bg-active:     #16233d;
    --bg-inverse:    #eef1f6;
    --text:          #e9edf3;
    --text-muted:    #9aa5b5;
    --text-subtle:   #6f7a8a;
    --text-inverse:  #0d1017;
    --text-accent:   #7aa5ff;
    --border:        #232b38;
    --border-strong: #333d4d;
    --accent:        #3b7bff;
    --accent-hover:  #5a91ff;
    --accent-soft:   #16233d;
    --on-accent:     #ffffff;
    --success: #4ade80;  --success-soft: #0f2d1f;
    --warning: #fbbf24;  --warning-soft: #33260a;
    --danger:  #f87171;  --danger-soft:  #341417;
    --info:    #7aa5ff;  --info-soft:    #16233d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 2px 10px rgba(0, 0, 0, .45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #0d1017;
  --bg-raised:     #151a23;
  --bg-sunken:     #0a0d13;
  --bg-hover:      #1b2230;
  --bg-active:     #16233d;
  --bg-inverse:    #eef1f6;
  --text:          #e9edf3;
  --text-muted:    #9aa5b5;
  --text-subtle:   #6f7a8a;
  --text-inverse:  #0d1017;
  --text-accent:   #7aa5ff;
  --border:        #232b38;
  --border-strong: #333d4d;
  --accent:        #3b7bff;
  --accent-hover:  #5a91ff;
  --accent-soft:   #16233d;
  --on-accent:     #ffffff;
  --success: #4ade80;  --success-soft: #0f2d1f;
  --warning: #fbbf24;  --warning-soft: #33260a;
  --danger:  #f87171;  --danger-soft:  #341417;
  --info:    #7aa5ff;  --info-soft:    #16233d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 2px 10px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--text-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection { background: var(--accent); color: var(--on-accent); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  font: inherit; font-weight: 500; font-size: 13.5px;
  color: var(--text); background: var(--bg-raised);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap;
  transition: background .14s var(--ease), border-color .14s var(--ease), transform .06s var(--ease);
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 34px; padding: 0; }

label.field { display: block; margin-bottom: 14px; }
label.field > span.label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
.hint { margin-top: 5px; font-size: 12.5px; color: var(--text-subtle); }
.error-text { margin-top: 5px; font-size: 12.5px; color: var(--danger); }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px;
  font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg-raised);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--border-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}

.checkbox { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

/* address field: local part + domain dropdown as one control */
.address-input { display: flex; align-items: stretch; }
.address-input input {
  border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none;
}
.address-input select {
  width: auto; min-width: 150px; flex: none;
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  background-color: var(--bg-sunken); font-weight: 500;
}
.address-preview {
  margin-top: 7px; font-family: var(--mono); font-size: 13px;
  color: var(--text-accent);
}

/* ---------- surfaces ---------- */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--border);
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px;
  font-size: 12px; font-weight: 600; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-muted);
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-subtle); }
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--warning); }
.status-dot.bad { background: var(--danger); }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }

.table-wrap { overflow-x: auto; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; }

.sidebar {
  display: flex; flex-direction: column;
  background: var(--bg-raised); border-right: 1px solid var(--border);
  min-height: 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--header-h); padding: 0 18px; flex: none;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  background: var(--accent); color: var(--on-accent);
  border-radius: 8px; font-weight: 700; font-size: 13px; letter-spacing: -.02em;
}
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.015em; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 10px; min-height: 0; }
.nav-group { margin-bottom: 20px; }
.nav-group-title {
  padding: 0 10px 7px; font-size: 11px; font-weight: 700;
  color: var(--text-subtle); text-transform: uppercase; letter-spacing: .07em;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; margin-bottom: 1px;
  font: inherit; font-size: 13.5px; font-weight: 500; text-align: left;
  color: var(--text-muted); background: none; border: none;
  border-radius: var(--radius); cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--bg-active); color: var(--text-accent); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item .count {
  margin-left: auto; font-size: 12px; font-weight: 600;
  color: var(--text-subtle); font-variant-numeric: tabular-nums;
}
.nav-item.active .count { color: var(--text-accent); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: var(--header-h); padding: 0 18px; flex: none;
  background: var(--bg-raised); border-bottom: 1px solid var(--border);
}
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { height: 36px; padding-left: 34px; background: var(--bg-sunken); }
.topbar .search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-subtle); pointer-events: none;
}

.content { flex: 1; overflow-y: auto; min-height: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 26px 24px 60px; }
.page-head { margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--text-muted); max-width: 70ch; }

/* account switcher */
.account-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 9px 5px 5px; font: inherit;
  background: none; border: 1px solid transparent; border-radius: 999px;
  cursor: pointer; color: var(--text);
}
.account-btn:hover { background: var(--bg-hover); border-color: var(--border); }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  font-size: 11.5px; font-weight: 650; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }

.menu {
  position: absolute; z-index: 60; min-width: 250px; padding: 6px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; font: inherit; font-size: 13.5px; text-align: left;
  color: var(--text); background: none; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item.active { background: var(--bg-active); color: var(--text-accent); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }
.menu-label {
  padding: 7px 10px 5px; font-size: 11px; font-weight: 700;
  color: var(--text-subtle); text-transform: uppercase; letter-spacing: .06em;
}

/* ---------- mail ---------- */
.mail-layout { display: grid; grid-template-columns: var(--list-w) 1fr; flex: 1; min-height: 0; }
.mail-list { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; background: var(--bg-raised); }
.mail-list-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; flex: none; border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.mail-list-scroll { flex: 1; overflow-y: auto; min-height: 0; }

.msg-row {
  display: grid; grid-template-columns: auto auto 1fr; gap: 2px 10px;
  width: 100%; padding: 11px 14px; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--border);
  cursor: pointer; font: inherit; color: var(--text);
}
.msg-row:hover { background: var(--bg-hover); }
.msg-row.selected { background: var(--bg-active); }
.msg-row.unread .msg-from, .msg-row.unread .msg-subject { font-weight: 650; }
.msg-row.unread::before {
  content: ''; grid-row: 1 / span 3; align-self: center;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.msg-row:not(.unread)::before { content: ''; grid-row: 1 / span 3; width: 6px; }
.msg-check { grid-row: 1 / span 3; align-self: center; accent-color: var(--accent); width: 15px; height: 15px; }
.msg-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.msg-date { font-size: 12px; color: var(--text-subtle); flex: none; font-variant-numeric: tabular-nums; }
.msg-subject { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { font-size: 12.5px; color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-flags { display: flex; gap: 5px; align-items: center; flex: none; }
.msg-flags svg { width: 14px; height: 14px; color: var(--text-subtle); }
.msg-flags .starred { color: #eab308; fill: #eab308; }

.reader { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.reader-head { padding: 20px 26px 16px; border-bottom: 1px solid var(--border); background: var(--bg-raised); flex: none; }
.reader-subject { font-size: 19px; font-weight: 650; letter-spacing: -.015em; margin-bottom: 12px; }
.reader-meta { display: flex; align-items: flex-start; gap: 12px; }
.reader-body { flex: 1; overflow: hidden; min-height: 0; }
.reader-body iframe { width: 100%; height: 100%; border: none; background: var(--bg-raised); }
.reader-actions { display: flex; gap: 8px; padding: 12px 26px; border-top: 1px solid var(--border); background: var(--bg-raised); flex: none; flex-wrap: wrap; }

.notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; margin: 12px 26px 0;
  font-size: 13px; border-radius: var(--radius); border: 1px solid transparent;
}
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.notice-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.notice-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.notice-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }

.attachment-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 26px; border-top: 1px solid var(--border); }
.attachment {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; font-size: 13px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.attachment:hover { border-color: var(--border-strong); background: var(--bg-hover); text-decoration: none; }
.attachment svg { width: 16px; height: 16px; color: var(--text-subtle); }
.attachment .size { color: var(--text-subtle); font-size: 12px; }

/* ---------- compose ---------- */
.compose-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 13, 19, .45);
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 0 24px 0 0;
}
.compose {
  display: flex; flex-direction: column;
  width: min(720px, 100%); height: min(680px, 92vh);
  background: var(--bg-raised);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.compose-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); flex: none;
}
.compose-fields { padding: 4px 18px; flex: none; }
.compose-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.compose-row > label { flex: none; width: 52px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.compose-row input, .compose-row select { border: none; background: none; min-height: 26px; padding: 0; }
.compose-row input:focus, .compose-row select:focus { box-shadow: none; }
.compose-row select { font-weight: 550; color: var(--text); }
.compose-editor {
  flex: 1; overflow-y: auto; padding: 16px 18px; min-height: 0;
  font-size: 14px; line-height: 1.6; outline: none;
}
.compose-editor:empty::before { content: attr(data-placeholder); color: var(--text-subtle); }
.compose-toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 8px 14px; border-top: 1px solid var(--border); background: var(--bg-sunken); flex: none;
}
.compose-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--border); flex: none;
}
.tool-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer;
}
.tool-btn:hover { background: var(--bg-hover); color: var(--text); }
.tool-btn svg { width: 16px; height: 16px; }
.tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; flex: 1; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 9px; font-size: 12.5px;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 999px;
}
.chip button { background: none; border: none; cursor: pointer; color: var(--text-subtle); padding: 0; display: grid; }
.chip button:hover { color: var(--danger); }
.chip svg { width: 13px; height: 13px; }
.chips input { flex: 1; min-width: 140px; }

/* ---------- dialogs ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 13, 19, .5);
}
.dialog {
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
}
.dialog-head { padding: 20px 22px 0; }
.dialog-body { padding: 16px 22px; }
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 22px 20px;
}

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; font-size: 13.5px;
  background: var(--bg-inverse); color: var(--text-inverse);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: rise .2s var(--ease);
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- states ---------- */
.empty { display: grid; place-items: center; height: 100%; padding: 40px; text-align: center; }
.empty-inner { max-width: 340px; }
.empty svg { width: 36px; height: 36px; color: var(--text-subtle); margin-bottom: 14px; }
.empty h3 { margin-bottom: 6px; }
.empty p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.meter { height: 6px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s var(--ease); }
.meter.warn > span { background: var(--warning); }
.meter.bad > span { background: var(--danger); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; }
.stat .stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .stat-value { margin-top: 7px; font-size: 25px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .stat-sub { margin-top: 4px; font-size: 12.5px; color: var(--text-subtle); }

/* ---------- login ---------- */
.auth-screen { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px; }
.auth-card { width: min(400px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 26px; }
.auth-brand .brand-mark { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
.auth-brand .brand-name { font-size: 19px; }
.auth-foot { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--text-subtle); }

/* ---------- responsive ---------- */
.mobile-only { display: none; }

@media (max-width: 1100px) {
  :root { --list-w: 340px; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 90;
    width: min(280px, 84vw);
    transform: translateX(-100%); transition: transform .2s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 85; background: rgba(10,13,19,.45); }
  .mobile-only { display: inline-flex; }
  .mail-layout { grid-template-columns: 1fr; }
  .mail-list { border-right: none; }
  .mail-layout.reading .mail-list { display: none; }
  .mail-layout:not(.reading) .reader { display: none; }
  .page { padding: 20px 16px 48px; }
  .compose-overlay { padding: 0; }
  .compose { width: 100%; height: 100%; border-radius: 0; border: none; }
  .reader-head, .reader-actions, .attachment-strip { padding-left: 16px; padding-right: 16px; }
  .notice { margin-left: 16px; margin-right: 16px; }
}

@media (max-width: 520px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .address-input { flex-direction: column; }
  .address-input input { border-right: 1px solid var(--border-strong); border-radius: var(--radius) var(--radius) 0 0; }
  .address-input select { width: 100%; border-radius: 0 0 var(--radius) var(--radius); border-top: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
