:root {
  --bg: #070d19;
  --bg-soft: #101b30;
  --surface: rgba(10, 18, 34, 0.74);
  --surface-strong: rgba(18, 30, 52, 0.86);
  --surface-soft: rgba(255, 255, 255, 0.04);
  --border: rgba(147, 176, 219, 0.24);
  --text: #eef4ff;
  --muted: #9fb3d2;
  --primary: #f9b233;
  --primary-deep: #df7b16;
  --primary-soft: #ffe5ae;
  --danger: #ff7b7b;
  --ring: rgba(249, 178, 51, 0.36);
  --shadow: 0 22px 56px rgba(2, 6, 18, 0.5);
}

[data-theme="light"] {
  --bg: #f0f4fb;
  --bg-soft: #ffffff;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(18, 44, 79, 0.04);
  --border: rgba(24, 45, 74, 0.14);
  --text: #14253d;
  --muted: #5a7091;
  --primary: #f0a31b;
  --primary-deep: #dc7310;
  --primary-soft: #ffe0a1;
  --danger: #cf4747;
  --ring: rgba(240, 163, 27, 0.26);
  --shadow: 0 18px 44px rgba(24, 45, 74, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "DM Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(76, 151, 255, 0.2), transparent 40%),
    radial-gradient(circle at 88% 88%, rgba(250, 172, 56, 0.22), transparent 44%),
    linear-gradient(140deg, var(--bg), var(--bg-soft));
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(42px);
  pointer-events: none;
  opacity: 0.9;
}

.bg-orb-a {
  left: -10rem;
  top: -10rem;
  background: rgba(57, 123, 250, 0.28);
}

.bg-orb-b {
  right: -10rem;
  bottom: -10rem;
  background: rgba(241, 153, 28, 0.26);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at 50% 45%, rgba(0, 0, 0, 0.85), transparent 86%);
}

.page-shell {
  width: min(1180px, 94vw);
  margin: 20px auto 26px;
  position: relative;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
  padding: 18px 20px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: fadeLift 460ms ease;
}

.brand-block {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  margin-top: 12px;
  background: linear-gradient(160deg, var(--primary-soft), var(--primary-deep));
  box-shadow:
    0 0 0 6px rgba(249, 178, 51, 0.17),
    0 10px 24px rgba(249, 178, 51, 0.4);
}

.hero h1 {
  margin: 0;
  font-family: "Sora", "DM Sans", sans-serif;
  letter-spacing: 0.045em;
  font-size: clamp(1.52rem, 2.8vw, 2.34rem);
  line-height: 1.05;
}

.brand-kicker {
  display: inline-block;
  margin: 7px 0 2px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-soft);
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.hero-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.hero-link {
  text-decoration: none;
  font-weight: 700;
  color: var(--text);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 9px 13px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.hero-link:hover {
  transform: translateY(-1px);
  border-color: rgba(249, 178, 51, 0.6);
  background: rgba(249, 178, 51, 0.12);
}

.dashboard {
  display: grid;
  grid-template-columns: 336px 1fr;
  gap: 14px;
}

.panel {
  border-radius: 20px;
  border: 1px solid var(--border);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 34%);
  pointer-events: none;
}

.panel-side {
  display: grid;
  align-content: start;
  gap: 13px;
  animation: fadeLift 540ms ease;
}

.panel-main {
  display: grid;
  align-content: start;
  gap: 12px;
  animation: fadeLift 620ms ease;
}

.section-label {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

.address-box {
  position: relative;
  border: 1px dashed rgba(159, 187, 230, 0.4);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border-radius: 14px;
  padding: 13px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  word-break: break-all;
}

.address-box::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(110deg, transparent 12%, rgba(255, 255, 255, 0.26) 42%, transparent 70%);
  transform: translateX(-130%);
  animation: shine 3.7s ease-in-out infinite;
  pointer-events: none;
}

[data-theme="light"] .address-box {
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.72));
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-group label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 11px 12px;
  font-family: inherit;
  font-size: 0.97rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus {
  border-color: rgba(249, 178, 51, 0.7);
  box-shadow: 0 0 0 4px var(--ring);
}

[data-theme="light"] input,
[data-theme="light"] select {
  background: rgba(255, 255, 255, 0.85);
}

input::placeholder {
  color: var(--muted);
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.98rem;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  color: #3b2403;
  background: linear-gradient(165deg, var(--primary-soft), var(--primary));
  box-shadow: 0 9px 24px rgba(249, 178, 51, 0.3);
}

.btn-outline {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.btn-outline:hover {
  border-color: rgba(249, 178, 51, 0.55);
  background: rgba(249, 178, 51, 0.12);
}

.btn-theme {
  min-width: 92px;
}

.status-pill {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: lowercase;
  background: rgba(255, 255, 255, 0.03);
}

.status-pill.error {
  color: var(--danger);
}

.inbox-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.inbox-head h2 {
  margin: 0;
  font-family: "Sora", "DM Sans", sans-serif;
  font-size: 1.45rem;
}

.inbox-head small {
  color: var(--muted);
  font-size: 0.95rem;
}

.inbox-grid {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 12px;
  min-height: 450px;
}

.list-wrap,
.preview-wrap {
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(0, 0, 0, 0.14);
}

[data-theme="light"] .list-wrap,
[data-theme="light"] .preview-wrap {
  background: rgba(255, 255, 255, 0.67);
}

.list-wrap {
  padding: 9px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  max-height: 520px;
}

.preview-wrap {
  padding: 13px;
  overflow: auto;
}

.message-item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.message-item:hover {
  transform: translateY(-1px);
  border-color: rgba(159, 187, 230, 0.55);
}

.message-item.active {
  border-color: rgba(249, 178, 51, 0.8);
  background: linear-gradient(120deg, rgba(249, 178, 51, 0.17), rgba(249, 178, 51, 0.07));
  box-shadow: inset 0 0 0 1px rgba(249, 178, 51, 0.22);
}

.message-from,
.message-time {
  color: var(--muted);
  font-size: 0.79rem;
}

.message-subject {
  font-size: 0.94rem;
  font-weight: 700;
}

.preview-placeholder,
.empty-state {
  color: var(--muted);
}

.error {
  color: var(--danger);
  margin: 0;
}

.preview-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.preview-title {
  margin: 0;
  font-family: "Sora", "DM Sans", sans-serif;
  font-size: 1.12rem;
}

.preview-switch {
  display: inline-flex;
  gap: 6px;
}

.preview-tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
}

.preview-tab.active {
  border-color: rgba(249, 178, 51, 0.8);
  background: rgba(249, 178, 51, 0.15);
}

.preview-meta {
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.preview-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.58;
}

.preview-html-shell {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-height: 330px;
  background: rgba(0, 0, 0, 0.2);
}

.preview-frame {
  width: 100%;
  min-height: 330px;
  border: 0;
  display: block;
}

@keyframes fadeLift {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shine {
  0% {
    transform: translateX(-130%);
  }
  55% {
    transform: translateX(130%);
  }
  100% {
    transform: translateX(130%);
  }
}

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .inbox-grid {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .list-wrap {
    max-height: 250px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    margin-top: 12px;
    margin-bottom: 16px;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    border-radius: 16px;
  }

  .hero-controls {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .hero p {
    font-size: 0.86rem;
  }

  .panel {
    padding: 13px;
    border-radius: 15px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .btn {
    padding: 10px;
    font-size: 0.92rem;
  }

  .preview-head-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .preview-switch {
    width: 100%;
  }

  .preview-tab {
    flex: 1;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
