:root {
  color-scheme: light;
  --bg: #f5f1ea;
  --text: #26211c;
  --muted: #746b62;
  --surface: rgba(255, 252, 247, 0.96);
  --surface-soft: #f8f4ed;
  --surface-strong: #fffdf9;
  --border: rgba(76, 58, 46, 0.10);
  --border-strong: rgba(76, 58, 46, 0.15);
  --accent: #b76440;
  --accent-strong: #9c5232;
  --accent-soft: rgba(183, 100, 64, 0.10);
  --accent-tint: rgba(183, 100, 64, 0.05);
  --error: #a7371d;
  --success: #1f6a3a;
  --shadow-soft: 0 2px 10px rgba(59, 40, 26, 0.04);
  --shadow-button: 0 2px 8px rgba(156, 82, 50, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  padding: 2rem 1.5rem;
  overflow-x: hidden;
}

.dashboard {
  width: min(100%, 70rem);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.dashboard-column {
  min-width: 0;
}

.dashboard-column-controls {
  grid-column: 1 / -1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
}

.content-panel {
  width: min(100%, 52rem);
  margin: 0 auto;
  padding: 1.1rem;
}

.controls-panel {
  width: min(100%, 52rem);
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
  justify-items: center;
}

.control-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.selected-company {
  margin: -0.15rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  text-wrap: balance;
}

.panel-kicker {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.controls-panel h2 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
}

.account-controls {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

.account-select {
  width: 100%;
  min-height: 3.2rem;
  padding: 0 3rem 0 1rem;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background-color: var(--surface-strong);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3.25 5.5L7 9.25L10.75 5.5' stroke='%236E6E73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 0.95rem center;
  background-repeat: no-repeat;
  background-size: 0.9rem;
  color: var(--text);
  font: inherit;
  font-size: 0.98rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
  appearance: none;
  -webkit-appearance: none;
}

.account-select:hover,
.account-select:focus-visible {
  border-color: rgba(183, 100, 64, 0.26);
  box-shadow: 0 0 0 3px rgba(183, 100, 64, 0.08);
  outline: none;
}

.tab-strip {
  display: flex;
  width: min(100%, 18rem);
  padding: 0.2rem;
  gap: 0.25rem;
  border-radius: 12px;
  background: var(--accent-tint);
  border: 1px solid rgba(201, 111, 71, 0.16);
}

.tab-button {
  flex: 1 1 0;
  min-height: 2.65rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.28);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.tab-button:hover,
.tab-button:focus-visible {
  background: rgba(201, 111, 71, 0.14);
  color: var(--text);
  outline: none;
}

.tab-button.is-active {
  background: var(--accent);
  color: #fff;
  border: 1px solid rgba(201, 111, 71, 0.24);
}

.load-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.mail-toolbar,
.phone-toolbar {
  margin: 0;
  width: auto;
}

.mail-button,
.phone-button {
  min-height: 3.15rem;
  min-width: 7.5rem;
  padding: 0 1.45rem;
  border-radius: 16px;
  border: 1px solid rgba(169, 86, 52, 0.18);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-button);
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.mail-button:hover,
.mail-button:focus-visible,
.phone-button:hover,
.phone-button:focus-visible {
  background: var(--accent-strong);
  border-color: rgba(156, 82, 50, 0.22);
  box-shadow: 0 3px 10px rgba(156, 82, 50, 0.10);
  outline: none;
}

.mail-button[disabled],
.phone-button[disabled] {
  cursor: not-allowed;
  opacity: 0.62;
  box-shadow: none;
}

.mail-toolbar.is-loading .mail-button,
.phone-toolbar.is-loading .phone-button {
  opacity: 1;
  cursor: wait;
  background: var(--accent-strong);
  border-color: rgba(169, 86, 52, 0.26);
  position: relative;
}

.mail-toolbar.is-loading .mail-button::before,
.phone-toolbar.is-loading .phone-button::before {
  content: "";
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.55rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 999px;
  vertical-align: -0.1rem;
  animation: spin 700ms linear infinite;
}

.flash {
  margin: 0 0 0.95rem;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.94rem;
}

.flash-slot {
  min-height: 0;
}

.flash-slot,
.mail-results-shell,
.sms-results-shell {
  display: grid;
  justify-items: stretch;
}

.flash-slot > *,
.mail-results-shell > *,
.sms-results-shell > * {
  width: 100%;
}

.flash-error {
  color: var(--error);
  border-color: rgba(167, 55, 29, 0.18);
  background: #fff0f0;
}

.flash-success {
  color: var(--success);
  border-color: rgba(31, 106, 58, 0.18);
  background: #f4fff8;
}

.mail-results-shell,
.sms-results-shell {
  min-height: 12rem;
}

.sms-results-shell {
  min-height: 4.5rem;
}

.mail-list,
.sms-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.mail-item,
.sms-item {
  padding: 1.1rem 1.15rem;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  box-shadow: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.mail-item.is-open {
  border-color: rgba(183, 100, 64, 0.18);
  background: var(--surface-soft);
}

.mail-item:hover,
.sms-item:hover {
  border-color: var(--border-strong);
}

.mail-summary {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.mail-summary-main {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 0.5rem;
}

.mail-subject {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mail-from {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.mail-from,
.mail-time,
.sms-time,
.sms-empty,
.mail-empty {
  color: var(--muted);
  font-size: 0.94rem;
}

.mail-time {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mail-panel {
  margin-top: 1rem;
}

.mail-panel[hidden] {
  display: none;
}

.mail-render {
  margin-top: 0.9rem;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  overflow: hidden;
}

.mail-body {
  margin: 0;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  font: inherit;
  line-height: 1.6;
}

.mail-frame {
  width: 100%;
  min-height: 16rem;
  margin: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  display: block;
  overflow: hidden;
}

.mail-empty,
.sms-empty {
  margin: 0;
  padding: 1rem;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px dashed var(--border-strong);
  text-align: center;
  display: grid;
  place-items: center;
}

.mail-fetching {
  display: grid;
  place-items: center;
}

body.mobile-mail-open {
  overflow: hidden;
}

.mobile-mail-view {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  overflow-y: auto;
  padding: 0.85rem;
}

.mobile-mail-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 0.75rem;
  background: linear-gradient(180deg, var(--bg) 82%, rgba(245, 241, 234, 0));
}

.mobile-mail-back {
  min-height: 2.5rem;
  padding: 0 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.mobile-mail-sheet {
  padding-bottom: 1rem;
}

.mobile-mail-header {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.mobile-mail-subject,
.mobile-mail-from,
.mobile-mail-time {
  margin: 0;
}

.mobile-mail-subject {
  font-size: 1.08rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.mobile-mail-from,
.mobile-mail-time {
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mobile-mail-content {
  min-width: 0;
}

.mobile-mail-content .mail-frame,
.mobile-mail-content .mail-body {
  width: 100%;
}

.mail-loader-card {
  width: 100%;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  display: grid;
  gap: 0.9rem;
}

.mail-skeleton {
  display: grid;
  gap: 0.75rem;
}

.mail-skeleton-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.mail-skeleton-line {
  display: block;
  height: 0.95rem;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(221, 203, 184, 0.7) 20%, rgba(255, 251, 245, 0.95) 50%, rgba(221, 203, 184, 0.7) 80%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s linear infinite;
}

.mail-skeleton-line + .mail-skeleton-line {
  margin-top: 0.6rem;
}

.mail-skeleton-line.subject {
  width: min(70%, 20rem);
  height: 1.1rem;
}

.mail-skeleton-line.meta {
  width: min(38%, 10rem);
}

.mail-skeleton-line.time {
  width: min(24%, 7rem);
}

.mail-skeleton-line.short.subject {
  width: min(56%, 15rem);
}

.mail-skeleton-line.short.meta {
  width: min(30%, 8rem);
}

.mail-skeleton-line.time.short {
  width: min(18%, 5rem);
}

.otp-fetching {
  width: 100%;
  min-height: 4.5rem;
  display: grid;
  place-items: center;
}

.otp-loader {
  display: grid;
  place-items: center;
}

.otp-spinner {
  width: 12px;
  height: 12px;
  display: block;
  margin: 0 auto;
  position: relative;
  border-radius: 50%;
  box-sizing: border-box;
  color: var(--accent);
  animation: otp-dot-loader 1s linear infinite alternate;
}

.sms-head {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.sms-parties,
.sms-from,
.sms-meta,
.sms-to,
.sms-code,
.sms-text {
  margin: 0;
}

.sms-parties {
  display: grid;
  gap: 0.45rem;
}

.sms-from {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.2;
}

.sms-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.sms-to {
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.92rem;
}

.sms-code {
  padding: 0.32rem 0.68rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(201, 111, 71, 0.18);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sms-text {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

@keyframes skeleton-pulse {
  from {
    opacity: 0.65;
  }
  to {
    opacity: 1;
  }
}

@keyframes skeleton-shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@keyframes otp-dot-loader {
  0% {
    box-shadow:
      -38px -12px 0 0 currentColor,
      -14px 0 0 0 currentColor,
      14px 0 0 0 currentColor,
      38px 0 0 0 currentColor;
  }
  33% {
    box-shadow:
      -38px 0 0 0 currentColor,
      -14px -12px 0 0 currentColor,
      14px 0 0 0 currentColor,
      38px 0 0 0 currentColor;
  }
  66% {
    box-shadow:
      -38px 0 0 0 currentColor,
      -14px 0 0 0 currentColor,
      14px -12px 0 0 currentColor,
      38px 0 0 0 currentColor;
  }
  100% {
    box-shadow:
      -38px 0 0 0 currentColor,
      -14px 0 0 0 currentColor,
      14px 0 0 0 currentColor,
      38px -12px 0 0 currentColor;
  }
}

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

@media (max-width: 1080px) {
  .dashboard {
    width: min(100%, 60rem);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0.8rem;
  }

  .panel {
    border-radius: 16px;
  }

  .content-panel,
  .controls-panel {
    width: 100%;
    padding: 0.8rem;
  }

  .control-header {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .account-controls,
  .tab-strip,
  .load-strip {
    width: 100%;
  }

  .mail-summary,
  .sms-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .mail-button,
  .phone-button,
  .mail-toolbar,
  .phone-toolbar {
    width: 100%;
  }

  .mail-time {
    white-space: normal;
    font-size: 0.88rem;
  }

  .mail-item,
  .sms-item {
    padding: 0.9rem;
    border-radius: 16px;
  }

  .mail-subject {
    font-size: 0.95rem;
  }

  .mail-from {
    font-size: 0.9rem;
  }

  .mail-panel {
    margin-top: 0.8rem;
  }

  .mail-render {
    padding: 0;
  }

  .mail-frame {
    min-height: 12rem;
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 0.65rem;
  }

  .content-panel,
  .controls-panel {
    padding: 0.7rem;
  }

  .selected-company {
    font-size: 0.76rem;
  }

  .account-select,
  .mail-button,
  .phone-button {
    min-height: 3rem;
  }

  .mail-item,
  .sms-item {
    padding: 0.8rem;
  }

  .mail-subject {
    font-size: 0.92rem;
    line-height: 1.25;
  }

  .mail-from,
  .mail-time {
    font-size: 0.86rem;
  }

  .mail-frame {
    min-height: 10rem;
    border-radius: 8px;
  }

  .mobile-mail-view {
    padding: 0.7rem;
  }

  .mobile-mail-topbar {
    padding-bottom: 0.6rem;
  }

  .mobile-mail-subject {
    font-size: 1rem;
  }

  .mobile-mail-from,
  .mobile-mail-time {
    font-size: 0.88rem;
  }
}
