:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --text: #18212c;
  --muted: #667085;
  --line: #d9e2ec;
  --primary: #246bfe;
  --primary-strong: #1752ce;
  --primary-soft: #e8f0ff;
  --green: #16845b;
  --green-soft: #e6f7ef;
  --red: #c93a3a;
  --red-soft: #fff0ee;
  --amber: #b66b00;
  --amber-soft: #fff5df;
  --violet: #7454c7;
  --violet-soft: #f1ecfb;
  --shadow: 0 18px 45px rgba(31, 42, 68, 0.1);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(36, 107, 254, 0.18);
  font-family:
    "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(36, 107, 254, 0.08), transparent 320px),
    var(--bg);
}

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: var(--primary);
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.topbar,
.top-actions,
.brand,
.form-actions,
.filter-row,
.report-card-top,
.admin-item-top,
.tag-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.brand {
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand small,
.eyebrow {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand strong {
  display: block;
  font-size: 1.15rem;
}

.top-actions {
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
}

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

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

.button-ghost {
  background: color-mix(in srgb, var(--surface) 85%, var(--surface-2));
}

.button-danger {
  color: #fff;
  border-color: var(--red);
  background: var(--red);
}

.button-danger:hover {
  border-color: color-mix(in srgb, var(--red) 75%, #000);
  background: color-mix(in srgb, var(--red) 88%, #000);
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.auth-tab:focus-visible,
.admin-item:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header,
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.page-heading {
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 1.35rem + 1vw, 2.35rem);
  line-height: 1.12;
}

h2 {
  font-size: 1.12rem;
}

.muted,
.auth-copy p,
.report-card p {
  color: var(--muted);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px);
  gap: 22px;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 140px);
}

.auth-copy {
  max-width: 620px;
}

.auth-copy h1 {
  margin-bottom: 14px;
}

.auth-copy p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.75;
}

.auth-panel {
  padding: 20px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}

.auth-tab.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(31, 42, 68, 0.08);
}

.auth-panel h2 {
  margin-bottom: 18px;
}

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

.field strong {
  color: var(--red);
}

.field input,
.field select,
.field textarea,
.search-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
}

.field input,
.field select,
.field textarea {
  min-height: 42px;
  padding: 10px 12px;
}

.field textarea {
  resize: vertical;
  line-height: 1.55;
}

.field input::placeholder,
.field textarea::placeholder,
.search-field input::placeholder {
  color: color-mix(in srgb, var(--muted) 66%, transparent);
}

#authForm,
#reportForm,
.admin-form {
  display: grid;
  gap: 16px;
}

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

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

.form-actions {
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 20px 20px;
}

.form-message {
  min-height: 24px;
  margin: -6px 0 0;
  padding: 0 20px 18px;
  color: var(--muted);
  font-weight: 780;
}

#authForm .form-message {
  padding: 0;
}

.form-message.success {
  color: var(--green);
}

.form-message.error {
  color: var(--red);
}

.user-chip,
.count-pill,
.issue-id {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 850;
}

.user-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.history-list,
.admin-list,
.deleted-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.history-header {
  align-items: center;
}

.report-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.report-card-top {
  gap: 8px;
  flex-wrap: wrap;
}

.report-card h3 {
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.report-card p {
  margin: 0;
  line-height: 1.55;
}

.report-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
}

.pill,
.tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
}

.pill.blocker,
.pill.critical {
  color: var(--red);
  background: var(--red-soft);
}

.pill.normal {
  color: var(--amber);
  background: var(--amber-soft);
}

.pill.minor {
  color: var(--green);
  background: var(--green-soft);
}

.pill.status {
  color: var(--primary);
  background: var(--primary-soft);
}

.tag {
  color: var(--muted);
  background: var(--surface-2);
}

.tag-row {
  gap: 6px;
  flex-wrap: wrap;
}

.admin-note {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: var(--radius);
  color: var(--green);
  background: var(--green-soft);
  line-height: 1.5;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 18px 40px;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin: 0;
}

.guard-view {
  display: grid;
  min-height: calc(100vh - 140px);
  place-items: center;
}

.guard-panel {
  display: grid;
  max-width: 480px;
  justify-items: center;
  gap: 14px;
  padding: 30px;
  text-align: center;
}

.guard-panel svg {
  width: 34px;
  height: 34px;
  color: var(--primary);
}

.guard-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

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

.stat {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat span {
  font-size: 1.35rem;
  font-weight: 900;
}

.stat small {
  color: var(--muted);
  font-weight: 780;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(380px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.filter-row {
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-row select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  padding: 0 10px;
}

.search-field {
  display: flex;
  min-width: min(290px, 100%);
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.admin-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  text-align: left;
}

.admin-item:hover,
.admin-item.is-active {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
  background: var(--primary-soft);
}

.admin-item-top {
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-item strong {
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.deleted-panel {
  margin-top: 20px;
}

.deleted-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.deleted-item h3 {
  margin: 8px 0;
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.detail-panel {
  position: sticky;
  top: 16px;
}

.detail-body {
  display: grid;
  gap: 16px;
  padding: 18px 20px;
}

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

.detail-meta span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-2);
}

.detail-meta b {
  color: var(--text);
}

.detail-meta a {
  overflow-wrap: anywhere;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section h3 {
  font-size: 0.96rem;
}

.detail-section p,
.detail-section li {
  color: var(--muted);
  line-height: 1.6;
}

.detail-section p,
.detail-section ol {
  margin: 0;
}

.detail-section pre {
  margin: 0;
  max-height: 190px;
  overflow: auto;
  padding: 12px;
  border-radius: var(--radius);
  color: var(--text);
  background: #111820;
  font:
    0.84rem/1.55 "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 850;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
  flex: 0 0 auto;
}

@media (max-width: 1080px) {
  .auth-layout,
  .user-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  .topbar,
  .page-heading,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .filter-row,
  .form-actions {
    align-items: stretch;
  }

  .top-actions .button,
  .form-actions .button,
  .filter-row select,
  .search-field {
    flex: 1 1 100%;
  }

  .form-grid,
  .stats-row,
  .detail-meta,
  .deleted-item {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    align-items: start;
    min-height: auto;
  }
}
