/* Light (default): warm cream with a green accent */
:root {
  --bg: #f7f4ec;
  --surface: #fffdf8;
  --surface-2: #f2eee3;
  --hover: #f6f2e8;
  --border: #e6e0d1;
  --text: #1f2a22;
  --muted: #6f776d;
  --accent: #2f8a57;
  --accent-strong: #26744a;
  --accent-soft: #e2f0e5;
  --on-accent: #ffffff;
  --ok: #2f9e5b;
  --warn: #b7791f;
  --bad: #c2412d;
  --shadow: 0 1px 2px rgba(60, 50, 20, 0.05), 0 6px 20px rgba(60, 50, 20, 0.06);
  --radius: 14px;
  color-scheme: light;
}

/* Dark */
:root[data-theme="dark"] {
  --bg: #0f1311;
  --surface: #161c18;
  --surface-2: #1d2520;
  --hover: #1a211d;
  --border: #27312b;
  --text: #e6ece7;
  --muted: #8d988f;
  --accent: #5cc285;
  --accent-strong: #74d197;
  --accent-soft: #1b2f23;
  --on-accent: #0c1a11;
  --ok: #4fc47e;
  --warn: #e0a43a;
  --bad: #f07a68;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03"; /* Inter: single-storey a, open digits, round quotes */
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background .2s, color .2s;
}
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 12.5px; letter-spacing: 0; font-feature-settings: normal; }
.muted { color: var(--muted); }

/* Icons */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 14px; height: 14px; }
.ic.lg { width: 28px; height: 28px; }

/* Icon buttons with tooltip */
.ib {
  position: relative;
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.ib:hover { background: var(--surface-2); color: var(--text); }
.ib.danger:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.ib.on { color: var(--ok); }
.ib.primary { background: var(--accent); color: var(--on-accent); }
.ib.primary:hover { background: var(--accent-strong); color: var(--on-accent); }
.ib:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Floating tooltip (positioned by app.js, never clipped by cards or dialogs) */
#tip {
  position: fixed; top: 0; left: 0; z-index: 300;
  background: var(--text); color: var(--bg);
  font-size: 12px; font-weight: 500; line-height: 1.2; white-space: nowrap;
  padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow);
  pointer-events: none; opacity: 0; transition: opacity .12s;
}
#tip.show { opacity: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-weight: 500;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .6; cursor: progress; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; }
.login > .theme-corner { position: absolute; top: 18px; right: 18px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 34px 28px 22px; display: grid; gap: 16px; justify-items: center;
}
.logo { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.login-title { font-size: 18px; font-weight: 600; letter-spacing: -.02em; margin-top: -4px; }
.login-form { display: grid; gap: 10px; width: 100%; }

/* Layout */
.shell { display: grid; grid-template-columns: 76px 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 0; background: var(--surface); border-right: 1px solid var(--border);
}
.rail .logo { width: 42px; height: 42px; border-radius: 12px; margin-bottom: 18px; }
.rail .ib { width: 44px; height: 44px; border-radius: 12px; }
.rail .ib.active { background: var(--accent-soft); color: var(--accent); }
.rail .spacer { flex: 1; }
.rail .avatar.round { width: 32px; height: 32px; font-size: 12px; margin: 6px 0; }

main { padding: 36px clamp(16px, 4vw, 48px) 64px; width: 100%; max-width: 1180px; margin: 0 auto; }
.head { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.head h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.025em; }
.head .grow { flex: 1; }
.page-hint { color: var(--muted); margin: -12px 0 20px; font-size: 13.5px; max-width: 760px; }
.count { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 9px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.stat .stat-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.stat.warn .stat-ic { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.stat .stat-txt { display: grid; line-height: 1.15; }
.stat b { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* Cards & rows */
.cards { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 14px; padding: 16px 16px 16px 20px; }
.card-head .title { display: grid; min-width: 0; }
.card-head .title b { font-weight: 600; font-size: 15px; letter-spacing: -.012em; }
.card-head .title span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head .grow { flex: 1; }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 13px; letter-spacing: 0;
  color: #fff; background: var(--accent);
}
.avatar.round { border-radius: 999px; width: 28px; height: 28px; font-size: 11px; }

.list { border-top: 1px solid var(--border); }
.card > .list:first-child { border-top: 0; }
.row {
  display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; align-items: center; gap: 16px;
  padding: 10px 14px 10px 20px; min-height: 58px;
}
.row + .row { border-top: 1px solid var(--border); }
.row:hover { background: var(--hover); }
.row .main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .main .txt { display: grid; min-width: 0; }
.row .main .txt > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .main .txt .muted { font-size: 12.5px; }
.row .meta { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.row .acts {
  display: flex; gap: 2px; padding-left: 12px; border-left: 1px solid var(--border);
}
.row.off .main { opacity: .5; }
a.sub { color: var(--text); text-decoration: none; font-weight: 500; }
a.sub:hover { color: var(--accent); }

.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.bad { background: var(--bad); }

.chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap;
  max-width: 220px; overflow: visible; font-variant-numeric: tabular-nums;
}
.chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chip.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 11%, transparent); }
.chip.accent { color: var(--accent); background: var(--accent-soft); }

.empty { display: grid; place-items: center; gap: 10px; padding: 52px 16px; color: var(--muted); }
.empty .ic { width: 34px; height: 34px; opacity: .6; }

/* Forms */
.field {
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
  transition: border-color .12s, background .12s;
}
.field:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .ic { color: var(--muted); }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 100%;
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .85; }
.field select { cursor: pointer; }
.field select option { background: var(--surface); color: var(--text); }
.field.area { height: auto; align-items: flex-start; padding: 11px 12px; }
.field.area textarea { min-height: 120px; resize: vertical; height: auto; }
.field .suffix { color: var(--muted); font-size: 12.5px; }
/* Buttons inside a field (show / generate password) */
.field .ib.in-field { width: 30px; height: 30px; margin-right: -6px; }
.field .ib.in-field.accent { color: var(--accent); }
.field .ib.in-field.accent:hover { background: var(--accent-soft); }

