:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --ink: #15211b;
  --muted: #6b746f;
  --line: #dfe5dd;
  --panel: #ffffff;
  --accent: #0f7b5f;
  --accent-2: #d36b32;
  --accent-3: #315f9f;
  --danger: #bc3b3b;
  --soft: #eef3f0;
  --shadow: 0 8px 24px rgba(24, 34, 28, 0.07);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

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

button.ghost {
  background: transparent;
}

button.smallButton {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

button:hover {
  border-color: #b8c4bd;
}

button svg {
  width: 18px;
  height: 18px;
}

.iconButton {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
}

.dangerButton {
  color: var(--danger);
}

.dangerButton:hover {
  background: #fdecec;
  border-color: #efb4b4;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  justify-content: flex-start;
  padding: 0 12px;
  background: transparent;
}

.tab.active {
  border-color: var(--accent);
  background: #edf4f1;
  color: var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.content {
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

.muted,
#periodLabel {
  color: var(--muted);
}

.filters {
  min-width: min(620px, 100%);
  display: grid;
  grid-template-columns: 1fr 150px 150px;
  gap: 10px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.panelHeader {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.periodControls {
  min-width: min(340px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.formPanel {
  align-content: start;
}

.formGrid,
.roleGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.roleGrid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 4px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metrics article {
  min-height: 92px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  display: grid;
  align-content: space-between;
  box-shadow: var(--shadow);
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  font-size: 30px;
  line-height: 1;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.capacityPanel {
  gap: 16px;
}

.capacityGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.capacityCard {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 12px;
  background: #fbfcfa;
}

.capacityCard.over {
  border-color: #efb4b4;
  background: #fff8f8;
}

.capacityTop {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.capacityTop strong {
  font-size: 15px;
}

.capacityTop span {
  color: var(--muted);
  font-weight: 700;
}

.capacityTrack {
  height: 9px;
  border-radius: 999px;
  background: #e5ebe7;
  overflow: hidden;
}

.capacityTrack span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.capacityCard.over .capacityTrack span {
  background: var(--danger);
}

.capacityStats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.capacityStats span {
  min-width: 0;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px;
  font-size: 14px;
  font-weight: 700;
}

.capacityStats small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 3px;
}

.barChart {
  display: grid;
  gap: 12px;
}

.barRow {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.barLabel {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.barTrack {
  height: 22px;
  border-radius: 999px;
  background: #e8ede8;
  overflow: hidden;
  display: flex;
}

.bar {
  min-width: 2px;
  height: 100%;
}

.bar.contract {
  background: var(--accent-3);
}

.bar.delivered {
  background: var(--accent);
}

.bar.hours {
  background: var(--accent-2);
}

.bar.capacity {
  background: var(--accent-3);
}

.lineChart {
  min-height: 230px;
  display: grid;
  grid-template-columns: repeat(var(--points, 1), minmax(28px, 1fr));
  align-items: end;
  gap: 10px;
  padding-top: 20px;
}

.monthPoint {
  min-height: 170px;
  display: grid;
  align-content: end;
  gap: 8px;
}

.monthBars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 3px;
  height: 150px;
}

.monthBars span {
  display: block;
  min-height: 2px;
  border-radius: 6px 6px 0 0;
}

.monthPoint small {
  color: var(--muted);
  text-align: center;
}

.statusList {
  display: grid;
  gap: 10px;
}

.statusItem {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.actionItem {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.rowActions {
  display: inline-flex;
  gap: 8px;
  justify-content: flex-end;
}

.statusItem strong {
  font-size: 14px;
}

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

.chip {
  border-radius: 999px;
  padding: 5px 8px;
  background: #edf4f1;
  color: var(--accent);
  font-size: 12px;
}

.chip.warn {
  background: #fff3e9;
  color: var(--accent-2);
}

.chip.danger {
  background: #fdecec;
  color: var(--danger);
}

.tableWrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

td:last-child,
th:last-child {
  width: 112px;
  text-align: center;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.commentCell {
  max-width: 420px;
  line-height: 1.35;
}

.statusSelect {
  min-width: 150px;
}

.modal {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(21, 33, 27, 0.34);
}

.modal form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal p {
  color: var(--ink);
  white-space: pre-wrap;
  max-height: min(60vh, 520px);
  overflow: auto;
  line-height: 1.45;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metrics,
  .grid.two,
  .roleGrid,
  .capacityGrid {
    grid-template-columns: 1fr 1fr;
  }

  .panelHeader {
    display: grid;
  }
}

@media (max-width: 680px) {
  .content,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .filters,
  .periodControls,
  .formGrid,
  .roleGrid,
  .metrics,
  .grid.two,
  .capacityGrid {
    grid-template-columns: 1fr;
  }

  .barRow {
    grid-template-columns: minmax(82px, 120px) minmax(0, 1fr) 58px;
  }
}
