:root {
  --bg: #f5efe7;
  --bg-strong: #e8dac9;
  --panel: rgba(255, 250, 243, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.76);
  --panel-border: rgba(61, 42, 24, 0.12);
  --text: #2f2318;
  --muted: #6e5b48;
  --accent: #c46832;
  --accent-strong: #934118;
  --danger: #b73f33;
  --danger-soft: rgba(183, 63, 51, 0.12);
  --shadow: 0 24px 80px rgba(77, 47, 22, 0.12);
  --radius-xl: 20px;
  --radius-lg: 15px;
  --radius-md: 12px;
  --ease: 220ms ease;
  --max-width: 1040px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.4;
  background:
    radial-gradient(circle at top left, rgba(255, 205, 166, 0.92), transparent 33%),
    radial-gradient(circle at bottom right, rgba(192, 106, 55, 0.18), transparent 24%),
    linear-gradient(145deg, var(--bg), #f9f5ef 48%, var(--bg-strong));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 35, 24, 0.04) 1px, transparent 1px);
  background-size: 16px 16px;
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

textarea {
  resize: vertical;
}

.landing-body,
.dashboard-body {
  min-height: 100vh;
}

.screen-shell {
  position: relative;
  z-index: 1;
  width: min(var(--max-width), calc(100% - 28px));
  margin: 0 auto;
  padding: 16px 0 18px;
  min-height: 100vh;
}

.compact-shell {
  display: flex;
  align-items: center;
}

.landing-card,
.entry-card,
.panel,
.login-card,
.modal-card {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.landing-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.88fr);
  gap: 16px;
  width: 100%;
  min-height: min(720px, calc(100vh - 34px));
  padding: 20px;
  border-radius: 24px;
}

.home-card {
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: center;
  min-height: min(560px, calc(100vh - 34px));
  text-align: center;
}

.landing-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px;
}

.home-copy {
  align-items: center;
}

.landing-side {
  display: grid;
  gap: 12px;
}

.landing-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 220px));
  gap: 12px;
  margin-top: 16px;
}

.home-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  color: #fff9f3;
  text-decoration: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  transition:
    transform var(--ease),
    opacity var(--ease),
    filter var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.home-link-btn.alt {
  background: linear-gradient(135deg, #648e55, #3b612f);
}

.home-link-btn:hover {
  transform: translateY(-1px);
}

.landing-facts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.landing-facts span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(47, 35, 24, 0.08);
  color: var(--muted);
  font-size: 12px;
}

.landing-note-card {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(47, 35, 24, 0.08);
}

.landing-note-card h2 {
  margin-bottom: 6px;
}

.landing-note-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  font-size: clamp(30px, 4.4vw, 48px);
  line-height: 1;
  letter-spacing: 0.02em;
}

h2 {
  font-size: clamp(18px, 2vw, 22px);
}

h3 {
  font-size: 18px;
}

.landing-copy p,
.type-meta,
.mini-note,
.stat-card span,
.summary-strip span {
  color: var(--muted);
}

.landing-copy p {
  max-width: 480px;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.55;
}

.page-subtitle {
  max-width: 520px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.entry-grid,
.compact-type-grid,
.stats-grid,
.summary-strip,
.action-grid {
  display: grid;
  gap: 10px;
}

.compact-entry-grid {
  align-self: stretch;
  grid-template-columns: 1fr;
}

.entry-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 158px;
  padding: 16px;
  border-radius: 18px;
  text-decoration: none;
  transition:
    transform var(--ease),
    border-color var(--ease),
    background var(--ease);
}

.entry-card.alt {
  background:
    linear-gradient(145deg, rgba(255, 248, 239, 0.92), rgba(255, 225, 207, 0.82)),
    var(--panel);
}

.entry-card h2 {
  margin-top: 10px;
}

.entry-card p {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.entry-tag,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(196, 104, 50, 0.12);
  color: var(--accent-strong);
}

.pill-empty {
  background: rgba(78, 65, 54, 0.08);
  color: var(--muted);
}