/* Quick-pick pills under a field */
.field-group { display: grid; gap: 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 2px; }
.pill {
  height: 28px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums;
  transition: background .12s, color .12s, border-color .12s;
}
.pill:hover { color: var(--text); border-color: var(--accent); }
.pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.multi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; padding-left: 2px; }
.pill { display: inline-flex; align-items: center; gap: 5px; }
.ib.accent { color: var(--accent); }
.ib.accent:hover { background: var(--accent-soft); color: var(--accent); }

/* Tool site icon in place of the letters avatar */
.avatar.tool-icon { background: #fff; border: 1px solid var(--border); padding: 6px; overflow: hidden; }
.avatar.tool-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Cookie dialog */
.cookie-bar { display: flex; align-items: center; gap: 8px; }
.cookie-bar .grow { flex: 1; }
.cookie-bar .btn { height: 34px; }
.field.area textarea { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; }

/* Docs page */
.docs { display: grid; gap: 16px; }
.doc { padding: 6px 20px 18px; }
.doc-head { display: flex; align-items: center; gap: 8px; }
.doc-head h2 { flex: 1; font-size: 16px; font-weight: 650; letter-spacing: -.015em; margin: 14px 0 6px; }
.doc p { color: var(--muted); margin: 4px 0 12px; }
.doc ul { margin: 12px 0 0; padding-left: 20px; color: var(--text); }
.doc li { margin: 4px 0; }
.doc-block { margin-top: 12px; }
.doc-label { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 550; color: var(--muted); margin-bottom: 4px; }
.doc-label .ib { width: 28px; height: 28px; }
.doc pre.snippet { max-height: none; }

/* Login details card */
.cred-card { display: grid; gap: 8px; }
.cred {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px 10px 12px; border-radius: 12px; background: var(--surface-2);
}
.cred-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.cred-txt { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.cred-txt small { color: var(--muted); font-size: 11.5px; }
.cred-txt .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

/* Themed dropdown */
.field.dd { width: 100%; cursor: pointer; text-align: left; }
.field.dd:hover { border-color: var(--border); }
.field.dd[aria-expanded="true"] { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.dd:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dd-label { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
.dd-label .dd-main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-label .dd-hint { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-chev { color: var(--muted); transition: transform .15s; }
.field.dd[aria-expanded="true"] .dd-chev { transform: rotate(180deg); color: var(--accent); }
.dd-menu {
  position: fixed; z-index: 250; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(30, 30, 10, .16), 0 2px 6px rgba(30, 30, 10, .06);
  animation: dd-in .12s ease-out;
}
:root[data-theme="dark"] .dd-menu { box-shadow: 0 14px 36px rgba(0, 0, 0, .5); }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } }
.dd-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.dd-opt.active { background: var(--surface-2); }
.dd-opt.sel { color: var(--accent); }
.dd-opt.sel .dd-main { font-weight: 550; }
.dd-ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.dd-opt.active .dd-ic { background: var(--surface); }
.dd-opt.sel .dd-ic { background: var(--accent-soft); color: var(--accent); }
.dd-txt { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.dd-txt .dd-main, .dd-txt .dd-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-txt .dd-hint { color: var(--muted); font-size: 12px; }
.dd-tick { visibility: hidden; color: var(--accent); }
.dd-opt.sel .dd-tick { visibility: visible; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--muted);
}
.seg button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.switch { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.switch .grow { flex: 1; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Modal */
dialog {
  border: 1px solid var(--border); padding: 0; border-radius: 20px; width: min(480px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(20, 20, 10, .22);
}
dialog::backdrop { background: rgba(25, 28, 20, .38); backdrop-filter: blur(3px); }
.modal { display: grid; gap: 12px; padding: 22px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.modal-head .logo { width: 38px; height: 38px; border-radius: 11px; }
.modal-head b { flex: 1; font-size: 16px; font-weight: 600; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.secret { display: flex; gap: 8px; align-items: stretch; }
.secret code {
  flex: 1; padding: 11px 12px; border-radius: 10px; background: var(--surface-2);
  word-break: break-all; font-size: 12.5px;
}
pre.snippet {
  margin: 0; padding: 12px; border-radius: 10px; background: var(--surface-2); flex: 1;
  font-size: 12px; white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto;
}
.note { display: flex; gap: 8px; align-items: center; color: var(--warn); font-size: 12.5px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 8px;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 100; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); color: #fff; }

.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Medium screens: chips drop below the name, actions stay on the right */
@media (max-width: 1000px) {
  .row { grid-template-columns: 1fr auto; }
  .row .meta { grid-column: 1; grid-row: 2; justify-content: flex-start; flex-wrap: wrap; }
  .row .acts { grid-column: 2; grid-row: 1 / span 2; }
}

/* Phones: rail becomes a bottom bar */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; bottom: 0; top: auto; height: 62px; width: 100%; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--border); padding: 0 8px; z-index: 20; }
  .rail .logo, .rail .spacer { display: none; }
  main { padding: 24px 16px 96px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 10px; gap: 8px; flex-direction: column; align-items: flex-start; }
  .stat .stat-ic { width: 32px; height: 32px; }
  .row { grid-template-columns: 1fr; gap: 8px; }
  .row .meta, .row .acts { grid-column: 1; grid-row: auto; }
  .row .acts { border-left: 0; padding-left: 0; }
}
