:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --line: #e3e6eb;
  --accent: #1f5fbf;
  --accent-dark: #174a96;

  /* Bar segments */
  --seg-picking: #1f5fbf;
  --seg-forklift: #4c9be8;
  --seg-wrapping: #2a9d8f;
  --seg-booking: #8ab17d;
  --seg-labeling: #e9c46a;
  --seg-collection: #9b6bd6;
  --seg-surcharge: #e76f51;

  /* Storage status */
  --good-bg: #e3f4e8; --good-fg: #1e6b3a;
  --tight-bg: #fff3d6; --tight-fg: #8a5a00;
  --vtight-bg: #ffe2d1; --vtight-fg: #a23c0c;
  --over-bg: #b42318; --over-fg: #ffffff;

  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; display: inline-block; }
.center { text-align: center; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1.5rem;
  padding: .75rem 1.5rem; background: #1d2330; color: #fff;
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.mainnav { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem 1.25rem; }
.mainnav a, .mainnav .linklike { color: #dfe5ee; text-decoration: none; }
.mainnav a:hover, .mainnav .linklike:hover { color: #fff; }
.mainnav .muted { color: #9aa4b2; }
form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; margin-bottom: 1.25rem;
}
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }

/* Buttons */
.button {
  display: inline-block; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--accent-dark); }
.button.secondary { background: #fff; color: var(--accent); }
.button.secondary:hover { background: #eef3fb; }
.button.small { padding: .3rem .7rem; font-size: .9rem; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; background: #e8f0fb; }
.msg-success { background: var(--good-bg); color: var(--good-fg); }
.msg-error { background: #fde4e1; color: #8f1d12; }

/* Week header */
.week-head, .page-head { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head { justify-content: space-between; }
.week-title p { margin: .15rem 0 0; }
.nav-arrow {
  display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem;
  border-radius: 50%; background: #fff; border: 1px solid var(--line); font-size: 1.3rem; text-decoration: none;
}
.nav-arrow:hover { background: #eef3fb; }
.week-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.week-summary { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .75rem 1.25rem; display: flex; flex-direction: column; min-width: 12rem;
}
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-note { color: var(--muted); font-size: .8rem; }
.empty-note { margin-top: 0; }

/* Chart */
.chart { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); column-gap: .75rem; }
.chart-axis { position: relative; height: 320px; margin-top: 1.75rem; }
.tick {
  position: absolute; right: 0; transform: translateY(50%);
  font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chart-plot { position: relative; height: 320px; margin-top: 1.75rem; border-bottom: 1px solid #b8bfca; }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.chart-cols { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: 1rem; height: 100%; }
.chart-plot .chart-cols { position: relative; }
.bar-col { position: relative; height: 100%; }
.bar {
  position: absolute; left: 14%; right: 14%; bottom: 0; height: 100%;
  display: flex; flex-direction: column-reverse;
}
.seg { width: 100%; min-height: 1px; }
.seg:first-child { border-radius: 0 0 3px 3px; }
.bar-total { text-align: center; font-weight: 700; padding-bottom: .2rem; font-variant-numeric: tabular-nums; }
.bar-col.closed {
  background: repeating-linear-gradient(135deg, #f3f4f6 0 8px, #e9ebef 8px 16px);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
}
.closed-label { color: var(--muted); font-weight: 600; text-align: center; padding: .5rem; }

.seg-picking { background: var(--seg-picking); }
.seg-forklift { background: var(--seg-forklift); }
.seg-wrapping { background: var(--seg-wrapping); }
.seg-booking { background: var(--seg-booking); }
.seg-labeling { background: var(--seg-labeling); }
.seg-collection { background: var(--seg-collection); }
.seg-surcharge {
  background: repeating-linear-gradient(135deg, var(--seg-surcharge) 0 5px, #f08c74 5px 10px);
}

/* Per-day figures under the bars: one grid row per field, so rows line up across days */
.info-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 1rem; row-gap: .6rem; padding-top: .75rem;
}
.info-cell { min-width: 0; }
.info-cell.day-name { font-weight: 700; text-align: center; padding-bottom: .1rem; }
.info-label { color: var(--muted); font-size: .8rem; }
.info-value { font-variant-numeric: tabular-nums; }
.info-value.big { font-size: 1.25rem; font-weight: 700; }
.surcharge-note { color: #a23c0c; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.status-good { background: var(--good-bg); color: var(--good-fg); }
.status-tight { background: var(--tight-bg); color: var(--tight-fg); }
.status-very_tight { background: var(--vtight-bg); color: var(--vtight-fg); }
.status-over { background: var(--over-bg); color: var(--over-fg); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; padding: 0; margin: 1.25rem 0 0; font-size: .9rem; }
.legend li { display: flex; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; border: 1px solid rgba(0,0,0,.08); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data thead th { font-size: .85rem; color: var(--muted); font-weight: 600; }
table.data tbody th { font-weight: 500; }
table.data .num { text-align: right; }
table.data tr.strong td, table.data tr.strong th { font-weight: 700; background: #f8f9fb; }
table.data tr.inactive { color: var(--muted); }
table.data td.actions a { margin-right: .9rem; }
details.details summary { cursor: pointer; font-weight: 600; }
details.details[open] summary { margin-bottom: .75rem; }

/* Week editor */
.day-edit h2 { margin-bottom: .5rem; }
.edit-table { border-collapse: collapse; margin-bottom: .6rem; }
.edit-table th { text-align: left; font-size: .85rem; color: var(--muted); font-weight: 600; padding: .25rem .5rem .25rem 0; }
.edit-table td { padding: .3rem .75rem .3rem 0; vertical-align: top; }
.edit-table select, .edit-table input[type=number] { font: inherit; padding: .4rem .5rem; border: 1px solid #c9cfd8; border-radius: 6px; }
.edit-table select { min-width: 17rem; }
.edit-table input[type=number] { width: 8rem; }
.edit-table input[type=checkbox] { width: 1.1rem; height: 1.1rem; margin-top: .55rem; }
.errorlist { list-style: none; margin: .25rem 0 0; padding: 0; color: #b42318; font-size: .85rem; }
.form-errors { color: #b42318; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; }
.form-actions.sticky {
  position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; margin-top: 0;
  border-top: 1px solid var(--line);
}

/* Stacked forms (login, users) */
.stacked-form > div { margin-bottom: .9rem; }
.stacked-form label { display: block; font-weight: 600; margin-bottom: .25rem; }
.stacked-form input[type=text], .stacked-form input[type=password] {
  width: 100%; font: inherit; padding: .5rem .6rem; border: 1px solid #c9cfd8; border-radius: 6px;
}
.stacked-form input[type=checkbox] { width: 1.1rem; height: 1.1rem; vertical-align: middle; }
.stacked-form .helptext, .stacked-form [id$="_helptext"] { display: block; color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.stacked-form ul { margin: .25rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .85rem; }
.stacked-form ul.errorlist { padding-left: 0; color: #b42318; }

/* Year calendar */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.month { margin-bottom: 0; padding: 1rem; }
.mini-cal { width: 100%; border-collapse: separate; border-spacing: 3px; text-align: center; font-variant-numeric: tabular-nums; }
.mini-cal th { font-size: .75rem; color: var(--muted); font-weight: 600; }
.mini-cal th.wk { width: 2.4rem; }
.mini-cal th.wk a { display: block; padding: .3rem 0; border-radius: 6px; text-decoration: none; font-weight: 700; color: var(--accent); }
.mini-cal th.wk a:hover { background: #eef3fb; }
.mini-cal td { border-radius: 6px; padding: 0; height: 2rem; }
.mini-cal td a { display: block; line-height: 2rem; color: var(--text); text-decoration: none; }
.mini-cal td a:hover { outline: 2px solid var(--accent); border-radius: 6px; }
.mini-cal tr.current th.wk a { background: var(--accent); color: #fff; }
.mini-cal td.today { box-shadow: inset 0 0 0 2px var(--text); }
.cal-good { background: var(--good-bg); }
.cal-tight { background: var(--tight-bg); }
.cal-very_tight { background: var(--vtight-bg); }
.cal-over { background: var(--over-bg); }
td.cal-over a { color: #fff; }
.cal-closed { background: repeating-linear-gradient(135deg, #f3f4f6 0 4px, #e3e6eb 4px 8px); }
td.cal-closed a { color: var(--muted); }

@media (max-width: 720px) {
  main { padding: 1rem; }
  .card { padding: 1rem; }
  .chart { grid-template-columns: 2rem minmax(0, 1fr); column-gap: .4rem; }
  .chart-cols { column-gap: .4rem; }
  .bar { left: 4%; right: 4%; }
  .bar-total { font-size: .8rem; }
  .info-grid { column-gap: .4rem; font-size: .8rem; }
  .info-value.big { font-size: 1rem; }
  .edit-table select { min-width: 0; width: 100%; }
  .edit-table input[type=number] { width: 5.5rem; }
  .week-actions { margin-left: 0; }
}
