:root {
  --bg-dark: #050d1e;
  --bg-card: rgba(9, 22, 46, 0.92);
  --bg-card-inner: rgba(13, 31, 64, 0.78);
  --border-subtle: rgba(16, 185, 129, 0.25);
  --border-glow: rgba(16, 185, 129, 0.55);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-green: #10b981;
  --accent-green-light: #34d399;
  --accent-green-dark: #059669;
  --accent-blue: #1e3a8a;
  --grad-green: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --grad-green-bright: linear-gradient(90deg, #059669 0%, #10b981 50%, #34d399 100%);
  --grad-navy: linear-gradient(145deg, rgba(11, 27, 56, 0.95) 0%, rgba(6, 16, 36, 0.98) 100%);
}

[hidden] {
  display: none !important;
}

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

body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.14) 0%, transparent 42%),
    radial-gradient(circle at 85% 20%, rgba(30, 64, 175, 0.22) 0%, transparent 45%),
    linear-gradient(rgba(16, 185, 129, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 185, 129, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 36px 36px, 36px 36px;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

.tm-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.tm-header {
  border-bottom: 1px solid rgba(16, 185, 129, 0.18);
  background: rgba(5, 13, 30, 0.9);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tm-header-inner {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

.tm-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--grad-green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.45);
}

.tm-brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.tm-brand-sub {
  font-size: 12px;
  color: #6ee7b7;
  font-weight: 600;
}

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

.tm-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
  font-size: 12.5px;
  font-weight: 600;
}

.tm-admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  transition: all 0.18s ease;
}

.tm-admin-link:hover {
  background: var(--grad-green);
  color: #ffffff;
}

.tm-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.65; }
}

/* Main Content */
.tm-main {
  padding-top: 28px;
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.tm-control-card {
  background: var(--grad-navy);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 35px rgba(16, 185, 129, 0.1);
  backdrop-filter: blur(20px);
}

.tm-eyebrow {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent-green-light);
  margin-bottom: 6px;
}

.tm-headline {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 6px;
}

.tm-subline {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.tm-subline strong {
  color: #6ee7b7;
}

/* Active Email Display Bar */
.tm-active-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(13, 37, 76, 0.9) 0%, rgba(6, 78, 59, 0.45) 100%);
  border: 1.5px solid rgba(16, 185, 129, 0.48);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tm-active-label {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #34d399;
  margin-bottom: 4px;
}

.tm-active-email {
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  word-break: break-all;
}

.tm-active-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* All Buttons Unified in Emerald Green Theme */
.tm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
  color: #ffffff;
  white-space: nowrap;
}

.tm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tm-btn-primary,
.tm-btn-accent,
.tm-btn-secondary,
.tm-btn-copy,
.tm-btn-refresh,
.tm-btn-otp-copy {
  background: var(--grad-green);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.3);
}

.tm-btn-primary:hover:not(:disabled),
.tm-btn-accent:hover:not(:disabled),
.tm-btn-secondary:hover:not(:disabled),
.tm-btn-copy:hover:not(:disabled),
.tm-btn-refresh:hover:not(:disabled),
.tm-btn-otp-copy:hover:not(:disabled) {
  background: var(--grad-green-bright);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.48);
}

/* Action Grid */
.tm-action-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
}

.tm-action-box {
  background: var(--bg-card-inner);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 16px;
  padding: 16px;
}

