:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --surface-muted: #edf3f1;
  --border: #d7e1dd;
  --ink: #17211f;
  --muted: #62706c;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #2563eb;
  --amber: #b7791f;
  --danger: #b42318;
  --success: #12715b;
  --shadow: 0 18px 45px rgba(20, 37, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.1), rgba(244, 247, 246, 0) 320px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft JhengHei", "PingFang HK", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

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

.app-header,
.toolbar,
.panel-head,
.subsection-head,
.target-entry,
.toolbar-actions,
.score-row,
.app-footer {
  display: flex;
  gap: 14px;
}

.app-header {
  align-items: end;
  justify-content: space-between;
  margin-bottom: 22px;
}

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

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

h1 {
  font-size: 38px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

.status-pill {
  min-width: 112px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.status-pill.loading {
  color: var(--amber);
}

.status-pill.error {
  color: var(--danger);
}

.status-pill.success {
  color: var(--success);
}

.toolbar,
.panel,
.stat-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.toolbar {
  align-items: end;
  justify-content: space-between;
  padding: 16px;
  margin-bottom: 16px;
}

.target-form {
  flex: 1;
  min-width: 280px;
}

.target-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.target-entry {
  align-items: center;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  padding: 0 13px;
  background: var(--surface-soft);
  color: var(--ink);
}

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

.primary-button,
.secondary-button,
.small-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
}

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

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary-button,
.small-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover:not(:disabled),
.small-button:hover:not(:disabled) {
  background: var(--surface-muted);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.small-button.danger {
  color: var(--danger);
}

.compact {
  min-height: 36px;
  padding: 0 12px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

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

.stat-card {
  padding: 16px;
}

.stat-card span,
.score-card span,
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  line-height: 1;
}

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

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.target-list {
  display: grid;
  gap: 10px;
}

.target-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.target-item.selected {
  border-color: rgba(15, 118, 110, 0.58);
  box-shadow: inset 3px 0 0 var(--accent);
}

.target-main {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.target-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 900;
}

.target-url {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.target-metrics,
.target-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-metric {
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef6f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.mini-metric strong {
  color: var(--ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}

.badge.ok {
  background: rgba(18, 113, 91, 0.1);
  color: var(--success);
}

.badge.warning,
.badge.pending {
  background: rgba(183, 121, 31, 0.12);
  color: var(--amber);
}

.badge.error {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.detail-empty,
.empty-list,
.error-box,
.ok-box {
  display: grid;
  min-height: 120px;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.error-box {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.ok-box {
  min-height: 74px;
  border-style: solid;
  color: var(--success);
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.score-card,
.metric-card,
.locked-box,
.issue-item,
.reminder-item,
.recommendation-item,
.smart-summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.score-card {
  min-height: 118px;
  padding: 15px;
}

.score-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.score-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.subsection {
  padding-top: 18px;
  border-top: 1px solid var(--border);
  margin-top: 18px;
}

.subsection-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.metric-card {
  min-height: 78px;
  padding: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.smart-panel {
  display: grid;
  gap: 12px;
}

.smart-summary {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 4px 14px;
  padding: 14px;
}

.smart-summary span {
  grid-row: span 2;
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.smart-summary strong {
  font-size: 28px;
  line-height: 1;
}

.smart-summary small {
  color: var(--muted);
  line-height: 1.4;
}

.reminder-grid,
.recommendation-list {
  display: grid;
  gap: 10px;
}

.reminder-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reminder-item,
.recommendation-item {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.reminder-item {
  grid-template-columns: 34px minmax(0, 1fr);
}

.reminder-item span,
.recommendation-score {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.reminder-item.critical span,
.recommendation-item.critical .recommendation-score {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.reminder-item.warning span,
.recommendation-item.warning .recommendation-score {
  background: rgba(183, 121, 31, 0.14);
  color: var(--amber);
}

.reminder-item.success span {
  background: rgba(18, 113, 91, 0.1);
  color: var(--success);
}

.reminder-item strong,
.recommendation-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.reminder-item small,
.recommendation-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.recommendation-item {
  grid-template-columns: 64px minmax(0, 1fr);
}

.recommendation-score {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  font-size: 14px;
}

.recommendation-item p {
  margin: 6px 0 0;
  color: var(--ink);
  line-height: 1.48;
}

.issue-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.issue-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px 10px;
  padding: 12px;
}

.issue-item span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.issue-item.critical span {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.issue-item.warning span {
  background: rgba(183, 121, 31, 0.14);
  color: var(--amber);
}

.issue-item strong {
  align-self: center;
  overflow-wrap: anywhere;
}

.issue-item small {
  grid-column: 2;
  color: var(--muted);
  line-height: 1.4;
}

.history-bars {
  display: flex;
  align-items: end;
  gap: 5px;
  height: 110px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.history-bar {
  flex: 1;
  min-width: 7px;
  height: max(6px, var(--height));
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--blue), var(--accent));
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 10px;
}

table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background: #f0f5f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

td {
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.locked-box {
  padding: 16px;
}

.lock-mark {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
}

.locked-box strong {
  display: block;
  margin-top: 10px;
  font-size: 18px;
}

.locked-box p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.app-footer {
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.app-footer a {
  color: var(--accent-dark);
  font-weight: 900;
  text-decoration: none;
}

.header-actions,
.admin-actions,
.tag-row,
.split-fields {
  display: flex;
  gap: 10px;
}

.header-actions {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.secondary-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-link:hover {
  background: var(--surface-muted);
}

.scope-card {
  min-width: min(100%, 320px);
}

.scope-card span,
.stack-form span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.scope-card strong {
  display: block;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  background: var(--surface-soft);
  overflow-wrap: anywhere;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 26px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 18px;
  font-size: 30px;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.form-status {
  min-height: 24px;
  margin: 12px 0;
  color: var(--danger);
  font-weight: 850;
}

.admin-shell {
  max-width: 1480px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-grid .panel:last-child {
  grid-column: 1 / -1;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.admin-item strong,
.admin-item small {
  display: block;
  overflow-wrap: anywhere;
}

.admin-item small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.admin-actions,
.tag-row {
  align-items: center;
  flex-wrap: wrap;
}

.split-fields {
  align-items: start;
}

.split-fields label {
  flex: 1;
  min-width: 0;
}

.admin-form {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface-soft);
}

.inline-check {
  display: inline-flex;
  width: auto;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.inline-check input {
  width: 18px;
  min-height: 18px;
}

.inline-check span {
  margin: 0;
}

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

.group-card {
  gap: 12px;
}

.admin-user-password {
  min-width: min(100%, 320px);
}

.compact-empty {
  min-height: 56px;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .toolbar,
  .workspace,
  .score-row {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .workspace,
  .score-row {
    display: grid;
  }

  .stats-grid,
  .metric-grid,
  .reminder-grid,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid .panel,
  .admin-grid .panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 22px, 680px);
    padding-top: 22px;
  }

  .app-header,
  .toolbar-actions,
  .target-entry,
  .header-actions,
  .split-fields,
  .admin-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 30px;
  }

  .stats-grid,
  .metric-grid,
  .reminder-grid,
  .checkbox-grid,
  .smart-summary {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .secondary-link {
    width: 100%;
  }

  .smart-summary span {
    grid-row: auto;
  }
}
