:root {
  color-scheme: light;
  --bg: #f8f9fb;
  --panel: #fffefa;
  --panel-strong: #fff4e8;
  --ink: #161a20;
  --ink-soft: #373d47;
  --muted: #626a76;
  --line: #e4e0d8;
  --line-strong: #d4ccc0;
  --accent: #ed752e;
  --accent-dark: #a9461e;
  --green: #2d7b5f;
  --green-soft: #eaf5ef;
  --gold: #d69b31;
  --red: #c3453f;
  --blue: #2f638f;
  --shadow: 0 24px 70px rgba(64, 53, 42, 0.14);
  --radius: 8px;
  --control-radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --font: "Avenir Next", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.62;
}

body[data-app="simpic"] {
  background: var(--bg);
}

body.admin-body {
  background: #f5f6f2;
}

a {
  color: var(--accent-dark);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(228, 224, 216, 0.86);
  background: rgba(255, 254, 250, 0.9);
  backdrop-filter: blur(16px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
}

body[data-page="feedback"] .topbar {
  position: static;
}

body[data-page="feedback"] .nav {
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--ink);
  color: #fffaf2;
  font-weight: 900;
}

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

.ghost-link,
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(237, 117, 46, 0.24);
  border-radius: var(--control-radius);
  background: #fff4e8;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  line-height: 1.14;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(40px, 7vw, 72px);
}

h2 {
  font-size: clamp(26px, 3.4vw, 40px);
}

h3 {
  font-size: 20px;
}

.section {
  padding: 42px 0 72px;
}

.feedback-page {
  padding: 18px 0 64px;
}

.feedback-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: start;
  gap: 18px;
}

.panel,
.ticket-card,
.admin-panel,
.auth-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.96);
  box-shadow: 0 16px 42px rgba(38, 54, 48, 0.08);
}

.panel {
  padding: 26px;
}

.feedback-panel {
  max-width: none;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel-header.compact {
  margin-bottom: 18px;
}

.panel-header.compact h1,
.panel-header.compact h2 {
  font-size: 26px;
}

.panel-header p,
.muted {
  color: var(--muted);
}

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

.field {
  display: grid;
  gap: 7px;
}

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

.field label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.field small {
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
.searchbar input,
.searchbar select,
.compact-input,
.token-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  background: #fffaf2;
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
}

.field input[type="file"] {
  padding: 9px 12px;
}

.field textarea {
  min-height: 150px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.searchbar input:focus,
.searchbar select:focus,
.compact-input:focus,
.token-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 116, 99, 0.14);
}

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

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: #fffaf2;
  color: var(--ink-soft);
  font-weight: 850;
}

.segmented input:checked + label {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffaf2;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.button,
.button-secondary,
.button-danger,
.button-quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--control-radius);
  padding: 0 16px;
  font-weight: 900;
  text-decoration: none;
}

.button {
  border: 1px solid rgba(237, 117, 46, 0.26);
  background: #fff4e8;
  color: var(--accent-dark);
}

.button-secondary {
  border: 1px solid rgba(237, 117, 46, 0.26);
  background: #fff4e8;
  color: var(--accent-dark);
}

.button.primary-soft {
  border-color: rgba(237, 117, 46, 0.28);
  background: #fff4e8;
  color: var(--accent-dark);
}

.button.wide {
  width: min(100%, 620px);
}

.submit-actions {
  justify-content: center;
}

.button-quiet {
  border: 1px solid var(--line);
  background: #fffaf2;
  color: var(--ink-soft);
}

.button-danger {
  border: 1px solid rgba(179, 58, 47, 0.34);
  background: #fff0ed;
  color: var(--red);
}

.button:hover,
.button-secondary:hover,
.button-quiet:hover,
.button-danger:hover {
  transform: translateY(-1px);
}

