/* Brankas Akun — palet "baja & kuningan" seperti lemari brankas */
:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --surface-sunk: #e3e7ed;
  --ink: #17233a;
  --steel: #56667d;
  --line: #cbd2dc;
  --brass: #9c7634;
  --brass-ink: #ffffff;
  --brass-soft: #f3ead9;
  --danger: #ad3b2c;
  --focus: #2f6fd6;

  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  --radius-lg: 14px;
  --radius-sm: 7px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111a27;
    --surface: #182334;
    --surface-sunk: #0d1520;
    --ink: #e2e8f0;
    --steel: #93a2b8;
    --line: #2a3850;
    --brass: #d1a95e;
    --brass-ink: #1b1406;
    --brass-soft: #2b2617;
    --danger: #f0806f;
    --focus: #7fb0ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
.mono { font-family: var(--mono); font-size: 0.92em; }
[hidden] { display: none !important; }

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

/* ---------- Tombol ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.94rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.btn:hover { border-color: var(--steel); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--brass); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--steel); }
.btn-quiet:hover { color: var(--ink); border-color: var(--line); }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; padding: 0.75rem; }

.link-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.15rem 0.3rem;
  margin-left: 0.35rem;
  color: var(--brass);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Form ---------- */
label { display: block; margin-bottom: 1rem; }
label > span { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 0.35rem; }
label em { font-weight: 400; font-style: normal; color: var(--steel); }
label small { display: block; color: var(--steel); font-size: 0.82rem; margin-top: 0.3rem; }
input, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}
input:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.pw-input { display: flex; gap: 0.4rem; }
.pw-input input { flex: 1; min-width: 0; font-family: var(--mono); }
.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login {
  width: 100%;
  max-width: 360px;
}
.login-mark { color: var(--brass); margin-bottom: 1.25rem; }
.login h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
.login-sub { color: var(--steel); margin: 0.5rem 0 2rem; }

/* ---------- Kerangka aplikasi ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.brand svg { color: var(--brass); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: 1.5rem;
}
.toolbar h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
.count { margin: 0.25rem 0 0; color: var(--steel); font-size: 0.92rem; }
.toolbar-actions { display: flex; gap: 0.6rem; flex: 1 1 360px; max-width: 520px; }
.toolbar-actions input { flex: 1; min-width: 0; background: var(--surface); }

/* ---------- Daftar akun ---------- */
.accounts {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.accounts:empty { display: none; }

.account {
  display: grid;
  grid-template-columns: minmax(200px, 1.1fr) minmax(260px, 1.4fr) auto;
  grid-template-areas:
    "main creds actions"
    "notes notes notes";
  gap: 0.5rem 1.5rem;
  align-items: center;
  padding: 1.1rem 1.25rem;
}
.account + .account { border-top: 1px solid var(--line); }

.acc-main { grid-area: main; display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.acc-initial {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brass-soft);
  color: var(--brass);
  font-weight: 700;
}
.acc-title { min-width: 0; }
.acc-name { font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-url {
  display: block;
  color: var(--steel);
  font-size: 0.86rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.acc-url:hover { color: var(--ink); text-decoration: underline; }

.acc-creds { grid-area: creds; margin: 0; display: grid; gap: 0.3rem; min-width: 0; }
.acc-creds > div { display: grid; grid-template-columns: 5.5rem 1fr; align-items: center; }
.acc-creds dt { color: var(--steel); font-size: 0.82rem; }
.acc-creds dd { margin: 0; display: flex; align-items: center; min-width: 0; flex-wrap: wrap; }
.acc-user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }

/* Slot password: seperti celah brankas yang terbuka saat ditampilkan */
.slot {
  display: inline-block;
  background: var(--surface-sunk);
  border-radius: 4px;
  padding: 0.05rem 0.5rem;
  letter-spacing: 0.08em;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}
.slot.open {
  letter-spacing: 0;
  background: var(--brass-soft);
  user-select: all;
  animation: slot-open 180ms ease-out;
}
@keyframes slot-open {
  from { clip-path: inset(0 50% 0 50%); }
  to { clip-path: inset(0 0 0 0); }
}

.acc-actions { grid-area: actions; display: flex; gap: 0.3rem; justify-content: flex-end; }
.acc-notes {
  grid-area: notes;
  margin: 0.2rem 0 0;
  padding-left: 3.25rem;
  color: var(--steel);
  font-size: 0.88rem;
  white-space: pre-wrap;
  max-width: 75ch;
}

/* ---------- Kosong ---------- */
.empty {
  text-align: center;
  padding: 4rem 1.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.empty h2 { font-size: 1.25rem; }
.empty p { color: var(--steel); max-width: 44ch; margin: 0.6rem auto 1.5rem; }
.empty-search { color: var(--steel); text-align: center; padding: 2rem; }

/* ---------- Dialog ---------- */
dialog {
  width: min(520px, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 1.75rem;
}
dialog::backdrop { background: rgba(10, 18, 30, 0.55); }
dialog h2 { font-size: 1.3rem; margin-bottom: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* ---------- Responsif ---------- */
@media (max-width: 860px) {
  .account {
    grid-template-columns: 1fr;
    grid-template-areas: "main" "creds" "notes" "actions";
    gap: 0.75rem;
  }
  .acc-notes { padding-left: 0; }
  .acc-actions { justify-content: flex-start; flex-wrap: wrap; }
  .toolbar-actions { max-width: none; }
}
@media (max-width: 480px) {
  .toolbar-actions { flex-direction: column; }
  .pw-input { flex-wrap: wrap; }
  .pw-input input { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .slot.open { animation: none; }
}
