:root {
  --ink: #1a2332;
  --muted: #6b645a;
  --paper: #f7f4ef;
  --card: #fffdf8;
  --line: #e2ddd4;
  --teal: #1b6b63;
  --teal-d: #134e48;
  --clay: #c45c26;
  --warn: #9b2c2c;
  --ok: #2f6b3a;
  --rail: #172029;
  --rail-text: #d9d2c5;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --ui: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--teal-d); }
.quiet { color: var(--muted); text-decoration: none; font-size: 13px; }
.quiet:hover { color: var(--ink); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail {
  background: var(--rail);
  color: var(--rail-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 20px;
  letter-spacing: 0.02em;
  color: #f4efe6;
  margin-bottom: 28px;
}
.brand-lg { font-size: 26px; margin-bottom: 8px; justify-content: center; }
.brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--clay);
  color: #fff;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 14px;
  border-radius: 4px;
}
.rail nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  color: var(--rail-text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-link:hover, .nav-link.is-active { background: #243140; color: #fff; }
.nav-link em {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.45;
}
.rail-foot { font-size: 13px; }
.who { display: flex; flex-direction: column; margin-bottom: 8px; }
.who strong { color: #fff; font-weight: 600; }
.who span { color: #9aa3ad; text-transform: capitalize; }

.main { padding: 28px 36px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; gap: 16px; }
.page-head h1 { font-family: var(--sans); font-weight: 500; font-size: 28px; margin: 4px 0 6px; }
.muted { color: var(--muted); }

.filters { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #f3eee6; }
.table .subject { font-weight: 600; }
.table .empty { text-align: center; color: var(--muted); cursor: default; padding: 36px; }
.mono { font-family: var(--mono); font-size: 13px; }

.pill, .prio, .site {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.site { background: #e7f0ee; color: var(--teal-d); }
.pill-new { background: #f3e2d4; color: var(--clay); }
.pill-open { background: #dcece9; color: var(--teal-d); }
.pill-pending { background: #efe6c9; color: #6a5420; }
.pill-resolved { background: #dce8dc; color: var(--ok); }
.pill-closed { background: #eceae6; color: var(--muted); }
.prio-low { color: var(--muted); }
.prio-normal { color: var(--ink); }
.prio-high { color: var(--clay); }
.prio-urgent { color: var(--warn); font-weight: 700; }

.split { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
.thread { display: flex; flex-direction: column; gap: 12px; }
.bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.bubble header { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 8px; }
.bubble time { color: var(--muted); }
.bubble .body { white-space: pre-wrap; }
.bubble.is-requester { border-left: 3px solid var(--teal); }
.bubble.is-agent { border-left: 3px solid var(--clay); }
.bubble.is-internal {
  background: #fff8d9;
  border-style: dashed;
}
.bubble.is-system { color: var(--muted); font-style: italic; }

.composer, .meta {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.meta h2 {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 6px;
}
.meta h2:first-child { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type="email"], input[type="password"], input[type="text"], select, textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
textarea { resize: vertical; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }

.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.btn-primary:hover { background: var(--teal-d); }
.btn:hover { filter: brightness(0.98); }

.flash {
  background: #e7f0ee;
  color: var(--teal-d);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 16px;
}
.flash-err { background: #f8e4e1; color: var(--warn); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 10% -10%, #e7d3c2 0%, transparent 50%),
    var(--paper);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 18px 40px rgba(26, 35, 50, 0.06);
}
.lede { margin: 0 0 8px; color: var(--muted); text-align: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; flex-wrap: wrap; gap: 12px; }
  .rail nav { flex-direction: row; flex: 1; }
  .split { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}
