:root {
  --bg: #081525;
  --surface: #0e2036;
  --surface-2: #0a192c;
  --line: #213a56;
  --line-soft: rgba(117, 150, 187, 0.2);
  --text: #edf5ff;
  --muted: #8da3bd;
  --accent: #54c9ef;
  --accent-2: #8f76eb;
  --gold: #f2ca77;
  --danger: #ff9aae;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 12% 0%, #132c4a 0, var(--bg) 36rem);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
select,
input {
  font: inherit;
  line-height: 1.45;
}

button {
  min-height: 36px;
  cursor: pointer;
}

select,
input { min-height: 40px; }

button:disabled { cursor: not-allowed; }

[hidden] { display: none !important; }

.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
  flex-direction: column;
  padding: 0 28px;
}

main {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.topbar {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  min-width: max-content;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--accent);
  border: 1px solid rgba(84, 201, 239, 0.4);
  border-radius: 8px;
  font-family: Georgia, serif;
  font-size: 22px;
  line-height: 1;
}

.brand strong { font-size: 18px; letter-spacing: 0.04em; }
.brand-subtitle { color: var(--muted); font-size: 15px; }

.topbar-actions {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.fullscreen-button {
  min-height: 36px;
  padding: 0 12px;
  color: #9fd9ea;
  border: 1px solid rgba(84, 201, 239, 0.28);
  border-radius: 5px;
  background: rgba(84, 201, 239, 0.06);
  font-size: 14px;
}

.fullscreen-button:hover { border-color: var(--accent); color: #e7fbff; }

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 14px;
}

.topbar-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64df9d;
  box-shadow: 0 0 8px #64df9d;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 18px;
}

.page-heading h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-heading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.local-note {
  padding: 8px 12px;
  color: #8bcfe4;
  border: 1px solid rgba(84, 201, 239, 0.23);
  border-radius: 5px;
  background: rgba(84, 201, 239, 0.06);
  font-size: 14px;
  white-space: nowrap;
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.73fr) minmax(530px, 1.55fr) minmax(245px, 0.62fr);
  align-items: stretch;
  gap: 12px;
}

@media (min-width: 761px) {
  .calculator-grid {
    min-height: 0;
    flex: 1;
  }

  .compact-panel { min-height: 0; }

  .detail-section {
    flex: 0 0 auto;
    margin-bottom: 0;
  }
}

.compact-panel,
.detail-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(14, 32, 54, 0.92);
}

.compact-panel { padding: 18px; }

.panel-title-row,
.number-actions,
.parsed-title-row,
.detail-heading,
.summary-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-row { min-height: 32px; margin-bottom: 12px; }
.panel-title-row h2 { margin: 0; font-size: 18px; line-height: 1.25; }

.text-button {
  min-height: 36px;
  padding: 5px 0;
  color: var(--accent);
  border: 0;
  background: transparent;
  font-size: 15px;
}

