:root {
  color-scheme: light;
  --paper: #f4f3f0;
  --paper-2: #fffcf8;
  --ink: #1c2430;
  --ink-soft: #5e6872;
  --muted: #8a847c;
  --line: #e6e2db;
  --line-strong: #d4cfc6;
  --accent: #0f6b63;
  --accent-deep: #0c574f;
  --accent-soft: #e7f3f1;
  --warn: #8a5a12;
  --warn-soft: #f8f1e3;
  --danger: #9c3b32;
  --danger-soft: #f8ebe9;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.04), 0 10px 28px rgba(28, 36, 48, 0.05);
  --radius: 10px;
  --control-h: 34px;
  --sidebar: 248px;
  --header: 56px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
summary {
  font: inherit;
  color: inherit;
}

button,
summary {
  cursor: pointer;
}

a {
  color: var(--accent-deep);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 50;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
}

.skip:focus {
  top: 8px;
}

.boot {
  margin: 18vh auto;
  max-width: 28rem;
  text-align: center;
  color: var(--ink-soft);
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.gate-card {
  width: min(420px, 100%);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}

img.mark {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
}

img.mark-lg {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.gate-card h1,
.page-head h1,
.dialog h2,
.palette h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.lead {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.form-error {
  min-height: 1.4em;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 12px;
  background: rgba(255, 252, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.favs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: auto;
}

.favs a {
  flex: none;
  height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 12px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.frame {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: calc(100vh - var(--header));
}

.sidebar {
  position: sticky;
  top: var(--header);
  height: calc(100vh - var(--header));
  overflow: auto;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  padding: 8px 10px 20px;
  transition: transform 160ms ease;
}

.nav-mask {
  display: none;
}

.nav-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 16px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.nav-group span {
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
  letter-spacing: 0;
}

.nav-section {
  margin-bottom: 2px;
}

.nav-toggle,
.menu-btn,
.btn,
.tab,
.user > summary,
.menu-item {
  height: var(--control-h);
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
}

.nav-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  text-align: left;
  font-weight: 650;
  font-size: 13px;
}

.nav-toggle:hover,
.menu-btn:hover,
.btn-ghost:hover,
.user > summary:hover,
.menu-item:hover,
.nav-link:hover {
  background: rgba(28, 36, 48, 0.04);
}

.chevron {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  margin-right: 4px;
}

.nav-section.is-open .chevron {
  transform: rotate(225deg);
  margin-top: 4px;
}

.nav-sub {
  display: grid;
  gap: 2px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

.nav-sub[hidden] {
  display: none;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px 0 18px;
  border-radius: 8px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
}

.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 650;
}

.side-foot {
  margin: 18px 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 22px 24px 40px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.crumb {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.btn,
.tab,
.menu-item,
.user > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: #f7f6f3;
}

.gate .dialog-actions .btn {
  width: 100%;
}

.btn-ghost {
  color: var(--ink-soft);
  padding-inline: 10px;
}

.menu-btn {
  display: none;
  width: var(--control-h);
  padding: 0;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: #efece6;
  border-radius: var(--radius);
}

.tab {
  color: var(--ink-soft);
}

.tab[aria-selected="true"] {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 36, 48, 0.06);
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.card-pad,
.toolbar-card {
  padding: 14px;
}

.toolbar-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.stat {
  padding: 16px;
}

.stat p,
.stat strong {
  margin: 0;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat span,
.hint {
  color: var(--muted);
  font-size: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 12px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

.card ul,
.note-list {
  margin: 0;
  padding-left: 18px;
}

.card li + li,
.note-list li + li {
  margin-top: 6px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  margin-bottom: 12px;
  background:
    linear-gradient(180deg, rgba(15, 107, 99, 0.06), rgba(15, 107, 99, 0)),
    #fff;
}

.hero h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.field span,
.field-label {
  font-size: 13px;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  height: var(--control-h);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.search input {
  width: 220px;
}

.table-wrap {
  overflow: auto;
}

.table-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px 0;
}

.table-switch .btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

td.cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.pager span {
  color: var(--ink-soft);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-weight: 450;
}

th {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
  background: #fbfaf8;
}

.empty {
  color: var(--ink-soft);
  text-align: center;
}

.user {
  position: relative;
}

.user > summary {
  list-style: none;
  background: #fff;
  border-color: var(--line);
  padding-inline: 12px;
}

.user > summary::-webkit-details-marker {
  display: none;
}

.user-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.menu-item {
  width: 100%;
  justify-content: flex-start;
}

dialog {
  width: min(480px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(28, 36, 48, 0.28);
}

.dialog,
.palette {
  padding: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.palette {
  width: min(640px, calc(100% - 32px));
}

.palette input {
  margin: 12px 0;
}

.palette-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow: auto;
}

.palette-list a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.palette-list a small {
  display: block;
  color: var(--muted);
}

.palette-list a.is-active,
.palette-list a:hover {
  background: var(--accent-soft);
}

kbd {
  display: inline-block;
  min-width: 1.2em;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fff;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.bars {
  display: grid;
  gap: 3px;
  width: 14px;
}

.bars span {
  display: block;
  height: 1.5px;
  background: currentColor;
}

@media (max-width: 1080px) {
  .stats,
  .split {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .menu-btn {
    display: inline-flex;
  }

  .frame {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(84vw, 300px);
    transform: translateX(-105%);
    box-shadow: var(--shadow);
  }

  body.is-nav-open .sidebar {
    transform: none;
  }

  body.is-nav-open .nav-mask {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(28, 36, 48, 0.28);
    border: 0;
    padding: 0;
  }

  .stats,
  .split,
  .toolbar-card,
  .page-head,
  .hero {
    grid-template-columns: 1fr;
    display: grid;
  }

  .search input {
    width: 100%;
  }

  .favs {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
