:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --blue: #0071e3;
  --blue-dark: #005bb5;
  --paper: #ffffff;
  --wash: #f5f5f7;
  --line: #e5e5ea;
  --success: #13795b;
  --warning: #a85d00;
  --danger: #b42318;
  --shadow: 0 18px 55px rgba(0, 0, 0, .07);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(0, 0, 0, .07);
  background: rgba(250, 250, 252, .9);
  backdrop-filter: saturate(180%) blur(20px);
}
.admin-topbar-inner {
  width: min(1240px, calc(100% - 40px));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 28px;
}
.admin-brand { display: flex; align-items: center; gap: 11px; min-width: max-content; font-weight: 850; }
.admin-brand img { width: 46px; height: 46px; object-fit: contain; border-radius: 50%; }
.admin-brand small { display: block; margin-top: -3px; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .12em; }
.admin-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.admin-nav a { padding: 8px 13px; border-radius: 999px; color: #555b64; font-size: 14px; font-weight: 750; }
.admin-nav a:hover, .admin-nav a[aria-current="page"] { color: #075fae; background: #eaf4ff; }
.admin-account { display: flex; align-items: center; gap: 12px; color: #60656e; font-size: 13px; }
.admin-account form { margin: 0; }

.admin-main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 0; font-size: clamp(32px, 4vw, 48px); line-height: 1.1; letter-spacing: -.035em; }
.page-heading p { margin: 9px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.page-actions form { margin: 0; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  cursor: pointer;
  transition: .18s ease;
}
.button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.button-secondary { color: #075fae; background: #eef6ff; border-color: #c9e1fb; }
.button-secondary:hover { background: #dfefff; }
.button-quiet { min-height: 36px; padding: 6px 11px; color: #555b64; background: #fff; border-color: #dedee3; font-size: 13px; }
.button-quiet:hover { color: #075fae; background: #f3f8ff; }
.button-small { min-height: 34px; padding: 6px 10px; border-radius: 9px; font-size: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; margin-bottom: 22px; }
.stat-card { padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); }
.stat-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 750; }
.stat-card strong { display: block; margin-top: 4px; font-size: 30px; line-height: 1.2; }
.stat-card.pending strong { color: var(--warning); }
.stat-card.processing strong { color: var(--blue); }
.stat-card.resolved strong { color: var(--success); }
.stat-card.urgent strong { color: var(--danger); }

.filter-card { margin-bottom: 22px; padding: 18px; border-radius: 20px; background: var(--wash); }
.filter-form { display: grid; grid-template-columns: minmax(220px, 1fr) 170px 170px auto; gap: 10px; align-items: end; }
.field { display: grid; gap: 7px; }
.field span { color: #41464f; font-size: 12px; font-weight: 800; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #d8d8de;
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  outline: 0;
}
.field textarea { resize: vertical; line-height: 1.65; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #62a9ed; box-shadow: 0 0 0 4px rgba(0, 113, 227, .1); }
.filter-actions { display: flex; gap: 8px; }

.notice { margin-bottom: 20px; padding: 12px 15px; border: 1px solid #b8e1d1; border-radius: 12px; color: #0b6b4d; background: #effaf6; font-size: 14px; }
.notice.error { border-color: #f0bbb6; color: var(--danger); background: #fff3f2; }
.result-summary { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.feedback-list { display: grid; gap: 12px; }
.feedback-card { padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 8px 26px rgba(0, 0, 0, .035); }
.feedback-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.feedback-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.feedback-id { color: #858991; font: 650 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge { padding: 4px 9px; border-radius: 999px; color: #4b5563; background: #f0f1f3; font-size: 11px; font-weight: 800; }
.badge.pending { color: #8b4d00; background: #fff3df; }
.badge.processing { color: #075fae; background: #eaf4ff; }
.badge.resolved { color: #0d6b4d; background: #e8f8f1; }
.badge.archived { color: #666b74; background: #eeeeef; }
.badge.category { color: #5b527b; background: #f0edfa; }
.badge.priority-important { color: #98530b; background: #fff2e3; }
.badge.priority-urgent { color: #a32118; background: #fff0ef; }
.badge.priority-normal { color: #56606c; background: #f0f2f4; }
.feedback-time { margin-top: 7px; color: #83878f; font-size: 12px; }
.feedback-message { margin: 18px 0 15px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.feedback-contact { padding-top: 13px; border-top: 1px solid #eeeeef; color: #666b74; font-size: 13px; overflow-wrap: anywhere; }
.feedback-contact strong { color: #3f444c; }
.feedback-select-wrap { display: flex; align-items: flex-start; gap: 13px; }
.feedback-select { width: 18px; height: 18px; margin: 4px 0 0; accent-color: var(--blue); }
.admin-note { margin-top: 14px; padding: 13px 15px; border-left: 3px solid #76aee4; border-radius: 0 11px 11px 0; background: #f5f9fd; }
.admin-note strong { color: #365f87; font-size: 12px; }
.admin-note p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #4e5966; font-size: 13px; }
.feedback-editor { margin-top: 15px; border-top: 1px solid #eeeeef; }
.feedback-editor summary { width: max-content; padding-top: 13px; color: #075fae; font-size: 13px; font-weight: 800; cursor: pointer; }
.feedback-edit-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-top: 14px; padding: 17px; border-radius: 16px; background: var(--wash); }
.feedback-note-field { grid-column: 1 / -1; }
.feedback-edit-action { grid-column: 1 / -1; }
.empty-state { padding: 56px 24px; border: 1px dashed #d4d4da; border-radius: 22px; color: var(--muted); text-align: center; background: #fafafa; }

.bulk-toolbar { display: flex; align-items: center; gap: 11px; margin: 0 0 13px; padding: 13px 15px; border: 1px solid #d8e7f7; border-radius: 15px; background: #f5f9fd; }
.bulk-toolbar > span { margin-right: auto; color: #3e5368; font-size: 13px; font-weight: 800; }
.bulk-toolbar .field { width: min(330px, 100%); }
.bulk-toolbar select { min-height: 42px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.dashboard-stats { margin-bottom: 26px; }
.dashboard-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; }
.dashboard-wide { grid-column: 1 / -1; }
.panel-card { padding: 23px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 9px 30px rgba(0, 0, 0, .035); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.panel-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-heading > a { color: #075fae; font-size: 13px; font-weight: 800; }
.panel-note { margin: 15px 0 0; padding-top: 13px; border-top: 1px solid #eeeeef; color: var(--muted); font-size: 12px; }
.compact-empty { padding: 28px 12px; color: var(--muted); text-align: center; font-size: 13px; }
.activity-list { display: grid; }
.activity-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 2px; border-top: 1px solid #eeeeef; }
.activity-item:first-child { border-top: 0; }
.activity-item:hover strong { color: #075fae; }
.activity-main { min-width: 0; display: grid; }
.activity-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.activity-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.health-summary, .audit-result { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; font-style: normal; font-size: 11px; font-weight: 800; }
.health-summary.healthy, .audit-result.success { color: #0d6b4d; background: #e8f8f1; }
.health-summary.warning, .audit-result.failure { color: #a32118; background: #fff0ef; }
.health-list { display: grid; }
.health-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid #eeeeef; font-size: 13px; }
.health-row:first-child { border-top: 0; }
.health-row span { display: flex; align-items: center; gap: 8px; color: #4d535c; }
.health-row strong { color: #3d424a; font-size: 12px; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #aeb4bc; }
.health-dot.healthy { background: #25a878; }
.health-dot.warning { background: #d7463e; }
.audit-compact-list { display: grid; }
.audit-compact-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 2px; border-top: 1px solid #eeeeef; }
.audit-compact-row:first-child { border-top: 0; }
.audit-compact-row > span { min-width: 0; display: grid; gap: 2px; }
.audit-compact-row > span:last-child { justify-items: end; }
.audit-compact-row strong { font-size: 13px; }
.audit-compact-row small { color: var(--muted); font-size: 11px; }

.audit-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.audit-filter-form { grid-template-columns: minmax(220px, 1fr) minmax(180px, .7fr) auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 18px; }
.audit-table { width: 100%; min-width: 780px; border-collapse: collapse; background: #fff; font-size: 13px; }
.audit-table th { padding: 13px 16px; color: #60656e; background: #f7f7f9; text-align: left; font-size: 11px; }
.audit-table td { padding: 14px 16px; border-top: 1px solid #eeeeef; vertical-align: top; }

.form-panel { max-width: 680px; padding: 26px; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.form-grid { display: grid; gap: 18px; }
.form-note { margin: 0; color: var(--muted); font-size: 13px; }
.form-error { margin: 0; padding: 11px 13px; border-radius: 10px; color: var(--danger); background: #fff1f0; font-size: 13px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, #fff 0%, #f5f5f7 100%); }
.login-shell { width: min(460px, 100%); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; font-size: 20px; font-weight: 850; }
.login-brand img { width: 58px; height: 58px; object-fit: contain; border-radius: 50%; }
.login-card { padding: 32px; border: 1px solid var(--line); border-radius: 28px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 30px; letter-spacing: -.03em; }
.login-card > p { margin: 8px 0 25px; color: var(--muted); font-size: 14px; }
.login-card .button { width: 100%; margin-top: 3px; }
.setup-box { padding: 16px; border-radius: 14px; color: #5b4a24; background: #fff8e8; font-size: 13px; }
.setup-box strong { display: block; margin-bottom: 7px; color: #72530a; }
.setup-box code { display: block; margin-top: 10px; padding: 10px; overflow-wrap: anywhere; border-radius: 9px; color: #343434; background: rgba(255,255,255,.8); font: 600 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.back-home { display: block; margin-top: 18px; color: #686d76; font-size: 13px; text-align: center; }
.back-home:hover { color: var(--blue); }

@media (max-width: 900px) {
  .admin-topbar-inner { flex-wrap: wrap; gap: 8px 16px; padding: 10px 0; }
  .admin-nav { order: 3; width: 100%; overflow-x: auto; margin-left: 0; }
  .admin-account { margin-left: auto; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-form { grid-template-columns: 1fr 1fr; }
  .filter-form .field:first-child { grid-column: 1 / -1; }
  .filter-form-extended .filter-query { grid-column: 1 / -1; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-wide { grid-column: auto; }
}

@media (max-width: 600px) {
  .admin-main, .admin-topbar-inner { width: min(100% - 24px, 1240px); }
  .admin-main { padding-top: 30px; }
  .admin-brand span { font-size: 14px; }
  .admin-brand img { width: 40px; height: 40px; }
  .admin-account > span { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 16px; }
  .filter-form { grid-template-columns: 1fr; }
  .filter-form .field:first-child { grid-column: auto; }
  .filter-actions { flex-wrap: wrap; }
  .bulk-toolbar { align-items: stretch; flex-direction: column; }
  .bulk-toolbar > span { margin-right: 0; }
  .bulk-toolbar .field, .bulk-toolbar .button { width: 100%; }
  .feedback-card { padding: 17px; }
  .feedback-card-head { align-items: stretch; flex-direction: column; }
  .feedback-card-head form .button { width: 100%; }
  .feedback-edit-form { grid-template-columns: 1fr; }
  .feedback-note-field, .feedback-edit-action { grid-column: auto; }
  .audit-stats { grid-template-columns: 1fr 1fr; }
  .audit-filter-form { grid-template-columns: 1fr; }
  .audit-compact-row { align-items: flex-start; flex-direction: column; }
  .audit-compact-row > span:last-child { justify-items: start; }
  .login-card { padding: 25px 20px; border-radius: 22px; }
}