.compact-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.compact-topbar h1 {
  font-size: clamp(26px, 3.6vw, 34px);
}

.page-heading {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-btn,
button,
.extract-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform var(--ease),
    filter var(--ease),
    background var(--ease),
    border-color var(--ease),
    opacity var(--ease);
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

button,
.extract-btn {
  width: 100%;
  color: #fff9f3;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.ghost-btn {
  width: auto;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(47, 35, 24, 0.1);
}

.danger-btn {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(183, 63, 51, 0.16);
}

button:hover:not(:disabled),
.ghost-btn:hover,
.extract-btn:hover:not(:disabled),
.entry-card:hover {
  transform: translateY(-1px);
}

button:disabled,
.extract-btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(47, 35, 24, 0.12);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition:
    border-color var(--ease),
    box-shadow var(--ease),
    background var(--ease);
}

input:focus,
textarea:focus {
  border-color: rgba(196, 104, 50, 0.5);
  box-shadow: 0 0 0 3px rgba(196, 104, 50, 0.12);
  background: rgba(255, 255, 255, 0.96);
}

textarea {
  min-height: 88px;
}

input[type="file"] {
  padding: 9px 10px;
}

.login-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 88px);
}

.login-card {
  width: min(340px, 100%);
  padding: 18px;
  border-radius: 18px;
}

.login-card h2 {
  margin-bottom: 12px;
}

.auth-form,
.stack-form {
  display: grid;
  gap: 8px;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 14px;
}

.panel-tight {
  padding: 12px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-title-row h2 {
  font-size: 16px;
}

.mini-note {
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(220px, 240px) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 64px);
  align-items: start;
}

.dashboard-stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

.sidebar-panel {
  display: grid;
  gap: 10px;
}

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

.quick-action-list .ghost-btn,
.quick-action-list button {
  width: 100%;
}

.list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

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

.stat-card,
.summary-strip > div,
.type-card {
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid rgba(47, 35, 24, 0.08);
}

.stat-card {
  padding: 10px;
}

.stat-card strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(20px, 2.4vw, 24px);
}

.summary-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-strip > div {
  padding: 10px 12px;
}

.summary-strip strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(20px, 2.4vw, 24px);
}

.compact-type-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  align-content: start;
  overflow: auto;
  padding-right: 2px;
}

#adminTypeList {
  max-height: calc(100vh - 118px);
}

#userTypeList {
  max-height: calc(100vh - 136px);
}

.type-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.type-headline {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.type-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.type-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.type-copy h3 {
  font-size: 16px;
  line-height: 1.2;
}

.type-meta {
  min-height: 0;
  font-size: 12px;
  line-height: 1.45;
}

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

.metric-pill {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(196, 104, 50, 0.1);
}

.metric-pill b {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.metric-pill strong {
  display: block;
  font-size: 15px;
  line-height: 1.15;
}

.action-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.action-btn {
  width: auto;
  flex: 1 1 104px;
  padding: 9px 10px;
  font-size: 12px;
}

.extract-btn {
  margin-top: auto;
}

.compact-extract-btn {
  min-width: 112px;
}

.user-type-headline {
  align-items: stretch;
}

.user-type-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.key-manager-head {
  margin-bottom: 6px;
}

.key-manager-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.key-manager-chip {
  padding: 6px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(47, 35, 24, 0.08);
  text-align: center;
}

.key-manager-chip b {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
  line-height: 1.05;
}

.key-manager-chip span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.05;
}

.key-list {
  display: grid;
  gap: 4px;
}

.key-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(47, 35, 24, 0.08);
}

.key-row-meta,
.key-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.key-row-meta {
  min-width: 0;
}

.key-index {
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(47, 35, 24, 0.06);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
}

.key-row-input {
  margin: 0;
  min-height: 0;
  padding: 5px 7px;
  font-size: 12px;
  line-height: 1.15;
}

