:root {
  --bg: #0C0F14;
  --surface: #121720;
  --surface-elev: #181E29;
  --surface-hover: #1D2533;
  --surface-active: #202B3D;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ECEFF4;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 10px;
  --radius-sm: 6px;
}

html[data-theme="light"] {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-elev: #EFECE4;
  --surface-hover: #F2EFE9;
  --surface-active: #E8EEFA;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #111827;
  --text-muted: #4B5563;
  --text-dim: #6B7280;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger-soft: rgba(239, 68, 68, 0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
select {
  height: 36px;
  line-height: 1.2;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  outline: none;
  transition: border-color 0.16s var(--ease);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 13px 13px;
}

textarea {
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.16s var(--ease);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elev);
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13.5px;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-elev);
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.12s var(--ease);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

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

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.btn-full {
  width: 100%;
}

.btn-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elev);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text);
}

.btn-xs:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-danger-text {
  color: var(--danger);
}

.icon-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.link-btn {
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 4px 6px;
}

.link-btn:hover {
  color: var(--text);
}

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 32px 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.auth-logo {
  width: 34px;
  height: 34px;
}

.auth-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-addon-wrap {
  height: 36px;
  display: flex;
  align-items: stretch;
}

.input-addon-wrap input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.input-addon {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.input-addon-select {
  height: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 0 28px 0 10px;
}

.form-error {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  font-size: 13px;
}

/* App Shell */
.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-icon {
  width: 24px;
  height: 24px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: -0.02em;
}

.topbar-search {
  flex: 1;
  max-width: 560px;
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search .search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  padding: 7px 32px 7px 34px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13.5px;
}

.search-clear {
  position: absolute;
  right: 8px;
  font-size: 18px;
  color: var(--text-dim);
  padding: 0 5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  background: var(--surface-elev);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-email {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-only {
  display: none;
}

/* Workspace */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-top {
  padding: 14px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-compose {
  width: 100%;
  justify-content: flex-start;
  height: 38px;
  padding: 0 14px;
  font-weight: 600;
}

.mailbox-switcher select {
  width: 100%;
  height: 34px;
  font-size: 12.5px;
  padding: 0 28px 0 10px;
  background-color: var(--bg);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mini-plus {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
}

.mini-plus:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-muted);
  text-align: left;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.nav-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #FFFFFF;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 6px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.quota-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-elev);
  overflow: hidden;
  margin-bottom: 6px;
}

.quota-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s var(--ease);
}

.quota-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

/* Main Pane */
.main-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.mail-workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.mail-list-col {
  width: 375px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.list-toolbar {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.list-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pane-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.pane-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-left: auto;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: transparent;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 500;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.bulk-bar span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
}

.message-list {
  flex: 1;
  overflow-y: auto;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.12s var(--ease);
}

.msg-row:hover {
  background: var(--surface-hover);
}

.msg-row.selected {
  background: var(--surface-active);
}

.msg-row.unread .msg-sender,
.msg-row.unread .msg-subject {
  font-weight: 600;
  color: var(--text);
}

.msg-row-checks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.star-btn {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 0;
}

.star-btn.starred {
  color: var(--warning);
}

.msg-row-main {
  flex: 1;
  min-width: 0;
}

.msg-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.msg-sender {
  font-size: 13.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.msg-subject-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.msg-subject {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.msg-thread-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.msg-snippet {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-meta-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.mini-pill {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.mini-pill.failed {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}

.mini-pill.scheduled {
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.35);
}

/* Reading Pane */
.mail-read-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}

.empty-read-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
}

.empty-read-state svg {
  width: 38px;
  height: 38px;
  opacity: 0.45;
}

.message-detail-pane {
  padding: 22px 26px 36px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.detail-subject-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-subject {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.read-receipt-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-size: 13px;
}

.thread-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.thread-item-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.sender-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #FFFFFF;
  flex-shrink: 0;
}

.sender-meta {
  min-width: 0;
}

.sender-name-line {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sender-addr {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.rcpt-line {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.thread-attachments {
  padding: 10px 18px;
  background: var(--surface-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.att-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
}

.att-pill:hover {
  border-color: var(--border-strong);
}

.att-size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.email-iframe {
  width: 100%;
  border: none;
  display: block;
  min-height: 180px;
  background: #FFFFFF;
}

.quick-reply-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-reply-card textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
}

.quick-reply-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Module Views */
.module-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 40px;
}

.module-container {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.module-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.module-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-head .card-title {
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.toolbar-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-ok {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.32);
  color: var(--success);
}

.badge-warn {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.32);
  color: var(--warning);
}

.badge-accent {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--accent);
}

.badge-err {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.32);
  color: var(--danger);
}

.list-row-item {
  border-top: 1px solid var(--border);
  padding: 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.module-section-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-quota-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-quota-row .quota-bar {
  flex: 1;
  margin-bottom: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.status-ok {
  color: var(--success);
  font-weight: 500;
}

.status-err {
  color: var(--danger);
  font-weight: 500;
}

.status-warn {
  color: var(--warning);
  font-weight: 500;
}

/* Composer Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.composer-card {
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.generic-modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.generic-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.composer-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
}

.composer-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--border);
}

.composer-row label {
  width: 64px;
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.composer-row input,
.composer-row select {
  flex: 1;
  height: 32px;
  background-color: transparent;
  border: none;
  padding: 0 4px;
}

.composer-row select {
  padding-right: 28px;
}

.chip-input-wrap {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  position: relative;
}

.chip-input-wrap input {
  min-width: 160px;
  flex: 1;
}

.addr-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  font-size: 12.5px;
}

.addr-chip button {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  z-index: 60;
}

.autocomplete-item {
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.autocomplete-item:hover {
  background: var(--surface-hover);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 7px 14px;
  background: var(--surface-elev);
  border-bottom: 1px solid var(--border);
}

.editor-toolbar button {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.editor-toolbar button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.editor-toolbar select {
  height: 28px;
  font-size: 12px;
  padding: 0 26px 0 8px;
  background-color: var(--surface);
}

.toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
}

.compose-editor {
  min-height: 240px;
  max-height: 360px;
  overflow-y: auto;
  padding: 14px 18px;
  outline: none;
  font-size: 14px;
  line-height: 1.6;
}

.compose-editor blockquote {
  border-left: 2px solid var(--border-strong);
  margin: 8px 0;
  padding-left: 12px;
  color: var(--text-muted);
}

.compose-attachments-zone {
  padding: 9px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.compose-attachments-zone.drag-over {
  background: var(--accent-soft);
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.composer-footer {
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-elev);
}

.composer-options {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.toggle-inline input[type="datetime-local"] {
  padding: 4px 8px;
  font-size: 12px;
}

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  color: var(--text);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--danger);
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.45);
}

.tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.tab-btn {
  height: 34px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  color: var(--text-muted);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.tab-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tab-btn.active {
  background: var(--surface-elev);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 1024px) {
  .mail-list-col {
    width: 310px;
  }
}

@media (max-width: 820px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: 54px;
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s var(--ease);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mail-list-col {
    width: 100%;
  }
  .mail-read-col {
    display: none;
  }
  .mail-workspace.reading-mobile .mail-list-col {
    display: none;
  }
  .mail-workspace.reading-mobile .mail-read-col {
    display: flex;
  }
  .user-email {
    display: none;
  }
}