.text-button:hover:not(:disabled) { color: #b7eefa; }
.text-button:disabled { color: #627890; }

textarea,
select,
input {
  color: var(--text);
  border: 1px solid #294561;
  border-radius: 7px;
  outline: none;
  background: var(--surface-2);
}

textarea:focus,
select:focus,
input:focus {
  border-color: rgba(84, 201, 239, 0.7);
  box-shadow: 0 0 0 2px rgba(84, 201, 239, 0.1);
}

textarea {
  display: block;
  width: 100%;
  min-height: 128px;
  padding: 12px;
  resize: vertical;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 16px;
  line-height: 1.7;
}

textarea::placeholder { color: #607895; }

.number-actions {
  min-height: 42px;
  color: #7690aa;
  font-family: Consolas, monospace;
  font-size: 14px;
}

.secondary-button {
  min-height: 38px;
  padding: 0 14px;
  color: #c9eaf5;
  border: 1px solid #315370;
  border-radius: 6px;
  background: #102942;
  font-size: 15px;
}

.secondary-button:hover { border-color: var(--accent); color: var(--accent); }

.field-help {
  margin: 8px 0 0;
  color: #728aa4;
  font-size: 14px;
  line-height: 1.45;
}

.parsed-block {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
}

.parsed-title-row { margin-bottom: 5px; color: var(--muted); font-size: 14px; }
.parsed-count { color: var(--accent); }

.parsed-list {
  display: flex;
  max-height: 76px;
  flex-wrap: wrap;
  gap: 7px;
  overflow: auto;
}

.number-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  color: #dbeafd;
  border: 1px solid #29435f;
  border-radius: 4px;
  background: #0b1c31;
  font-family: Consolas, monospace;
  font-size: 14px;
}

.chip-type { color: var(--accent); font-family: Inter, "Microsoft YaHei", sans-serif; font-size: 13px; }
.number-chip.broadband .chip-type { color: #b6a1ff; }

.parameter-title-row { margin-bottom: 8px; }

.rule-bar {
  display: grid;
  grid-template-columns: 76px minmax(210px, 0.6fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.rule-bar > label { color: var(--muted); font-size: 15px; }
.rule-bar > select { width: 100%; min-height: 42px; padding: 0 11px; font-size: 15px; }

.rule-description {
  overflow: hidden;
  color: #748ba4;
  font-size: 14px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dynamic-fields { display: grid; gap: 10px; }

.field-grid {
  display: grid;
  gap: 10px;
}

.field-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field-group { min-width: 0; }

.field-group > label {
  display: block;
  min-height: 22px;
  margin-bottom: 5px;
  color: #99aec4;
  font-size: 14px;
  line-height: 1.45;
}

.field-group > label span { display: none; }

.input-shell { position: relative; }
.input-shell input { width: 100%; height: 42px; padding: 0 11px; font-family: Consolas, monospace; font-size: 15px; }
.input-shell.has-suffix input { padding-right: 34px; }
.input-suffix { position: absolute; top: 50%; right: 11px; color: #7189a4; font-size: 13px; transform: translateY(-50%); pointer-events: none; }

.select-shell { position: relative; }
.select-shell select { width: 100%; height: 42px; padding: 0 34px 0 11px; appearance: none; font-size: 14px; }
.select-shell svg { position: absolute; top: 50%; right: 10px; width: 16px; height: 16px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }

select option,
select optgroup { color: var(--text); background: #10233a; }

.formula-preview {
  min-height: 58px;
  margin-top: 11px;
  padding: 8px 10px;
  overflow: auto;
  color: #a1ddec;
  border: 1px dashed rgba(84, 201, 239, 0.28);
  border-radius: 6px;
  background: rgba(84, 201, 239, 0.05);
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.calculate-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 8px;
  color: white;
  border: 1px solid rgba(126, 201, 239, 0.35);
  border-radius: 7px;
  background: linear-gradient(90deg, #4e65d9, #2ca6d4);
  font-size: 16px;
  font-weight: 650;
}

.calculate-button:hover { filter: brightness(1.08); }
.calculate-button span { padding: 2px 5px; color: rgba(255, 255, 255, 0.62); border: 1px solid rgba(255,255,255,.18); border-radius: 3px; font-family: Consolas, monospace; font-size: 13px; font-weight: 400; }

.summary-panel { display: flex; flex-direction: column; }
.copy-button { margin-left: auto; }

.total-score {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.total-score span { color: var(--muted); font-size: 14px; }
.total-score strong { margin-left: auto; color: var(--gold); font-family: Consolas, monospace; font-size: 34px; font-weight: 600; letter-spacing: -0.06em; line-height: 1; }
.total-score em { color: #9a8355; font-style: normal; font-size: 14px; }

.summary-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 0; }
.summary-metrics div { min-width: 0; }
.summary-metrics span { display: block; color: #788fa8; font-size: 13px; line-height: 1.45; }
.summary-metrics strong { color: #dce9f7; font-family: Consolas, monospace; font-size: 17px; font-weight: 500; line-height: 1.4; }
.summary-metrics small { color: #788fa8; font-size: 13px; }

.summary-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 14px; line-height: 1.5; }
.summary-bottom strong { color: #dceafb; font-family: Consolas, monospace; font-size: 14px; }
.summary-bottom span:last-child strong { color: var(--gold); }
.trace-note { margin: 6px 0 0; color: #6e859f; font-size: 13px; line-height: 1.4; }
.calculated-at { display: block; margin-top: 7px; color: #69819b; font-family: Consolas, monospace; font-size: 13px; }

.detail-section { margin-top: 14px; padding: 14px 16px; }
.detail-heading { margin-bottom: 10px; }
.detail-heading strong { font-size: 16px; }
.detail-heading span { color: var(--muted); font-size: 14px; }

.hit-list { display: grid; max-height: 160px; gap: 7px; overflow: auto; }
.empty-state { display: flex; min-height: 76px; align-items: center; justify-content: center; padding: 12px; color: #728aa4; border: 1px dashed rgba(117, 150, 187, 0.23); border-radius: 6px; background: rgba(7, 22, 38, 0.38); font-size: 15px; text-align: center; }

.hit-card {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(7, 22, 38, 0.54);
}

.hit-number { color: #dceaff; font-family: Consolas, monospace; font-size: 14px; }
.hit-title-row { display: flex; align-items: center; gap: 5px; }
.hit-title { color: #d8e5f5; font-size: 14px; font-weight: 600; }
.hit-tag { padding: 1px 4px; color: var(--accent); border-radius: 3px; background: rgba(84, 201, 239, 0.1); font-size: 13px; }
.hit-card.broadband .hit-tag { color: #b6a1ff; background: rgba(143, 118, 235, 0.12); }
.hit-formula { overflow: hidden; margin-top: 1px; color: #7189a4; font-family: Consolas, monospace; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.hit-score { color: var(--gold); font-family: Consolas, monospace; font-size: 16px; text-align: right; }
.hit-score small { display: block; color: #7189a4; font-family: Inter, "Microsoft YaHei", sans-serif; font-size: 13px; }

footer { padding: 8px 1px 12px; color: #607791; font-size: 13px; text-align: center; }

html:fullscreen,
html:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

@media (min-width: 761px) and (min-height: 600px) {
  .app-shell { min-height: 100vh; }
  .calculator-grid { flex: 1 1 auto; }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  max-width: min(390px, calc(100vw - 36px));
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: #e9f8ff;
  border: 1px solid rgba(84, 201, 239, 0.36);
  border-radius: 6px;
  background: #12334d;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(7px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast span { min-width: 0; flex: 1; }
.toast button { flex: 0 0 auto; min-height: 32px; padding: 4px 10px; color: #e7fbff; border: 1px solid rgba(231, 251, 255, 0.35); border-radius: 4px; background: rgba(255,255,255,.06); font-size: 14px; }
.toast.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.toast.error { color: #ffe8ed; border-color: rgba(255,154,174,.4); background: #572b3d; }

@media (max-width: 1120px) {
  .calculator-grid { grid-template-columns: minmax(250px, .75fr) minmax(460px, 1.4fr); }
  .summary-panel { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 20px; }
  .summary-panel .panel-title-row { margin: 0; }
  .summary-panel .total-score { padding: 0; border: 0; }
  .summary-panel .summary-metrics, .summary-panel .summary-bottom, .summary-panel .trace-note, .summary-panel .calculated-at { display: none; }
}

@media (min-width: 761px) and (max-width: 900px) {
  .app-shell { padding: 0 20px; }
  .brand-subtitle, .topbar-status { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-button, .fullscreen-button { padding: 0 10px; }
}

@media (max-width: 760px) {
  .app-shell { width: 100%; padding: 0 14px; }
  .topbar {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 11px 0;
  }
  .brand-subtitle, .topbar-status { display: none; }
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 7px;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .topbar-button, .fullscreen-button { flex: 0 0 auto; }
  .connection-status-area { width: 100%; max-width: 100%; justify-content: flex-start; }
  .connection-note { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .connection-retry-button { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 10px; padding: 18px 0 14px; }
  .page-heading h1 { font-size: 28px; }
  .page-heading p { font-size: 15px; }
  .calculator-grid { grid-template-columns: 1fr; }
  .summary-panel { grid-column: auto; display: flex; }
  .summary-panel .panel-title-row { margin-bottom: 10px; }
  .summary-panel .total-score { padding: 12px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
  .summary-panel .summary-metrics, .summary-panel .summary-bottom, .summary-panel .trace-note, .summary-panel .calculated-at { display: grid; }
  .summary-panel .summary-bottom { display: flex; }
  .summary-panel .trace-note, .summary-panel .calculated-at { display: block; }
  .rule-bar { grid-template-columns: 1fr; gap: 7px; }
  .rule-bar > label { display: none; }
  .rule-description { white-space: normal; }
  .detail-section { margin-bottom: 10px; }
  .hit-card { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .hit-number { grid-column: 1 / -1; }
  .hit-formula { display: none; }
}

@media (max-width: 450px) {
  .app-shell { width: 100%; padding: 0 10px; }
  .compact-panel { padding: 15px; }
  .field-grid.two-columns, .field-grid.three-columns { grid-template-columns: 1fr; }
  textarea { min-height: 112px; }
  footer { font-size: 13px; line-height: 1.5; }
}

.topbar-button {
  min-height: 36px;
  padding: 0 12px;
  color: #a8c9dc;
  border: 1px solid rgba(117, 150, 187, 0.24);
  border-radius: 5px;
  background: rgba(117, 150, 187, 0.06);
  font-size: 14px;
}

.topbar-button:hover { color: #e7fbff; border-color: rgba(84, 201, 239, 0.72); }

.connection-status-area {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.connection-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.connection-note::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8da3bd;
  content: "";
}

.connection-note[data-state="connected"]::before { background: #64df9d; box-shadow: 0 0 7px rgba(100, 223, 157, 0.7); }
.connection-note[data-state="syncing"]::before { background: var(--accent); animation: connectionPulse 1s ease-in-out infinite; }
.connection-note[data-state="offline"]::before,
.connection-note[data-state="error"]::before { background: var(--danger); }
.connection-retry-button { white-space: nowrap; }

@keyframes connectionPulse {
  50% { opacity: 0.35; }
}

.member-assignment {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin-top: 10px;
}

.member-assignment label { color: var(--muted); font-size: 14px; }
.member-select-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 7px; }
.member-assignment select { width: 100%; min-width: 0; min-height: 40px; padding: 0 10px; font-size: 14px; }
.member-assignment select:disabled { color: #607895; }

.favorite-member-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  color: #8098b1;
  border: 1px solid #294561;
  border-radius: 7px;
  background: var(--surface-2);
  font-size: 22px;
  line-height: 1;
}
.favorite-member-button:hover:not(:disabled),
.favorite-member-button[aria-pressed="true"] { color: var(--gold); border-color: rgba(242, 202, 119, 0.62); }
.favorite-member-button:disabled { opacity: 0.45; }

.calculation-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr);
  gap: 9px;
  margin-top: 11px;
}

.calculation-actions .calculate-button { margin-top: 0; }

.save-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  color: #c9eaf5;
  border: 1px solid #315370;
  border-radius: 7px;
  background: #102942;
  font-size: 15px;
  font-weight: 600;
}

.save-button:hover:not(:disabled) { color: #e7fbff; border-color: var(--accent); background: #123451; }
.save-button:disabled { color: #637a92; border-color: #29445f; background: #0d2137; }

.primary-button:not(.calculate-button) {
  min-height: 40px;
  padding: 0 16px;
  color: #fff;
  border: 1px solid rgba(126, 201, 239, 0.42);
  border-radius: 7px;
  background: linear-gradient(90deg, #4e65d9, #2ca6d4);
  font-size: 15px;
  font-weight: 650;
}
.primary-button:hover:not(:disabled) { filter: brightness(1.08); }
.primary-button:disabled { opacity: 0.48; cursor: not-allowed; }

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(3, 13, 25, 0.78);
  cursor: default;
}

.modal-card {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(680px, 100%);
  max-height: min(820px, calc(100vh - 40px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(84, 201, 239, 0.34);
  border-radius: 13px;
  background: #0d2036;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.52);
}

.modal-card-small { width: min(460px, 100%); }
.modal-card-wide { width: min(1080px, 100%); height: min(820px, calc(100vh - 40px)); }

.modal-header {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-header h2 { margin: 2px 0 0; font-size: 22px; line-height: 1.2; }
.modal-eyebrow { margin: 0; color: var(--accent); font-size: 14px; letter-spacing: 0.08em; }
.modal-header-actions { display: inline-flex; align-items: center; gap: 13px; }

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: #9fb7cd;
  border: 1px solid #31506c;
  border-radius: 6px;
  background: #102942;
  font-size: 23px;
  line-height: 1;
}

.icon-button:hover { color: #e9f8ff; border-color: var(--accent); }

.modal-form { display: grid; gap: 12px; padding: 22px; overflow-y: auto; }
.modal-form label { color: #a4b9cd; font-size: 15px; }
.modal-form input { min-height: 42px; padding: 0 11px; }
.modal-help { margin: 2px 0 10px; color: #7590aa; font-size: 14px; line-height: 1.6; }
.modal-help strong { color: var(--gold); font-family: Consolas, monospace; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.form-actions .primary-button { width: auto; min-height: 40px; padding: 0 16px; }

.admin-layout {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(280px, 0.78fr) minmax(0, 1.5fr);
  overflow: hidden;
}

.admin-sidebar,
.admin-main { min-width: 0; padding: 20px 22px; }
.admin-sidebar { overflow-y: auto; border-right: 1px solid var(--line-soft); background: rgba(7, 22, 38, 0.34); }
.admin-main { display: flex; flex-direction: column; overflow-y: auto; }
.admin-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.admin-section-heading h3 { margin: 0; color: #e4effb; font-size: 16px; line-height: 1.4; }
.admin-section-heading p { margin: 5px 0 0; color: #728ba5; font-size: 14px; line-height: 1.5; }
.admin-subsection-eyebrow { margin: 0 0 4px !important; color: var(--accent) !important; font-size: 13px !important; letter-spacing: 0.06em; }
.admin-score-actions { display: inline-flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.admin-score-actions .secondary-button { min-height: 38px; padding: 0 11px; font-size: 14px; }

.inline-form { display: flex; gap: 9px; }
.inline-form input { width: 100%; min-width: 0; height: 42px; padding: 0 11px; }
.inline-form button { flex: 0 0 auto; }

.admin-group-list,
.admin-member-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  overflow: auto;
}

.admin-group-list { max-height: 280px; }
.admin-member-list { max-height: 180px; }

.admin-group-item,
.admin-member-item {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(8, 25, 44, 0.78);
}

.admin-group-item { width: 100%; color: #caddec; text-align: left; }
.admin-group-item:hover { border-color: rgba(84, 201, 239, 0.46); }
.admin-group-item.active { color: #ebfbff; border-color: rgba(84, 201, 239, 0.72); background: rgba(84, 201, 239, 0.1); }
.admin-group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-group-count { flex: 0 0 auto; color: #7fbfd4; font-family: Consolas, monospace; font-size: 14px; }

.admin-member-item { color: #d4e4f4; font-size: 15px; }
.admin-member-meta { overflow: hidden; color: #7891a9; font-family: Consolas, monospace; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.remove-member-button,
.danger-text-button {
  min-height: 36px;
  padding: 5px 0;
  color: #ff9aae;
  border: 0;
  background: transparent;
  font-size: 14px;
}
.remove-member-button:hover:not(:disabled),
.danger-text-button:hover:not(:disabled) { color: #ffd7df; }
.danger-text-button:disabled { color: #677c92; }

.admin-empty,
.score-empty {
  display: flex;
  min-height: 65px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: #7189a2;
  border: 1px dashed rgba(117, 150, 187, 0.24);
  border-radius: 6px;
  background: rgba(7, 22, 38, 0.38);
  font-size: 14px;
  text-align: center;
}

.admin-tool-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.rule-version-form,
.user-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.rule-version-form input,
.rule-version-form select,
.user-form input,
.user-form select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
}

.rule-version-form textarea {
  grid-column: 1 / -1;
  min-height: 90px;
}

.rule-version-form .form-actions,
.user-form .form-actions { grid-column: 1 / -1; }

.rule-version-list,
.user-list,
.audit-list {
  display: grid;
  max-height: 280px;
  gap: 8px;
  margin-top: 12px;
  overflow: auto;
}

.rule-version-item,
.user-item,
.audit-item {
  display: flex;
  min-width: 0;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(7, 22, 38, 0.48);
}

.rule-version-item > div,
.user-item > div { min-width: 0; }
.rule-version-item > div:last-child,
.user-item > div:last-child { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.rule-version-item strong,
.user-item strong,
.audit-item strong { display: block; color: #dfeaf7; font-size: 15px; }
.rule-version-item span,
.user-item span,
.audit-item span { display: block; margin-top: 3px; color: #8199b1; font-size: 13px; line-height: 1.5; }
.rule-version-item small,
.audit-item small { display: block; margin-top: 3px; overflow-wrap: anywhere; color: #7189a2; font-size: 13px; line-height: 1.5; }
.audit-item { align-items: flex-start; flex-direction: column; }

.password-section {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.group-password-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.group-password-section h3 { margin: 0; font-size: 16px; }
.group-password-section p { margin: 4px 0 9px; color: #7189a2; font-size: 14px; line-height: 1.4; }
.group-password-section .password-form { grid-template-columns: minmax(0, 1fr) auto auto; }

.admin-score-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.admin-score-section .admin-section-heading { margin-bottom: 7px; }
.admin-score-summary { margin: 0 0 10px; color: #7f96ad; font-size: 14px; line-height: 1.5; }
.admin-score-filter-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; gap: 9px; margin-bottom: 10px; }
.admin-score-filter-row label { color: #91a8bf; font-size: 14px; }
.admin-score-filter-row select { min-width: 0; height: 40px; padding: 0 10px; font-size: 14px; }
.admin-score-list { display: grid; max-height: 300px; gap: 8px; overflow: auto; }
.admin-score-record { padding: 11px; border: 1px solid var(--line-soft); border-radius: 7px; background: rgba(7, 22, 38, 0.48); }
.admin-score-record-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-score-record-header > div { min-width: 0; }
.admin-score-record-header strong { color: #dfeaf7; font-size: 15px; }
.admin-score-record-header .score-record-tag { margin-left: 5px; }
.admin-score-record-header small { display: block; margin-top: 3px; color: #748ca4; font-size: 13px; }
.admin-score-record-total { color: var(--gold) !important; font-family: Consolas, monospace; white-space: nowrap; }
.admin-score-detail-list { display: grid; max-height: 150px; gap: 4px; margin-top: 7px; overflow: auto; border-top: 1px solid rgba(117, 150, 187, 0.12); padding-top: 5px; }
.admin-score-detail-row,
.score-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 9px; border-radius: 5px; background: rgba(10, 29, 49, 0.72); }
.admin-score-detail-row > div,
.score-detail-row > div { min-width: 0; }
.admin-score-detail-row strong,
.score-detail-row strong { color: #dceaff; font-family: Consolas, monospace; font-size: 14px; }
.admin-score-detail-row span,
.score-detail-tag { margin-left: 5px; color: #80c6da; font-size: 13px; }
.admin-score-detail-row small,
.score-detail-row small { display: block; overflow: hidden; margin-top: 2px; color: #7189a2; font-family: Consolas, monospace; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.admin-score-detail-row > strong:last-child,
.score-detail-row > strong { flex: 0 0 auto; color: var(--gold); }

.password-section h3 { margin: 0; font-size: 16px; }
.password-section p { margin: 4px 0 9px; color: #7189a2; font-size: 14px; }
.password-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 9px; }
.password-form input { min-width: 0; height: 42px; padding: 0 11px; }

.score-filters {
  display: grid;
  grid-template-columns: auto minmax(170px, 0.9fr) auto minmax(170px, 0.9fr) auto;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.score-filters label { color: #91a8bf; font-size: 14px; }
.score-filters select { width: 100%; min-width: 0; height: 40px; padding: 0 10px; font-size: 14px; }
.score-filter-total { display: inline-flex; align-items: baseline; gap: 4px; padding-left: 5px; white-space: nowrap; }
.score-filter-total span { color: #7891a9; font-size: 14px; }
.score-filter-total strong { color: var(--gold); font-family: Consolas, monospace; font-size: 24px; line-height: 1; }
.score-filter-total em { color: #9a8355; font-size: 14px; font-style: normal; }
.score-summary { margin: 14px 22px 9px; color: #7f96ad; font-size: 14px; line-height: 1.5; }
.member-score-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; padding: 0 22px 13px; }
.member-total-card { min-width: 0; padding: 10px 11px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(7, 22, 38, 0.4); }
.member-total-card > span { display: block; overflow: hidden; color: #b7cadd; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.member-total-card strong { display: block; margin-top: 3px; color: var(--gold); font-family: Consolas, monospace; font-size: 20px; font-weight: 600; }
.member-total-card strong em { color: #9a8355; font-family: Inter, "Microsoft YaHei", sans-serif; font-size: 13px; font-style: normal; }
.member-total-card small { display: block; margin-top: 2px; color: #7189a2; font-size: 13px; }
.score-list { display: grid; min-height: 120px; max-height: 430px; gap: 8px; padding: 0 22px 22px; overflow: auto; }

.score-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(7, 22, 38, 0.52);
}

.score-record-title { display: flex; align-items: center; gap: 6px; color: #dfeaf7; font-size: 15px; }
.score-record-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-record-tag { padding: 2px 4px; color: #88cde2; border-radius: 3px; background: rgba(84, 201, 239, 0.1); font-size: 13px; white-space: nowrap; }
.score-record-meta { overflow: hidden; margin-top: 4px; color: #748ca4; font-size: 13px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.score-record-details { display: grid; max-height: 155px; gap: 4px; margin-top: 7px; overflow: auto; padding-top: 5px; border-top: 1px solid rgba(117, 150, 187, 0.12); }
.score-detail-number { color: #dceaff; font-family: Consolas, monospace; font-size: 13px; }
.score-record-value { color: var(--gold); font-family: Consolas, monospace; font-size: 20px; text-align: right; white-space: nowrap; }
.score-record-value small { display: block; margin-top: 2px; color: #7189a2; font-family: Inter, "Microsoft YaHei", sans-serif; font-size: 13px; }

@media (max-width: 760px) {
  .topbar-actions { gap: 7px; }
  .topbar-button, .fullscreen-button { padding: 0 10px; }
  .member-assignment { grid-template-columns: 70px minmax(0, 1fr); }
  .modal { padding: 10px; }
  .modal-card { max-height: calc(100vh - 20px); }
  .admin-layout { grid-template-columns: 1fr; overflow: auto; }
  .admin-sidebar { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .admin-section-heading { align-items: stretch; flex-direction: column; }
  .admin-section-heading > button { align-self: flex-start; }
  .admin-group-list { max-height: 190px; }
  .admin-member-list { max-height: 190px; }
  .admin-score-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .admin-score-actions .secondary-button { flex: 1 1 150px; }
  .admin-score-list { max-height: 280px; }
  .password-form, .group-password-section .password-form { grid-template-columns: 1fr; }
  .rule-version-form, .user-form { grid-template-columns: 1fr; }
  .rule-version-form textarea,
  .rule-version-form .form-actions,
  .user-form .form-actions { grid-column: auto; }
  .score-filters { grid-template-columns: 56px minmax(0, 1fr); }
  .score-filter-total { grid-column: 1 / -1; padding: 6px 0 0; }
}

@media (max-width: 450px) {
  .topbar-button { font-size: 14px; }
  .calculation-actions { grid-template-columns: 1fr; }
  .modal-header { min-height: 70px; padding: 13px 15px; }
  .modal-header h2 { font-size: 20px; }
  .admin-sidebar, .admin-main { padding: 16px; }
  .score-filters, .score-list, .member-score-totals { padding-left: 15px; padding-right: 15px; }
  .score-summary { margin-left: 15px; margin-right: 15px; }
}

.save-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 11px;
}
.save-meta-grid label,
.report-filter-row label,
.admin-filter-grid label { display: grid; gap: 5px; color: #8199b1; font-size: 13px; line-height: 1.45; }
.save-meta-grid input { min-width: 0; height: 40px; padding: 0 10px; font-size: 14px; }
.date-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 7px; }
.date-shortcut-button {
  min-height: 40px;
  padding: 0 11px;
  color: #9fcddd;
  border: 1px solid #294561;
  border-radius: 6px;
  background: #102942;
  font-size: 13px;
}
.date-shortcut-button:hover { color: var(--accent); border-color: var(--accent); }
.inline-field-status {
  min-height: 0;
  margin-top: 3px;
  color: #7990a8;
  font-size: 13px;
  line-height: 1.35;
}
.inline-field-status:empty { display: none; }
.inline-field-status.error { color: var(--danger); }
.inline-field-status.warning { color: #f2ca77; }
.inline-field-status.success { color: #72dba1; }
.field-invalid { border-color: rgba(255, 154, 174, 0.85) !important; box-shadow: 0 0 0 2px rgba(255, 154, 174, 0.09) !important; }
.record-note-input { min-height: 64px; margin-top: 10px; font-family: inherit; font-size: 14px; }
.entry-state-row {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #7189a2;
  font-size: 13px;
}
.draft-status[data-state="dirty"] { color: #f2ca77; }
.draft-status[data-state="saved"] { color: #72dba1; }
.number-action-buttons { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 11px; }
.entry-status-panel {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  color: #7189a2;
  font-size: 13px;
  line-height: 1.4;
}
.entry-status-panel.ready { color: #a7dce9; }
.entry-status-panel.saved { color: #72dba1; }
.post-save-actions { display: inline-flex; flex: 0 0 auto; flex-wrap: wrap; gap: 12px; }
.save-confirm-content { display: grid; gap: 11px; padding: 20px 22px 10px; }
.save-confirm-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 10px; border-bottom: 1px solid rgba(117, 150, 187, 0.12); }
.save-confirm-row span { color: #8199b1; font-size: 14px; }
.save-confirm-row strong { color: #e5effa; font-size: 15px; text-align: right; }
.save-confirm-row.total strong { color: var(--gold); font-family: Consolas, monospace; font-size: 21px; }
.save-confirm-row.warning { padding: 8px; border: 1px solid rgba(242, 202, 119, 0.28); border-radius: 6px; background: rgba(242, 202, 119, 0.07); }
.save-confirm-row.warning strong { max-width: 72%; color: #f2ca77; line-height: 1.5; }
.save-confirm-actions { padding: 12px 22px 22px; }
.compact-action-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin: 10px 0 6px; }
.admin-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 8px 0; align-items: end; }
.admin-filter-grid select,
.admin-filter-grid input { min-width: 0; height: 40px; padding: 0 10px; font-size: 14px; }
.admin-filter-grid .filter-search { grid-column: 1 / -1; }
.score-record-admin-side { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.score-record-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.score-record-actions .text-button { font-size: 13px; }
.status-active { color: #72dba1; background: rgba(100, 223, 157, 0.1); }
.status-void { color: #ff9aae; background: rgba(255, 154, 174, 0.1); }
.admin-score-record.voided { opacity: 0.68; }
.void-reason { margin: 6px 0 0; color: #ff9aae; font-size: 13px; }

.report-modal-card,
.data-modal-card,
.import-modal-card { width: min(1180px, 100%); overflow-y: auto; }
.report-modal-card > .modal-header,
.data-modal-card > .modal-header,
.import-modal-card > .modal-header {
  position: sticky;
  top: 0;
  z-index: 3;
  flex: 0 0 auto;
  background: #0d2036;
}
.scores-modal-card .score-list { min-height: 0; max-height: none; flex: 1; }
.hit-info { min-width: 0; }
.report-filter-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.report-filter-row input,
.report-filter-row select { width: 100%; min-width: 0; height: 40px; padding: 0 10px; font-size: 14px; }
.report-metrics { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 9px; padding: 16px 22px; }
.report-metric { padding: 12px; border: 1px solid var(--line-soft); border-radius: 7px; background: rgba(7, 22, 38, 0.42); }
.report-metric span { display: block; color: #8199b1; font-size: 13px; }
.report-metric strong { display: inline-block; margin-top: 5px; color: var(--gold); font-family: Consolas, monospace; font-size: 22px; }
.report-metric small { margin-left: 4px; color: #9a8355; font-size: 13px; }
.report-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr); gap: 14px; padding: 0 22px 22px; }
.report-table-section { min-width: 0; }
.report-table-section h3 { margin: 0 0 9px; font-size: 16px; }
.report-table-wrap,
.import-preview-wrap { overflow: auto; border: 1px solid var(--line-soft); border-radius: 7px; }
.report-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.report-layout .report-table-section:last-child .report-table { min-width: 100%; }
.report-table th,
.report-table td { padding: 10px 12px; border-bottom: 1px solid rgba(117, 150, 187, 0.12); color: #b9cadd; font-size: 13px; line-height: 1.5; text-align: left; white-space: nowrap; }
.report-table th { color: #8199b1; background: rgba(7, 22, 38, 0.55); font-weight: 500; }
.report-table td strong { color: var(--gold); font-family: Consolas, monospace; }
.table-empty { padding: 18px !important; color: #7189a2 !important; text-align: center !important; }
.report-modal-card > .modal-help { margin: 0 22px 20px; }

.data-center-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 22px; overflow-y: auto; }
.data-tool-card { padding: 16px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(7, 22, 38, 0.42); }
.data-tool-card h3 { margin: 0; font-size: 16px; }
.data-tool-card p { margin: 7px 0 12px; color: #8199b1; font-size: 14px; line-height: 1.5; }
.data-tool-card .form-actions { flex-wrap: wrap; }
.server-login-form { display: grid; gap: 9px; }
.server-login-form input { height: 40px; padding: 0 10px; }

.import-toolbar { display: flex; align-items: center; gap: 9px; padding: 16px 22px 9px; }
.import-toolbar input[type="file"] { min-width: 0; min-height: 42px; flex: 1; padding: 7px; font-size: 14px; }
.import-textarea { min-height: 96px; margin: 0 22px 10px; width: calc(100% - 44px); font-family: Consolas, monospace; font-size: 14px; }
.import-summary { margin: 0 22px 10px; color: #91a8bf; font-size: 14px; line-height: 1.5; }
.import-preview-wrap { max-height: 360px; margin: 0 22px 22px; }
.import-ok { color: #72dba1 !important; }
.import-error { color: #ff9aae !important; }

@media print {
  .topbar, .page-heading, .calculator-grid, footer, .modal-backdrop, .modal-header-actions { display: none !important; }
  .modal { position: static !important; display: block !important; padding: 0; background: #fff; }
  .modal-card { max-height: none; border: 0; background: #fff; color: #111; box-shadow: none; }
}

@media (max-width: 760px) {
  .report-filter-row, .data-center-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-layout { grid-template-columns: 1fr; }
  .report-layout .report-table { min-width: 620px; }
  .report-metrics { grid-template-columns: repeat(3, minmax(90px, 1fr)); }
}

@media (max-width: 450px) {
  .save-meta-grid, .admin-filter-grid, .report-filter-row, .data-center-grid { grid-template-columns: 1fr; }
  .date-input-row { grid-template-columns: minmax(0, 1fr) repeat(2, minmax(58px, auto)); }
  .date-shortcut-button { padding: 0 8px; }
  .number-actions { align-items: flex-start; flex-direction: column; gap: 6px; padding: 6px 0; }
  .number-action-buttons { width: 100%; justify-content: space-between; }
  .entry-status-panel { align-items: flex-start; flex-direction: column; }
  .post-save-actions { width: 100%; justify-content: space-between; }
  .save-confirm-row { flex-direction: column; gap: 5px; }
  .save-confirm-row strong,
  .save-confirm-row.warning strong { max-width: 100%; text-align: left; overflow-wrap: anywhere; }
  .rule-version-item,
  .user-item { align-items: flex-start; flex-direction: column; }
  .rule-version-item > div:last-child,
  .user-item > div:last-child { width: 100%; justify-content: flex-start; }
  .score-record { grid-template-columns: 1fr; }
  .score-record-admin-side { align-items: flex-start; }
  .score-record-actions { justify-content: flex-start; }
  .report-metrics { grid-template-columns: repeat(2, minmax(110px, 1fr)); padding-left: 15px; padding-right: 15px; }
  .report-layout { padding-left: 15px; padding-right: 15px; }
  .import-toolbar { flex-wrap: wrap; padding-left: 15px; padding-right: 15px; }
  .import-toolbar input[type="file"] { flex-basis: 100%; }
  .import-textarea, .import-summary, .import-preview-wrap { margin-left: 15px; margin-right: 15px; width: calc(100% - 30px); }
}

/* Desktop single-screen workspace: keep the larger type without page scrolling. */
@media (min-width: 961px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body { line-height: 1.45; }

  .app-shell {
    height: 100vh;
    min-height: 0;
    padding: 0 20px;
    overflow: hidden;
  }

  main { overflow: hidden; }

  .topbar {
    height: 54px;
    min-height: 54px;
    gap: 12px;
    padding: 4px 0;
  }

  .brand { gap: 8px; }
  .brand-mark { width: 30px; height: 30px; }
  .topbar-actions { gap: 6px; }
  .topbar-button,
  .fullscreen-button { min-height: 34px; padding: 0 10px; }

  .page-heading {
    flex: 0 0 auto;
    align-items: center;
    padding: 8px 0 7px;
  }

  .page-heading h1 { font-size: 28px; line-height: 1.15; }
  .page-heading p { margin-top: 2px; font-size: 15px; line-height: 1.35; }
  .local-note { padding: 5px 9px; }

  .calculator-grid {
    min-height: 0;
    flex: 1 1 auto;
    grid-template-columns: minmax(230px, 0.76fr) minmax(480px, 1.55fr) minmax(190px, 0.64fr);
    gap: 10px;
    overflow: hidden;
  }

  .summary-panel {
    grid-column: auto;
    display: flex;
    grid-template-columns: none;
    align-items: stretch;
  }
  .summary-panel .panel-title-row { margin-bottom: 7px; }
  .summary-panel .total-score { padding: 8px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
  .summary-panel .summary-metrics { display: grid; }
  .summary-panel .summary-bottom { display: flex; }
  .summary-panel .trace-note,
  .summary-panel .calculated-at { display: block; }

  .compact-panel {
    height: 100%;
    min-height: 0;
    padding: 12px;
    overflow: hidden;
  }

  .panel-title-row { min-height: 28px; margin-bottom: 7px; }
  .panel-title-row h2 { line-height: 1.2; }
  .text-button { min-height: 32px; padding: 3px 0; }

  textarea {
    min-height: 92px;
    padding: 9px 10px;
    line-height: 1.55;
  }

  .number-actions { min-height: 32px; }
  .secondary-button { min-height: 36px; padding: 0 11px; }
  .field-help {
    display: -webkit-box;
    margin-top: 5px;
    overflow: hidden;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .parsed-block { margin-top: 4px; padding-top: 4px; }
  .parsed-title-row { margin-bottom: 3px; }
  .parsed-list { max-height: 66px; gap: 5px; }
  .number-panel .chip-type { display: none; }
  .number-panel .number-chip { min-height: 27px; padding: 3px 6px; }

  .member-assignment {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 7px;
    margin-top: 6px;
  }
  .member-select-row { grid-template-columns: minmax(0, 1fr) 36px; gap: 6px; }
  .member-assignment select,
  .favorite-member-button { min-height: 36px; }
  .favorite-member-button { width: 36px; }

  .save-meta-grid { gap: 5px; margin-top: 6px; }
  .save-meta-grid label,
  .report-filter-row label,
  .admin-filter-grid label { gap: 2px; }
  .save-meta-grid input,
  .date-shortcut-button { height: 36px; min-height: 36px; }
  .date-input-row { gap: 5px; }
  .inline-field-status { margin-top: 2px; line-height: 1.25; }
  .record-note-input { min-height: 48px; margin-top: 6px; }
  .entry-state-row { min-height: 26px; }
  .number-panel .field-help { -webkit-line-clamp: 3; }

  .parameter-title-row { margin-bottom: 6px; }
  .rule-bar {
    grid-template-columns: 72px minmax(200px, 0.58fr) minmax(0, 1fr);
    gap: 8px;
    margin-bottom: 7px;
  }
  .rule-bar > select { min-height: 36px; padding: 0 9px; }
  .rule-description { line-height: 1.35; }
  .dynamic-fields,
  .field-grid { gap: 6px; }
  .field-group > label { min-height: 17px; margin-bottom: 2px; line-height: 1.2; }
  .input-shell input,
  .select-shell select { height: 36px; }
  .formula-preview {
    min-height: 44px;
    max-height: 44px;
    margin-top: 7px;
    padding: 4px 8px;
    overflow: hidden;
    line-height: 1.35;
  }
  .calculation-actions { gap: 7px; margin-top: 7px; }
  .calculate-button,
  .save-button { min-height: 40px; }
  .entry-status-panel { min-height: 28px; margin-top: 4px; line-height: 1.3; }

  .total-score { padding: 8px 0; }
  .summary-metrics { gap: 6px; padding: 9px 0; }
  .summary-bottom { padding-top: 8px; }
  .trace-note { margin-top: 4px; }
  .calculated-at { margin-top: 4px; }

  .summary-panel .detail-section {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    margin-top: 8px;
    padding: 8px;
    overflow: hidden;
  }
  .summary-panel .detail-heading {
    flex: 0 0 auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 1px;
    margin-bottom: 5px;
  }
  .summary-panel .detail-heading strong { white-space: nowrap; }
  .summary-panel .detail-heading span { line-height: 1.3; }
  .summary-panel .hit-list {
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    gap: 5px;
    overflow: auto;
  }
  .summary-panel .empty-state { height: 100%; min-height: 52px; padding: 7px; }
  .summary-panel .hit-card {
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    min-height: 48px;
    padding: 6px 8px;
  }
  .summary-panel .hit-number { grid-column: 1 / -1; }
  .summary-panel .hit-formula { display: none; }
  .summary-panel .hit-title-row { flex-wrap: wrap; }
  .summary-panel .hit-score { align-self: end; }

  footer {
    flex: 0 0 auto;
    padding: 4px 1px 6px;
    line-height: 1.3;
  }
}

@media (min-width: 761px) and (max-width: 960px) {
  .summary-panel .detail-section { grid-column: 1 / -1; }
}

@media (min-width: 961px) and (max-height: 720px) {
  .topbar { height: 50px; min-height: 50px; }
  .page-heading { padding: 5px 0; }
  .page-heading h1 { font-size: 26px; }
  .page-heading p { display: none; }
  .compact-panel { padding: 10px; }
  textarea { min-height: 76px; }
  .field-help { -webkit-line-clamp: 1; }
  .record-note-input { min-height: 42px; }
  .summary-panel .detail-section { margin-top: 6px; padding: 6px; }
  footer { padding: 2px 1px 4px; }
}