:root {
  --bg: #050711;
  --panel: rgba(12, 16, 31, 0.9);
  --panel-strong: #10162a;
  --ink: #f5f8ff;
  --muted: #9aa8c4;
  --line: rgba(99, 243, 255, 0.18);
  --cyan: #26f7ff;
  --green: #39ff88;
  --pink: #ff3df2;
  --yellow: #fff36b;
  --danger: #ff5572;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
  --inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(99, 243, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 243, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 12% 8%, rgba(255, 61, 242, 0.16), transparent 26rem),
    radial-gradient(circle at 88% 2%, rgba(38, 247, 255, 0.16), transparent 28rem),
    linear-gradient(135deg, #050711 0%, #0d1020 48%, #061114 100%);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  border: 1px solid rgba(99, 243, 255, 0.14);
  border-radius: 8px;
  padding: 12px;
  background: rgba(5, 8, 18, 0.62);
  box-shadow: var(--shadow), var(--inset);
}

.brand,
.status-pill,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 1px solid rgba(38, 247, 255, 0.6);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(38, 247, 255, 0.96), rgba(57, 255, 136, 0.95) 58%, rgba(255, 61, 242, 0.88)),
    var(--cyan);
  box-shadow: 0 0 28px rgba(38, 247, 255, 0.32);
}

.brand p,
.brand strong,
.status-pill strong,
.status-pill small {
  display: block;
  overflow-wrap: anywhere;
}

.brand p,
.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand strong {
  font-size: 1.12rem;
}

.status-pill {
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(12, 16, 31, 0.94), rgba(7, 10, 22, 0.84));
  box-shadow: var(--inset);
}

.topbar-actions {
  margin-left: auto;
}

.admin-link,
.logout-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--cyan);
  background: rgba(7, 10, 22, 0.84);
  font-weight: 850;
  text-decoration: none;
}

.logout-button {
  color: var(--pink);
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(57, 255, 136, 0.13), 0 0 22px rgba(57, 255, 136, 0.5);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(255, 85, 114, 0.45);
}

.status-pill small,
.muted,
.panel-heading p,
.compact-title p,
.stats-strip span,
.meta-line span {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(290px, 370px) minmax(0, 1fr);
  gap: 16px;
}

.composer,
.inbox-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 110px),
    var(--panel);
  box-shadow: var(--shadow), var(--inset);
  backdrop-filter: blur(18px);
}

.composer {
  align-self: start;
  padding: 18px;
}

.panel-heading {
  display: flex;
  gap: 12px;
  align-items: center;
}

.panel-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: #071015;
  background: var(--green);
  box-shadow: 0 0 26px rgba(57, 255, 136, 0.34);
  font-size: 1.6rem;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.panel-heading h1 {
  margin-bottom: 4px;
  font-size: 1.28rem;
  line-height: 1.1;
}

.panel-heading p {
  margin-bottom: 0;
  line-height: 1.45;
}

.email-form,
.sequence-box,
.current-mail,
.history-block {
  margin-top: 20px;
}

.email-form label,
.sequence-box > label,
.sequence-grid label,
.current-mail > span {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.address-row {
  display: flex;
  align-items: center;
  min-height: 52px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 6, 16, 0.86);
  overflow: hidden;
}

.address-row input {
  min-width: 0;
  flex: 1;
  height: 52px;
  border: 0;
  padding: 0 13px;
  color: var(--ink);
  background: transparent;
  outline: 0;
  font-weight: 800;
}

.address-row span {
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--cyan);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

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

.action-row {
  margin-top: 12px;
}

.primary-action,
.ghost-action,
.sequence-action,
.icon-button,
.toggle,
.compact-title button,
.mail-copy,
.history-item,
.delete-message {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(7, 10, 22, 0.84);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.primary-action,
.sequence-action {
  color: #031010;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  border-color: rgba(57, 255, 136, 0.62);
  font-weight: 900;
  box-shadow: 0 0 24px rgba(38, 247, 255, 0.22);
}

.primary-action:active,
.sequence-action:active,
.ghost-action:active,
.icon-button:active {
  transform: translateY(0);
}

.primary-action {
  flex: 1;
}

.ghost-action {
  padding: 0 14px;
  color: var(--pink);
  font-weight: 850;
}

.primary-action:hover,
.ghost-action:hover,
.sequence-action:hover,
.icon-button:hover,
.compact-title button:hover,
.mail-copy:hover,
.history-item:hover,
.delete-message:hover {
  transform: translateY(-1px);
  border-color: rgba(38, 247, 255, 0.74);
  box-shadow: 0 0 22px rgba(38, 247, 255, 0.18);
}

.sequence-box,
.history-block {
  padding-top: 18px;
  border-top: 1px solid rgba(111, 255, 233, 0.16);
}

.compact-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.compact-title h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.compact-title p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.compact-title button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 850;
}

.plain-input,
.sequence-grid input,
.sequence-grid select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(5, 8, 18, 0.72);
  outline: 0;
  font-weight: 800;
}

.plain-input {
  margin-top: 8px;
}