.key-row-time {
  max-width: 96px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-row-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.key-action-btn {
  width: auto;
  min-width: 40px;
  padding: 5px 7px;
  font-size: 10px;
}

.key-empty-state {
  min-height: 120px;
}

.export-keys-text {
  min-height: 240px;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.35;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 18px 14px;
  text-align: center;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
  border: 1px dashed rgba(47, 35, 24, 0.16);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 60;
  max-width: min(300px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  color: white;
  background: rgba(26, 20, 15, 0.92);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(39, 27, 18, 0.44);
}

.modal-card {
  width: min(620px, 100%);
  padding: 14px;
  border-radius: 18px;
}

.slim-modal {
  max-height: min(86vh, 760px);
  overflow: auto;
}

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

.sticky-modal-card .modal-head {
  position: sticky;
  top: -14px;
  z-index: 8;
  margin: -14px -14px 8px;
  padding: 11px 14px 8px;
  background: rgba(255, 250, 243, 0.95);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(47, 35, 24, 0.08);
}

.icon-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}

#extractResult {
  min-height: 160px;
  margin: 8px 0 10px;
}

.confirm-modal-card {
  width: min(360px, 100%);
}

.confirm-message {
  margin: 8px 0 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-actions .ghost-btn,
.confirm-actions button {
  width: auto;
  min-width: 88px;
}

.user-theme {
  --bg: #edf2e8;
  --bg-strong: #dce6d3;
  --panel: rgba(247, 252, 245, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.76);
  --panel-border: rgba(28, 58, 34, 0.12);
  --text: #203427;
  --muted: #5f7363;
  --accent: #4f7640;
  --accent-strong: #315027;
  --danger: #9d4033;
  --danger-soft: rgba(157, 64, 51, 0.1);
  --shadow: 0 24px 80px rgba(24, 52, 28, 0.1);
}

@media (max-width: 1024px) {
  .landing-card,
  .dashboard-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

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

  #adminTypeList,
  #userTypeList {
    max-height: none;
  }
}

@media (max-width: 780px) {
  .screen-shell {
    width: min(calc(100% - 18px), var(--max-width));
    padding: 16px 0 22px;
  }

  .compact-shell {
    align-items: stretch;
  }

  .landing-card,
  .panel,
  .login-card,
  .modal-card {
    padding: 12px;
    border-radius: 16px;
  }

  .compact-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .sidebar-panel,
  .compact-type-grid {
    grid-template-columns: 1fr;
  }

  .key-manager-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-grid,
  .summary-strip,
  .metric-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stat-card,
  .summary-strip > div,
  .metric-pill {
    padding: 8px 6px;
  }

  .stat-card strong,
  .summary-strip strong,
  .metric-pill strong {
    font-size: 13px;
  }

  .stat-card span,
  .summary-strip span,
  .metric-pill b,
  .mini-note {
    font-size: 10px;
  }

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

  .type-headline,
  .user-type-headline {
    flex-direction: column;
  }

  .user-type-side {
    justify-items: stretch;
  }

  .action-flow {
    display: flex;
    flex-wrap: wrap;
  }

  .action-btn {
    flex: 1 1 calc(50% - 8px);
  }

  .landing-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .login-wrap {
    min-height: auto;
    padding-top: 12px;
  }

  .type-meta {
    min-height: 0;
  }

  .sticky-modal-card .modal-head {
    top: -12px;
    margin: -12px -12px 6px;
    padding: 9px 12px 6px;
  }

  .key-list {
    gap: 3px;
  }

  .key-row {
    gap: 4px;
    padding: 3px 4px;
  }

  .key-row-input {
    padding: 4px 6px;
    font-size: 11px;
  }

  .key-row-time {
    display: none;
  }

  .key-action-btn {
    min-width: 34px;
    padding: 4px 6px;
    font-size: 10px;
  }

  .export-keys-text {
    min-height: 220px;
    font-size: 11px;
  }

  .confirm-actions {
    justify-content: stretch;
  }

  .confirm-actions .ghost-btn,
  .confirm-actions button {
    flex: 1 1 0;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: clamp(24px, 10vw, 34px);
  }

  .entry-card {
    min-height: auto;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
}
