:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --ink: #2a2723;
  --muted: #6f6a60;
  --line: #e3ddd0;
  --brand: #5d6b2f;
  --brand-ink: #ffffff;
  --brand-soft: #eef1df;
  --accent: #b5532a;
  --ok: #2f7d46;
  --ok-soft: #e3f3e8;
  --warn: #9a6a00;
  --warn-soft: #fbf0d3;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --info: #2b5f8a;
  --info-soft: #e1edf7;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .35rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }
code { background: #f0ece2; padding: .1em .35em; border-radius: 4px; font-size: .9em; }
small, .muted { color: var(--muted); }
.upper { text-transform: uppercase; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--line); padding: .6rem 1rem;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; text-decoration: none; color: var(--ink); }
.brand-sub { font-weight: 400; color: var(--muted); }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800;
}
.brand-mark.big { width: 44px; height: 44px; font-size: 1.4rem; border-radius: 12px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { padding: .4rem .75rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.nav a:hover { background: var(--brand-soft); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .nav-form { display: inline; }
.nav .nav-form button {
  font: inherit; padding: .4rem .75rem; border-radius: 8px; border: 1px dashed #c9bf9f; background: none; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.nav .nav-form button:hover { background: var(--brand-soft); }
.acting-banner {
  display: flex; gap: .75rem 1.25rem; align-items: center; justify-content: center; flex-wrap: wrap;
  background: var(--warn-soft); border-bottom: 1px solid #ecd596; color: #6b4a00; padding: .5rem 1rem; font-size: .95rem;
}
.who { display: flex; align-items: center; gap: .9rem; font-size: .9rem; }
.who-name { color: var(--muted); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.wrap.narrow { max-width: 460px; padding-top: 3rem; }
.narrow-card { max-width: 520px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card.highlight { background: var(--brand-soft); border-color: #d5dcb4; }
.login { padding: 1.75rem; }
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.login-brand h1 { margin: 0; font-size: 1.35rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-head h1, .page-head h2 { margin: 0; }
.count { background: var(--brand); color: var(--brand-ink); border-radius: 999px; font-size: .8rem; padding: .05rem .55rem; vertical-align: middle; }
.count.warn { background: var(--warn); }
.card-warn { background: var(--warn-soft); border-color: #ecd596; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.grid3 { display: grid; grid-template-columns: 1.2fr 1.4fr .8fr; gap: .6rem; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem 1.5rem; }
.summary p, .summary ul { margin: 0; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; font-weight: 600; }
label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; font-size: 1rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid #cfc8b8; border-radius: 8px; padding: .5rem .65rem; min-height: 42px; width: 100%;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; flex: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid #9fb15a; outline-offset: 1px;
}

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid #cfc8b8; border-radius: 8px; padding: .55rem 1rem; min-height: 42px; width: auto;
}
.btn:hover { background: #f3efe5; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #4e5b26; }
.btn.danger { color: var(--bad); border-color: #e3b3af; }
.btn.small { padding: .25rem .65rem; min-height: 34px; font-size: .9rem; }
.btn:disabled { opacity: .6; cursor: progress; }
button.link, .btn.link { background: none; border: 0; color: var(--brand); text-decoration: underline; padding: 0; min-height: 0; font-weight: 400; cursor: pointer; font: inherit; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }
.actions-cell { white-space: nowrap; }
form.inline { display: inline; }
.inline-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 160px; }
.inline-form.tight { gap: .4rem; flex-wrap: nowrap; }
.inline-form.tight input { min-width: 120px; }
ol.steps { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1rem; font-size: .9rem; }
ol.steps li { padding: .2rem .7rem; border-radius: 999px; background: #eeeae0; color: var(--muted); }
ol.steps li.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
kbd { background: #f0ece2; border: 1px solid #d8d1bf; border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; font-size: .85em; }
.err { color: var(--bad); }
td input[type=checkbox], th input[type=checkbox] { margin: 0; }
details.raw { margin-top: .6rem; font-size: .9rem; }
details.raw summary { cursor: pointer; color: var(--muted); }
details.raw pre { background: #f3efe5; border-radius: 8px; padding: .75rem; overflow-x: auto; font-size: .85rem; }
.stack-sm { display: flex; flex-direction: column; gap: .35rem; min-width: 230px; align-items: flex-start; }
.stack-sm input { min-height: 36px; padding: .3rem .55rem; font-size: .9rem; }

.pkg-row { display: grid; grid-template-columns: 1.6fr repeat(4, minmax(0, 1fr)) auto; gap: .6rem; align-items: end; margin-bottom: .6rem; }
.pkg-row .preset { margin-bottom: 0; }

.flash { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: var(--ok-soft); border-color: #b7dcc2; color: #1d5a31; }
.flash-error { background: var(--bad-soft); border-color: #efbab6; color: #7d1a14; }
.flash-warn { background: var(--warn-soft); border-color: #ecd596; color: #6b4a00; }

.badge { display: inline-block; font-size: .78rem; font-weight: 600; border-radius: 999px; padding: .1rem .6rem; vertical-align: middle; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #eeeae0; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.table-wrap + label, .table-wrap + .flash { margin-top: 1rem; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 2px solid var(--line); padding: .5rem .6rem; }
.table td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.chosen td { background: var(--brand-soft); }

ul.plain, ul.items { list-style: none; margin: 0; padding: 0; }
ul.items li { padding: .2rem 0; }
.note { background: var(--warn-soft); border-radius: 8px; padding: .5rem .75rem; margin: .5rem 0 0; }
.big { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.price { color: var(--brand); margin-left: .5rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.7rem; line-height: 1.3; }
.stat small { margin-top: .15rem; }
.stat.good { background: var(--ok-soft); border-color: #b7dcc2; }
.stat.good strong { color: var(--ok); }

.filters { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label { min-width: 180px; }
.creds { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 1rem 0; }
.creds dt { color: var(--muted); }
.creds dd { margin: 0; font-size: 1.05rem; }

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .pkg-row { grid-template-columns: 1fr 1fr; }
  .pkg-row .preset { grid-column: 1 / -1; }
  .pkg-row .remove-pkg { grid-column: 1 / -1; justify-self: start; }
  .topbar { flex-direction: column; align-items: stretch; gap: .35rem; position: static; }
  .nav { flex: none; flex-wrap: nowrap; overflow-x: auto; margin: 0 -.25rem; padding-bottom: .15rem; }
  .nav a { white-space: nowrap; }
  .who { width: 100%; justify-content: space-between; }
  h1 { font-size: 1.35rem; }
  .btn.small { min-height: 40px; }
}

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