/* ============================================================
   Businessmail design system — shadcn/ui tokens + components.
   Views should reuse these classes and add minimal CSS only.
   ============================================================ */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 10% 3.9%;
  --radius: 0.5rem;
  --brand: 221 83% 53%;
}
.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 240 10% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 50.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
  --brand: 217 91% 60%;
}

* { box-sizing: border-box; border-color: hsl(var(--border)); }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px; line-height: 1.5;
  color: hsl(var(--foreground)); background: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; color: inherit; }
a { color: hsl(var(--brand)); }
svg.icon { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  border: 1px solid transparent; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s; background: transparent; }
.btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / .9); }
.btn-outline { border-color: hsl(var(--border)); background: hsl(var(--background)); }
.btn-outline:hover { background: hsl(var(--accent)); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover { background: hsl(var(--secondary) / .8); }
.btn-ghost:hover { background: hsl(var(--accent)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { height: 36px; width: 36px; padding: 0; }
.btn-icon.btn-sm { height: 32px; width: 32px; }

/* badges, inputs, cards */
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 9999px;
  font-size: 11px; font-weight: 600; line-height: 1; border: 1px solid transparent; }
.badge-sec { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }

.input, .textarea, .select {
  width: 100%; border: 1px solid hsl(var(--input)); background: transparent;
  border-radius: var(--radius); padding: 8px 12px; font-size: 14px; color: hsl(var(--foreground)); }
.input { height: 36px; padding-top: 0; padding-bottom: 0; }
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid hsl(var(--ring)); outline-offset: 1px; }
.label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field { margin-bottom: 16px; }

.card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); }

.avatar { border-radius: 9999px; display: grid; place-items: center; color: #fff;
  font-weight: 600; font-size: 12px; flex: none; }

.muted { color: hsl(var(--muted-foreground)); }
.row-flex { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.sep { width: 1px; height: 20px; background: hsl(var(--border)); margin: 0 6px; }
.hr { height: 1px; background: hsl(var(--border)); border: 0; margin: 16px 0; }
.spinner { width: 18px; height: 18px; border: 2px solid hsl(var(--muted)); border-top-color: hsl(var(--foreground));
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex;
  flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 10px 16px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: rise .2s ease; }
.toast.error { border-color: hsl(var(--destructive)); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* modal / dialog */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 90; }
.dialog { background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius); padding: 24px; width: 420px; max-width: calc(100vw - 32px); box-shadow: 0 16px 40px rgba(0,0,0,.3); }

/* app chrome */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 16px; border-bottom: 1px solid hsl(var(--border)); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: hsl(var(--primary));
  color: hsl(var(--primary-foreground)); display: grid; place-items: center; }
