/* meerk dashboard design system: a quiet utility with a light gray canvas, white surfaces, compact controls
   and a clear hierarchy. Colour has a job: lilac = selection and information, peach = warnings,
   lime = healthy or running. Matches the macOS POC dashboard (app.css). */
@font-face {
  font-family: Inter;
  src: url("assets/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #FAFAFA;
  --surface: #FFFFFF;
  --cream: #FFF8EF;
  --ink: #16181D;
  --muted: #777777;
  --secondary-ink: #6D6D6D;
  --edge: #EAEAEA;
  --control-edge: #D8D8D8;
  --lilac: #C8B6FF;
  --lilac-wash: #F0EAFF;
  --peach: #FFD1C2;
  --lime: #A8FF60;
  --focus: #6F519B;
  --warning-ink: #774738;
  --high-ink: #6C3124;
  --radius-card: 12px;
  --radius-control: 7px;
  --sidebar-width: 204px;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 2.5vw, 32px); font-weight: 600; line-height: 1.2; letter-spacing: -.04em; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
a { color: var(--ink); text-decoration-color: var(--control-edge); text-underline-offset: .2em; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
strong { font-weight: 600; }
.center { display: grid; place-items: center; min-height: 60vh; }
.muted { color: var(--secondary-ink); overflow-wrap: anywhere; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code {
  font: 12px/1.5 ui-monospace, Menlo, monospace;
  padding: 1px 5px;
  background: var(--page);
  border: 1px solid var(--edge);
  border-radius: 5px;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- brand */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--ink);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.055em;
  text-decoration: none;
}
.brand img { flex: none; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--lilac-wash);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- signed out */
.auth { max-width: 440px; margin: 0 auto; padding: clamp(28px, 6vh, 56px) 16px 64px; }
.auth > .brand { margin-bottom: 22px; }
.auth h1 { margin-bottom: 6px; }
.auth label { display: grid; gap: 5px; margin: 12px 0; font-weight: 500; }
.auth input { width: 100%; }
.auth .small { margin-top: 14px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; color: var(--secondary-ink); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--edge); }

/* ---------------------------------------------------------------- app layout */
.layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100dvh;
  overflow: auto;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--edge);
  background: var(--surface);
}
.sidebar .brand { padding-inline: 7px; }
.nav { display: grid; gap: 3px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 7px 9px;
  border-radius: var(--radius-control);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--page); }
.nav a[aria-current="page"] { background: var(--lilac-wash); }
.nav-icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-foot {
  display: grid;
  justify-items: start;
  gap: 8px;
  margin-top: auto;
  padding: 13px 8px 0;
  border-top: 1px solid var(--edge);
  color: var(--secondary-ink);
  font-size: 12px;
}
.who { display: flex; align-items: center; gap: 9px; min-width: 0; max-width: 100%; }
.who .nav-icon { color: var(--muted); }
.who span { overflow-wrap: anywhere; }
.sidebar-foot .link { font-size: 12px; }

