:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #66727c;
  --line: #d9e0e5;
  --brand: #116466;
  --brand-dark: #0b4b4d;
  --danger: #a63d2a;
  --warn: #9a6b00;
  --ok: #2f6f3e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

main.wide {
  max-width: 1320px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topnav a,
.link-button {
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  padding: 6px 4px;
}

.spacer {
  flex: 1;
}

.panel,
.ticket-row,
.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.ticket-list {
  display: grid;
  gap: 10px;
}

.ticket-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.ticket-card-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.ticket-title-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.ticket-title-line h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.28;
  flex: 1;
  min-width: 0;
}

.ticket-title-line a:not(.button) {
  color: var(--text);
  text-decoration: none;
}

.ticket-title-line a:not(.button):hover {
  color: var(--brand);
  text-decoration: underline;
}

.ticket-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ticket-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.ticket-row p {
  margin: 0;
}

.ticket-preview {
  display: grid;
  gap: 3px;
}

.ticket-preview strong {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
}

.transcription-preview {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.ticket-date {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
  white-space: nowrap;
}

.ticket-open {
  min-height: 34px;
  padding: 7px 11px;
}

.meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
}

.user-actions,
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input {
  min-width: 180px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 9px 13px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

button.secondary,
.button.secondary {
  background: #44515c;
}

button.danger,
.button.danger {
  background: var(--danger);
}

.danger-zone {
  border-color: #e3a19c;
}

.alert {
  border: 1px solid #e3a19c;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff4f2;
  color: var(--danger);
  font-weight: 700;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e8eef1;
  color: #25313a;
  font-size: 0.84rem;
  font-weight: 700;
}

.badge.warn {
  background: #fff2cc;
  color: var(--warn);
}

.badge.ok {
  background: #dff1e4;
  color: var(--ok);
}

.badge.danger {
  background: #f7dddd;
  color: var(--danger);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.status-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.status-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.status-head h2 {
  margin: 0 0 4px;
}

.status-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.status-card.ok .status-dot {
  background: #159447;
}

.status-card.bad .status-dot {
  background: #c7372f;
}

.status-card.ok {
  border-color: #84c99e;
}

.status-card.bad {
  border-color: #e3a19c;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

.device-cell {
  max-width: 360px;
  word-break: break-word;
}

code {
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9em;
}

.stack {
  display: grid;
  gap: 14px;
}

.compact-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.section-title {
  margin: 24px 0 10px;
}

audio {
  width: 100%;
}

.confirmation {
  max-width: 560px;
  margin: 8vh auto 0;
  text-align: center;
}

.confirmation-number {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  font-size: 1.8rem;
  font-weight: 700;
  background: #f7fafb;
}

.qr-box {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.qr-box img {
  width: 320px;
  max-width: 100%;
  height: auto;
}

@media (max-width: 720px) {
  main {
    padding: 12px;
  }

  .topnav {
    overflow-x: auto;
    align-items: center;
  }

  .ticket-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }

  .ticket-title-line {
    align-items: stretch;
  }

  .ticket-open {
    flex: 0 0 auto;
  }

  .ticket-date {
    text-align: left;
    white-space: normal;
    border-top: 1px solid var(--line);
    padding-top: 10px;
  }

  .ticket-meta-grid {
    display: grid;
    gap: 5px;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
