/* The owner's dashboard. A plain, quiet admin (owner, 2026-10-06: «простая современная админка», our own sheet,
   neutral look): greys, one accent — the brand's sun — and three tones for states. Modern CSS only, no framework, no
   build: cascade layers, nesting, oklch and light-dark() for the dark theme. Served from the dashboard's own origin
   (CSP style-src 'self'); the templates carry no style attribute. */
@layer base, layout, parts;

:root {
  color-scheme: light dark;
  --bg: light-dark(oklch(98.4% 0.002 260), oklch(16.5% 0.008 260));
  --surface: light-dark(oklch(100% 0 0), oklch(20.5% 0.01 260));
  --sunken: light-dark(oklch(96.4% 0.003 260), oklch(24% 0.011 260));
  --text: light-dark(oklch(24% 0.01 260), oklch(93% 0.004 260));
  --muted: light-dark(oklch(50% 0.012 260), oklch(70% 0.01 260));
  --rule: light-dark(oklch(91.5% 0.004 260), oklch(29% 0.012 260));
  --accent: oklch(67% 0.2 42);
  --ok: light-dark(oklch(50% 0.13 150), oklch(76% 0.14 150));
  --warn: light-dark(oklch(56% 0.13 70), oklch(81% 0.13 80));
  --crit: light-dark(oklch(54% 0.19 27), oklch(73% 0.16 25));
  --info: light-dark(oklch(50% 0.12 255), oklch(76% 0.1 255));
  --radius: 10px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@layer base {
  * { box-sizing: border-box; }
  html { background: var(--bg); }
  body {
    margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  }
  h1 { font-size: 22px; line-height: 1.25; font-weight: 650; margin: 0 0 4px; letter-spacing: -0.01em; }
  h2 {
    font-size: 12px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
    margin: 32px 0 10px;
  }
  p { margin: 0 0 10px; max-width: 70ch; }
  a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px;
    &:hover { text-decoration-color: var(--accent); } }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
  button, input, select, textarea { font: inherit; color: inherit; }
  input, select, textarea {
    background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 38px;
  }
  input { width: 100%; }
  button {
    background: var(--text); color: var(--bg); border: 0; border-radius: 8px; padding: 8px 14px; min-height: 38px;
    font-weight: 600; cursor: pointer;
    &:hover { background: color-mix(in oklch, var(--text) 85%, var(--accent)); }
  }
  label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
  hr { border: 0; border-top: 1px solid var(--rule); margin: 24px 0; }
}

@layer layout {
  .shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100dvh; }
  .side {
    position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px;
    padding: 20px 12px; border-right: 1px solid var(--rule); background: var(--surface);
  }
  .brand { font-weight: 700; padding: 0 10px 18px; letter-spacing: -0.01em;
    & span { display: block; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0.02em; } }
  .side nav { display: flex; flex-direction: column; gap: 2px; }
  .side nav a {
    text-decoration: none; padding: 7px 10px; border-radius: 8px; color: var(--muted); font-weight: 500;
    &:hover { color: var(--text); background: var(--sunken); }
    &[aria-current="page"] { color: var(--text); background: var(--sunken); box-shadow: inset 2px 0 0 var(--accent); }
  }
  .who {
    margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--rule); display: flex; align-items: center;
    justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px;
  }
  main { padding: 28px 36px 64px; max-width: 1100px; min-width: 0; }
  main.center { margin: 0 auto; max-width: 400px; padding-top: 12vh; }
  .lede { color: var(--muted); margin-bottom: 20px; }

  @media (max-width: 760px) {
    /* minmax(0, …) and min-width: 0: a grid or flex item never grows past the screen to fit a table or the menu;
       those scroll in their own frame */
    .shell { grid-template-columns: minmax(0, 1fr); }
    .side, .side nav { min-width: 0; }
    .side {
      position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px;
      padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--rule);
    }
    .brand { padding: 0; & span { display: none; } }
    .side nav { flex-direction: row; overflow-x: auto; order: 3; width: 100%; scrollbar-width: none; }
    .side nav a { white-space: nowrap; padding: 6px 10px; }
    .side nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
    .who { margin: 0 0 0 auto; padding: 0; border: 0; }
    main { padding: 20px 16px 48px; }
  }
}

