:root {
  color-scheme: dark;
  --page: #101112;
  --sidebar: #141516;
  --surface: #191a1c;
  --surface-raised: #202225;
  --surface-hover: #25272a;
  --field: #121314;
  --line: #303236;
  --line-strong: #45484d;
  --text: #ececea;
  --muted: #999b9e;
  --faint: #6f7276;
  --accent: #e8c15a;
  --accent-ink: #17140b;
  --green: #61c995;
  --red: #e77b86;
  --amber: #ddb86a;
}

* {
  box-sizing: border-box;
}
html {
  background: var(--page);
}
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: "Kanit", sans-serif;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.55;
}
button,
input,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.custom-select-trigger:focus-visible,
.custom-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  padding: 38px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}
.brand-mark,
.logo span {
  display: grid;
  place-items: center;
  background: var(--text);
  color: #171819;
  font-weight: 700;
}
.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 22px;
  border-radius: 5px;
}
.product-label,
.section-context {
  margin: 0 0 3px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 400;
}
.login-card h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 500;
}
.muted,
.login-note {
  color: var(--muted);
}
.discord-login,
.button {
  border: 0;
  border-radius: 5px;
  font-weight: 400;
}
.discord-login {
  display: flex;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin: 26px 0 12px;
  padding: 11px 14px;
  background: #5865f2;
  color: white;
}
.discord-login:hover {
  background: #6874ee;
}
.discord-login:disabled {
  cursor: wait;
  opacity: 0.55;
}
.login-note {
  margin-bottom: 0;
  font-size: 12px;
}
.alert {
  padding: 10px 12px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.alert.error {
  border-color: #663c42;
  background: #29191c;
  color: #ef9da5;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 12px 14px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 28px;
  color: var(--text);
  text-decoration: none;
}
.logo span {
  width: 31px;
  height: 31px;
  border-radius: 4px;
  font-size: 12px;
}
.logo strong {
  font-size: 16px;
  font-weight: 500;
}
.sidebar nav {
  display: grid;
  gap: 3px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}
.nav-item i {
  width: 19px;
  color: var(--faint);
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
}
.nav-item:hover {
  background: #1d1f21;
  color: var(--text);
}
.nav-item.active {
  background: var(--surface-raised);
  color: var(--text);
}
.nav-item.active i {
  color: var(--accent);
}
.sidebar-bottom {
  margin-top: auto;
}
.status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 8px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.status-dot.online {
  background: var(--green);
}
.status div,
.profile div {
  display: grid;
}
.status strong,
.profile strong {
  font-weight: 400;
}
.status small,
.profile small {
  color: var(--muted);
  font-size: 11px;
}
.logout {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}
.logout:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.main {
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 20px 34px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.25;
}
.profile {
  display: flex;
  align-items: center;
  gap: 10px;
}
.profile img,
.profile-fallback {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
}
.profile-fallback {
  display: grid;
  place-items: center;
  background: var(--surface-raised);
  color: var(--accent);
}
#app {
  max-width: 1280px;
  padding: 30px 34px 64px;
}
.loading {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--muted);
}
.loading span {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
}
.stat-card {
  padding: 19px 21px;
  background: var(--surface);
}
.stat-card small {
  color: var(--muted);
}
.stat-value {
  margin-top: 4px;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
}
.stat-card:first-child .stat-value {
  color: var(--green);
}
.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 14px;
  margin-top: 14px;
}
.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}
.card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}
.button {
  padding: 8px 13px;
}
.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.button.primary:hover {
  background: #f1d175;
}
.button.secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.button.secondary:hover {
  background: var(--surface-hover);
}
.button.danger {
  background: #331e22;
  color: #ef9da5;
}

.ticket-list,
.category-list {
  border-top: 1px solid var(--line);
}
.ticket-row,
.category-row {
  display: grid;
  align-items: center;
  min-height: 58px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}
