@font-face {
  font-family: "MiSans";
  src: url("/fonts/MiSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #fffefd;
  --panel-soft: #f8fbfa;
  --line: #dde8e5;
  --line-strong: #bdccc8;
  --text: #18232c;
  --muted: #6f7e82;
  --muted-strong: #4d5f63;
  --accent: #e6465f;
  --accent-dark: #cc3650;
  --accent-soft: #fff3f5;
  --ink: #355967;
  --ink-soft: #edf6f7;
  --success: #227b61;
  --success-soft: #eef9f4;
  --warning: #9b6a22;
  --warning-soft: #fff7ea;
  --danger: #b43b34;
  --danger-soft: #fff2f0;
  --focus: #4087d6;
  --shadow: 0 18px 48px rgba(54, 77, 90, 0.08);
  font-family:
    "MiSans", "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-weight: 400;
}

body::before {
  display: none;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 34px;
}

.workspace {
  max-width: 1280px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 60px;
  height: 60px;
  place-items: center;
  border-radius: 14px;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.brand-mark img {
  display: block;
  width: 108%;
  height: 108%;
  object-fit: contain;
}

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

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

h1 {
  font-size: 34px;
  line-height: 1.15;
  font-weight: 400;
}

h2 {
  font-size: 19px;
  line-height: 1.3;
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.config-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.64);
  backdrop-filter: blur(14px);
  font-size: 14px;
  box-shadow: 0 10px 22px rgba(54, 77, 90, 0.05);
}

.config-button.ok {
  color: var(--success);
  border-color: #bfe7d0;
  background: var(--success-soft);
}

.config-button.warn {
  color: var(--warning);
  border-color: #f2d79e;
  background: var(--warning-soft);
}

.config-button.error {
  color: var(--danger);
  border-color: #f2c4bd;
  background: var(--danger-soft);
}

.import-panel,
.data-panel {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(221, 232, 229, 0.82);
  border-radius: 14px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.import-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.panel-heading,
.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-heading p,
.table-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

textarea {
  width: 100%;
  min-height: 154px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px 17px;
  color: var(--text);
  background: rgba(248, 251, 250, 0.68);
  outline: none;
  line-height: 1.55;
}

textarea::placeholder {
  color: #8994a5;
}

textarea:focus {
  border-color: var(--focus);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 0 0 4px rgba(47, 109, 246, 0.12);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 400;
  white-space: nowrap;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(230, 70, 95, 0.18);
}

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

.secondary-button {
  color: #285260;
  border-color: #c8dddf;
  background: rgba(237, 246, 247, 0.72);
  backdrop-filter: blur(12px);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #eef3f8;
}

.ghost-button {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(12px);
}

.ghost-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.danger-button {
  color: #fff;
  background: var(--danger);
  box-shadow: 0 12px 24px rgba(180, 59, 52, 0.16);
}

.danger-button:hover:not(:disabled) {
  background: #9f302b;
}

#statusText {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

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

.summary-item {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 30px rgba(54, 77, 90, 0.055);
}

.summary-item:nth-child(1) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0, rgba(255, 248, 244, 0.58) 100%);
}

.summary-item:nth-child(2) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0, rgba(246, 251, 255, 0.58) 100%);
}

.summary-item:nth-child(3) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0, rgba(247, 251, 245, 0.58) 100%);
}

.summary-item:nth-child(4) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0, rgba(255, 248, 251, 0.58) 100%);
}

