:root {
  --bg: #f6f3ec;
  --paper: #fffdf8;
  --ink: #202936;
  --muted: #667387;
  --line: #ded6c9;
  --soft: #f3eee4;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9f3ee;
  --danger: #be123c;
  --danger-soft: #ffe4e6;
  --shadow: 0 18px 45px rgba(45, 41, 34, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.09), transparent 34%),
    linear-gradient(300deg, rgba(37, 99, 235, 0.08), transparent 28%),
    var(--bg);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.app-header,
.entry-panel,
.panel,
.results-area {
  border: 1px solid rgba(222, 214, 201, 0.94);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 21px;
  line-height: 1.22;
}

.rule-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rule-strip span,
.count-pill,
.rank-pill,
.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 800;
}

.rule-strip span,
.count-pill {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.entry-panel,
.panel,
.results-area {
  padding: 20px;
}

.entry-panel {
  margin-bottom: 18px;
}

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

.button-row,
.mini-actions,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn,
.quick-actions button,
.mini-actions button {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--accent);
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.secondary-btn,
.quick-actions button,
.mini-actions button,
.ghost-btn {
  color: var(--ink);
  background: #ebe5d9;
}

.danger-btn {
  color: var(--danger);
  background: var(--danger-soft);
}

.entry-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.entry-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

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

.entry-number {
  font-size: 16px;
}

.entry-fields {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(150px, 1fr) minmax(130px, 0.8fr);
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.region-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.region-select {
  position: relative;
  margin-top: 12px;
}

.region-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  text-align: left;
}

.region-select-trigger span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.region-select-trigger strong {
  color: var(--ink);
  font-size: 14px;
}

.region-select-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.region-select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(45, 41, 34, 0.18);
  padding: 12px;
}

.region-select-menu .mini-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 10px;
}

.entry-region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.region-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  padding: 7px 9px;
  color: var(--ink);
}

.region-option:hover {
  background: #e2f1ed;
}

.region-option input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--accent);
}

.region-option span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

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

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

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  margin: 18px 0 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search-box span {
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.search-box input {
  min-height: 0;
  border: 0;
  padding: 0;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
}

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

.summary-grid div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  padding: 13px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.08;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 260px;
  border: 1px dashed #c8bda9;
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.72);
  color: var(--muted);
  text-align: center;
  padding: 32px;
}

.empty-state strong {
  color: var(--ink);
  font-size: 21px;
}

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

.activity-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.activity-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.activity-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.activity-title h3 {
  font-size: 18px;
  line-height: 1.3;
}

.rank-pill {
  color: #fff;
  background: var(--accent);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.meta-chip {
  border-radius: 6px;
  color: #394554;
  background: var(--soft);
}

.meta-chip.matched {
  color: var(--accent-dark);
  background: #e2f7f0;
}

.hidden {
  display: none;
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 20px, 760px);
    padding: 10px 0;
  }

  .app-header,
  .section-head,
  .panel-head,
  .activity-top {
    flex-direction: column;
    align-items: stretch;
  }

  .app-header,
  .section-head,
  .panel-head {
    display: flex;
  }

  .rule-strip {
    justify-content: flex-start;
  }

  .entry-fields,
  .workspace,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .query-panel {
    position: static;
  }

}
