:root {
  --bg: #0d1115;
  --panel: #141a20;
  --panel-2: #192027;
  --line: #2b343d;
  --line-soft: #222a31;
  --ink: #eef1ee;
  --muted: #9aa7a1;
  --accent: #d7a441;
  --accent-2: #2fa787;
  --danger: #e26d5a;
  --shadow: 0 12px 30px rgba(0, 0, 0, .22);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-height: 100dvh; margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 14px; line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.lock-screen {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 15% 15%, rgba(215,164,65,.11), transparent 28rem),
              radial-gradient(circle at 80% 75%, rgba(47,167,135,.09), transparent 30rem), var(--bg);
}
.lock-panel, .panel, .modal {
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.lock-panel { width: min(400px, 100%); padding: 26px; }
.brand-lock, .brand { display: flex; align-items: center; gap: 12px; color: var(--accent); }
.brand-lock svg, .brand svg { width: 28px; height: 28px; }
.brand-lock strong, .brand strong { display: block; color: var(--ink); font-size: 18px; }
.brand-lock span, .brand span { color: var(--muted); font-size: 12px; }
.lock-form { margin-top: 24px; display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field label { color: var(--muted); font-size: 12px; }
input, textarea, select {
  width: 100%; min-height: 40px; padding: 9px 11px; color: var(--ink);
  background: #0f151a; border: 1px solid var(--line); border-radius: 6px; outline: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(215,164,65,.12); }

.primary, .ghost {
  min-height: 38px; padding: 8px 12px; border-radius: 6px; display: inline-flex;
  align-items: center; justify-content: center; gap: 7px; transition: .18s ease;
}
.primary { background: var(--accent); color: #20180a; font-weight: 700; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.ghost:hover { background: #222a31; }
.ghost.danger { color: var(--danger); border-color: rgba(226,109,90,.36); }
.wide { width: 100%; }
.icon-only { width: 38px; padding: 0; flex: 0 0 auto; }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar {
  display: flex; flex-direction: column; gap: 20px; padding: 22px 16px;
  background: #10151a; border-right: 1px solid var(--line-soft);
}
.side-nav { display: grid; gap: 6px; }
.nav-item, .mobile-tabs button {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  background: transparent; border-radius: 6px; border: 0; text-align: left;
}
.nav-item { min-height: 40px; padding: 9px 11px; }
.nav-item:hover, .nav-item.active { color: var(--ink); background: #202831; }
.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.safe-state { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 12px; color: var(--accent-2); background: rgba(47,167,135,.08); border: 1px solid rgba(47,167,135,.24); border-radius: 6px; }
.safe-state strong, .safe-state span { display: block; }
.safe-state strong { color: var(--ink); font-size: 13px; }
.safe-state span { font-size: 12px; color: var(--muted); }

.main-area { display: flex; flex-direction: column; min-width: 0; max-height: 100dvh; }
.topbar {
  min-height: 74px; padding: 16px 26px; display: flex; align-items: center; gap: 20px;
  justify-content: space-between; border-bottom: 1px solid var(--line-soft); background: rgba(13,17,21,.94);
}
.title-block h1 { margin: 0; font-size: 21px; letter-spacing: 0; }
.title-block p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; min-width: min(380px, 42vw); }
.search-box { position: relative; display: flex; align-items: center; flex: 1; }
.search-box svg { position: absolute; left: 11px; color: var(--muted); }
.search-box input { padding-left: 38px; }
.mobile-lock { display: none; }

.view-root { flex: 1; overflow: auto; padding: 24px 26px 36px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.view-head h2 { margin: 0; font-size: 16px; }
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.head-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.section { margin-bottom: 22px; }
.panel { padding: 16px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title h3 { margin: 0; font-size: 15px; }
.panel-title span { color: var(--muted); font-size: 12px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.metric .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.metric .value { margin-top: 10px; font-size: 27px; line-height: 1; font-weight: 700; }
.metric.warning .value { color: var(--accent); }
.metric.good .value { color: var(--accent-2); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 16px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }
.audit-item, .mini-item { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.audit-item:first-of-type, .mini-item:first-of-type { border-top: 0; padding-top: 0; }
.audit-item svg { color: var(--accent); flex: 0 0 auto; margin-top: 2px; }
.audit-item.ok svg { color: var(--accent-2); }
.mini-item strong { display: block; font-size: 13px; }
.mini-item span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
  min-height: 32px; padding: 6px 11px; border-radius: 999px; color: var(--muted);
  background: #182027; border: 1px solid var(--line); font-size: 12px;
}
.chip.active { color: #1d1708; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.items { display: grid; gap: 10px; }
.item {
  padding: 13px 14px; display: flex; gap: 14px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.item.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.credential-check { display: grid; place-items: center; width: 24px; height: 38px; flex: 0 0 auto; }
.credential-check input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); }
.selection-bar { border-color: rgba(215,164,65,.42); }
.selection-bar select { min-width: 160px; }
.item.focused { border-color: rgba(215,164,65,.55); }
.item-main { flex: 1; min-width: 0; }
.item-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.item-title .pin { color: var(--accent); }
.item-meta { margin-top: 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.item-notes { margin-top: 7px; color: #c6cdc9; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.secret-line { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.secret-line input { min-height: 34px; font-family: Consolas, monospace; }
.item-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.mini { width: 34px; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: #1d252d; color: var(--muted); border: 1px solid var(--line); }
.mini:hover { color: var(--ink); background: #272f38; }
.mini.danger:hover { color: var(--danger); border-color: rgba(226,109,90,.5); }
.mini svg { width: 16px; height: 16px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.tag { padding: 2px 7px; color: var(--muted); background: #1b232a; border-radius: 999px; font-size: 11px; }
.tag-button { border: 1px solid transparent; cursor: pointer; transition: .16s ease; }
.tag-button:hover { color: var(--ink); border-color: var(--line); background: #223038; }
.tag-button.active, .tag-button.active:hover { color: #20180a; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.badge { padding: 2px 7px; border-radius: 999px; font-size: 11px; background: #223038; color: #b9c7c1; }
.badge.good { color: #9ff0d9; background: rgba(47,167,135,.14); }
.badge.warn { color: #ffd889; background: rgba(215,164,65,.13); }
.badge.bad { color: #ffb3a5; background: rgba(226,109,90,.14); }
.link-row { cursor: pointer; }
.link-row:hover { border-color: rgba(47,167,135,.5); }
.initial { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 6px; background: #202831; color: var(--accent); font-weight: 800; }

.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }
.quick-form { display: grid; grid-template-columns: minmax(0,1fr) 190px auto auto; gap: 10px; align-items: end; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; min-height: 40px; }
.check input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.modal-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(4,7,10,.72); }
.modal { width: min(720px, 100%); max-height: min(88dvh, 760px); overflow: auto; padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-form { display: grid; gap: 14px; }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: min(360px, calc(100vw - 40px));
  padding: 11px 14px; border-left: 3px solid var(--accent); background: #1a2128; color: var(--ink);
  box-shadow: var(--shadow); border-radius: 6px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--danger); }
.mobile-tabs { display: none; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .grid-two { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 68px; }
  .sidebar { display: none; }
  .topbar { position: sticky; top: 0; z-index: 10; padding: 14px 16px; }
  .top-actions { min-width: 0; }
  .mobile-lock { display: inline-flex; }
  .view-root { padding: 16px; }
  .view-head { align-items: flex-start; flex-direction: column; }
  .head-actions { width: 100%; }
  .head-actions .primary, .head-actions .ghost { flex: 1; }
  .item { flex-direction: column; }
  .item-actions { width: 100%; justify-content: flex-end; }
  .quick-form { grid-template-columns: 1fr; align-items: stretch; }
  .check { min-height: 34px; }
  .form-grid { grid-template-columns: 1fr; }
  .mobile-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid;
    grid-template-columns: repeat(9, 1fr); height: 64px; background: #10161b;
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabs button { height: 100%; flex-direction: column; justify-content: center; gap: 3px; font-size: 10px; color: var(--muted); border-radius: 0; }
  .mobile-tabs button.active { color: var(--accent); }
  .mobile-tabs span { font-size: 10px; }
}
