:root {
  --bg: #f3f0e8;
  --bg-accent: #e7efe8;
  --ink: #1c2420;
  --muted: #5d6a63;
  --line: #cfd8d2;
  --panel: #fffdf8;
  --brand: #0f5c4c;
  --brand-dark: #0a4036;
  --accent: #c45c26;
  --inbound: #e8f2ef;
  --outbound: #fff4ea;
  --danger: #9b2c2c;
  --shadow: 0 10px 30px rgba(28, 36, 32, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 92, 76, 0.12), transparent 40%),
    radial-gradient(circle at bottom right, rgba(196, 92, 38, 0.12), transparent 35%),
    linear-gradient(160deg, var(--bg), var(--bg-accent));
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--brand-dark);
  letter-spacing: 0.01em;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav a { color: var(--ink); }
.nav .user { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
}

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

h1, h2 {
  margin: 0 0 0.75rem;
  line-height: 1.2;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }

.muted { color: var(--muted); }
.stack { display: grid; gap: 0.85rem; }

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 110px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: #2f3b36; }
.btn-secondary:hover { background: #1c2420; }
.btn-danger { background: var(--danger); }

.flash {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
}

.flash-ok { background: #e7f6ee; color: #14532d; }
.flash-err { background: #fde8e8; color: var(--danger); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  border-top: 1px solid var(--line);
}

.list li:first-child { border-top: 0; }

.list a.row {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 0.15rem;
  color: inherit;
  text-decoration: none;
}

.list a.row:hover { background: rgba(15, 92, 76, 0.04); }

.row-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.badge {
  display: inline-flex;
  min-width: 1.4rem;
  justify-content: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.meta { font-size: 0.85rem; color: var(--muted); }
.snippet {
  font-size: 0.92rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread {
  display: grid;
  gap: 0.75rem;
  max-height: 55vh;
  overflow: auto;
  padding-right: 0.25rem;
}

.bubble {
  max-width: 80%;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.bubble.inbound {
  justify-self: start;
  background: var(--inbound);
}

.bubble.outbound {
  justify-self: end;
  background: var(--outbound);
}

.bubble .meta { margin-top: 0.35rem; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(420px, 100%);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
