/* whatGM control panel.
   No web fonts and no inline styles: the CSP is default-src 'none' with
   style-src 'self', which forbids both. System fonts also mean the panel
   paints instantly on a 1-core VM, which matters more here than a typeface. */

:root {
  --bg:        #F6F6F3;
  --surface:   #FFFFFF;
  --surface-2: #EFF0EB;
  --ink:       #15181A;
  --ink-2:     #454C50;
  --muted:     #737C80;
  --line:      #E1E3DD;
  --line-2:    #C9CDC5;

  --accent:      #0E6B4F;
  --accent-ink:  #0A5741;
  --accent-soft: #E0EFE8;

  --warn:      #8A5A0B;
  --warn-soft: #FAEFDA;
  --danger:      #A32C22;
  --danger-soft: #FAE7E4;
  --good:        #16714D;
  --good-soft:   #DEEFE6;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "Segoe UI Mono",
          Menlo, Consolas, monospace;

  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0C0E0E;
    --surface:   #14181A;
    --surface-2: #1C2124;
    --ink:       #E7EBE9;
    --ink-2:     #AEB8B5;
    --muted:     #7C8785;
    --line:      #252B2D;
    --line-2:    #384042;

    --accent:      #4CC79A;
    --accent-ink:  #8FDCBC;
    --accent-soft: #10271F;

    --warn:      #DDA556;
    --warn-soft: #2C2312;
    --danger:      #EE8A7D;
    --danger-soft: #331A17;
    --good:        #5CC493;
    --good-soft:   #10261B;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ------------------------------------------------------------ login ----- */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.15rem;
}
.brand span { color: var(--accent); }

.login-sub {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0 0 1.4rem;
}

/* --------------------------------------------------------- app chrome --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.7rem clamp(0.9rem, 3vw, 1.6rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { margin: 0; }
.topbar-spacer { flex: 1; }

.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.9rem) clamp(0.9rem, 3vw, 1.6rem) 5rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0 0 0.9rem;
}
.section-head h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.section-head .count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* -------------------------------------------------------------- pills --- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.22rem 0.55rem;
  border-radius: 100px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  background: var(--surface-2);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill.good   { color: var(--good);   border-color: var(--good);   background: var(--good-soft); }
.pill.warn   { color: var(--warn);   border-color: var(--warn);   background: var(--warn-soft); }
.pill.danger { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.pill.muted  { color: var(--muted); }

/* ------------------------------------------------------------ buttons --- */

button, .btn {
  font: inherit;
  font-size: 0.87rem;
  font-weight: 500;
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

button.danger { color: var(--danger); border-color: var(--line-2); }
button.danger:hover { border-color: var(--danger); background: var(--danger-soft); }

button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover { background: var(--surface-2); border-color: var(--line); }

button.block { width: 100%; justify-content: center; }

.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* ------------------------------------------------------------- fields --- */

.field { margin-bottom: 0.95rem; }
.field > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 0.28rem;
}
.field .hint {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 0.28rem;
}

input[type="text"], input[type="password"], input[type="time"],
input[type="date"], input[type="number"], textarea, select {
  font: inherit;
  font-size: 0.9rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input[type="time"], input[type="date"], input[type="number"] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
textarea { resize: vertical; min-height: 4.5rem; font-family: var(--mono); font-size: 0.85rem; }

input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.field-error { font-size: 0.78rem; color: var(--danger); margin-top: 0.28rem; }

.field-row {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
}
@media (min-width: 620px) {
  .field-row.two { grid-template-columns: 1fr 1fr; }
  .field-row.three { grid-template-columns: 1fr 1fr 1fr; }
}

/* radio group for repeat type */
.choices { display: flex; flex-direction: column; gap: 0.3rem; }
.choice {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
}
.choice:hover { background: var(--surface-2); }
.choice input { accent-color: var(--accent); margin: 0; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice .inline-field { margin-left: auto; width: 5.5rem; }

/* weekday toggles */
.days { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.day {
  font-family: var(--mono);
  font-size: 0.78rem;
  width: 2.4rem;
  text-align: center;
  padding: 0.35rem 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.day.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------------------------------------------------------- job rows --- */

.jobs { display: flex; flex-direction: column; gap: 0.5rem; }

.job {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 0.95rem;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .job { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}
.job.off { opacity: 0.62; }

.job-main { min-width: 0; }
.job-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}
.job-name { font-weight: 600; }
.job-time {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.job-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: baseline;
}
.job-meta .sep { color: var(--line-2); }
.job-meta code {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-2);
}
.job-msg {
  margin-top: 0.28rem;
  font-size: 0.85rem;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------- notices --- */

.notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.notice .tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  padding-top: 0.18rem;
}
.notice p { margin: 0; }
.notice p + p { margin-top: 0.4rem; }
.notice.warn   { background: var(--warn-soft);   border-color: var(--warn); }
.notice.warn .tag { color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: var(--danger); }
.notice.danger .tag { color: var(--danger); }
.notice.good   { background: var(--good-soft);   border-color: var(--good); }
.notice.good .tag { color: var(--good); }

.empty {
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------- panel --- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.1rem;
}
.panel-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.panel-head h3 { margin: 0; font-size: 1rem; }
.panel-foot {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.qr-box { text-align: center; padding: 0.5rem 0; }
.qr-box img {
  max-width: 260px;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

/* -------------------------------------------------------------- toast --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius);
  font-size: 0.87rem;
  max-width: min(90vw, 34rem);
  z-index: 50;
}
.toast.bad { background: var(--danger); color: #fff; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
