:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1f2421;
  --muted: #6b716d;
  --line: #e2e0d8;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e3f3ea;
  --bad: #b3261e;
  --bad-bg: #fbe6e4;
  --warn: #c98a12;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
sub { font-size: .7em; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 650; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: .55rem; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: #fff; font-size: .8rem; letter-spacing: .02em; }
.top nav { display: flex; gap: 1rem; align-items: center; }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem; }

.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: .55rem 1rem; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.danger { color: var(--bad) !important; }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin-bottom: 1.2rem; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2.5rem; text-align: center; }

/* listy i tabele */
table { border-collapse: collapse; width: 100%; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th, .list td, .data th, .data td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.list th, .data th { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: none; }
.r { text-align: right !important; font-variant-numeric: tabular-nums; }
.data tr.sum td { font-weight: 700; border-top: 2px solid var(--ink); }
.actions { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tablewrap { overflow-x: auto; }

/* formularz */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem 1.2rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: .85rem; font-weight: 600; }
.field label small { color: var(--muted); font-weight: 400; }
input, select, textarea { font: inherit; padding: .45rem .55rem; border: 1px solid #cfccc2; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.inrow { display: flex; gap: .4rem; }
.inrow input { flex: 1 1 40%; }
.inrow select.preset { flex: 1 1 60%; color: var(--muted); font-size: .85rem; }
.help { color: var(--muted); font-size: .78rem; }
.err { color: var(--bad); font-size: .8rem; font-weight: 600; }
.has-err input, .has-err select { border-color: var(--bad); background: var(--bad-bg); }
.parts td { padding: .25rem .2rem; }
.parts th { font-size: .78rem; color: var(--muted); text-align: left; padding: .3rem .2rem; font-weight: 600; }
.parts input.n { width: 5.2rem; text-align: right; }
.parts td:first-child input { min-width: 9rem; }
.parts select { min-width: 6rem; }
#add-part { margin-top: .7rem; }
.bar { position: sticky; bottom: 0; background: var(--bg); padding: .9rem 0; display: flex; gap: 1rem; align-items: center; border-top: 1px solid var(--line); }

/* wyniki */
.head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.2rem; }
.head p { margin: 0; }
.tiles { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: .9rem; margin-bottom: 1.2rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; }
.tile .k { font-size: .8rem; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .3rem; }
.tile .u { font-size: .8rem; color: var(--muted); }
.tile .s { font-size: .82rem; margin-top: .5rem; }
.tile.main .v { font-size: 2.6rem; }
.tile.main.ok { border-left: 5px solid var(--ok); }
.tile.main.bad { border-left: 5px solid var(--bad); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.two .card { margin-bottom: 1.2rem; }

.scale { position: relative; height: 70px; margin: 1.5rem .5rem .5rem; }
.track { position: absolute; left: 0; right: 0; top: 30px; height: 14px; border-radius: 7px; background: linear-gradient(90deg, #2e9c5a, #9cc93f 30%, #f1c232 55%, #e8742b 75%, #c62828); }
.mark { position: absolute; top: 22px; height: 30px; width: 3px; background: var(--ink); transform: translateX(-1.5px); }
.mark span { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: .8rem; font-weight: 700; }
.mark.req span { top: 34px; }
.mark.bld span { top: -22px; }
.mark.req { background: #444; width: 2px; }
.mark.bld { width: 4px; }

.barcol { width: 30%; }
.hbar { position: relative; height: 14px; }
.hbar span { position: absolute; left: 0; top: 0; height: 100%; border-radius: 3px; }
.loss, .sw.loss { background: #d8d4c8; }
.need, .sw.need { background: var(--accent); }
.legend { font-size: .82rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: .6rem; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile.main { grid-column: 1 / -1; }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main { padding: 1rem; }
  .top { padding: .7rem 1rem; }
  .list thead { display: none; }
  .list td { display: block; border: 0; padding: .2rem .8rem; }
  .list tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
}

/* logowanie */
.top nav form { display: inline; }
.login { max-width: 380px; margin: 3rem auto; }
.login form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }
.login code { font-size: .85rem; }
