/* MOTIF LogIn — minimal, Apple-like UI */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f9f9fb;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e3e3e8;
  --accent: #0071e3;
  --accent-hover: #0062c4;
  --accent-soft: #e8f1fc;
  --danger: #d70015;
  --danger-soft: #fdecee;
  --warn: #b25000;
  --warn-soft: #fff4e5;
  --ok: #1a7f37;
  --ok-soft: #e9f6ec;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #232326;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: #333336;
    --accent: #2997ff;
    --accent-hover: #4aa8ff;
    --accent-soft: #0b2a4a;
    --danger: #ff453a;
    --danger-soft: #3a1513;
    --warn: #ff9f0a;
    --warn-soft: #3a2a10;
    --ok: #30d158;
    --ok-soft: #10301a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.3; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
code, pre { font-family: var(--mono); font-size: 13px; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
pre { background: #1d1d1f; color: #f5f5f7; padding: 16px; border-radius: 12px; overflow-x: auto; line-height: 1.5; margin: 0 0 16px; }
pre code { background: none; border: 0; padding: 0; color: inherit; word-break: normal; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* brand / logo — Climate Crisis (SIL OFL 1.1, assets/fonts/LICENSE.txt) */
@font-face {
  font-family: "Climate Crisis";
  src: url("/assets/fonts/climate-crisis-logo.woff2") format("woff2");
  font-display: block;
  unicode-range: U+46, U+49, U+4C-4D, U+4F, U+54, U+67, U+6E-6F;
}
.brand { display: inline-flex; align-items: center; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo { display: inline-flex; flex-direction: column; align-items: center; text-align: center; font-family: "Climate Crisis", var(--font); font-size: 26px; line-height: .92; letter-spacing: .01em; }
.logo > span { display: block; }
.topbar .logo { font-size: 13px; }

/* ---------- auth pages ---------- */
body.auth { min-height: 100vh; }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px 28px; }
.auth-card.landing { max-width: 480px; }
.auth-card.landing h1 { font-size: 22px; margin: 18px 0 10px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-loading { display: grid; justify-items: center; gap: 12px; padding: 24px 0; color: var(--muted); }
.auth-footer { margin-top: 20px; display: flex; gap: 8px; font-size: 12px; color: var(--muted); }
.auth-footer a { color: var(--muted); }
.service-head { text-align: center; margin-bottom: 22px; }
.service-logo { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); display: inline-grid; place-items: center; font-size: 24px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.service-head h1 { font-size: 20px; margin-bottom: 4px; }
.service-host { font-size: 13px; color: var(--muted); }
.service-host b { color: var(--text); font-weight: 600; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.provider-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.provider-btn svg { width: 18px; height: 18px; flex: none; }
.legal-note { font-size: 12px; color: var(--muted); text-align: center; margin: 18px 0 0; }
.switch-link { text-align: center; font-size: 14px; margin-top: 16px; }
.status-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; font-weight: 700; font-size: 22px; }
.status-icon.error { background: var(--danger-soft); color: var(--danger); }
.status-icon.ok { background: var(--ok-soft); color: var(--ok); }
.status-icon.info { background: var(--accent-soft); color: var(--accent); }
.auth-card h1 { text-align: center; }
.auth-card > p, .center { text-align: center; }
.current-user { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; margin-bottom: 4px; }
.current-user .who { font-size: 14px; color: var(--muted); text-align: center; word-break: break-all; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--danger); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], input[type=datetime-local], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid=true] { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 400; margin: 8px 0; cursor: pointer; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }
.choices { display: grid; gap: 4px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 500; font-size: 15px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, opacity .15s; min-height: 44px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { font-size: 13px; padding: 6px 12px; min-height: 32px; border-radius: 8px; }
.btn.block { width: 100%; }
.linklike { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

/* ---------- notices / badges ---------- */
.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; margin: 0 0 14px; background: var(--accent-soft); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.info { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ---------- spinner ---------- */
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- console ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.topbar-tag { font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; }
.admin .topbar-tag { color: var(--danger); font-weight: 600; }
.topnav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topnav a { color: var(--text); padding: 6px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.console-main { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 28px; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px; }
.card h2 { margin-top: 0; font-size: 17px; }
.card.danger-zone { border: 1px solid var(--danger-soft); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.tile .label { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.tile .value.danger { color: var(--danger); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.app-card { display: grid; gap: 10px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; color: var(--text); }
.app-card:hover { text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px rgba(0,0,0,.1); }
.app-card .title { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 16px; }
.app-card .title img, .app-card .title .ph { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 15px; color: var(--muted); flex: none; }
.meter { display: grid; gap: 6px; }
.meter .bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.meter .bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.meter.full .bar > span { background: var(--danger); }
.meter.near .bar > span { background: var(--warn); }
.meter .txt { font-size: 14px; display: flex; justify-content: space-between; }
.meter .txt b { font-size: 18px; }
.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field code { flex: 1; display: flex; align-items: center; padding: 8px 12px; font-size: 14px; }
.code-block { position: relative; }
.code-block .btn { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 360px; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }
.restriction { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; font-size: 14px; }
.restriction.active { border-color: var(--danger); background: var(--danger-soft); }
.restriction .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; z-index: 100; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.diff { width: 100%; font-size: 13px; margin: 8px 0 14px; }
.diff td { padding: 6px 8px; }
.diff .old { color: var(--danger); text-decoration: line-through; }
.diff .new { color: var(--ok); font-weight: 600; }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; }
#toast .t { background: #1d1d1f; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: fade .2s; }

/* ---------- docs ---------- */
.doc-main { max-width: 780px; margin: 0 auto; padding: 32px 24px 80px; }
.doc h1 { font-size: 30px; }
.doc h2 { font-size: 21px; margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--line); }
.doc table { margin: 0 0 16px; }
.doc td, .doc th { border: 1px solid var(--line); }
.doc blockquote { margin: 0 0 16px; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.doc li { margin-bottom: 4px; }

@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; border-radius: 18px; }
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }

  .topnav { order: 3; flex-basis: 100%; }
  .console-main, .doc-main { padding: 20px 16px 60px; }
  .page-head h1 { font-size: 24px; }
  .card { padding: 18px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}