@layer parts {
  /* a card: the sign-in, a notice */
  .card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 24px; }
  .card form { display: grid; gap: 14px; }
  .card button { width: 100%; }
  .notice {
    border: 1px solid color-mix(in oklch, var(--warn) 40%, var(--rule)); border-radius: var(--radius);
    background: color-mix(in oklch, var(--warn) 9%, var(--surface)); padding: 12px 14px; margin: 12px 0;
    &.crit { border-color: color-mix(in oklch, var(--crit) 40%, var(--rule));
      background: color-mix(in oklch, var(--crit) 9%, var(--surface)); }
    &:empty { display: none; }
  }

  /* «Service»: the verdict and one line per part of the service */
  .verdict {
    --tone: var(--ok);
    font-size: 19px; font-weight: 650; margin: 8px 0 6px; color: var(--tone);
    &.warn { --tone: var(--warn); } &.crit { --tone: var(--crit); }
  }
  .rows.signals {
    & li { grid-template-columns: max-content minmax(0, 15em) minmax(0, 1fr); align-items: baseline; }
    & .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tone, var(--ok)); align-self: center; }
    & .name { font-weight: 600; }
    & .value { font-variant-numeric: tabular-nums; }
    & .note { grid-column: 2 / -1; color: var(--muted); font-size: 13px; }
    & .ok { --tone: var(--ok); } & .warn { --tone: var(--warn); } & .crit { --tone: var(--crit); }
    & .warn .value { color: var(--warn); } & .crit .value { color: var(--crit); font-weight: 600; }
    @media (max-width: 760px) {
      & li { display: grid; grid-template-columns: max-content minmax(0, 1fr); }
      & .value, & .note { grid-column: 2; }
    }
  }
  details.history { margin-top: 32px;
    & summary { cursor: pointer; font-size: 12px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase;
      color: var(--muted); }
    & .table-wrap { margin-top: 12px; } }

  /* a state in a word */
  .badge {
    --tone: var(--muted);
    display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.3; padding: 3px 8px; border-radius: 999px;
    color: var(--tone); background: color-mix(in oklch, var(--tone) 13%, transparent); max-width: 100%;
    &.ok { --tone: var(--ok); } &.warn { --tone: var(--warn); } &.crit { --tone: var(--crit); }
    &.info { --tone: var(--info); }
  }

  /* lists of lines: checks, requests, claims, the queue */
  .rows {
    list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule);
    border-radius: var(--radius); overflow: hidden;
    /* name · state · details, the states in one column whatever the name's length */
    & li { display: grid; grid-template-columns: minmax(0, 17em) max-content minmax(0, 1fr); align-items: center;
      gap: 4px 14px; padding: 11px 16px; border-top: 1px solid var(--rule); }
    & li:first-child { border-top: 0; }
    & .main { font-weight: 600; overflow-wrap: anywhere; }
    & .main:only-child { grid-column: 1 / -1; }
    & .meta { grid-column: 3; color: var(--muted); font-size: 13px; text-align: right; }
    & .empty { display: block; color: var(--muted); }
    @media (max-width: 760px) {
      & li { display: flex; flex-wrap: wrap; }
      & .meta { flex-basis: 100%; text-align: left; }
    }
  }

  /* label and value: one check */
  .kv {
    display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 0; background: var(--surface);
    border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
    & dt, & dd { margin: 0; padding: 10px 16px; border-top: 1px solid var(--rule); }
    & dt { color: var(--muted); font-size: 13px; }
    & :is(dt, dd):nth-child(-n + 2) { border-top: 0; }
  }

  /* the filter of «Checks» */
  .filter { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 16px;
    & label { font-size: 12px; } }

  .actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
  .button {
    display: inline-block; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 600;
    border: 1px solid var(--rule); background: var(--surface);
    &:hover { border-color: var(--accent); }
  }
  button.link { background: none; color: var(--muted); padding: 0; min-height: 0; font-weight: 500;
    text-decoration: underline; text-underline-offset: 3px; &:hover { color: var(--text); background: none; } }

  /* the days: the one place days are compared with days; wide on a phone, it scrolls in its own frame */
  .table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule);
    border-radius: var(--radius); }
  table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
  th, td { padding: 9px 14px; text-align: right; border-top: 1px solid var(--rule); white-space: nowrap; }
  th { border-top: 0; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--sunken); }
  th:first-child, td:first-child { text-align: left; }
  tbody tr:hover { background: var(--sunken); }
  .hint { color: var(--muted); font-size: 13px; margin-top: 8px; }

  /* «Check sites»: a list for the queue */
  .send {
    display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
    padding: 14px 16px; margin: 0 0 18px;
    & label { font-size: 13px; }
    & label .hint { font-weight: 400; margin-left: 6px; }
    & textarea { width: 100%; min-height: 6em; resize: vertical; font-family: var(--mono); font-size: 13px; }
    & .actions { margin: 0; align-items: center; }
    & .hint, & .notice { margin: 0; }
    & button:disabled { opacity: 0.45; cursor: not-allowed; }
  }

  /* the clients */
  .tabs { display: flex; gap: 4px; margin: 0 0 14px; flex-wrap: wrap;
    & a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 500;
      border: 1px solid var(--rule); background: var(--surface); }
    & a:hover { color: var(--text); }
    & a[aria-current="page"] { color: var(--text); border-color: var(--text); } }
  .badges { display: flex; flex-wrap: wrap; gap: 4px; }
  /* a client: the site and its labels, then the addresses, then the checks and the report */
  .rows.clients li { grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; }
  .rows.clients .meta { grid-column: 1 / -1; text-align: left; }
  .rows.clients .meta .line { display: block; overflow-wrap: anywhere; }
  .rows.clients .meta .line:first-child { color: var(--text); }
  .crumbs { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
  .keep {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 16px;
    margin: 16px 0 8px;
    & p { margin: 0; color: var(--muted); font-size: 13px; }
  }
  button.quiet { background: var(--surface); color: var(--text); border: 1px solid var(--rule);
    &:hover { border-color: var(--crit); color: var(--crit); background: var(--surface); } }
  .score { margin: 0 0 12px; color: var(--muted);
    & .num { font-size: 28px; font-weight: 650; color: var(--text); margin-right: 6px; font-variant-numeric: tabular-nums; } }
  .rows.problems { padding: 0;
    & li { grid-template-columns: max-content minmax(0, 1fr); align-items: start; }
    & .badge { margin-top: 2px; }
    & .do { font-weight: 600; }
    & .gives { grid-column: 2; color: var(--muted); font-size: 13px; }
    @media (max-width: 760px) { & li { display: grid; } }
  }

  .muted { color: var(--muted); }
  .foot { color: var(--muted); font-size: 12px; margin-top: 40px; }
}
