:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f5;
  --border: #d6dee2;
  --text: #172026;
  --muted: #68757f;
  --primary: #1f6f8b;
  --primary-strong: #155573;
  --success: #247a4a;
  --success-soft: #e3f4ea;
  --warning: #9a6400;
  --warning-soft: #fff2cf;
  --danger: #b42318;
  --danger-soft: #fde7e4;
  --focus: #0b84a5;
  --shadow: 0 14px 38px rgb(23 32 38 / 10%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid rgb(11 132 165 / 35%);
  outline-offset: 2px;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card {
  display: grid;
  width: min(100%, 420px);
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-heading {
  display: grid;
  gap: 4px;
}

.auth-heading h1,
.topbar h1 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 2rem);
  line-height: 1.15;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-login {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
}

.tab {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}

.tab.active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.content {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 20px clamp(16px, 4vw, 40px) 40px;
}

.panel {
  display: grid;
  gap: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.2;
}

.button.primary {
  background: var(--primary);
  color: white;
}

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

.button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--primary-strong);
}

.button.success {
  background: var(--success);
  color: white;
}

.button.warning {
  background: var(--warning);
  color: white;
}

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

.button.compact {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.button.wide {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.inline-select select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.password-control {
  position: relative;
  display: grid;
}

.password-control input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: inline-grid;
  width: 36px;
  height: 32px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.password-toggle-icon {
  position: relative;
  width: 18px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 80% 20% / 80% 20%;
  transform: translateY(-50%) rotate(45deg);
}

.password-toggle-icon::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  transform: translate(-50%, -50%);
}

.password-toggle.visible .password-toggle-icon::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  content: "";
  transform: translate(-50%, -50%) rotate(90deg);
}

.field input,
.field select,
.inline-select select {
  padding: 8px 10px;
}

.field .password-control input {
  padding-right: 48px;
}

.field textarea {
  min-height: 88px;
  padding: 10px;
  resize: vertical;
}

.inline-select {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.inline-select select {
  width: auto;
  min-width: 170px;
}

.message,
.notice {
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 8px;
}

.message.danger,
.notice.danger {
  border-color: #f4b6ae;
  background: var(--danger-soft);
  color: #7a1a13;
}

.message.warning,
.notice.warning {
  border-color: #f2ce82;
  background: var(--warning-soft);
  color: #614000;
}

.message.success,
.notice.success {
  border-color: #a9dec0;
  background: var(--success-soft);
  color: #14532d;
}

.notices {
  display: grid;
  gap: 8px;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  gap: 8px;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.empty-state p {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.state-kind {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
  text-transform: uppercase;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.subline,
.muted {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.87rem;
}

.danger-text {
  color: var(--danger);
}

.notification-cell {
  display: grid;
  gap: 4px;
  align-items: start;
}

.compact-textarea {
  width: 100%;
  min-width: 180px;
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 750;
  white-space: nowrap;
}

.badge.success {
  background: var(--success-soft);
  color: #14532d;
}

.badge.warning {
  background: var(--warning-soft);
  color: #614000;
}

.badge.danger {
  background: var(--danger-soft);
  color: #7a1a13;
}

.badge.neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.access-form .field:first-child {
  grid-column: 1 / -1;
}

.span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.result-box,
.inline-form,
.ticket-detail {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.result-box > div:first-child,
.detail-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.result-box h2,
.inline-form h2,
.ticket-detail h2,
.message-thread h3 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
}

.key-values {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
}

.key-values dt {
  color: var(--muted);
  font-weight: 700;
}

.key-values dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.warning-form {
  border-color: #f2ce82;
  background: #fffaf0;
}

.warning-copy {
  margin: 4px 0 0;
  color: #614000;
}

.support-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
}

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

.ticket-card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.ticket-card.active {
  border-color: var(--primary);
  box-shadow: inset 4px 0 0 var(--primary);
}

.ticket-title {
  font-weight: 800;
}

.message-thread {
  display: grid;
  gap: 10px;
}

.thread-message {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
}

.thread-message.admin {
  border-color: #bbd8e3;
  background: #eef8fb;
}

.thread-message p {
  margin: 0;
  white-space: pre-wrap;
}

.message-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.reply-form {
  display: grid;
  gap: 12px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-select {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-select select {
    width: 100%;
  }

  .form-grid,
  .support-layout {
    grid-template-columns: 1fr;
  }

  .key-values {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }
}
