:root {
  --bg: #f4efe8;
  --surface: #ffffff;
  --text: #2a231c;
  --muted: #6d6258;
  --line: #e4d9cb;
  --accent: #a0522d;
  --accent-dark: #7a3d20;
  --danger: #b33a3a;
  --ok: #2f7a4f;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-top: env(safe-area-inset-top, 0px);
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #f7f3ed, #ebe2d6);
}

.view {
  min-height: 100vh;
}

.login-card {
  width: min(420px, calc(100% - 32px));
  margin: 10vh auto;
  padding: 36px 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(42, 35, 28, 0.1);
}

.login-card img {
  margin: 0 auto 16px;
  border-radius: 10px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
  font-size: 1.8rem;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-card form,
.settings-card form {
  display: grid;
  gap: 12px;
  text-align: left;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #faf7f2;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(160, 82, 45, 0.12);
}

button,
.admin-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.admin-actions a:hover {
  background: var(--accent-dark);
}

.back-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 0.9rem;
}

.status {
  margin-top: 12px;
  font-size: 0.9rem;
}

.status.ok {
  color: var(--ok);
}

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

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-brand img {
  border-radius: 8px;
}

.admin-brand strong {
  display: block;
}

.admin-brand span {
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-tabs {
  display: flex;
  gap: 8px;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

#logout-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

#logout-btn:hover {
  background: #faf7f2;
  color: var(--text);
}

.admin-main {
  width: min(960px, calc(100% - 40px));
  margin: 28px auto 48px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
}

.messages-list {
  display: grid;
  gap: 16px;
}

.message-card {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(42, 35, 28, 0.05);
}

.message-card.unread {
  border-left: 4px solid var(--accent);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.message-meta strong {
  color: var(--text);
  font-size: 1rem;
}

.message-body {
  margin: 0 0 14px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.message-actions {
  display: flex;
  gap: 8px;
}

.message-actions button {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 0.82rem;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #922f2f;
}

.btn-muted {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-muted:hover {
  background: #faf7f2;
  color: var(--text);
}

.settings-card {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(42, 35, 28, 0.05);
}

.settings-card h2 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
}

.settings-card > p {
  margin: 0 0 20px;
  color: var(--muted);
}

@media (max-width: 700px) {
  .admin-header {
    padding: 16px;
  }

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