/* BetterNotes Sync – admin and account pages. No external resources. */
:root {
  --accent: #0a84c6;
  --accent-soft: #e6f3fb;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1d2733;
  --muted: #6b7785;
  --line: #e2e7ec;
  --green: #1f8a4c;
  --green-soft: #e5f5ec;
  --red: #c4362c;
  --red-soft: #fdecea;
  --amber: #b26a00;
  --amber-soft: #fff4e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; font-weight: 650; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 .8rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .7rem; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 .9rem; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: .7rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 650; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.logo { display: inline-flex; }
.brand-sub { color: var(--muted); font-weight: 500; padding-left: .5rem; border-left: 1px solid var(--line); }
.nav { margin-left: auto; display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a, .linkbtn {
  color: var(--muted); padding: .4rem .7rem; border-radius: 8px; font-weight: 500; font-size: .93rem;
}
.nav a:hover, .linkbtn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.linkbtn { background: none; border: 0; cursor: pointer; font: inherit; font-size: .93rem; }
form.inline { display: inline; margin: 0; }

.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 1.5rem 1rem 2rem; flex: 1; }
body.narrow .container { max-width: 560px; padding-top: 3rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.auth { max-width: 440px; margin: 0 auto; padding: 1.75rem; }
.card.auth.wide { max-width: 640px; }
.card.highlight { border-color: var(--accent); background: var(--accent-soft); }
.danger-zone { border-color: #f0c7c3; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .grid2 + h2 { margin-top: 1rem; }
.section-title { margin-top: 1.5rem; }

/* forms */
label { display: block; font-weight: 550; font-size: .9rem; margin: .9rem 0 .35rem; }
input[type=text], input[type=password], input[type=search], input[type=email] {
  width: 100%; padding: .6rem .75rem; border: 1px solid #cfd7df; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input.code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Consolas, Menlo, monospace; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .58rem 1rem; border-radius: 8px;
  border: 1px solid #cfd7df; background: #fff; color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0873ad; }
.btn.warn { color: var(--amber); border-color: #ecc98a; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #a92d24; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.block { width: 100%; margin-top: 1.2rem; }
.row-form { display: flex; gap: .5rem; align-items: center; }
.row-form input { flex: 1; min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions form { margin: 0; }

/* alerts & badges */
.alert { border-radius: 10px; padding: .75rem 1rem; margin: 0 auto 1rem; border: 1px solid; }
body.narrow .alert { max-width: 440px; }
.alert.ok { background: var(--green-soft); border-color: #bfe3cd; color: #165f36; }
.alert.err { background: var(--red-soft); border-color: #f3c3be; color: #8f241c; }
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.grey { background: #eef1f4; color: var(--muted); }
.badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.title-row h1 { margin: 0; }
.back { margin: 0 0 .5rem; font-size: .9rem; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 550; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.55rem; font-weight: 650; margin-top: .2rem; }
.stat-note { color: var(--muted); font-size: .82rem; }
.stat.wide { grid-column: span 2; }
.stat-of { font-size: .95rem; font-weight: 500; color: var(--muted); }
.diskbar { margin: .45rem 0 .35rem; }
progress.bar.big { width: 100%; height: 10px; border-radius: 5px; }
progress.bar.big::-webkit-progress-bar, progress.bar.big::-webkit-progress-value { border-radius: 5px; }

/* per-account usage and inline quota editing */
.table td.usage { min-width: 9.5rem; white-space: nowrap; }
.usage-text { font-size: .88rem; margin-bottom: .3rem; }
.usage progress.bar { width: 100%; max-width: 160px; display: block; }
.quota-cell { white-space: nowrap; }
.quota-edit summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .35rem; }
.quota-edit summary::-webkit-details-marker { display: none; }
.edit-hint { color: var(--accent); font-size: .8rem; font-weight: 550; }
.quota-edit[open] .edit-hint { display: none; }
.mini-form { display: flex; gap: .35rem; margin-top: .4rem; }
.mini-form input { width: 7.5rem; padding: .35rem .5rem; font-size: .88rem; }
.quota-edit .hint { margin: .25rem 0 0; font-size: .78rem; }
.btn.small { padding: .32rem .65rem; font-size: .85rem; }

/* search */
.search { display: flex; gap: .5rem; margin-bottom: 1rem; max-width: 560px; }
.search input { flex: 1; min-width: 0; }

/* table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #f9fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #fafcfd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table td.email { font-weight: 550; overflow-wrap: anywhere; min-width: 15rem; }
.table td.empty { text-align: center; color: var(--muted); padding: 2rem; }
.sort { color: inherit; }
.sort:hover { color: var(--text); text-decoration: none; }
.sort.active { color: var(--accent); }
.arrow { font-size: .7em; margin-left: .3em; }
.quota { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
progress.bar { -webkit-appearance: none; appearance: none; width: 90px; height: 6px; border: 0; border-radius: 3px; background: #e7ecf0; overflow: hidden; }
progress.bar::-webkit-progress-bar { background: #e7ecf0; border-radius: 3px; }
progress.bar::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
progress.bar::-moz-progress-bar { background: var(--accent); border-radius: 3px; }
progress.bar.warn::-webkit-progress-value { background: var(--red); }
progress.bar.warn::-moz-progress-bar { background: var(--red); }
.pager { display: flex; justify-content: space-between; margin-top: .5rem; }

/* key/value list, devices */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.devices li:last-child { border-bottom: 0; }
.dev-name { font-weight: 550; overflow-wrap: anywhere; }

/* TOTP setup & reset code */
.steps { padding-left: 1.2rem; color: var(--text); }
.steps li { margin: .25rem 0; }
.totp-setup { display: grid; grid-template-columns: 200px 1fr; gap: 1.5rem; align-items: start; margin-top: 1rem; }
.qr-wrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; }
svg.qr { width: 100%; height: auto; display: block; }
.label { font-weight: 550; font-size: .9rem; margin-bottom: .35rem; }
.secret { display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; letter-spacing: .08em; overflow-wrap: anywhere; user-select: all; }
.resetcode { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: 2rem; font-weight: 700; letter-spacing: .2em; margin: .2rem 0 .6rem; user-select: all; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .container { padding: 1rem .75rem 1.5rem; }
  body.narrow .container { padding-top: 1.25rem; }
  .card.auth { padding: 1.25rem; }
  .totp-setup { grid-template-columns: 1fr; }
  .qr-wrap { max-width: 220px; margin: 0 auto; }
  .row-form { flex-direction: column; align-items: stretch; }
  .search { flex-wrap: wrap; }
  .stat-value { font-size: 1.3rem; }
  .kv { grid-template-columns: 1fr; gap: .1rem; }
  .kv dd { margin-bottom: .5rem; }
  .brand-sub { display: none; }
  .nav { margin-left: 0; width: 100%; }
}
.status-cell { white-space: nowrap; }
.status-cell .badge + .badge { margin-left: .25rem; }
