@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================ Tokens ============================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Background & surface */
  --bg-root: #F5F7FA;
  --bg-surface: #FFFFFF;
  --bg-soft: #F8FAFC;
  --bg-hover: #F1F5F9;

  /* Border */
  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;

  /* Blue primary palette */
  --primary: #2563EB;
  --primary-strong: #1D4ED8;
  --primary-soft: #EFF6FF;
  --primary-border: #BFDBFE;
  --indigo: #6366F1;
  --indigo-soft: #EEF2FF;
  --indigo-border: #C7D2FE;

  /* Status */
  --green: #16A34A;
  --green-soft: #F0FDF4;
  --green-border: #BBF7D0;
  --yellow: #D97706;
  --yellow-soft: #FFFBEB;
  --yellow-border: #FDE68A;
  --red: #DC2626;
  --red-soft: #FEF2F2;
  --red-border: #FECACA;
  --violet: #7C3AED;
  --violet-soft: #F5F3FF;
  --violet-border: #DDD6FE;

  /* Geometry */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-md: 14px;
  --radius-lg: 16px;
  --sidebar-w: 248px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

  /* Motion */
  --transition: all 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
svg { display: block; flex-shrink: 0; }

/* ============================ App shell ============================ */
.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* ============================ Sidebar ============================ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #60A5FA 0%, #2563EB 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo svg { width: 20px; height: 20px; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-text small {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.sidebar-close { display: none; }

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

.nav-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9.5px 12px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  cursor: pointer;
}

.nav-item svg { width: 18px; height: 18px; }

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

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

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--indigo-soft);
  color: var(--indigo);
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar svg { width: 17px; height: 17px; }

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.user-meta strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-meta small {
  font-size: 11px;
  color: var(--text-muted);
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-left: auto;
  box-shadow: 0 0 0 3px var(--green-soft);
}

/* ---- Session panel (sidebar) ---- */
.session-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.session-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.session-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.session-copy svg { width: 13px; height: 13px; }

.session-copy:hover { background: var(--bg-hover); color: var(--primary); }

.session-id {
  display: block;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 10px;
  word-break: break-all;
  user-select: all;
}

.session-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-block { width: 100%; }

.btn-block svg { width: 13px; height: 13px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 39;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-overlay.show { opacity: 1; }

/* ============================ Main ============================ */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
}

/* ============================ Topbar ============================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

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

#navToggle { display: none; }

.page-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.page-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-icon svg { width: 17px; height: 17px; }

.page-title-wrap { min-width: 0; }

.page-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-crumb {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-crumb span { margin: 0 5px; color: var(--border-strong); }

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

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.date-badge svg { width: 14px; height: 14px; color: var(--primary); }

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn svg { width: 17px; height: 17px; }

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.icon-btn:active { transform: scale(0.95); }

.notif-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  border: 1.5px solid var(--bg-surface);
}

.avatar-badge {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #60A5FA 0%, #2563EB 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: var(--shadow-xs);
}

/* ============================ Content ============================ */
.content {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

.section {
  margin-bottom: 32px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.section-head p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ============================ Buttons ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  line-height: 1;
}

.btn svg { width: 15px; height: 15px; }

.btn:active { transform: scale(0.97); }

.btn:focus-visible,
.icon-btn:focus-visible,
.nav-item:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

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

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

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-ghost {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
}

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

.btn-ghost-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}

.btn-ghost-danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-sm { padding: 8px 14px; font-size: 12.5px; }

/* ============================ Welcome banner ============================ */
.welcome-banner {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, #EFF6FF 0%, #E0EAFF 55%, #F5F3FF 100%);
  border: 1px solid var(--primary-border);
  padding: 30px 34px;
  margin-bottom: 32px;
}

.welcome-text { position: relative; z-index: 1; max-width: 560px; }

.welcome-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--primary-border);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.welcome-text h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-text p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.welcome-decor { position: absolute; inset: 0; pointer-events: none; }

