:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #64707d;
  --line: #d9e0e6;
  --accent: #256f84;
  --accent-dark: #174f60;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #16703d;
  --shadow: 0 1px 2px rgb(15 23 42 / 8%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header {
  display: grid;
  grid-template-columns: auto minmax(220px, 340px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand a {
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
}

.topnav {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 14px;
  flex-wrap: wrap;
}

.topnav form {
  margin: 0;
}

.header-search {
  display: grid;
  grid-template-columns: minmax(0, 220px) auto;
  gap: 6px;
  align-items: center;
  justify-self: center;
  width: min(100%, 300px);
}

.header-search input {
  height: 34px;
  padding: 6px 9px;
}

.header-search button {
  height: 34px;
  padding: 5px 10px;
}

.user {
  color: var(--muted);
  font-size: 13px;
}

.auth-note {
  margin: -4px 0 16px;
  color: var(--muted);
}

main {
  width: min(1120px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.action-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 480px;
  margin: 0 auto 14px;
}

.action-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 4px rgb(15 23 42 / 16%);
}

.action-nav a:hover {
  text-decoration: none;
  filter: brightness(0.97);
}

.action-nav a.write {
  background: #16a34a;
}

.action-nav a.list {
  background: #2563eb;
}

.action-nav a.active {
  box-shadow: 0 0 0 3px rgb(255 255 255), 0 0 0 6px rgb(37 111 132 / 35%);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}

.panel.narrow,
.panel.auth {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.panel.auth {
  margin-top: 10vh;
}

h1,
h2 {
  margin: 0 0 16px;
  line-height: 1.25;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

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

label,
fieldset {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

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

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

textarea {
  resize: vertical;
}

button {
  border: 1px solid #b9c4ce;
  border-radius: 6px;
  padding: 9px 13px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

button.primary:hover {
  background: var(--accent-dark);
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid #b9c4ce;
  border-radius: 6px;
  padding: 8px 12px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
}

.button:hover {
  text-decoration: none;
}

.primary-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: auto;
}

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

.list-controls {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin-bottom: 18px;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tabs a {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 82px;
  padding: 10px 16px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.tabs a.active {
  background: #dceff4;
  border-color: #9cc7d3;
  color: #174f60;
  font-weight: 700;
}

.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.ticket-card {
  display: grid;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid #9aa8b3;
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.ticket-card:hover {
  text-decoration: none;
  border-color: #b7c5ce;
}

.ticket-card h2 {
  margin: 0;
}

.ticket-card p {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
}

.priority-high,
.priority-urgent {
  border-left-color: var(--warn);
}

.priority-urgent {
  border-left-color: var(--danger);
}

.ticket-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-id {
  color: var(--muted);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f5;
  color: #364653;
  font-size: 12px;
  font-weight: 700;
}

.badge.status {
  background: #dceff4;
  color: #174f60;
}

.badge.priority {
  background: #fff1d6;
  color: #774500;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.ticket-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.status-form {
  display: flex;
  gap: 8px;
  min-width: 240px;
}

.status-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.quick-status-form {
  margin: 0;
}

.complete-button {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
  font-weight: 700;
}

.complete-button:hover {
  background: #15803d;
}

.details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 18px;
}

.details div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: #fafbfc;
}

.details dt {
  color: var(--muted);
  font-size: 12px;
}

.details dd {
  margin: 2px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.body-text {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  overflow-wrap: anywhere;
}

.comment {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.comment p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.comment-form {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.attachments {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.attachments ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachments li {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.attachments img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

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

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

.notice {
  border: 1px solid #f1c27d;
  background: #fff7e8;
  color: #7a4600;
  border-radius: 6px;
  padding: 10px;
}

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

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

.user-edit {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 1.2fr) minmax(180px, 1.3fr) auto auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfc;
}

.inactive-user {
  opacity: 0.62;
}

.user-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
}

.user-status.active {
  background: #dcfce7;
  color: #166534;
}

.user-status.inactive {
  background: #e5e7eb;
  color: #4b5563;
}

@media (max-width: 760px) {
  header,
  .ticket-heading {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .topnav,
  .status-actions,
  .status-form,
  .user-edit,
  .grid-2,
  .details {
    grid-template-columns: 1fr;
  }

  .topnav {
    justify-self: stretch;
  }

  .header-search {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-self: stretch;
    width: 100%;
  }

  .status-form {
    display: grid;
    min-width: 0;
  }

  main {
    width: min(100vw - 20px, 1120px);
    margin-top: 14px;
  }
}