.button[disabled],
.button-secondary[disabled],
.button-quiet[disabled] {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.ticket-card {
  padding: 20px;
}

.ticket-result {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.ticket-card h3 {
  margin-bottom: 10px;
}

.status-box {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.code {
  display: inline-flex;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  color: var(--ink);
  font-size: 13px;
}

.notice {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(31, 116, 99, 0.22);
  background: var(--green-soft);
  color: var(--ink);
}

.notice.error {
  border-color: rgba(179, 58, 47, 0.28);
  background: #fff0ed;
  color: var(--red);
}

.notice.is-visible {
  display: block;
}

.notice.always {
  display: block;
}

.ticket-picker {
  margin-bottom: 14px;
}

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

.upload-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: #fffaf2;
  color: var(--ink-soft);
  text-decoration: none;
}

.upload-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item small {
  flex: 0 0 auto;
  color: var(--muted);
}

.ticket-thread {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.message {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf2;
}

.message.admin {
  border-color: rgba(31, 116, 99, 0.28);
  background: #edf6f1;
}

.message.internal {
  border-color: rgba(220, 166, 61, 0.34);
  background: #fff8df;
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.footer {
  padding: 28px 0 42px;
  color: var(--muted);
  font-size: 13px;
}

.admin-layout {
  min-height: calc(100vh - 68px);
}

.admin-main {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  min-width: 0;
  padding: 22px 0 28px;
}

.admin-overview {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.4fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
}

.overview-copy,
.overview-meta {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.94);
  box-shadow: 0 12px 32px rgba(38, 54, 48, 0.06);
}

.overview-copy {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 20px;
}

.overview-copy h1 {
  font-size: 30px;
}

.overview-copy .eyebrow,
.overview-meta .eyebrow,
.admin-panel-head .eyebrow {
  margin-bottom: 8px;
}

.overview-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr);
  gap: 18px;
  padding: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  min-height: 88px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.9);
  box-shadow: 0 10px 24px rgba(38, 54, 48, 0.05);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.72fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-panel {
  min-width: 0;
  overflow: hidden;
}

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

.searchbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(112px, 0.6fr)) auto;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.ticket-row {
  position: relative;
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 82px 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.ticket-row:hover,
.ticket-row.active {
  background: #fff8ea;
}

.ticket-row.active {
  box-shadow: inset 0 0 0 1px rgba(237, 117, 46, 0.36);
}

.ticket-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-row-time {
  position: absolute;
  top: 15px;
  right: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.row-meta,
.badge-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf1;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 850;
}

.badge.open,
.badge.waiting_user,
.badge.triaged {
  border-color: rgba(231, 98, 50, 0.3);
  background: #fff0e8;
  color: var(--accent-dark);
}

.badge.replied,
.badge.closed {
  border-color: rgba(31, 116, 99, 0.28);
  background: var(--green-soft);
  color: var(--green);
}

.badge.urgent,
.badge.high {
  border-color: rgba(179, 58, 47, 0.34);
  background: #fff0ed;
  color: var(--red);
}

.detail-empty {
  display: grid;
  place-items: center;
  min-height: 420px;
  color: var(--muted);
  padding: 30px;
  text-align: center;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  gap: 0;
  min-height: calc(100vh - 330px);
}

.detail-content {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
  padding: 18px;
}

.detail-title,
.detail-section {
  display: grid;
  gap: 12px;
}

.detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-title h2 {
  max-width: 760px;
  font-size: 28px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.detail-title .badge-line {
  margin-top: 12px;
}

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

.kv {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf1;
}

.kv span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.kv strong {
  overflow-wrap: anywhere;
}

.detail-actions {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: #fff8ec;
}

.detail-action-card {
  display: grid;
  gap: 12px;
}

.detail-action-card h3,
.reply-box h3 {
  font-size: 16px;
}

.detail-actions .actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 0;
}

.detail-actions .button,
.detail-actions .button-secondary,
.detail-actions .button-quiet {
  justify-content: center;
  width: 100%;
}

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

.reply-box {
  display: grid;
  gap: 10px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  border: 0;
}

.reply-box textarea {
  min-height: 118px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fffaf1;
  padding: 10px 12px;
  resize: vertical;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 800;
}

.app-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.app-list.compact {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-top: 0;
}

.app-pill {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf1;
}

.app-pill strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.auth-card {
  width: min(430px, 100%);
  padding: 24px;
}

.auth-card .field {
  margin-top: 18px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .feedback-grid,
  .admin-layout,
  .admin-grid,
  .admin-overview,
  .overview-meta,
  .metric-grid,
  .detail-body {
    grid-template-columns: 1fr;
  }

  .admin-main {
    width: min(100% - 28px, 1180px);
  }

  .admin-overview,
  .overview-meta {
    min-width: 0;
  }

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

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

  .detail-body {
    min-height: 0;
  }

  .detail-actions {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 28px, 1180px);
  }

  body:not([data-page="feedback"]) .nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  body[data-page="feedback"] .nav {
    gap: 12px;
  }

  body[data-page="feedback"] .brand {
    min-width: 0;
  }

  body[data-page="feedback"] .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    min-width: 0;
    overflow: visible;
    padding-bottom: 0;
  }
  }

  .form-grid,
  .detail-fields,
  .editor-grid,
  .searchbar {
    grid-template-columns: 1fr;
  }

  .ticket-row {
    padding-right: 16px;
  }

  .ticket-row-time {
    position: static;
    order: -1;
  }

  .panel {
    padding: 18px;
  }

  .admin-main {
    width: min(100% - 24px, 1180px);
    padding: 14px 0;
  }

  .admin-overview,
  .metric-grid,
  .admin-grid {
    gap: 12px;
  }

  .overview-copy,
  .overview-meta,
  .detail-content,
  .detail-actions {
    padding: 14px;
  }
}
