:root {
  --bg: #f5f6f3;
  --card: #ffffff;
  --text: #1d2420;
  --muted: #5f6b64;
  --line: #dfe3dd;
  --brand: #2f6f4f;
  --brand-dark: #24573d;
  --brand-soft: #e6f1ea;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --bad: #a3271f;
  --bad-soft: #fdeceb;
  --run: #1f5f99;
  --run-soft: #e7f0fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816; --card: #1c211e; --text: #e8ece9; --muted: #a2ada6; --line: #303833;
    --brand: #5fb488; --brand-dark: #7cc79f; --brand-soft: #1f3429;
    --warn: #f0c060; --warn-soft: #3a3020; --bad: #f08a80; --bad-soft: #3d2220; --run: #7fb6ea; --run-soft: #1e2d3d;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #141816; --card: #1c211e; --text: #e8ece9; --muted: #a2ada6; --line: #303833;
  --brand: #5fb488; --brand-dark: #7cc79f; --brand-soft: #1f3429;
  --warn: #f0c060; --warn-soft: #3a3020; --bad: #f08a80; --bad-soft: #3d2220; --run: #7fb6ea; --run-soft: #1e2d3d;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .2rem 0 .3rem; }
h2 { font-size: 1.15rem; margin: 0 0 .4rem; }
p { margin: .3rem 0 .6rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* header */
.top { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.top-row { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand span { color: var(--text); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding-top: 8px; }
.tabs a {
  padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tabs a.on { color: var(--text); border-bottom-color: var(--brand); }
.tabs a.ext { margin-left: auto; color: var(--brand); }
.logout { margin: 0; }
.foot { color: var(--muted); font-size: .85rem; padding-top: 8px; padding-bottom: 40px; }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.flash {
  background: var(--brand-soft); color: var(--brand-dark); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; font-weight: 600;
}
.error {
  background: var(--bad-soft); color: var(--bad); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px;
}
.notice { background: var(--warn-soft); border-color: transparent; }
.notice ul { margin: 0; padding-left: 20px; }
.notice-line, .warn-line { color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; margin: 6px 0; font-size: .95rem; }

/* status */
.status { display: flex; gap: 18px; align-items: flex-start; }
.status h1 { margin-top: 0; }
.status-icon { flex: 0 0 44px; height: 44px; border-radius: 50%; position: relative; }
.status-icon.ok { background: var(--brand); }
.status-icon.ok::after { content: ""; position: absolute; left: 15px; top: 9px; width: 10px; height: 19px; border: solid #fff; border-width: 0 4px 4px 0; transform: rotate(45deg); }
.status-icon.paused { background: var(--muted); }
.status-icon.paused::before, .status-icon.paused::after { content: ""; position: absolute; top: 12px; width: 6px; height: 20px; background: #fff; border-radius: 2px; }
.status-icon.paused::before { left: 13px; } .status-icon.paused::after { right: 13px; }
.status-icon.wait { background: var(--run-soft); border: 4px solid var(--run); }
.status-icon.spin { border: 5px solid var(--run-soft); border-top-color: var(--run); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status-icon.spin { animation: none; } }
.status-running { border-left: 5px solid var(--run); }
.status-idle { border-left: 5px solid var(--brand); }
.status-paused { border-left: 5px solid var(--muted); }
.status-waiting { border-left: 5px solid var(--run); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.wide { width: 100%; }
button.link { background: none; border: 0; padding: 4px; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* forms */
.form fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.form legend, .form label { font-weight: 600; display: block; margin-bottom: 6px; padding: 0; }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 0; }
input[type=text], input:not([type]), input[type=password], input[type=number], input[type=time], select {
  width: 100%; min-height: 46px; padding: 8px 12px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, .btn:focus-visible, button.link:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand); }
.prefix { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.prefix span { padding: 0 4px 0 12px; color: var(--muted); }
.prefix input { border: 0; min-height: 44px; }
.prefix.narrow { max-width: 220px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline { display: flex; align-items: center; gap: 10px; }
.inline select { width: 96px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: flex !important; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; font-weight: 400 !important; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--brand); }
.times { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.days, .types { display: flex; flex-wrap: wrap; gap: 8px; }
.day, .pill { position: relative; margin: 0 !important; }
.day input, .pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.day span, .pill span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 58px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; font-weight: 600; background: var(--card);
}
.day input:checked + span, .pill input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.day input:focus-visible + span, .pill input:focus-visible + span { outline: 3px solid var(--brand-soft); }
.quick { margin-top: 8px; color: var(--muted); font-size: .95rem; }
.back { text-decoration: none; font-weight: 600; }

/* lists */
.runs, .cities, .plain { list-style: none; margin: 0; padding: 0; }
.runs li { padding: 12px 0; border-top: 1px solid var(--line); }
.runs li:first-child { border-top: 0; padding-top: 4px; }
.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.run-when { font-weight: 600; }
.run-body { margin-top: 4px; }
.run-note { margin-top: 4px; color: var(--muted); font-size: .92rem; }
.badge { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge.ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.run { background: var(--run-soft); color: var(--run); }
.plain li { padding: 4px 0; }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.city { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.city h2 { margin: 0; }
.city p { margin: 6px 0; }
.city-actions { display: flex; gap: 8px; flex-shrink: 0; }
.city-actions form { margin: 0; }

/* login */
.login { max-width: 380px; margin: 60px auto 0; text-align: center; }
.login .card { text-align: left; margin-top: 18px; }
.login-logo { color: var(--brand); }
.login input { margin-bottom: 14px; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 1.4rem; }
  .card { padding: 16px; }
  .grid2, .choice-row { grid-template-columns: 1fr; }
  .times { grid-template-columns: 1fr 1fr; }
  .city { flex-direction: column; }
  .city-actions { width: 100%; }
  .city-actions .btn, .city-actions form { flex: 1; }
  .city-actions form .btn { width: 100%; }
  .tabs a { padding: 10px 10px; }
  .tabs a.ext { margin-left: 0; }
  .status { gap: 14px; }
}