.searchwrap { position: relative; flex: 1; max-width: 560px; }
.searchwrap .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: hsl(var(--muted-foreground)); }
.searchwrap .input { padding-left: 34px; }
.body { display: grid; grid-template-columns: 240px 1fr; min-height: 0; }
.sidebar { border-right: 1px solid hsl(var(--border)); padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.navbtn { display: flex; align-items: center; gap: 12px; width: 100%; height: 36px; padding: 0 12px; border: 0;
  border-radius: var(--radius); font-size: 14px; font-weight: 500; background: transparent; color: hsl(var(--foreground)); cursor: pointer; }
.navbtn:hover { background: hsl(var(--accent)); }
.navbtn.active { background: hsl(var(--secondary)); }
.navbtn .count { margin-left: auto; font-size: 12px; color: hsl(var(--muted-foreground)); font-weight: 500; }
.navlabel { padding: 14px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: hsl(var(--muted-foreground)); }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
#view { min-height: 0; overflow: hidden; }

.center-screen { display: grid; place-items: center; height: 100vh; padding: 24px; }
.auth-card { width: 400px; max-width: 100%; }

/* ---- mailbox: list + reader two-pane (mounted inside #view) ---- */
.mailbox { display: grid; grid-template-columns: 400px 1fr; height: 100%; min-height: 0; }
.mail-list { border-right: 1px solid hsl(var(--border)); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 14px 16px 12px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid hsl(var(--border)); }
.list-head h2 { margin: 0; font-size: 18px; font-weight: 700; text-transform: capitalize; }
.tabs { margin-left: auto; display: inline-flex; background: hsl(var(--muted)); border-radius: var(--radius); padding: 3px; gap: 2px; }
.tab { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: hsl(var(--muted-foreground)); cursor: pointer; }
.tab.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.rows { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.row { text-align: left; width: 100%; border: 1px solid transparent; background: transparent; border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.row:hover { background: hsl(var(--accent)); }
.row.selected { background: hsl(var(--accent)); border-color: hsl(var(--border)); }
.row .l1 { display: flex; align-items: center; gap: 8px; }
.row .from { font-weight: 600; font-size: 14px; }
.row.unread .from::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--brand)); margin-right: 6px; vertical-align: middle; }
.row .time { margin-left: auto; font-size: 12px; color: hsl(var(--muted-foreground)); }
.row .subj { font-size: 13px; font-weight: 500; }
.row .snip { font-size: 12px; color: hsl(var(--muted-foreground)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .tags { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.list-empty, .reader-empty { display: grid; place-items: center; height: 100%; color: hsl(var(--muted-foreground)); padding: 40px; text-align: center; }

.reader { display: flex; flex-direction: column; min-height: 0; }
.reader-toolbar { height: 52px; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: 1px solid hsl(var(--border)); }
.reader-scroll { overflow: auto; padding: 24px; }
.mail-head { display: flex; align-items: flex-start; gap: 14px; padding-bottom: 20px; border-bottom: 1px solid hsl(var(--border)); margin-bottom: 20px; }
.mail-head .name { font-weight: 600; font-size: 15px; }
.mail-head .time { margin-left: auto; font-size: 13px; color: hsl(var(--muted-foreground)); }
.notice { display: flex; align-items: center; gap: 8px; font-size: 13px; color: hsl(var(--muted-foreground)); background: hsl(var(--muted)); border-radius: var(--radius); padding: 8px 12px; margin: 16px 0; }
.mail-frame { width: 100%; border: 0; background: #fff; border-radius: var(--radius); }
.prose { font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-wrap: break-word; }
.attach-card { display: inline-flex; align-items: center; gap: 10px; border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; font-weight: 500; margin: 8px 8px 0 0; text-decoration: none; color: inherit; }
.msg-block { padding: 16px 0; border-bottom: 1px solid hsl(var(--border)); }

/* ---- compose window ---- */
.compose-card { position: fixed; right: 24px; bottom: 0; width: 560px; max-width: calc(100vw - 48px); background: hsl(var(--popover)); border: 1px solid hsl(var(--border)); border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 16px 40px rgba(0,0,0,.3); z-index: 80; display: flex; flex-direction: column; }
.compose-head { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); padding: 10px 16px; display: flex; align-items: center; font-weight: 600; font-size: 13px; border-radius: var(--radius) var(--radius) 0 0; }
.compose-field { display: flex; gap: 8px; padding: 8px 16px; border-bottom: 1px solid hsl(var(--border)); font-size: 13px; align-items: center; }
.compose-field label { color: hsl(var(--muted-foreground)); width: 48px; }
.compose-field input { border: 0; outline: none; background: transparent; flex: 1; color: hsl(var(--foreground)); font-size: 13px; }
.compose-body { padding: 14px 16px; min-height: 180px; font-size: 14px; line-height: 1.6; color: hsl(var(--foreground)); outline: none; overflow: auto; }
.compose-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid hsl(var(--border)); }

/* ---- settings / admin tables ---- */
.page { max-width: 820px; margin: 0 auto; padding: 32px 24px; overflow: auto; height: 100%; }
.page h1 { font-size: 22px; margin: 0 0 4px; }
.page h2 { font-size: 16px; margin: 28px 0 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: hsl(var(--muted-foreground)); padding: 8px 12px; border-bottom: 1px solid hsl(var(--border)); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table td { padding: 10px 12px; border-bottom: 1px solid hsl(var(--border)); }
.dns-rec { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: hsl(var(--muted)); padding: 8px 12px; border-radius: 6px; margin: 4px 0; word-break: break-all; }