.content { width: 100%; max-width: 1450px; min-width: 0; padding: clamp(20px, 3vw, 42px); }
.content > .message { margin-bottom: 14px; }
.view { display: grid; gap: 16px; align-content: start; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.view-head p { margin-top: 4px; font-size: 13px; }

/* ---------------------------------------------------------------- building blocks */
.card {
  min-width: 0;
  padding: clamp(14px, 1.65vw, 20px);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  background: var(--surface);
}

/* Buttons, inputs and selects share one shape. */
button, input, select, textarea {
  color: var(--ink);
  border: 1px solid var(--control-edge);
  border-radius: var(--radius-control);
  background: var(--surface);
}
input[type=email], input[type=password], input[type=text], select, textarea { min-height: 34px; padding: 6px 9px; }
input::placeholder { color: var(--secondary-ink); opacity: 1; }
input[type=radio], input[type=checkbox] { min-height: auto; accent-color: var(--ink); }
button { cursor: pointer; min-height: 32px; padding: 5px 10px; font-size: 13px; font-weight: 500; }
button:not(:disabled):hover { background: var(--page); border-color: #B7B7B7; }
button:disabled { opacity: .55; cursor: default; }
button.primary { color: var(--surface); background: var(--ink); border-color: var(--ink); }
button.primary:not(:disabled):hover { background: #33353A; border-color: #33353A; }
.wide { width: 100%; margin-top: 12px; }
.link, .link:not(:disabled):hover {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--control-edge);
  text-underline-offset: .2em;
}
.link:not(:disabled):hover { text-decoration-color: var(--ink); }

/* Status messages: quiet notice; errors use the warning colours. */
.message {
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius-control);
  font-size: 13px;
}
.message:empty { display: none; }
.message[data-kind=error] { border-color: var(--peach); background: var(--cream); color: var(--warning-ink); }

/* Pills: short labels. Healthy = lime dot, warning = peach, information = lilac. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--page);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.pill.pending { border-color: transparent; background: var(--lilac-wash); }
.pill.off { border-color: var(--peach); background: var(--cream); color: var(--warning-ink); }
.pill.ok::before, .pill.status::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--lime);
  border: 1px solid #618646;
}
.pill.status { padding: 4px 8px; border-color: var(--edge); background: var(--surface); color: var(--ink); }
.pill.status.off::before { background: var(--peach); border-color: #A86754; }

/* Definition lists: label column and value column. */
.facts { display: grid; gap: 5px; margin: 12px 0; font-size: 13px; }
.facts div { display: grid; grid-template-columns: minmax(100px, .52fr) minmax(0, 1.7fr); gap: 13px; }
.facts dt { color: var(--secondary-ink); overflow-wrap: anywhere; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.wide-facts { margin: 4px 0; }
.wide-facts div { grid-template-columns: minmax(110px, .3fr) minmax(0, 1.7fr); }

/* ---------------------------------------------------------------- overview */
.banner {
  padding: 9px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
}
.banner::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 8px 1px 0; vertical-align: middle; border-radius: 50%; }
.banner.ok::before { background: var(--lime); border: 1px solid #618646; }
.banner.off { border-color: var(--peach); background: var(--cream); color: var(--warning-ink); }
.banner.off::before { background: var(--peach); border: 1px solid #A86754; }
.banner.off a { color: var(--warning-ink); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat {
  display: grid;
  align-content: start;
  min-width: 0;
  padding: clamp(14px, 1.65vw, 20px);
  border: 1px solid var(--edge);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.stat-label { margin-bottom: 7px; font-size: 14px; font-weight: 500; }
.stat-value {
  margin-bottom: 4px;
  font-size: clamp(24px, 2.4vw, 28px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.stat-hint { color: var(--secondary-ink); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.rows, .plain, .rules, .connections { list-style: none; padding: 0; margin: 0; }
.rows li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--edge);
  font-size: 13px;
}
.rows li:last-child { border-bottom: 0; }
.rows li span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.card > .small.muted { margin-top: 8px; }
.plain li { position: relative; padding: 5px 0 5px 18px; font-size: 13px; }
.plain li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 13px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lilac);
}

/* ---------------------------------------------------------------- tables (activity, usage) */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.filters label { display: flex; align-items: center; gap: 8px; color: var(--secondary-ink); font-size: 13px; font-weight: 500; }
.filters select { font-size: 13px; }
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--edge); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--secondary-ink); background: var(--page); font-size: 12px; font-weight: 500; white-space: nowrap; }
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
table.activity { min-width: 48rem; }
.activity td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity td:nth-child(2) { min-width: 170px; }
.activity td:nth-child(3), .activity td:nth-child(4) { min-width: 110px; }
.activity td strong { font-weight: 500; }
tr.row { cursor: pointer; }
tr.row:hover td, tr.row[aria-expanded=true] td { background: var(--page); }
tr.row:focus-visible { outline-offset: -2px; }
tr.detail td { background: var(--page); padding: 10px 12px 12px; }
.table-wrap + .muted { margin-top: 12px; }
.table-wrap + .muted:empty { display: none; }
.card > button.secondary, .card > button:not(.primary):not(.link) { margin-top: 12px; }
.usage td:not(:first-child), .usage th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.usage td:first-child { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- settings */
.levels { display: grid; gap: 8px; margin: 4px 0 10px; padding: 0; border: 0; }
.levels label {
  display: block;
  padding: 11px 13px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.levels label:hover { background: var(--page); }
.levels label:has(input:checked) { border-color: var(--lilac); background: var(--lilac-wash); }
.levels label em { color: var(--secondary-ink); font-style: normal; font-size: 13px; }
.levels label span { display: block; margin: 3px 0 0 22px; font-size: 13px; }
.toggle {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 12px 0 14px;
  padding: 11px 13px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.toggle input { margin-top: 4px; flex: none; }
.toggle .muted { font-size: 13px; }
.rules li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--edge);
  font-size: 13px;
}
.rules li:last-child { border-bottom: 0; }
.rule-form, .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.rule-form .muted { font-size: 13px; }
.inline-form input { flex: 1; min-width: 14ch; max-width: 26rem; }

/* ---------------------------------------------------------------- account */
.steps { margin: 8px 0; padding-left: 20px; }
.steps li { margin: 10px 0; font-size: 13px; }
.steps li .muted { display: block; margin-top: 4px; }
.connections li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--edge);
  font-size: 13px;
}
.connections li:last-child { border-bottom: 0; }
.connections li > span:first-child { flex: 1; font-weight: 500; }