.summary-item span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.summary-item strong {
  color: var(--text);
  font-size: 34px;
  line-height: 1;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.data-panel {
  overflow: hidden;
}

.table-toolbar {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.table-wrap {
  position: relative;
  overflow-x: auto;
}

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

th,
td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: rgba(247, 251, 250, 0.76);
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
}

tbody tr {
  background: rgba(255, 255, 255, 0.5);
}

tbody tr:hover {
  background: rgba(255, 247, 248, 0.66);
}

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

.note-title {
  display: inline-block;
  max-width: 390px;
  color: var(--text);
  font-weight: 400;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-title:hover {
  color: var(--accent);
}

.note-url {
  max-width: 430px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric {
  min-width: 82px;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

.updated-at {
  min-width: 160px;
  color: var(--muted);
  font-size: 13px;
}

.row-status {
  max-width: 260px;
  font-size: 13px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-ok {
  color: var(--success);
  background: var(--success-soft);
}

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

.status-loading {
  color: var(--warning);
  background: var(--warning-soft);
}

.row-actions {
  width: 92px;
  white-space: nowrap;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.icon-button:hover:not(:disabled) {
  color: var(--accent);
  border-color: #f0b4c0;
  background: var(--accent-soft);
}

.empty-state {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 56px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 400;
}

.table-wrap.has-data .empty-state {
  display: none;
}

.site-footer {
  padding: 18px 4px 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  display: grid;
  gap: 14px;
  width: min(620px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 28px 60px rgba(17, 24, 39, 0.22);
}

.delete-modal {
  width: min(420px, 100%);
  gap: 18px;
}

.delete-message {
  margin: 10px 0 0;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.55;
}

.delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cookie-input {
  min-height: 170px;
}

.cookie-helper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#cookieStatusText {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 880px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
  }

  .brand-block {
    gap: 10px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    justify-content: stretch;
    gap: 10px;
  }

  .config-button,
  .secondary-button {
    width: 100%;
    min-height: 38px;
    padding: 0 12px;
    font-size: 13px;
  }

  h1 {
    font-size: 22px;
    line-height: 1.2;
  }

  h2 {
    font-size: 17px;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 11px;
  }

  .brand-mark {
    width: 41px;
    height: 41px;
    border-radius: 12px;
    font-size: 19px;
  }

  .brand-mark img {
    width: 109.34%;
    height: 109.34%;
  }

  .import-panel {
    gap: 12px;
    padding: 15px;
  }

  .panel-heading,
  .table-toolbar {
    gap: 8px;
  }

  .panel-heading p,
  .table-toolbar p {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
  }

  textarea {
    min-height: 104px;
    padding: 12px 13px;
    line-height: 1.45;
  }

  .actions {
    gap: 8px;
  }

  button {
    min-height: 38px;
    padding: 0 14px;
    font-size: 14px;
  }

  #statusText {
    min-height: 18px;
    font-size: 12px;
  }

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

  .summary-item {
    min-height: 78px;
    gap: 6px;
    padding: 13px 14px;
  }

  .summary-item span {
    font-size: 12px;
  }

  .summary-item strong {
    font-size: 26px;
  }

  .table-toolbar {
    display: grid;
    padding: 15px;
  }

  .table-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 10px;
  }

  .table-actions button {
    width: 100%;
    padding: 0 8px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }

  td {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    flex: 0 0 68px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
  }

  td:first-child {
    display: block;
    grid-column: 1 / -1;
    padding-bottom: 5px;
  }

  td:first-child::before,
  .row-actions::before {
    display: none;
  }

  .note-title,
  .note-url {
    max-width: 100%;
  }

  .note-title {
    display: -webkit-box;
    font-size: 15px;
    line-height: 1.35;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .note-url {
    display: none;
  }

  .metric {
    display: grid;
    gap: 2px;
    justify-items: start;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(251, 252, 254, 0.62);
    font-size: 16px;
    line-height: 1.1;
  }

  .metric::before {
    flex: none;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
  }

  .updated-at {
    grid-column: 1 / 3;
  }

  .row-status {
    grid-column: 3 / 4;
  }

  .updated-at,
  .row-status {
    display: grid;
    gap: 2px;
    justify-items: start;
    min-height: 46px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    background: rgba(251, 252, 254, 0.62);
    line-height: 1.25;
  }

  .updated-at {
    border-radius: 8px;
    border-right: 1px solid var(--line);
  }

  .row-status {
    border-radius: 8px;
  }

  .updated-at::before,
  .row-status::before {
    flex: none;
    font-size: 11px;
    line-height: 1.2;
  }

  .updated-at,
  .row-status {
    min-width: 0;
    max-width: none;
    font-size: 12px;
  }

  .status-chip {
    max-width: 100%;
    min-height: auto;
    padding: 0;
    border-radius: 0;
    background: transparent;
    font-size: 12px;
  }

  .row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    grid-column: 1 / -1;
    width: 100%;
    padding-top: 2px;
  }

  .row-actions .icon-button {
    width: 34px;
    min-height: 34px;
  }

  .empty-state {
    padding: 32px 16px;
  }

  .site-footer {
    padding-top: 12px;
  }
}

@media (max-width: 380px) {
  .topbar-actions {
    grid-template-columns: 1fr;
  }
}
