:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --text: #1b231e;
  --muted: #5d6b62;
  --border: #d9dfda;
  --accent: #1f6f4a;
  --accent-text: #ffffff;
  --accent-soft: #e2f0e8;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --ok: #1f7a3f;
  --ok-soft: #e0f3e6;
  --radius: 14px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #1a201c;
    --surface-2: #232b26;
    --text: #e6ebe7;
    --muted: #9aa8a0;
    --border: #2f3a33;
    --accent: #4cbf86;
    --accent-text: #0d1a12;
    --accent-soft: #173023;
    --danger: #ff8a80;
    --danger-soft: #3a1c1a;
    --warn: #ffcc66;
    --warn-soft: #3a2f14;
    --ok: #6fdc9a;
    --ok-soft: #173023;
    color-scheme: dark;
  }
  .logo,
  .mark {
    filter: invert(1);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.boot {
  text-align: center;
  margin-top: 40vh;
  color: var(--muted);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

main.center {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

main.center .card {
  width: 100%;
}

h1 {
  font-size: 1.5rem;
  margin: 0.4rem 0 1rem;
}

h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  width: min(280px, 75vw);
  height: auto;
  align-self: center;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.7rem;
  color: inherit;
  text-decoration: none;
}

.field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
}

.field > span {
  font-weight: 600;
  font-size: 0.95rem;
}

.field small {
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* no zoom on iPhone */
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button,
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.block {
  display: block;
  width: 100%;
}

button.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0.5rem 0.3rem;
  margin-top: 0.6rem;
}

.big {
  padding: 1rem;
  font-size: 1.05rem;
  margin: 1.2rem 0;
}

.error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  margin-bottom: 0.8rem;
}

.notice {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.bar .mark {
  height: 26px;
}

.bar a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.menu-link {
  justify-self: end;
  font-size: 1.4rem;
  line-height: 1;
}

.site,
.ticket {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.ticket.unread {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.bad {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge.accent,
.badge.new {
  background: var(--accent-soft);
  color: var(--accent);
}

.count {
  font-size: 0.75rem;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 0 0.45rem;
}

.urgency {
  display: grid;
  gap: 0.4rem;
}

.choice {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
}

.choice input {
  width: auto;
  accent-color: var(--accent);
}

.choice span {
  display: grid;
}

.choice small {
  color: var(--muted);
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice.down:has(input:checked) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.thread {
  display: grid;
  gap: 0.6rem;
  margin: 1rem 0;
}

.msg {
  max-width: 85%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
}

.msg.mine {
  justify-self: end;
  background: var(--accent-soft);
}

.msg.theirs {
  justify-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
}

.msg .meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.msg .text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sys {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.reply textarea {
  margin-bottom: 0.6rem;
}

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 0.4rem;
  width: min(92vw, 420px);
  z-index: 20;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 0.7rem 1rem;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
}

.toast.err {
  background: var(--danger);
  color: #fff;
}

/* Header content aligned with the page column on wide screens. */
.bar {
  padding-left: max(1rem, calc((100% - 560px) / 2 + 1rem));
  padding-right: max(1rem, calc((100% - 560px) / 2 + 1rem));
}

.open-section h2 {
  margin-top: 0.5rem;
}

.open-ticket {
  border: 2px solid var(--accent);
  box-shadow: 0 2px 12px rgb(0 0 0 / 12%);
  display: grid;
  gap: 0.5rem;
}

.open-ticket.unread {
  border-color: var(--danger);
}

.ot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ot-subject {
  font-size: 1.2rem;
  font-weight: 700;
}

.ot-last {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.report-small {
  margin: 1.2rem 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.notice.left {
  text-align: left;
  margin-bottom: 1rem;
  display: grid;
  gap: 0.4rem;
}

.notice.left p {
  margin: 0;
}

.reply strong {
  display: block;
  margin-bottom: 0.5rem;
}

/* Finished reports: small and quiet. */
.done-section {
  margin-top: 1.8rem;
}

.done-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.done-list {
  display: grid;
  border-top: 1px solid var(--border);
}

.done-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.2rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.done-check {
  color: var(--ok);
}

.done-subject {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.done-new {
  color: var(--accent);
  font-size: 0.7rem;
}

.done-date {
  font-size: 0.78rem;
}