.ticket-row {
  grid-template-columns: minmax(0, 1fr) 110px 100px;
}
.ticket-row:hover,
.category-row:hover {
  background: rgba(255, 255, 255, 0.015);
}
.ticket-row strong,
.category-row strong {
  font-weight: 400;
}
.ticket-row small,
.category-row small {
  display: block;
  color: var(--muted);
}
.ticket-row time {
  color: var(--faint);
  font-size: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  color: var(--muted);
  font-size: 12px;
}
.pill::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}
.pill.open {
  color: var(--green);
}
.pill.closed {
  color: var(--amber);
}
.pill.deleted,
.pill.off {
  color: var(--red);
}
.category-row {
  grid-template-columns: 42px minmax(0, 1fr) 160px 130px;
  gap: 10px;
}
.cat-emoji {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--field);
  font-size: 17px;
}
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.icon-button {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}
.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}
.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.form-section {
  display: grid;
  gap: 18px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid label,
.form-section label {
  display: grid;
  gap: 6px;
  color: #d5d6d4;
  font-size: 13px;
  font-weight: 400;
}
.form-grid .wide {
  grid-column: 1 / -1;
}
input:not([type="checkbox"]),
textarea {
  width: 100%;
  min-height: 41px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  background: var(--field);
  color: var(--text);
  font-weight: 300;
  transition: border-color 120ms ease;
}
input[type="number"] {
  appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}
input:not([type="checkbox"]):focus,
textarea:focus {
  border-color: #77715e;
}
textarea {
  resize: vertical;
}
label small,
fieldset small {
  color: var(--muted);
  font-weight: 300;
}
fieldset {
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
legend {
  padding: 0 5px;
  color: #d5d6d4;
  font-size: 13px;
}

.native-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}
.custom-select {
  position: relative;
  min-width: 0;
}
.custom-select-trigger {
  position: relative;
  width: 100%;
  min-height: 41px;
  padding: 9px 36px 9px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--field);
  color: var(--text);
  text-align: left;
}
.custom-select-trigger::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  content: "";
  transform: translateY(-70%) rotate(45deg);
  transition: transform 120ms ease;
}
.custom-select.open .custom-select-trigger {
  border-color: #77715e;
}
.custom-select.open .custom-select-trigger::after {
  transform: translateY(-20%) rotate(225deg);
}
.custom-select-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  max-height: 230px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #202123;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}
.custom-select-menu[hidden] {
  display: none;
}
.custom-option {
  display: block;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}
.custom-option:hover,
.custom-option.selected {
  background: var(--surface-hover);
  color: var(--text);
}
.custom-option.selected::after {
  float: right;
  color: var(--accent);
  content: "✓";
}

.role-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 170px;
  margin-bottom: 6px;
  overflow: auto;
}
.role-choice {
  position: relative;
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted) !important;
  cursor: pointer;
  user-select: none;
}
.role-choice:hover {
  border-color: var(--line-strong);
  color: var(--text) !important;
}
.role-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.check-box {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--field);
  color: var(--accent-ink);
}
.check-box::after {
  content: "✓";
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  opacity: 0;
}
.role-choice input:focus-visible + .check-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.role-choice input:checked + .check-box {
  border-color: var(--accent);
  background: var(--accent);
}
.role-choice input:checked + .check-box::after {
  opacity: 1;
}
.role-choice:has(input:checked) {
  border-color: #6b624a;
  background: #242219;
  color: var(--text) !important;
}
.member-choice > span:last-child {
  display: grid;
  line-height: 1.2;
}
.member-choice strong {
  color: inherit;
  font-size: 13px;
  font-weight: 400;
}
.member-choice small {
  margin-top: 2px;
  color: var(--faint);
  font-size: 11px;
}
.member-picker {
  max-height: 240px;
}

.color-control {
  display: grid;
  grid-template-columns: 41px 1fr;
}
.color-swatch {
  display: block;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 5px 0 0 5px;
  background: var(--accent);
}
.color-control input {
  border-radius: 0 5px 5px 0 !important;
  font-family: ui-monospace, monospace !important;
  text-transform: uppercase;
}
.hint {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
}
.hint strong {
  color: var(--text);
  font-weight: 400;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 4, 5, 0.78);
}
.modal-backdrop[hidden] {
  display: none;
}
.modal-card {
  width: min(700px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 23px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
}
.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
}
.modal-head .icon-button {
  font-size: 18px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-raised);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}
.toast.error {
  border-color: #704149;
  color: #ef9da5;
}

@media (max-width: 900px) {
  .grid-two {
    grid-template-columns: 1fr;
  }
  .category-row {
    grid-template-columns: 42px 1fr 120px;
  }
  .category-row > .limit-info {
    display: none;
  }
}
@media (max-width: 700px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    z-index: 5;
    top: auto;
    bottom: 0;
    width: 100%;
    height: auto;
    padding: 6px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }
  .logo,
  .sidebar-bottom {
    display: none;
  }
  .sidebar nav {
    grid-template-columns: repeat(3, 1fr);
  }
  .nav-item {
    justify-content: center;
    font-size: 12px;
  }
  .nav-item i {
    display: none;
  }
  .main {
    padding-bottom: 62px;
  }
  .topbar {
    min-height: 74px;
    padding: 15px 18px;
  }
  .profile div {
    display: none;
  }
  #app {
    padding: 20px 18px 32px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .wide {
    grid-column: auto;
  }
  .ticket-row {
    grid-template-columns: 1fr auto;
  }
  .ticket-row > time {
    display: none;
  }
  .category-row {
    grid-template-columns: 38px 1fr auto;
  }
  .category-row .pill {
    display: none;
  }
  .modal-card {
    padding: 18px;
  }
}
