/* Dark only, colours taken from the Stalwart web UI. */
:root {
  color-scheme: dark;
  --bg: #18181b;
  --card: #1f1f23;
  --input: #2a2a2e;
  --hover: #26262a;
  --line: #2e2e33;
  --fg: #f4f4f2;
  --muted: #a1a19b;
  --brand: #db2d54;
  --danger: #f4839a;
  --danger-bg: rgba(219, 45, 84, 0.1);
  --danger-line: rgba(219, 45, 84, 0.3);
  --ok: #4ade80;
  --radius: 10px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
main { max-width: 84rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
main.narrow { max-width: 36rem; }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 2rem 0 0.75rem; }
p { margin: 0 0 0.9rem; }
a { color: var(--fg); }
code, .key, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Top bar */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--fg); text-decoration: none; }
.brand-mark { width: 1.6rem; height: 1.6rem; border-radius: 6px; background: var(--brand); display: grid; place-items: center; }
.brand-mark svg { width: 1rem; height: 1rem; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.top nav a, .top nav button {
  color: var(--muted); text-decoration: none; padding: 0.35rem 0.65rem; border-radius: var(--radius-sm);
  background: none; border: 0; font: inherit; cursor: pointer;
}
.top nav a:hover, .top nav button:hover, .top nav a[aria-current="page"] { color: var(--fg); background: var(--hover); }
.top .who { color: var(--muted); font-size: 0.85rem; padding: 0 0.5rem; }
.inline { display: inline; margin: 0; }

/* Cards and forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.stack { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-weight: 500; font-size: 0.9rem; }
input, select {
  font: inherit; padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--input); color: var(--fg); width: 100%; min-width: 0;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--fg);
  background: var(--fg); color: var(--bg); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.secondary:hover { background: var(--hover); }
.btn.danger { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint, .meta { color: var(--muted); font-size: 0.88rem; }
.error {
  color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem;
}
.notice { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 1rem; margin: 0 0 1.25rem; }
.big {
  font: 600 1.4rem/1.3 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; padding: 1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.addr-inline { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.key { word-break: break-all; font-size: 0.95rem; }

/* Address page */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.head h1 { margin: 0; }
.create { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.create input { flex: 1 1 16rem; }
.filter { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.filter select { width: auto; }
.filter input { flex: 1 1 14rem; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
th { color: var(--muted); font-weight: 500; font-size: 0.82rem; white-space: nowrap; }
th.num, td.num { text-align: right; }
th button {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem; color: inherit;
}
th button:hover { color: var(--fg); }
th button::after { content: "↕"; opacity: 0.35; font-size: 0.8em; }
th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; }
th[aria-sort] button { color: var(--fg); }
td.addr { font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }
td.date { white-space: nowrap; color: var(--muted); }
td.note { min-width: 12rem; }
td.note .empty { color: var(--muted); }
tr.off td.addr, tr.gone td.addr { color: var(--muted); }
tr.gone td.addr { text-decoration: line-through; }
td.tools { white-space: nowrap; text-align: right; width: 1%; }
.edit-form { display: flex; align-items: center; gap: 0.25rem; }
.edit-form input { padding: 0.3rem 0.5rem; flex: 1 1 auto; width: 12rem; }
.edit-form[hidden], .note-view[hidden] { display: none; }

.icon {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer;
  vertical-align: middle;
}
.icon:hover { color: var(--fg); background: var(--input); border-color: var(--line); }
.icon.danger:hover { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.icon.ok:hover { color: var(--ok); }
.icon svg { width: 1rem; height: 1rem; }
.icon.copy { width: 1.6rem; height: 1.6rem; margin-left: 0.25rem; }
.icon.copy svg { width: 0.85rem; height: 0.85rem; }

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.8rem; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); border-color: rgba(74, 222, 128, 0.3); }
.badge.gone { color: var(--danger); border-color: var(--danger-line); }
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* Confirmation dialog */
dialog {
  background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; max-width: min(28rem, calc(100vw - 2rem));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 0.6rem; }
dialog .actions { justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 1150px) {
  .col-created { display: none; }
}
@media (max-width: 900px) {
  .col-last { display: none; }
}
@media (max-width: 640px) {
  .col-count, .col-status { display: none; } /* status stays visible as grey or struck-through address */
  th, td { padding: 0.5rem 0.4rem; }
  .icon { width: 1.8rem; height: 1.8rem; }
  td.addr { white-space: normal; font-size: 0.76rem; } /* breaks after the hyphens */
  td.tools { padding-left: 0; padding-right: 0.3rem; }
  td.addr .icon.copy { display: none; }
  td.note { min-width: 0; }
  .who { display: none; }
}
