[hidden],
.filtered {
  display: none !important;
}

:root {
  --bg: #f6f2ef;
  --surface: #fff;
  --border: #ebe4df;
  --text: #2b2230;
  --muted: #7d727f;
  --accent: #9b4d6c;
  --accent-dark: #7e3a56;
  --accent-soft: #f6e9ef;
  --red: #b42d3a;
  --green: #1d7a55;
  --amber: #a15c07;
  --blue: #2f5ea8;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(43 34 48 / 0.04), 0 6px 20px rgb(43 34 48 / 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.6rem;
  margin: 18px 0 8px;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

/* Navigation */

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  overflow-x: auto;
}

.nav .brand {
  font-weight: 700;
  color: var(--accent);
  margin-right: 14px;
  font-size: 1.1rem;
}

.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.nav a.active {
  background: var(--accent);
  color: #fff;
}

/* Building blocks */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin: 16px 0;
}

details.card > summary {
  cursor: pointer;
  list-style: none;
}

details.card > summary h2 {
  display: inline;
  margin: 0;
}

details.card > summary::before {
  content: "▸ ";
  color: var(--muted);
}

details.card[open] > summary::before {
  content: "▾ ";
}

.card-head,
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 0 16px;
  align-items: start;
}

.lead {
  color: var(--muted);
  max-width: 760px;
  margin-top: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.center {
  text-align: center;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.nowrap {
  white-space: nowrap;
}

.num {
  text-align: right;
  white-space: nowrap;
}

.neg {
  color: var(--red);
}

.pos {
  color: var(--green);
}

.notice {
  padding: 12px 16px;
  border-radius: var(--radius);
}

.notice.error {
  background: #fbe9eb;
  color: var(--red);
}

.notice.ok {
  background: #e5f4ec;
  color: var(--green);
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eee9ef;
  color: var(--muted);
}

.pill.ok {
  background: #e5f4ec;
  color: var(--green);
}

.pill.warn {
  background: #fdf1de;
  color: var(--amber);
}

.pill.bad {
  background: #fbe9eb;
  color: var(--red);
}

.pill.info {
  background: #e8eefa;
  color: var(--blue);
}

/* Forms */

input,
select,
button,
.button {
  font: inherit;
  font-size: 1rem;
}

input,
select {
  padding: 9px 12px;
  border: 1px solid #d9cfd6;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

button,
.button,
details > summary.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid #d9cfd6;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-dark);
}

button.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 6px;
}

button.danger {
  color: var(--red);
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

label .hint {
  font-weight: 400;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form select {
  flex: 1;
  min-width: 220px;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

tfoot th {
  border-bottom: 0;
  font-size: 1.05rem;
}

tr.cancelled td {
  opacity: 0.55;
}

/* Orders */

.month-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-picker label {
  position: relative;
}

.month-name {
  display: inline-block;
  min-width: 150px;
  text-align: center;
  font-size: 1.1rem;
  text-transform: capitalize;
  padding: 9px 12px;
  border: 1px solid #d9cfd6;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

/* The native month input sits invisibly over the month name, so tapping the name opens it. */
.month-picker input[type="month"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0 8px;
}

.stat {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  white-space: nowrap;
}

.stat-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat.highlight {
  background: var(--green);
  color: #fff;
}

.stat.highlight.loss {
  background: var(--red);
}

.stat.highlight .stat-label,
.stat.highlight .stat-note {
  color: rgb(255 255 255 / 0.8);
}

.line-item {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--text);
  padding: 4px 0;
}

.line-item:hover {
  text-decoration: none;
}

.line-item:hover .line-name {
  color: var(--accent);
}

.line-item img,
.line-item .noimg {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  background: var(--accent-soft);
}

.line-item > span {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.line-name {
  font-weight: 500;
}

td.left {
  font-size: 1.1rem;
}

.fees summary {
  cursor: pointer;
  color: var(--text);
}

.fees div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  text-align: left;
  white-space: normal;
  margin-top: 4px;
}

.fees div span:last-child {
  white-space: nowrap;
}

.predicted {
  color: var(--muted);
  font-style: italic;
}

/* Products */

.progress-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
}

.progress {
  flex: 1;
  max-width: 360px;
  height: 10px;
  border-radius: 999px;
  background: #e9dfe4;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar input[type="search"] {
  flex: 1;
  min-width: 220px;
}

.chips {
  display: flex;
  gap: 6px;
}

.chip {
  border-radius: 999px;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.product {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  color: var(--text);
  transition: transform 0.1s;
}

.product:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.product.ended {
  opacity: 0.6;
}

.product img,
.product .noimg {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--accent-soft);
}

.product-body {
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.product-name {
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-weight: 700;
}

.product-price.big {
  font-size: 1.5rem;
  margin: 4px 0;
}

.product-cost {
  margin-top: auto;
  font-size: 0.85rem;
}

.back {
  display: inline-block;
  margin-top: 16px;
}

.product-head {
  display: flex;
  gap: 20px;
  align-items: center;
  margin: 8px 0;
}

.product-head img {
  width: 160px;
  height: 160px;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow: var(--shadow);
}

.product-head h1 {
  font-size: 1.3rem;
  margin: 0;
}

.recipe .qty {
  width: 80px;
  text-align: right;
}

.recipe select {
  width: 100%;
}

.add-row td {
  border-bottom: 0;
}

.breakdown {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin: 0 0 8px;
}

.breakdown dd {
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

.breakdown .total {
  border-top: 2px solid var(--border);
  padding-top: 10px;
  font-size: 1.3rem;
  font-weight: 700;
}

.per-hour {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 24px;
}

.calc span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.calc input {
  width: 120px;
}

.calc-result {
  font-size: 1.15rem;
}

.similar {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  max-height: 420px;
  overflow-y: auto;
}

.similar label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.similar input {
  width: 20px;
  height: 20px;
  flex: none;
}

.similar img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
}

/* Materials */

.material-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.material-form .grow {
  flex: 1 1 240px;
}

.material-form label:not(.grow) input {
  width: 130px;
}

.unit-price {
  flex-basis: 100%;
  margin: 0;
  color: var(--green);
  font-weight: 600;
  min-height: 1.4em;
}

.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: flex-start;
}

.actions details[open] {
  flex-basis: 100%;
}

.popover {
  margin-top: 10px;
  padding: 14px;
  background: var(--bg);
  border-radius: 10px;
}

/* Phones: list tables turn into one card per row, each cell labelled. */
@media (max-width: 760px) {
  h1 {
    font-size: 1.35rem;
  }

  .card {
    padding: 14px;
  }

  .list,
  .list tbody,
  .list tfoot {
    display: block;
  }

  .list thead {
    display: none;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .month-picker label {
    flex: 1;
  }

  .month-name {
    width: 100%;
  }

  .card-head input[type="search"] {
    width: 100%;
  }

  .list tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }

  .list td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    flex-wrap: wrap;
    padding: 4px 0;
    text-align: right;
  }

  .list td[data-label] > .small {
    flex-basis: 100%;
  }

  .list td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.85rem;
    text-align: left;
  }

  .list td[data-label="Produkty"],
  .list td[data-label="Zamówienie"] {
    display: block;
    text-align: left;
  }

  .list td[data-label="Produkty"]::before,
  .list td[data-label="Zamówienie"]::before {
    content: none;
  }

  .list tfoot tr {
    display: block;
  }

  .list tfoot th {
    display: none;
  }

  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .fields {
    grid-template-columns: 1fr;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .product-head img {
    width: 96px;
    height: 96px;
  }

  .month-name {
    min-width: 0;
  }
}

/* Logout in the top bar; login page */

.nav .logout {
  margin-left: auto;
}

.login-page main {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  margin: 0;
  color: var(--accent);
}

.login-card p {
  margin: 0;
}
