:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --primary: #0f766e;
  --primary-d: #0b5d56;
  --danger: #dc2626;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 14px;
  background: var(--primary); color: #fff;
  box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 17px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: 8px;
  padding: 8px 12px; transition: filter .15s, background .15s;
}
button:active { transform: translateY(1px); }
.primary { background: #fff; color: var(--primary-d); font-weight: 600; }
.primary:hover { filter: brightness(.96); }
.ghost { background: rgba(255, 255, 255, .18); color: #fff; }
.ghost:hover { background: rgba(255, 255, 255, .28); }
.danger { background: var(--danger); color: #fff; }
.danger:hover { filter: brightness(.94); }

.subbar {
  position: sticky; top: 52px; z-index: 15;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--card); border-bottom: 1px solid var(--border);
}
.sync-status { font-size: 13px; color: var(--muted); min-width: 92px; }
.search { flex: 1; min-width: 120px; }
.search input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; background: var(--bg);
}

main { padding: 14px; max-width: 1100px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 13px; }

.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .1); transform: translateY(-1px); }
.card h3 { margin: 0 0 8px; font-size: 16px; word-break: break-all; }
.card .row { display: flex; gap: 6px; font-size: 13px; margin: 3px 0; }
.card .row .k { color: var(--muted); min-width: 64px; }
.card .row .v { color: var(--text); word-break: break-all; flex: 1; }
.card .expire { font-size: 12px; margin-top: 8px; }
.card .expire.soon { color: var(--danger); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 弹窗 */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay.hidden, .hidden { display: none !important; }
.login-card, .modal-card {
  background: var(--card); border-radius: 16px; padding: 22px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card input {
  width: 100%; margin: 14px 0; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px; font: inherit;
}
.login-card button { width: 100%; padding: 11px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 0; }

.modal-card { max-width: 460px; max-height: 86vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 12px; }
#editForm .field { margin-bottom: 10px; }
#editForm label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
#editForm input, #editForm textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 9px; font: inherit; background: var(--bg);
}
#editForm textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .primary, .modal-actions .danger { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; z-index: 80; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

/* 首页：两个独立服务入口 */
.home { max-width: 720px; }
.home-hint { color: var(--muted); margin: 6px 2px 14px; }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.home-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
}
.home-card:hover { box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.hc-icon { font-size: 44px; }
.hc-title { font-size: 18px; font-weight: 700; }
.hc-sub { font-size: 13px; color: var(--muted); min-height: 18px; margin-bottom: 4px; }
.home-card .primary { width: 100%; }

@media (max-width: 540px) {
  .brand { font-size: 15px; }
  .actions button { padding: 7px 9px; font-size: 13px; }
  .list { grid-template-columns: 1fr; }
  .home-cards { grid-template-columns: 1fr; }
}