.deco {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

.deco-1 { width: 180px; height: 180px; top: -70px; right: -30px; }
.deco-2 { width: 110px; height: 110px; bottom: -48px; right: 130px; background: rgba(99, 102, 241, 0.08); }
.deco-3 { width: 56px; height: 56px; top: 18px; right: 220px; background: rgba(255, 255, 255, 0.55); }

/* ============================ Stat cards ============================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  min-width: 0;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}

.stat-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg { width: 19px; height: 19px; }

.stat-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-icon.indigo { background: var(--indigo-soft); color: var(--indigo); }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.violet { background: var(--violet-soft); color: var(--violet); }

.stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-info strong {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-info span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}

.stat-info small {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================ Create box ============================ */
.create-box {
  background: var(--bg-surface);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
  animation: slideDown 200ms ease;
}

.create-box.hidden { display: none; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.create-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 13px;
}

.create-title-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.create-title-icon svg { width: 14px; height: 14px; }

.create-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.create-field { flex: 1; min-width: 0; }

.create-field input,
.create-field select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-soft);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  transition: var(--transition);
  min-height: 40px;
}

.create-field input::placeholder { color: var(--text-muted); font-weight: 400; }

.create-field input:hover,
.create-field select:hover { border-color: var(--border-strong); }

.create-field input:focus,
.create-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: var(--bg-surface);
}

.create-field select {
  appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
}

.domain-field { flex: 0 0 190px; }

/* ============================ Email card ============================ */
.email-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  margin-bottom: 16px;
}

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

.email-badge-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.email-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-size: 11.5px;
  font-weight: 600;
}

.email-badge svg { width: 13px; height: 13px; }

.email-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.email-status.offline .status-dot { background: var(--text-muted); box-shadow: 0 0 0 3px var(--bg-hover); }

.email-address-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.email-select-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.email-select-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--primary);
  pointer-events: none;
}

#inboxSelect {
  width: 100%;
  padding: 13px 40px 13px 42px;
  background: var(--bg-soft);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: -0.2px;
  appearance: none;
  cursor: pointer;
  transition: var(--transition);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 14px center;
  background-repeat: no-repeat;
  background-size: 16px;
}

#inboxSelect:hover { border-color: var(--border-strong); background-color: var(--bg-surface); }

#inboxSelect:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background-color: var(--bg-surface);
}

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

.email-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.email-card-foot svg { width: 14px; height: 14px; color: var(--primary); }

/* ============================ Panel / message list ============================ */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.panel-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.panel-head-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-head-icon svg { width: 15px; height: 15px; }

.panel-head h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  word-break: break-all;
}

.count-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  padding: 4px 11px;
  border-radius: 999px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.message-list { min-height: 240px; }

.message-item {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}

.message-item:last-child { border-bottom: none; }

.message-item:hover {
  background: var(--bg-hover);
}

.message-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--bg-hover);
}