.tm-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tm-box-badge,
.tm-badge-purple {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.tm-box-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.tm-input-group {
  display: flex;
  gap: 10px;
}

.tm-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(5, 13, 30, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: 12px;
  padding: 0 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tm-input-wrap:focus-within {
  border-color: var(--accent-green-light);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

.tm-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 4px;
  min-width: 0;
}

.tm-domain-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: #6ee7b7;
  font-weight: 600;
  padding-left: 6px;
  user-select: none;
}

.tm-generate-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tm-custom-form {
  flex: 1;
  display: flex;
  gap: 8px;
  min-width: 200px;
}

.tm-custom-form input {
  flex: 1;
  background: rgba(5, 13, 30, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  color: #fff;
  font-size: 13.5px;
  outline: none;
  min-width: 0;
}

.tm-custom-form input:focus {
  border-color: var(--accent-green-light);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

.tm-error-alert {
  margin-top: 14px;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 13.5px;
  font-weight: 600;
}

/* History Chips */
.tm-history-bar {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(16, 185, 129, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tm-history-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.tm-history-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(13, 31, 64, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #cbd5e1;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tm-chip:hover,
.tm-chip.active {
  background: rgba(16, 185, 129, 0.24);
  border-color: var(--accent-green-light);
  color: #fff;
}

.tm-chip-del {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}

.tm-chip-del:hover {
  color: #f87171;
}

/* OTP Spotlight Banner */
.tm-otp-spotlight {
  background: linear-gradient(135deg, rgba(13, 37, 76, 0.92) 0%, rgba(6, 78, 59, 0.65) 100%);
  border: 1.5px solid #10b981;
  border-radius: 18px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 12px 35px rgba(16, 185, 129, 0.22);
  flex-wrap: wrap;
}

.tm-otp-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #6ee7b7;
  margin-bottom: 4px;
}

.tm-otp-meta {
  font-size: 13.5px;
  color: #d1fae5;
  font-weight: 600;
}

.tm-otp-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.tm-otp-digits {
  font-family: "JetBrains Mono", monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #ffffff;
  background: rgba(5, 13, 30, 0.65);
  padding: 8px 18px;
  border-radius: 12px;
  border: 1px solid rgba(16, 185, 129, 0.55);
}

/* Workspace Split View */
.tm-workspace {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 20px;
  min-height: 540px;
}

.tm-inbox-panel,
.tm-reader-panel {
  background: var(--grad-navy);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tm-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.16);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tm-panel-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tm-panel-title {
  font-size: 16px;
  font-weight: 800;
}

.tm-msg-count {
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
}

.tm-autorefresh-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.tm-spinner-mini {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(16, 185, 129, 0.3);
  border-top-color: var(--accent-green-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.tm-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 620px;
}

.tm-msg-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(13, 31, 64, 0.55);
  border: 1px solid rgba(16, 185, 129, 0.14);
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
}

.tm-msg-item:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.4);
}

.tm-msg-item.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(13, 37, 76, 0.85) 100%);
  border-color: var(--accent-green-light);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.tm-msg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tm-msg-sender {
  font-size: 13.5px;
  font-weight: 800;
  color: #fff;
}

.tm-msg-time {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tm-msg-subject {
  font-size: 13.5px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 6px;
  line-height: 1.35;
}

.tm-msg-snippet {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tm-msg-otp-pill {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  font-weight: 800;
}

/* Empty States */
.tm-empty-state,
.tm-reader-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.tm-empty-icon {
  font-size: 42px;
  margin-bottom: 12px;
}

.tm-empty-state h3,
.tm-reader-empty h3 {
  color: #f1f5f9;
  font-size: 16px;
  margin-bottom: 6px;
}

.tm-empty-state p,
.tm-reader-empty p {
  font-size: 13.5px;
  max-width: 320px;
  line-height: 1.5;
}

/* Reader Panel */
.tm-reader-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
}

.tm-reader-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.16);
  background: rgba(9, 22, 46, 0.96);
}

.tm-reader-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.tm-reader-sender {
  font-size: 14px;
  font-weight: 800;
  color: #34d399;
}

.tm-reader-time {
  font-size: 12.5px;
  color: var(--text-muted);
}

.tm-reader-subject {
  font-size: 19px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 6px;
}

.tm-reader-to {
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
}

.tm-reader-extracted {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed rgba(16, 185, 129, 0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tm-action-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--grad-green);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.tm-reader-frame-wrap {
  flex: 1;
  background: #ffffff;
  min-height: 440px;
  position: relative;
}

.tm-reader-iframe {
  width: 100%;
  height: 100%;
  min-height: 440px;
  border: none;
  display: block;
}

/* Admin Panel Specific Styles */
.tm-admin-grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 22px;
  align-items: start;
}

.tm-form-field {
  margin-bottom: 14px;
}

.tm-form-field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: #6ee7b7;
  margin-bottom: 6px;
  letter-spacing: 0.4px;
}

.tm-form-field input,
.tm-form-field select {
  width: 100%;
  background: rgba(5, 13, 30, 0.9);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 11px;
  padding: 11px 14px;
  color: #ffffff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}

.tm-form-field input:focus,
.tm-form-field select:focus {
  border-color: var(--accent-green-light);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

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

.tm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tm-table th {
  text-align: left;
  padding: 12px 14px;
  color: #6ee7b7;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}

.tm-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

@media (max-width: 960px) {
  .tm-action-grid,
  .tm-workspace,
  .tm-admin-grid {
    grid-template-columns: 1fr;
  }
  .tm-message-list {
    max-height: 360px;
  }
}

@media (max-width: 600px) {
  .tm-control-card {
    padding: 18px;
  }
  .tm-headline {
    font-size: 20px;
  }
  .tm-active-email {
    font-size: 16px;
  }
  .tm-input-group {
    flex-direction: column;
  }
  .tm-otp-digits {
    font-size: 22px;
  }
}