.sequence-grid {
  display: grid;
  grid-template-columns: minmax(95px, 0.8fr) minmax(120px, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.sequence-action {
  width: 100%;
  margin-top: 10px;
}

.mail-copy {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 13px;
  text-align: left;
  border-style: dashed;
}

.mail-copy strong,
.mail-copy small {
  display: block;
  overflow-wrap: anywhere;
}

.mail-copy small {
  margin-top: 4px;
  color: var(--green);
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.history-item {
  width: 100%;
  padding: 10px;
  text-align: left;
  overflow-wrap: anywhere;
}

.inbox-panel {
  min-width: 0;
  overflow: hidden;
}

.inbox-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.inbox-toolbar h2 {
  margin-bottom: 0;
  font-size: clamp(1.2rem, 2.4vw, 2rem);
  overflow-wrap: anywhere;
}

.icon-button {
  width: 44px;
  font-size: 1.15rem;
}

.icon-button:disabled,
.mail-copy:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 850;
}

.toggle input {
  accent-color: var(--green);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 8, 18, 0.36);
}

.stats-strip div {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.stats-strip div:last-child {
  border-right: 0;
}

.stats-strip strong,
.stats-strip span {
  display: block;
}

.stats-strip strong {
  font-size: 1.32rem;
}

.mail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  min-height: 620px;
}

.message-list {
  border-right: 1px solid var(--line);
  background: rgba(8, 12, 26, 0.6);
  overflow: auto;
}

.message-item {
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 16px;
  border: 0;
  border-bottom: 1px solid rgba(111, 255, 233, 0.14);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.message-item.active {
  background: linear-gradient(90deg, rgba(38, 247, 255, 0.13), rgba(38, 247, 255, 0.025));
  box-shadow: inset 4px 0 0 var(--cyan);
}

.message-item.new {
  box-shadow: inset 4px 0 0 var(--green);
}

.sender {
  color: var(--cyan);
  font-size: 0.86rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject {
  overflow-wrap: anywhere;
}

.meta {
  color: var(--muted);
}

.empty-state,
.reader-empty {
  display: grid;
  min-height: 360px;
  place-items: center;
  align-content: center;
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.empty-state span,
.reader-empty span {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 50%;
  color: #061015;
  background: var(--cyan);
  box-shadow: 0 0 26px rgba(38, 247, 255, 0.38);
  font-size: 1.5rem;
  font-weight: 900;
}

.empty-state h3,
.reader-empty h3 {
  margin-bottom: 8px;
  color: var(--ink);
}

.empty-state p,
.reader-empty p {
  max-width: 320px;
  margin-bottom: 0;
  line-height: 1.5;
}

.reader {
  min-width: 0;
  background: rgba(4, 7, 17, 0.86);
  overflow: hidden;
}

.reader-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.reader-header h3 {
  margin: 8px 0 0;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.meta-grid {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.meta-line {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.meta-line strong {
  overflow-wrap: anywhere;
}

.reader-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.delete-message {
  padding: 0 14px;
  color: var(--danger);
  font-weight: 900;
}

.message-body {
  padding: 18px;
  overflow: auto;
}

.text-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  line-height: 1.6;
}

.html-frame {
  width: 100%;
  min-height: 500px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.attachment-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.attachment-list a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(5, 8, 18, 0.72);
  font-weight: 800;
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  padding: 13px 15px;
  border: 1px solid rgba(57, 255, 136, 0.42);
  border-radius: 8px;
  color: #04100d;
  background: var(--green);
  box-shadow: 0 0 28px rgba(57, 255, 136, 0.32);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  font-weight: 850;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(38, 247, 255, 0.06), transparent 130px),
    var(--panel);
  box-shadow: var(--shadow), var(--inset);
}

.login-brand {
  margin-bottom: 22px;
}

.login-form,
.admin-card {
  display: grid;
  gap: 12px;
}

.login-form label,
.admin-card label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(3, 6, 16, 0.86);
  outline: 0;
  font-weight: 800;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--yellow);
  font-weight: 800;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.admin-card {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 120px),
    var(--panel);
  box-shadow: var(--shadow), var(--inset);
}

.admin-card h1,
.admin-card h2 {
  margin-bottom: 0;
  font-size: 1.22rem;
}

.admin-submit {
  margin-top: 4px;
}

.admin-wide {
  grid-column: 1 / -1;
}

.admin-main-card {
  min-width: 0;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(111, 255, 233, 0.16);
  border-radius: 8px;
  padding: 12px;
  background: rgba(3, 6, 16, 0.68);
}

.admin-row strong,
.admin-row small {
  display: block;
  overflow-wrap: anywhere;
}

.admin-row small {
  margin-top: 4px;
  color: var(--muted);
}

.admin-row button {
  flex: 0 0 auto;
}

.admin-row-info {
  min-width: 0;
}

.admin-row-controls {
  display: grid;
  grid-template-columns: 110px minmax(150px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: min(620px, 62%);
}

.admin-row-controls select,
.admin-row-controls input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(5, 8, 18, 0.82);
  outline: 0;
  font-weight: 800;
}

.admin-row-controls .ghost-action,
.admin-row-controls .delete-message {
  min-height: 38px;
  padding: 0 12px;
}

.admin-row button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

@media (max-width: 980px) {
  .workspace,
  .mail-layout {
    grid-template-columns: 1fr;
  }

  .message-list {
    max-height: 360px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar,
  .inbox-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    max-width: none;
  }

  .topbar-actions {
    width: 100%;
    margin-left: 0;
  }

  .admin-link,
  .logout-button {
    flex: 1;
  }

  .composer,
  .inbox-toolbar,
  .reader-header,
  .message-body {
    padding: 14px;
  }

  .action-row,
  .toolbar-actions {
    align-items: stretch;
    width: 100%;
  }

  .primary-action,
  .ghost-action,
  .icon-button,
  .toggle {
    flex: 1;
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }

  .stats-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-strip div:last-child {
    border-bottom: 0;
  }

  .address-row {
    display: grid;
  }

  .address-row span {
    padding: 0 13px 12px;
  }

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

  .admin-wide {
    grid-column: auto;
  }

  .admin-row {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-row-controls {
    grid-template-columns: 1fr;
    min-width: 0;
  }
}
