:root {
  --bg: #e8f1f4;
  --bg-deep: #0f3d4c;
  --panel: #f7fbfc;
  --ink: #12262e;
  --muted: #4d6670;
  --line: #c5d8df;
  --accent: #1a7a8c;
  --accent-hover: #146273;
  --danger: #9b2c2c;
  --shadow: 0 18px 50px rgba(15, 61, 76, 0.14);
  --radius: 18px;
  --font: "Manrope", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(26, 122, 140, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(15, 61, 76, 0.12), transparent 55%),
    linear-gradient(160deg, #dceaf0 0%, var(--bg) 45%, #f3f7f8 100%);
}

a { color: inherit; }

.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(440px, 100%);
}

.login-panel {
  background: color-mix(in srgb, var(--panel) 92%, white);
  border: 1px solid color-mix(in srgb, var(--line) 80%, white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px 32px;
  backdrop-filter: blur(8px);
}

.brand {
  margin: 0 0 10px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.login-panel h1,
.dashboard h1 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.25rem);
  font-weight: 700;
  line-height: 1.15;
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

.alert {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #f3c4c4;
  font-size: 0.95rem;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.login-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, white);
  border-color: var(--accent);
}

.login-form button,
.btn-ghost {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.login-form button {
  margin-top: 6px;
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s ease;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: var(--bg-deep);
  color: #e8f4f7;
}

.alert-ok {
  background: #e7f6ee;
  color: #146c43;
  border: 1px solid #b7e4c7;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-ok {
  background: #e7f6ee;
  color: #146c43;
}

.badge-wait {
  background: #fff3cd;
  color: #856404;
}

.processed-at {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.inline-form {
  display: inline;
  margin: 0;
}

.btn-process {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}

.btn-process:hover {
  background: var(--accent-hover);
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-nav {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.topbar-nav a {
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  color: rgba(232, 244, 247, 0.82);
  font-weight: 600;
  font-size: 0.92rem;
}

.topbar-nav a:hover,
.topbar-nav a.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.panel {
  margin-top: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px 8px;
  box-shadow: 0 8px 24px rgba(15, 61, 76, 0.06);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
}

.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}

.btn-link:hover { text-decoration: underline; }

.empty {
  color: var(--muted);
  padding: 8px 0 18px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

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

.data-table code {
  font-size: 0.9rem;
}

.row-replace {
  background: #fff6e8;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 14px;
}

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

.filter-tab {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
}

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

.filter-search {
  display: flex;
  gap: 8px;
}

.filter-search input {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.filter-search button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--bg-deep);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.row-unread {
  background: #eef8fb;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 55vh;
  overflow-y: auto;
  padding-bottom: 18px !important;
}

.chat-bubble {
  max-width: min(640px, 92%);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.chat-bubble header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.chat-bubble p {
  margin: 0;
  line-height: 1.45;
  white-space: pre-wrap;
}

.chat-in {
  align-self: flex-start;
  background: #fff;
}

.chat-out {
  align-self: flex-end;
  background: #e5f3f6;
  border-color: #bdd8df;
}

.chat-compose {
  margin-top: 16px;
  display: grid;
  gap: 12px;
  padding-bottom: 18px !important;
}

.chat-compose label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.chat-compose textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  resize: vertical;
  background: #fff;
}

.btn-reset {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
}

.btn-reset:hover {
  background: #f0f5f7;
}

.meta {
  color: var(--muted);
  margin: 0 0 8px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.pagination a {
  text-decoration: none;
  min-width: 36px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
}

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

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 18px;
  }

  .topbar-nav {
    justify-content: flex-start;
    width: 100%;
  }

  .login-panel {
    padding: 28px 22px;
  }

  .filter-search {
    width: 100%;
  }

  .filter-search input {
    flex: 1;
    min-width: 0;
  }
}

.brand-mark {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
}

.brand-sub {
  font-size: 0.8rem;
  opacity: 0.75;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
}

.btn-ghost {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.dashboard {
  width: min(980px, calc(100% - 40px));
  margin: 36px auto 48px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 8px 24px rgba(15, 61, 76, 0.06);
}

.stat-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-value {
  margin: 0;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 700;
}

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 18px;
  }

  .login-panel {
    padding: 28px 22px;
  }
}
