/* Rakugami console. Paper, ink and the coral stamp of the brand; mint for "free", ink for "paid". */
:root {
  --paper: #fbfaf7; --card: #ffffff; --ink: #1e1b2a; --soft: #6b6779; --line: #e8e5dd; --sheet: #f1eee6;
  --coral: #ff6b57; --mint: #2fb7a3; --tape: #f5b63a; --bad: #c8382b; --ok: #1f8a6e; --warn: #b26b00;
  --free: #2fb7a3; --paid: #1e1b2a; --other: #b9b4c4;
  --radius: 14px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16141d; --card: #1f1c28; --ink: #f1eef8; --soft: #a7a2b5; --line: #34303f; --sheet: #2a2635;
    --paid: #e9e5f4; --other: #5d5770; --bad: #ff7b6b; --ok: #4fd1b0; --warn: #f5b63a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--soft); font-size: 13px; }
[hidden] { display: none !important; }

/* the stamp */
.stamp { width: 34px; height: 34px; flex: none; }
.stamp.big { width: 64px; height: 64px; }
.stamp-disc { fill: var(--coral); }
.stamp-ring { fill: none; stroke: #fff; stroke-width: 2.4; }
.stamp-glyph { fill: #fff; font: 600 33px "Klee One", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif; }

/* buttons and chips */
.btn { font: inherit; font-weight: 700; font-size: 14px; border: 0; border-radius: 999px; padding: 9px 18px; cursor: pointer;
  background: var(--sheet); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.small { font-size: 13px; padding: 6px 12px; }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.btn:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: default; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--sheet); color: var(--soft); white-space: nowrap; }
.chip.free { background: color-mix(in srgb, var(--free) 18%, transparent); color: var(--ok); }
.chip.paid { background: var(--ink); color: var(--paper); }
.chip.super { background: var(--coral); color: #fff; }

/* sign-in page */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { max-width: 380px; display: grid; gap: 16px; justify-items: center; text-align: center; }
.gate-card h1 { font-size: 26px; letter-spacing: -.02em; }
.gate-card p { color: var(--soft); }

/* top bar */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px max(16px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.wordmark { font-weight: 800; font-size: 22px; letter-spacing: -.045em; }
.brand .sub { color: var(--soft); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--soft); flex-wrap: wrap; }

/* layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 64px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.inner { gap: 28px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

/* status strip */
.status { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius); background: var(--sheet); flex-wrap: wrap; }
.status b { font-size: 17px; margin-right: 8px; }
.status span { color: var(--soft); }
.status .updated { margin-left: auto; font-size: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--other); flex: none; }
.dot.ok { background: var(--mint); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint) 25%, transparent); }
.dot.warn { background: var(--tape); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tape) 25%, transparent); }
.dot.bad { background: var(--coral); box-shadow: 0 0 0 4px color-mix(in srgb, var(--coral) 25%, transparent); }

/* meters */
.meter-figure { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.meter-figure b { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.meter-figure span { color: var(--soft); }
.meter { position: relative; height: 14px; border-radius: 7px; background: var(--sheet); overflow: visible; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: var(--paid); width: 0; transition: width .4s ease; }
#free-meter i { background: var(--free); }
.meter i.over { background: var(--coral); }
.meter s { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; left: 80%; }
@media (prefers-reduced-motion: reduce) { .meter i { transition: none; } }

/* alerts and logs */
.alerts, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.alerts li, .log li { display: grid; gap: 1px; font-size: 13px; padding-left: 12px; border-left: 3px solid var(--line); }
.alerts li.stop { border-left-color: var(--coral); }
.alerts li.warn { border-left-color: var(--tape); }
.alerts time, .log time { color: var(--soft); font-size: 12px; font-variant-numeric: tabular-nums; }

/* charts */
.chart { position: relative; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--soft); font: 12px var(--font); }
.chart .ink { fill: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.tip { position: absolute; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 160px; font-variant-numeric: tabular-nums; z-index: 3; }
.tip b { display: block; margin-bottom: 2px; }
.tip div { display: flex; justify-content: space-between; gap: 12px; }
.bars { display: grid; gap: 10px; }
.bars .row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bars .track { height: 12px; background: var(--sheet); border-radius: 6px; overflow: hidden; }
.bars .track i { display: block; height: 100%; background: var(--ink); border-radius: 6px; }
.bars .val { font-variant-numeric: tabular-nums; color: var(--soft); white-space: nowrap; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.tile { background: var(--sheet); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.tile b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--soft); }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--soft); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td code { font-size: 12px; }
.busy { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); margin-right: 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .busy { animation: none; } }
.empty { color: var(--soft); font-size: 13px; padding: 10px 0; }

/* forms */
.form { display: grid; gap: 10px; align-content: start; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--soft); }
input, select { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.row-form { display: flex; flex-wrap: wrap; gap: 10px; }
.row-form input { flex: 1 1 240px; }
.msg { font-size: 13px; min-height: 1.4em; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--bad); }
.settings { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 12px 0 0; font-size: 13px; }
.settings dt { color: var(--soft); }
.settings dd { margin: 0; }
summary { cursor: pointer; font-weight: 700; font-size: 15px; }
@media (max-width: 560px) {
  .bars .row { grid-template-columns: 1fr auto; }
  .bars .track { grid-column: 1 / -1; grid-row: 2; }
  .status .updated { margin-left: 0; width: 100%; }
}
