:root {
  --bg: #05080f;
  --card: #0f172a;
  --border: rgba(234, 179, 8, 0.22);
  --gold: #eab308;
  --text: #f8fafc;
  --muted: #94a3b8;
  --rose: #e11d48;
  --ok: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--gold);
}

.admin-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px);
  padding-left: max(clamp(16px, 4vw, 32px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 4vw, 32px), env(safe-area-inset-right, 0px));
  padding-bottom: max(clamp(16px, 4vw, 32px), env(safe-area-inset-bottom, 0px));
}

.admin-wrap--inbox {
  max-width: 720px;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-top h1 {
  margin: 0;
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
}

.admin-top h1 span {
  color: var(--gold);
  font-weight: 700;
}

.admin-top--inbox {
  align-items: flex-start;
  gap: clamp(12px, 3vw, 20px);
}

.admin-top__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 200px;
}

.admin-top__logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(234, 179, 8, 0.12);
}

.admin-top__titles h1 {
  font-size: clamp(1.1rem, 2.8vw, 1.35rem);
  line-height: 1.25;
}

.admin-top__sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.admin-top__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

.flash {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
}

.flash--ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.inbox-list {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 3vw, 20px);
}

.msg-card {
  background: linear-gradient(165deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: clamp(16px, 4vw, 22px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.msg-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 14px;
}

.msg-card__who {
  min-width: 0;
  flex: 1 1 180px;
}

.msg-card__name {
  margin: 0 0 8px;
  font-family: "Outfit", system-ui, sans-serif;
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  font-weight: 700;
  word-break: break-word;
}

.msg-card__badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.msg-card__program {
  font-size: 13px;
  color: var(--muted);
}

.msg-card__time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.msg-card__contacts {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  font-size: 14px;
}

.msg-card__contacts li {
  margin-bottom: 6px;
  word-break: break-word;
}

.msg-card__contacts li:last-child {
  margin-bottom: 0;
}

.msg-card__label {
  display: inline-block;
  min-width: 4.5em;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.msg-card__contacts--empty {
  color: var(--muted);
  font-size: 13px;
}

.msg-card__body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.55;
  color: #e2e8f0;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.msg-card__actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  gap: 10px;
  align-items: stretch;
}

.msg-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.msg-action:hover {
  background: rgba(255, 255, 255, 0.1);
}

.msg-action:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.msg-action__ico {
  flex-shrink: 0;
}

.msg-action--call {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.msg-action--call:hover {
  background: rgba(34, 197, 94, 0.18);
}

.msg-action--wa {
  border-color: rgba(37, 211, 102, 0.35);
  background: rgba(37, 211, 102, 0.08);
  color: #bbf7d0;
}

.msg-action--wa:hover {
  background: rgba(37, 211, 102, 0.15);
}

.msg-action--mail {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.1);
}

.msg-action--mail:hover {
  background: rgba(59, 130, 246, 0.16);
}

.msg-action--muted {
  border-color: rgba(148, 163, 184, 0.25);
  color: #cbd5e1;
}

.msg-action--danger {
  border-color: rgba(225, 29, 72, 0.45);
  background: rgba(225, 29, 72, 0.12);
  color: #fecaca;
}

.msg-action--danger:hover {
  background: rgba(225, 29, 72, 0.22);
}

.msg-action-form {
  display: contents;
}

.msg-action-form .msg-action {
  grid-column: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn--primary {
  background: linear-gradient(135deg, var(--rose), #be123c);
  border-color: transparent;
  color: #fff;
}

.btn--ghost {
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 40px);
  background:
    radial-gradient(ellipse 90% 60% at 50% -30%, rgba(234, 179, 8, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 100%, rgba(225, 29, 72, 0.06), transparent 45%),
    var(--bg);
}

.login-card {
  max-width: 400px;
  margin: 10vh auto;
  padding: 32px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
}

.login-card--minimal {
  max-width: 380px;
  width: 100%;
  margin: 0;
  padding: 40px 32px 36px;
  text-align: center;
}

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

.login-brand img {
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 10px 28px rgba(234, 179, 8, 0.18));
}

.login-form-min {
  text-align: left;
}

.login-card--minimal .login-form-min > .login-input-min:first-of-type {
  margin-bottom: 12px;
}

.login-card--minimal .login-input-min {
  margin-bottom: 0;
}

.login-input-min {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #020617;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 0;
}

.login-input-min::placeholder {
  color: #64748b;
}

.login-input-min:focus {
  outline: none;
  border-color: rgba(234, 179, 8, 0.45);
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.12);
}

.btn--login-full {
  width: 100%;
  justify-content: center;
  padding: 14px 18px;
  margin-top: 4px;
  font-size: 15px;
}

.login-card--minimal .err {
  text-align: left;
  margin-bottom: 16px;
}

.login-card h2 {
  margin: 0 0 8px;
  font-family: "Outfit", sans-serif;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.login-card input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #020617;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 16px;
}

.login-pass-wrap {
  position: relative;
  margin-bottom: 16px;
}

.login-pass-wrap input {
  padding-right: 48px;
  margin-bottom: 0;
}

.login-pass-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.login-pass-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.login-pass-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.login-pass-toggle__layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.login-pass-toggle__layer--hide {
  display: none !important;
}

.login-pass-toggle.is-revealed .login-pass-toggle__layer--show {
  display: none !important;
}

.login-pass-toggle.is-revealed .login-pass-toggle__layer--hide {
  display: flex !important;
}

.login-pass-toggle svg {
  display: block;
  flex-shrink: 0;
}

.login-card .btn--primary {
  width: 100%;
  justify-content: center;
  padding: 14px;
}

.err {
  background: rgba(225, 29, 72, 0.15);
  border: 1px solid rgba(225, 29, 72, 0.35);
  color: #fecaca;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.err.show {
  display: block;
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-row {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px 18px;
  cursor: grab;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px 16px;
  align-items: start;
}

.msg-row.dragging {
  opacity: 0.55;
}

.msg-row .drag-hint {
  color: var(--muted);
  font-size: 18px;
  padding-top: 4px;
  user-select: none;
}

.msg-meta {
  min-width: 0;
}

.msg-meta strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.msg-meta small {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--new {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
}

.badge--read {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}

.badge--replied {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.badge--archived {
  background: rgba(100, 116, 139, 0.25);
  color: #94a3b8;
}

.msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.msg-actions .btn {
  padding: 8px 12px;
  font-size: 12px;
}

.panel {
  display: none;
  margin-top: 20px;
  padding: 20px;
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.panel.open {
  display: block;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.panel pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  color: #e2e8f0;
  margin: 0 0 16px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
}

.panel label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.panel textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f172a;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 12px;
  resize: vertical;
}

.panel .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

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

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .msg-row {
    grid-template-columns: 1fr;
  }

  .msg-actions {
    justify-content: flex-start;
  }
}
