:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #14110f;
  --panel-strong: #1d1814;
  --line: #35302a;
  --line-strong: #544831;
  --text: #f7f3ec;
  --muted: #b9b0a5;
  --gold: #ffc400;
  --gold-soft: rgba(255, 196, 0, 0.16);
  --blue: #63b3ff;
  --green: #5ee0a0;
  --red: #ff6b6b;
  --shadow: rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

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

.login-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 64px var(--shadow);
  padding: 28px;
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #090908;
  color: var(--gold);
  font-weight: 800;
}

.brand-block h1,
.topbar h1,
.panel-heading h2,
.ticket-detail h2,
.detail-section h3 {
  margin: 0;
}

.brand-block h1 {
  font-size: 22px;
}

.brand-block p,
.detail-meta,
.ticket-meta,
.ticket-preview,
.session-box,
.empty-state,
.field span,
.select-field span,
.search-field span,
.metric span,
.panel-heading span,
.data-list dt,
.response-footer p {
  color: var(--muted);
}

.brand-block p {
  margin: 4px 0 0;
}

.field,
.select-field,
.search-field {
  display: grid;
  gap: 7px;
}

.field,
.select-field {
  margin-bottom: 14px;
}

.field span,
.select-field span,
.search-field span {
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0b0b;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 164px;
  resize: vertical;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--gold);
  color: #14100a;
}

.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.ghost-button {
  padding: 0 14px;
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

.ghost-link,
.primary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.ghost-link {
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--text);
}

.primary-link {
  background: var(--gold);
  color: #14100a;
  padding: 0 18px;
}

.icon-button {
  display: grid;
  width: 44px;
  place-items: center;
  border-color: var(--line);
  background: var(--panel);
  color: var(--gold);
  font-size: 22px;
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 14px;
}

#generateInfo {
  margin: -6px 0 14px;
  color: var(--muted);
}

.admin-view {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.toolbar,
.response-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h1 {
  margin-top: 4px;
  font-size: clamp(24px, 4vw, 36px);
}

.session-box {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.toolbar {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.toolbar .search-field {
  flex: 1 1 420px;
}

.toolbar .select-field {
  flex: 0 0 210px;
  margin-bottom: 0;
}

.toolbar-action {
  flex: 0 0 auto;
  width: auto;
  padding: 0 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 86px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.accent-blue {
  border-left-color: var(--blue);
}

.accent-green {
  border-left-color: var(--green);
}

.accent-muted {
  border-left-color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.ticket-list-panel,
.ticket-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.ticket-list-panel {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  font-size: 18px;
}

.ticket-list {
  max-height: calc(100vh - 330px);
  min-height: 320px;
  overflow: auto;
}

.ticket-item {
  display: grid;
  width: 100%;
  min-height: 92px;
  grid-template-columns: 12px minmax(0, 1fr) 24px;
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  padding: 14px 16px;
  text-align: left;
}

.ticket-item:hover,
.ticket-item.active {
  background: var(--panel-strong);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--gold);
}

.ticket-item-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ticket-subject,
.ticket-meta,
.ticket-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-meta,
.ticket-preview {
  font-size: 13px;
}

.ticket-arrow {
  color: var(--muted);
  font-size: 30px;
}

.ticket-detail {
  min-height: 540px;
  padding: 18px;
}

.empty-state {
  display: grid;
  min-height: 500px;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  font-size: 28px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin-top: 10px;
  font-size: 26px;
}

.status-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 14px;
  margin-bottom: 16px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0c0b;
  padding: 16px;
}

.detail-section h3 {
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 16px;
}

.detail-section p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.data-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.data-list div {
  display: grid;
  gap: 4px;
}

.data-list dt {
  font-size: 12px;
  font-weight: 800;
}

.data-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

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

.compact-form .field,
.compact-form .select-field {
  margin-bottom: 0;
}

.compact-form .primary-button {
  width: auto;
  min-width: 160px;
  padding: 0 18px;
}

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide-field {
  grid-column: 1 / -1;
}

.grid-form .form-error {
  grid-column: 1 / -1;
}

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

.form-actions .primary-button,
.form-actions .ghost-button {
  width: auto;
  min-width: 170px;
  padding: 0 18px;
}

.inline-action {
  min-height: 34px;
  margin: 2px 4px 2px 0;
  padding: 0 10px;
  font-size: 13px;
}

.inline-link {
  min-height: 34px;
  margin: 2px 4px 2px 0;
  padding: 0 10px;
  font-size: 13px;
}

.check-field {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-row,
.muted-line {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090908;
  padding: 10px 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

button.compact-row {
  width: 100%;
  cursor: pointer;
  text-align: left;
}

button.compact-row:hover {
  border-color: var(--gold);
  color: var(--text);
}

.audit-heading {
  margin: -18px -18px 16px;
}

.audit-list {
  display: grid;
  gap: 12px;
}

.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0c0b;
  padding: 14px;
}

.audit-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.audit-action {
  color: var(--gold);
}

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

.audit-data {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}

.audit-metadata {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090908;
  color: var(--muted);
  padding: 10px;
  white-space: pre-wrap;
}

.finance-section {
  margin-top: 16px;
}

.response-footer {
  margin-top: 14px;
}

.response-footer .primary-button {
  width: auto;
  min-width: 170px;
  padding: 0 18px;
}

@media (max-width: 980px) {
  .metrics-grid,
  .workspace,
  .detail-grid,
  .audit-data {
    grid-template-columns: 1fr;
  }

  .ticket-list {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .admin-view {
    padding: 14px;
  }

  .topbar,
  .toolbar,
  .session-box,
  .response-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar .select-field,
  .toolbar .search-field {
    flex-basis: auto;
    width: 100%;
  }

  .toolbar-action {
    width: 100%;
  }

  .icon-button {
    width: 100%;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .response-footer .primary-button {
    width: 100%;
  }

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

  .form-actions .primary-button,
  .form-actions .ghost-button {
    width: 100%;
  }
}
