:root {
  --bg-base: #070a0f;
  --bg-surface: #0c111a;
  --bg-card: #121927;
  --bg-card-hover: #172133;
  --bg-active: rgba(16, 185, 129, 0.12);
  
  --primary: #10b981;
  --primary-hover: #34d399;
  --primary-glow: rgba(16, 185, 129, 0.25);
  
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  
  --danger: #ef4444;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.mail-header {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--primary);
}

.brand-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-name {
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.brand-name strong {
  color: var(--primary);
}

.brand-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.header-center {
  flex: 1;
  max-width: 520px;
  margin: 0 20px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  gap: 8px;
  transition: border-color 0.15s ease;
}

.search-box:focus-within {
  border-color: var(--border-focus);
}

.search-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  color: var(--text-faint);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  width: 100%;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.security-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 8px 4px 4px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

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

.user-email-label {
  font-size: 12px;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 4px;
}

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

.btn-logout svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

/* Auth View */
.auth-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, rgba(16, 185, 129, 0.05) 0%, transparent 60%);
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-highlight {
  font-size: 10px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary);
  padding: 2px 5px;
  border-radius: 3px;
}

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

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

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

.input-with-suffix {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.input-with-suffix:focus-within {
  border-color: var(--border-focus);
}

.input-with-suffix input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.suffix-pill {
  padding: 0 12px;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-group input:focus {
  border-color: var(--border-focus);
}

.field-hint {
  font-size: 11px;
  color: var(--text-faint);
}

.perks-card {
  background: rgba(16, 185, 129, 0.04);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.perk-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.perk-icon {
  font-size: 16px;
}

.perk-info strong {
  display: block;
  font-size: 12px;
  color: var(--primary);
}

.perk-info span {
  font-size: 11px;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 16px var(--primary-glow);
}

.btn-outline {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.auth-alert {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
}

.auth-alert.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.auth-alert.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--primary);
}

/* Mail Workspace */
.mail-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 360px 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Col 1: Sidebar */
.sidebar-folders {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

.sidebar-top {
  margin-bottom: 16px;
}

.btn-compose {
  width: 100%;
  background: var(--primary);
  color: #000;
  padding: 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-compose:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 12px var(--primary-glow);
}

.folders-nav {
  flex: 1;
  overflow-y: auto;
}

.folder-group-title {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.8px;
  margin: 12px 8px 6px;
}

.folders-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.folder-item svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  color: var(--text-faint);
}

.folder-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

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

.folder-item.active svg {
  color: var(--primary);
}

.folder-label {
  flex: 1;
}

.folder-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
}

.folder-item.active .folder-badge {
  background: var(--primary);
  color: #000;
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.quota-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.quota-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 6px;
}

.quota-title {
  color: var(--text-muted);
}

.quota-value {
  color: var(--primary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.quota-bar-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.quota-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.quota-footer {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-faint);
}

.btn-config-client {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-config-client:hover {
  border-color: var(--border-focus);
  color: var(--primary);
}

.btn-config-client svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

/* Col 2: Mail List */
.mail-list-panel {
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.panel-header {
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
}

.panel-count {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}

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

.btn-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.messages-scroll {
  flex: 1;
  overflow-y: auto;
}

.mail-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s ease;
  position: relative;
}

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

.mail-item.selected {
  background: var(--bg-card-hover);
  border-left: 3px solid var(--primary);
}

.mail-item.unread .mail-subject {
  font-weight: 700;
  color: #fff;
}

.mail-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.mail-sender {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-date {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.mail-subject {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.mail-snippet {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-unread-indicator {
  position: absolute;
  top: 14px;
  left: 6px;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
}

/* Col 3: Reading Pane */
.mail-reader-panel {
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

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

.empty-icon {
  font-size: 40px;
}

.reader-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.reader-toolbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-left {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.verified-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.verified-tag svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.reader-head {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.reader-subject {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.sender-info-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sender-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #000;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.sender-meta {
  flex: 1;
}

.sender-from-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.sender-date {
  color: var(--text-faint);
  font-size: 11px;
  font-family: var(--font-mono);
}

.sender-to-line {
  font-size: 12px;
  color: var(--text-muted);
}

.reader-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.body-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #d1d5db;
}

.body-html-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
  border-radius: 4px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  width: 100%;
  max-width: 620px;
  background: var(--bg-surface);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
}

.modal-dialog.modal-config {
  max-width: 680px;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}

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

.compose-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.form-row label {
  width: 60px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-row input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}

.form-row input:focus {
  border-color: var(--border-focus);
}

.compose-editor textarea {
  width: 100%;
  height: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 14px;
  resize: vertical;
  outline: none;
}

.compose-editor textarea:focus {
  border-color: var(--border-focus);
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Config modal grid */
.modal-body {
  padding: 20px;
}

.config-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.config-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 6px;
}

.config-box h4 {
  font-size: 13px;
  color: var(--primary);
  margin-bottom: 10px;
}

.cfg-item {
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.cfg-item .k {
  color: var(--text-muted);
}

.cfg-item .v {
  color: #fff;
  font-family: var(--font-mono);
}

.config-note {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(16, 185, 129, 0.05);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 4px;
}