/* ---------------------------------------------------------------- responsive */
@media (min-width: 1024px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sidebar {
    position: static;
    height: auto;
    flex-flow: row wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 9px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--edge);
  }
  .sidebar .brand { padding: 0; }
  .sidebar .brand img { width: 24px; height: 24px; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav a { min-height: 33px; padding: 5px 8px; }
  .sidebar-foot { display: flex; align-items: center; gap: 10px; margin: 0 0 0 auto; padding: 0; border: 0; }
  .sidebar-foot .badge, .who { display: none; }
}
@media (max-width: 480px) {
  .sidebar .nav { order: 1; width: 100%; }
  .nav a { gap: 5px; padding-inline: 6px; font-size: 12px; }
  .stats { gap: 8px; }
  .view-head { flex-wrap: wrap; }
}
@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- setup wizard (MEE-15) */
.wizard { max-width: 680px; margin: 0 auto; padding: clamp(22px, 5vh, 48px) 16px 64px; }
.wizard-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
.wizard-who { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--secondary-ink); font-size: 13px; }
.wizard-who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { margin-bottom: 12px; }
.progress p { margin-bottom: 7px; color: var(--secondary-ink); font-size: 13px; font-weight: 500; }
.progress-bars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.progress-bars span { height: 4px; border-radius: 2px; background: var(--edge); }
.progress-bars span.done { background: var(--ink); }
.wizard-card { padding: clamp(18px, 3vw, 28px); }
.wizard-card h1 { margin-bottom: 6px; font-size: clamp(24px, 2.4vw, 28px); }
.wizard-card .lead { margin-bottom: 18px; color: var(--secondary-ink); }
.wizard-card > .message { margin-top: 14px; }
.wizard-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; }
.wizard-actions button { min-height: 38px; padding-inline: 16px; font-size: 14px; }
.wizard-actions .primary { min-width: 140px; }
.areas { display: grid; gap: 10px; margin-bottom: 12px; }
.area { border: 1px solid var(--edge); border-radius: var(--radius-control); background: var(--surface); }
.area:has(.switch input:checked) { border-color: var(--lilac); }
.area-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; }
.area-head strong { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.area-head .muted { display: block; font-size: 13px; }
.area-more { font-size: 13px; }
.area-status { display: block; margin-top: 3px; font-size: 12px; font-weight: 500; }
.area-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 6px 1px 0; vertical-align: middle; border-radius: 50%; background: #7DB65A; }
.area-status[data-kind=off] { color: var(--secondary-ink); }
.area-status[data-kind=off]::before { background: var(--control-edge); }
.area-status[data-kind=todo]::before { background: #E3A35B; }
.area-body { display: grid; gap: 10px; padding: 12px 14px 14px 62px; border-top: 1px solid var(--edge); font-size: 13px; }
.area-body[hidden] { display: none; }
.switch { position: relative; display: inline-block; flex: none; width: 36px; height: 20px; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch .slider { position: absolute; inset: 0; border-radius: 20px; background: var(--control-edge); transition: background .15s; }
.switch .slider::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .slider { background: var(--ink); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--focus); outline-offset: 2px; }
.editor-label { font-weight: 500; }
.editor .inline-form { margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 3px 1px 10px; border: 1px solid var(--edge); border-radius: 999px; background: var(--page); font-size: 12px; overflow-wrap: anywhere; }
.chip button { min-height: 22px; padding: 0 6px; border: 0; background: transparent; font-size: 15px; line-height: 1; }
.note { margin-bottom: 16px; padding: 10px 13px; border-radius: var(--radius-control); background: var(--lilac-wash); font-size: 13px; }
.setup-steps { margin: 0; padding: 0; list-style: none; counter-reset: setup; }
.setup-steps li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--edge); }
.setup-steps li:last-child { border-bottom: 0; }
.setup-steps li::before { counter-increment: setup; content: counter(setup); display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--edge); border-radius: 50%; background: var(--page); font-size: 12px; font-weight: 600; }
.setup-steps p { margin: 3px 0 8px; }
.setup-steps button { margin-top: 2px; }
.address { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.connect-status { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--edge); border-radius: var(--radius-control); font-size: 13px; }
.connect-status[data-kind=wait] { background: var(--page); }
.connect-status[data-kind=ok] { border-color: #9DCB7B; background: #F4FFEA; }
.connect-status[data-kind=error] { border-color: var(--peach); background: var(--cream); color: var(--warning-ink); }
.done-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: 4px 0 8px; border: 1px solid #618646; border-radius: 50%; background: var(--lime); font-size: 24px; font-weight: 600; }
@media (max-width: 520px) {
  .area-head { grid-template-columns: auto minmax(0, 1fr); }
  .area-more { grid-column: 2; justify-self: start; }
  .area-body { padding-left: 14px; }
  .wizard-who > span { display: none; }
}