.message-item.unread { background: var(--primary-soft); }
.message-item.unread:hover { background: #E4EDFB; }

.sender-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--indigo-soft);
  color: var(--indigo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.message-content { flex: 1; min-width: 0; }

.message-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.message-sender {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.message-time {
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.message-subject {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 3px;
  word-break: break-word;
  letter-spacing: -0.1px;
}

.message-subject:empty { display: none; }

.message-body {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 5px;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.message-body:empty { display: none; }

.unread-dot {
  align-self: center;
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary);
}

/* ============================ Cards / generic ============================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

/* ============================ Stats bars ============================ */
.stats-bars { padding: 20px; }

.bar-row { margin-bottom: 16px; }
.bar-row:last-child { margin-bottom: 0; }

.bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.bar-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 2px 9px;
  border-radius: 999px;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #60A5FA 0%, var(--primary) 100%);
  transition: width 0.4s ease;
  width: 0;
}

/* ============================ Activity ============================ */
.activity-card { overflow: hidden; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.activity-item:last-child { border-bottom: none; }

.activity-item:hover { background: var(--bg-hover); }

.activity-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-icon svg { width: 16px; height: 16px; }

.activity-body { flex: 1; min-width: 0; }

.activity-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.activity-sender {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.activity-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.activity-subject {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  word-break: break-word;
}

/* ============================ Services ============================ */
.service-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.service-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 22px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  min-width: 0;
}

.service-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.service-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.service-icon svg { width: 19px; height: 19px; }

.service-icon.blue { background: var(--primary-soft); color: var(--primary); }
.service-icon.green { background: var(--green-soft); color: var(--green); }
.service-icon.violet { background: var(--violet-soft); color: var(--violet); }

.service-card h4 {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.service-card p {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 14px;
  flex: 1;
}

.service-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  transition: var(--transition);
}

.service-action svg { width: 14px; height: 14px; transition: transform 0.2s ease; }

.service-action:hover { color: var(--primary-strong); }
.service-action:hover svg { transform: translateX(3px); }

/* ============================ Empty states ============================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  text-align: center;
}

.empty-state.compact { padding: 36px 20px; }

.empty-state .icon {
  font-size: 34px;
  margin-bottom: 12px;
  opacity: 0.5;
  filter: grayscale(0.4);
}

.empty-state .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.empty-state .sub {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.6;
}

/* ============================ Footer ============================ */
footer {
  text-align: center;
  padding: 24px 0 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

footer a { color: var(--text-muted); transition: var(--transition); }
footer a span { color: var(--primary); font-weight: 600; transition: var(--transition); }
footer a:hover { color: var(--text-secondary); }
footer a:hover span { color: var(--primary-strong); }

/* ============================ Toast ============================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  background: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toastIn 250ms ease;
}

.toast.fadeout { animation: toastOut 200ms ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

/* ============================ Email reader modal ============================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: min(85vh, 760px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-head-text { min-width: 0; }

.modal-eyebrow {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 5px;
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 22px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-meta span { display: inline-flex; align-items: center; gap: 5px; }
.modal-meta svg { width: 12.5px; height: 12.5px; color: var(--primary); }

.modal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-toolbar .btn { padding: 7px 12px; font-size: 12px; }
.modal-toolbar .btn svg { width: 13px; height: 13px; }

.modal-body {
  overflow-y: auto;
  padding: 20px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-email-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--indigo-soft);
  color: var(--indigo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.modal-email-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modal-from {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.modal-to {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.modal-email-body {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal-email-body:empty::after {
  content: '(tidak ada isi pesan)';
  color: var(--text-muted);
  font-style: italic;
}

/* ============================ Focus visible ============================ */
.btn:focus-visible,
.icon-btn:focus-visible,
.nav-item:focus-visible,
.service-action:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================ Responsive: tablet ============================ */
@media (max-width: 1199px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 24px 24px 44px; }
}

/* ============================ Responsive: mobile ============================ */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .sidebar-overlay.show { display: block; }

  .main { margin-left: 0; }

  #navToggle { display: inline-flex; }

  .topbar { padding: 10px 14px; }

  .date-badge { display: none; }

  .content { padding: 18px 14px 36px; }

  .welcome-banner { padding: 22px 20px; }
  .welcome-text h2 { font-size: 21px; }
  .deco-1 { width: 120px; height: 120px; }
  .deco-3 { display: none; }

  .stat-grid { grid-template-columns: 1fr; }

  .section-head { flex-wrap: wrap; }
  .section-head .btn { width: 100%; }

  .create-row {
    flex-direction: column;
    gap: 8px;
  }

  .domain-field { flex: none; }
  .create-field select { width: 100%; }

  .email-address-row { flex-direction: column; align-items: stretch; }
  .email-select-wrap { min-width: 0; }
  .email-actions { justify-content: stretch; }
  .email-actions .btn { flex: 1; justify-content: center; }

  .email-card-head { flex-direction: column; align-items: flex-start; }

  .panel-head { padding: 13px 14px; }

  .message-item { padding: 13px 14px; }

  .message-top { flex-direction: column; gap: 2px; align-items: flex-start; }

  .service-grid { grid-template-columns: 1fr; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-dialog {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-head { padding: 16px 16px 12px; }
  .modal-meta { padding: 10px 16px; }
  .modal-toolbar { padding: 10px 16px; }
  .modal-body { padding: 16px; }
  .modal-email-body { padding: 14px; }

  .toast-container { left: 14px; right: 14px; bottom: 14px; align-items: center; }
}

/* ============================ Responsive: small phone ============================ */
@media (max-width: 480px) {
  .page-crumb { display: none; }

  .avatar-badge { width: 32px; height: 32px; }

  .stat-card { padding: 16px; }

  .email-actions .btn { padding: 9px 10px; font-size: 12px; }
}

/* ============================ Reduced motion ============================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
