:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-soft: #f8f7f3;
  --line: #d7d2c6;
  --ink: #202124;
  --muted: #6d6a62;
  --brand: #265c4b;
  --brand-dark: #163a31;
  --accent: #d88b32;
  --danger: #b13b35;
  --shadow: 0 16px 34px rgba(31, 36, 33, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-pending .topbar,
.auth-pending .app-shell > .workspace,
.auth-pending .app-shell > .editor-panel,
.auth-pending .site-footer {
  display: none;
}

.authenticated .login-screen {
  display: none;
}

.authenticated {
  padding-top: 96px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #17352f;
}

.login-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.team-login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.team-login-grid button {
  min-height: 48px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
}

.team-login-grid button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.team-login-grid .lorenzo-login-button {
  grid-column: 1 / -1;
  background: #17352f;
  border-color: #17352f;
  color: #fff;
}

.team-login-grid .lorenzo-login-button:hover {
  background: var(--brand);
  color: #fff;
}

.team-login-grid .stock-login-button {
  grid-column: 1 / -1;
  border-color: #111;
  background: #fff;
  color: #111;
}

.team-login-grid .stock-login-button:hover {
  background: #111;
  color: #fff;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 3vw, 42px);
  background: #17352f;
  color: white;
}

.team-session {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.active-team-button {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  color: white;
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.active-team-button:disabled {
  cursor: default;
  opacity: 1;
}

.active-team-button.lorenzo-shortcut {
  background: white;
  color: #17352f;
}

.team-session button {
  color: white;
}

.team-session .active-team-button.lorenzo-shortcut {
  color: #17352f;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px clamp(18px, 3vw, 42px) 28px;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 16px;
  color: var(--brand);
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 780;
  text-decoration: none;
}

.site-footer a.active {
  background: var(--brand);
  color: #fff;
}

.app-version {
  display: inline-grid;
  gap: 1px;
  min-height: 38px;
  padding: 7px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.15;
}

.app-version span {
  color: var(--brand);
  font-weight: 820;
  text-transform: uppercase;
}

.app-version strong {
  color: var(--ink);
  font-size: 12px;
}

.app-version small {
  color: var(--muted);
  font-weight: 680;
}

.stock-mode {
  padding-top: 0;
  background: #fff;
}

.stock-mode .topbar {
  display: none;
}

.stock-mode .app-shell {
  padding: 0;
}

.stock-mode .section-head,
.stock-mode .stats {
  display: none;
}

.stock-page {
  display: grid;
  grid-template-columns: minmax(280px, 39vw) minmax(360px, 1fr);
  min-height: calc(100vh - 84px);
  padding: clamp(28px, 5vw, 76px) clamp(18px, 3vw, 42px) 24px 0;
  background: #fff;
  color: #050505;
}

.stock-categories {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-right: 28px;
  color: #8f8f8f;
  font-size: clamp(38px, 5vw, 68px);
  font-weight: 780;
  line-height: 0.98;
}

.stock-categories strong {
  width: 100%;
  color: #000;
  font-size: clamp(46px, 5.9vw, 82px);
  line-height: 0.92;
}

.stock-content {
  min-width: 0;
  padding-top: 18px;
}

.stock-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.stock-toolbar label {
  color: #111;
}

.stock-toolbar input {
  min-height: 38px;
  border-color: #111;
  border-radius: 0;
  background: #fff;
}

.stock-access-note {
  padding-bottom: 9px;
  color: #555;
  font-size: 12px;
  font-weight: 720;
  text-align: right;
  text-transform: uppercase;
}

.stock-list {
  border-top: 2px solid #111;
}

.stock-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(150px, 190px);
  align-items: center;
  gap: 12px;
  min-height: 39px;
  border-bottom: 1px solid #111;
}

.stock-row-title {
  display: grid;
  gap: 1px;
  width: 100%;
  padding: 5px 0;
  background: transparent;
  border: 0;
  color: #000;
  text-align: left;
}

.stock-row-title span {
  font-size: 22px;
  font-weight: 760;
  line-height: 1;
}

.stock-row-title small {
  color: #666;
  font-size: 11px;
  font-weight: 680;
}

.stock-row.reserved .stock-row-title small {
  color: #b13b35;
}

.stock-row-meta {
  display: flex;
  gap: 9px;
  color: #555;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.stock-row select {
  min-height: 30px;
  padding: 4px 8px;
  border-color: #111;
  border-radius: 0;
  background: #fff;
  color: #111;
  font-size: 12px;
  font-weight: 720;
}

.stock-admin-link {
  min-height: 38px;
  border: 1px solid #111;
  border-radius: 0;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 780;
}

.stock-admin-page {
  display: grid;
  gap: 18px;
}

.stock-admin-head {
  display: flex;
  justify-content: flex-end;
}

.stock-admin-form,
.stock-admin-list {
  display: grid;
  gap: 12px;
}

.stock-admin-form {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stock-admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stock-admin-row div {
  display: grid;
  gap: 4px;
}

.stock-admin-row strong {
  color: var(--ink);
  font-size: 17px;
}

.stock-admin-row span,
.stock-admin-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 760;
}

h2 {
  font-size: 24px;
  font-weight: 720;
}

.eyebrow {
  margin-bottom: 5px;
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
  font-weight: 740;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.tabs a {
  color: white;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 700;
}

.tabs a.active {
  background: white;
  color: #17352f;
}

.app-shell {
  padding: 24px clamp(18px, 3vw, 42px) 42px;
}

.workspace {
  min-width: 0;
}

.section-head,
.form-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.stats.logistics-stats {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.stats.program-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.stats.archive-year-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.program-stats .stat {
  min-height: 74px;
  min-width: 118px;
  padding: 10px 12px;
}

.program-stats .stat strong {
  font-size: 24px;
}

.program-stats .stat span {
  font-size: 10px;
}

.stat-button {
  display: block;
  width: 100%;
}

.stat-button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.stat-button.active span,
.stat-button.active strong {
  color: #fff;
}

.logistics-stats .stat-button.active,
.ready-to-ship-stats .stat-button.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(45, 93, 77, 0.18);
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.stat.procedure-pl,
.logistics-procedures label.procedure-pl {
  background: #fff3bf;
  border-color: #eadc8e;
}

.stat.procedure-balance,
.logistics-procedures label.procedure-balance {
  background: #dff4df;
  border-color: #b8ddb8;
}

.stat.attention-stat {
  background: #fff0d6;
  border-color: #efbd73;
}

.stat.attention-stat strong,
.stat.attention-stat span {
  color: #9b5a08;
}

.logistics-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #eef5f1;
  border: 1px solid #b9d0c5;
  border-radius: 8px;
}

.logistics-filter-bar div {
  display: grid;
  gap: 2px;
}

.logistics-filter-bar span,
.logistics-filter-bar small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.logistics-filter-bar strong {
  color: var(--ink);
  font-size: 18px;
}

.stat strong {
  display: block;
  font-size: 30px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.job-list {
  display: grid;
  gap: 12px;
}

.production-filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(180px, 0.8fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.production-program-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(118px, 1fr));
  gap: 10px;
}

.production-program-button {
  grid-column: span 1;
  min-height: 38px;
  padding: 7px 10px;
  justify-content: space-between;
  background: #f5f2ea;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 820;
}

.production-program-button strong {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  background: var(--brand);
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
}

.production-sort-direction {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: #ede8dc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.production-sort-direction button {
  min-height: 38px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
}

.production-sort-direction button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.production-phases {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f2eee6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.production-phases.compact {
  gap: 7px;
  padding: 8px;
  margin-top: 6px;
  background: #f6f2e9;
}

.empty-phase-button,
.edit-phase-button {
  width: 100%;
  min-height: 34px;
  font-size: 12px;
}

.article-supplier-editor {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-supplier-editor strong {
  font-size: 12px;
}

.article-supplier-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 33, 36, 0.42);
}

.phase-date-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 33, 36, 0.42);
}

.production-analysis-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 33, 36, 0.42);
}

.production-supplier-modal {
  position: fixed;
  inset: 0;
  z-index: 86;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 33, 36, 0.42);
}

.article-supplier-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(880px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.production-supplier-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.production-analysis-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.phase-date-dialog {
  display: grid;
  width: min(420px, 100%);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.article-supplier-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.production-analysis-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.production-supplier-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.phase-date-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.article-supplier-modal-head div {
  display: grid;
  gap: 3px;
}

.phase-date-modal-head div {
  display: grid;
  gap: 3px;
}

.production-analysis-head div {
  display: grid;
  gap: 3px;
}

.production-analysis-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.production-supplier-head div {
  display: grid;
  gap: 3px;
}

.article-supplier-modal-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
}

.phase-date-modal-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
}

.production-analysis-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
}

.production-supplier-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
}

.article-supplier-modal-head strong {
  font-size: 18px;
}

.production-analysis-head strong {
  font-size: 18px;
}

.production-supplier-head strong {
  font-size: 18px;
}

.phase-date-modal-head strong {
  font-size: 18px;
}

.production-supplier-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.phase-date-modal-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: #f1eee7;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.article-supplier-modal-body {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 18px;
}

.article-supplier-modal-body section {
  display: grid;
  gap: 10px;
}

.production-analysis-body {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding: 14px;
}

.analysis-filter-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.analysis-filter-actions .stat {
  min-height: 74px;
}

.analysis-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.analysis-row-button {
  width: 100%;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.analysis-row-button:hover {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 2px 10px rgba(31, 36, 33, 0.08);
}

.analysis-row-button em::after {
  content: " >";
}

.analysis-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.analysis-row strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-row em {
  color: var(--brand);
  font-size: 12px;
  font-style: normal;
  font-weight: 820;
  white-space: nowrap;
}

.phase-date-modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.phase-date-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.phase-date-summary div {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.phase-date-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
}

.phase-date-summary strong {
  color: var(--ink);
  font-size: 12px;
}

.production-supplier-body {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 16px 18px 18px;
}

.phase-date-modal-body label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.phase-date-modal-body input {
  min-height: 44px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.article-note-dialog textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
}

.production-program-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(980px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 36px));
}

.production-program-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.85fr);
  gap: 16px;
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.production-program-body section {
  display: grid;
  align-content: start;
  gap: 12px;
}

.production-program-body h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.production-program-form-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.production-program-form-title button {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 11px;
}

.production-program-list,
.production-program-po-list {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.production-program-po-list {
  max-height: min(420px, 46vh);
  overflow: auto;
  padding-right: 4px;
}

.production-program-card,
.production-program-po-list label {
  padding: 10px;
  background: #f7f4ed;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.production-program-card {
  display: grid;
  gap: 6px;
}

.production-program-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.production-program-card strong,
.production-program-po-list strong {
  color: var(--ink);
}

.production-program-card span,
.production-program-card small,
.production-program-po-list small {
  color: var(--muted);
  font-size: 11px;
}

.production-program-card p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.production-program-card button {
  justify-self: start;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 11px;
}

.production-program-selection {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.production-program-selection > div {
  display: grid;
  align-content: start;
  gap: 8px;
}

.production-program-selection > div > strong {
  color: var(--ink);
  font-size: 12px;
}

.production-program-po-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: #f7f4ed;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.production-program-po-list.selected .production-program-po-row {
  background: #edf6f0;
  border-color: #b9d0c5;
}

.production-program-po-row button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 11px;
}

.production-program-po-list label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.production-program-po-list input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.production-program-po-list span {
  display: grid;
  gap: 2px;
}

.small-empty {
  padding: 10px;
  min-height: auto;
}

.article-supplier-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.phase-date-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.empty-inline {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.supplier-modal-launcher {
  position: relative;
  margin-top: 5px;
}

.supplier-dropdown-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.supplier-dropdown-toggle:hover,
.supplier-dropdown-toggle:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(45, 93, 77, 0.1);
}

.supplier-dropdown-toggle::after {
  color: var(--muted);
  content: "Apri";
  font-size: 11px;
  font-weight: 820;
}

.supplier-dropdown-toggle span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.supplier-dropdown-toggle strong {
  min-width: 36px;
  padding: 3px 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand);
  font-size: 11px;
  text-align: center;
}

.production-phase-article {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: #fff;
  border: 1px solid #ded7ca;
  border-radius: 8px;
}

.production-phase-article header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.production-phase-article header span,
.production-phase-group p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.production-phase-group {
  display: grid;
  gap: 6px;
}

.production-phase-checks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

.production-phase-checks label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 2px 6px;
  min-height: 38px;
  padding: 6px 7px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.15;
}

.production-phase-checks > div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 5px 8px;
  min-height: 38px;
  padding: 6px 7px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.15;
}

.production-phase-checks > div.completed-phase {
  background: #dfddd6;
  border-color: #c3bdb2;
}

.production-phase-checks label.phase-late {
  background: #fff1f0;
  border-color: #e9a8a0;
}

.production-phase-checks > div.phase-late {
  background: #fff1f0;
  border-color: #e9a8a0;
}

.production-phase-checks label.phase-attention {
  background: #fff0d6;
  border-color: #efbd73;
}

.production-phase-checks > div.phase-attention {
  background: #fff0d6;
  border-color: #efbd73;
}

.production-phase-checks span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.production-phase-checks input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.production-phase-checks small {
  grid-column: 2;
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
  line-height: 1.1;
  white-space: nowrap;
}

.production-phase-checks label.phase-late small {
  color: #a33b31;
}

.production-phase-checks label.phase-attention small {
  color: #9b5a08;
}

.phase-date-button {
  grid-column: 2;
  justify-self: start;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--brand);
  font-size: 10px;
  font-weight: 760;
  line-height: 1.1;
  text-align: left;
  text-decoration: underline;
}

.job-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(23, 53, 47, 0.05);
}

.job-card.logistica {
  border-left-color: var(--accent);
}

.job-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.job-title {
  display: grid;
  gap: 4px;
}

.job-title strong {
  font-size: 19px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
}

.details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.progress-line {
  height: 10px;
  overflow: hidden;
  background: #ebe6dc;
  border-radius: 999px;
}

.progress-line span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.time-grid span {
  padding: 8px 10px;
  background: var(--surface-soft);
  border-radius: 7px;
}

.logistics-procedures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  padding: 10px;
  background: #f2eee6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.logistics-procedures label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 9px;
  background: #fff;
  border: 1px solid #ded7ca;
  border-radius: 7px;
  color: var(--ink);
  font-size: 12px;
}

.logistics-procedures input {
  width: auto;
  accent-color: var(--brand);
}

.logistics-procedures input:disabled {
  cursor: not-allowed;
}

.logistics-procedures label:has(input:disabled) {
  opacity: 0.52;
  cursor: not-allowed;
}

.detail-box {
  padding: 10px;
  background: var(--surface-soft);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.detail-box strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.note-preview {
  color: var(--muted);
  line-height: 1.45;
}

.editor-panel,
.password-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px clamp(14px, 3vw, 42px);
  overflow-y: auto;
  background: rgba(23, 32, 29, 0.48);
}

.editor-panel[hidden],
.password-panel[hidden] {
  display: none;
}

.editor-panel form,
.password-panel form {
  width: min(760px, 100%);
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.password-panel form {
  width: min(420px, 100%);
}

.remember-device {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 650;
}

.remember-device input {
  width: 16px;
  height: 16px;
}

.modal-open {
  overflow: hidden;
}

form {
  display: grid;
  gap: 16px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

fieldset {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--brand);
}

.range-value {
  justify-self: end;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(38, 92, 75, 0.17);
  border-color: var(--brand);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.job-main-grid {
  grid-template-columns: 1fr 1fr 1fr;
}

.po-labels-fieldset {
  margin-top: 12px;
}

.po-labels-grid {
  grid-template-columns: 1fr 1fr;
}

.checkbox-card {
  display: flex;
  min-height: 42px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 10px 12px;
  background: #f5f2ea;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 760;
}

.checkbox-card input {
  width: 16px;
  height: 16px;
}

.supplier-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.supplier-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 7px;
  background: var(--surface-soft);
  border-radius: 7px;
  color: var(--ink);
  font-size: 12px;
}

.raw-supplier-grid label {
  background: #e7e0d3;
  border: 1px solid #d3c8b8;
}

.raw-supplier-grid label.com-raw-supplier {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr);
  align-items: center;
}

.com-raw-supplier span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 780;
}

.com-raw-supplier input[data-article-com-note] {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #cbbfac;
  border-radius: 6px;
  font-size: 12px;
}

.supplier-grid input {
  width: auto;
}

#article-list {
  display: grid;
  gap: 10px;
}

.article-row {
  display: grid;
  grid-template-columns: 0.8fr 1.25fr 120px 82px 34px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-row button {
  width: 34px;
  height: 38px;
  padding: 0;
}

.article-image-preview {
  display: grid;
  place-items: center;
  min-height: 72px;
  height: 72px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.article-image-preview span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.article-specifications {
  grid-column: 1 / -1;
}

.article-supplier-section {
  grid-column: 1 / -1;
  background: #fff;
  padding: 8px;
}

.article-supplier-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.article-supplier-grid label {
  gap: 4px;
  min-height: 18px;
  padding: 3px 4px;
  border-radius: 5px;
  font-size: 10px;
  line-height: 1.1;
}

.article-supplier-grid input[type="checkbox"] {
  width: 12px;
  height: 12px;
}

.article-supplier-grid .com-raw-supplier {
  grid-column: span 2;
  grid-template-columns: auto minmax(80px, 1fr);
}

.article-supplier-grid .com-raw-supplier span {
  gap: 4px;
}

.article-supplier-grid .com-raw-supplier input[data-article-com-note] {
  min-height: 20px;
  padding: 3px 5px;
  font-size: 10px;
}

button {
  border: 0;
  border-radius: 7px;
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 780;
}

.primary {
  background: var(--brand);
  color: white;
}

.primary:hover {
  background: var(--brand-dark);
}

.secondary {
  background: #ece7dc;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost {
  background: transparent;
  color: var(--ink);
}

.danger {
  background: #f5e4e1;
  color: var(--danger);
  border: 1px solid #e6b8b2;
}

.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 28px;
  line-height: 1;
}

.messages {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.gantt-board {
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow: visible;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.gantt-scroll {
  max-width: 100%;
  max-height: min(720px, calc(100vh - 260px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.gantt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.gantt-toolbar strong {
  color: var(--ink);
  font-size: 16px;
}

.gantt-title-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.program-view-switch {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  background: #ede8dc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.program-view-switch button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
}

.program-view-switch button.active {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(31, 36, 33, 0.08);
}

.view-icon {
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--brand);
  border-radius: 4px;
}

.week-icon {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 4px,
    var(--brand) 5px,
    var(--brand) 6px
  );
}

.month-icon {
  background:
    linear-gradient(var(--brand), var(--brand)) 50% 33% / 100% 1px no-repeat,
    linear-gradient(var(--brand), var(--brand)) 50% 66% / 100% 1px no-repeat,
    linear-gradient(90deg, var(--brand), var(--brand)) 33% 50% / 1px 100% no-repeat,
    linear-gradient(90deg, var(--brand), var(--brand)) 66% 50% / 1px 100% no-repeat;
}

.year-icon {
  position: relative;
}

.year-icon::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 3px;
  height: 2px;
  background: var(--brand);
}

.year-icon::after {
  content: "";
  position: absolute;
  inset: 8px 4px 4px;
  background: var(--brand);
  border-radius: 2px;
}

.gantt-table {
  display: grid;
  grid-template-columns: var(--po-col-width, 105px) var(--article-col-width, 170px) var(--supplier-col-width, 220px) repeat(var(--week-count), var(--period-width, 118px));
  min-width: var(--calendar-min-width, 480px);
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.gantt-th,
.gantt-job-cell,
.gantt-article-cell,
.gantt-supplier-cell,
.gantt-week-cell {
  min-height: 58px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.gantt-th {
  position: relative;
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 38px;
  padding: 7px 8px;
  background: #f8f8f6;
  color: var(--ink);
  font-size: 11px;
  font-weight: 760;
  text-align: center;
}

.gantt-th span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.gantt-th.company-closed {
  background: #dedbd2;
  color: #68645c;
}

.gantt-th.company-closed span {
  color: #7c766c;
  font-size: 9px;
}

.gantt-band {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  min-height: 30px;
  padding: 6px 8px;
  background: #fbfbfa;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  font-weight: 780;
  text-transform: capitalize;
}

.gantt-fixed-head {
  top: 0;
  z-index: 12;
  grid-row: span 2;
  min-height: 68px;
  background: #eeeeea;
}

.gantt-table > .gantt-th:not(.gantt-fixed-head) {
  position: sticky;
  top: 30px;
  z-index: 8;
}

.gantt-th.current,
.gantt-week-cell.current {
  box-shadow: inset 0 0 0 2px rgba(177, 59, 53, 0.2);
}

.gantt-commessa,
.gantt-job-cell {
  position: sticky;
  left: 0;
  z-index: 4;
  text-align: left;
}

.gantt-commessa {
  z-index: 14;
}

.gantt-articolo-head,
.gantt-article-cell {
  position: sticky;
  left: var(--po-col-width, 105px);
  z-index: 3;
  box-shadow: 8px 0 12px -12px rgba(31, 36, 33, 0.55);
}

.gantt-articolo-head {
  z-index: 13;
}

.gantt-fornitore-head,
.gantt-supplier-cell {
  position: sticky;
  left: calc(var(--po-col-width, 105px) + var(--article-col-width, 170px));
  z-index: 2;
  box-shadow: 8px 0 12px -12px rgba(31, 36, 33, 0.5);
}

.gantt-fornitore-head {
  z-index: 12;
}

.gantt-commessa,
.gantt-articolo-head,
.gantt-fornitore-head {
  position: sticky;
}

.column-resizer {
  position: absolute;
  top: 0;
  right: -5px;
  z-index: 10;
  width: 10px;
  height: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: col-resize;
}

.column-resizer::after {
  position: absolute;
  top: 12px;
  right: 4px;
  bottom: 12px;
  width: 2px;
  background: rgba(32, 33, 36, 0.28);
  content: "";
}

.column-resizer:hover::after,
.resizing-column .column-resizer::after {
  background: var(--brand);
}

.resizing-column {
  cursor: col-resize;
  user-select: none;
}

.gantt-job-cell {
  min-height: 68px;
  background: #fff;
}

.gantt-job-cell.po-tone-a,
.gantt-article-cell.po-tone-a,
.gantt-supplier-cell.po-tone-a {
  background: #ffffff;
}

.gantt-job-cell.po-tone-b,
.gantt-article-cell.po-tone-b,
.gantt-supplier-cell.po-tone-b {
  background: #eeeeee;
}

.gantt-week-cell.po-tone-a {
  background: linear-gradient(90deg, #ffffff 0%, #ffffff 50%, #f7f7f5 50%, #f7f7f5 100%);
}

.gantt-week-cell.po-tone-b {
  background: linear-gradient(90deg, #f2f2f0 0%, #f2f2f0 50%, #ebebe8 50%, #ebebe8 100%);
}

.gantt-article-cell {
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 76px;
  padding: 8px 10px;
  background: #fbfaf7;
  text-align: left;
}

.gantt-article-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.gantt-article-cell strong {
  color: var(--ink);
  font-size: 12px;
}

.gantt-article-cell span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 680;
}

.gantt-article-cell small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.gantt-article-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.article-note-button {
  min-height: 26px;
  padding: 5px 8px;
  background: #e4e2dc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.article-note-button.has-notes {
  color: var(--ink);
  font-weight: 860;
}

.priority-note-button {
  background: #c84f45;
  border-color: #a83f36;
  color: #fff;
}

.priority-note-button.has-notes {
  color: #fff;
  font-weight: 860;
}

.custom-note-button {
  background: #e69b43;
  border-color: #c77b22;
  color: #fff;
}

.custom-note-button.has-notes {
  color: #fff;
  font-weight: 860;
}

.gantt-supplier-cell {
  display: grid;
  align-content: stretch;
  min-height: 42px;
  padding: 3px 5px;
  background: #fff;
}

.gantt-supplier-cell-content {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 6px;
  min-height: 34px;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(34, 38, 36, 0.1);
  border-radius: 6px;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.15;
}

.gantt-supplier-cell-content.phase-late {
  background: #fff1f0;
  border-color: #e9a8a0;
}

.gantt-supplier-cell-content.phase-attention {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(34, 38, 36, 0.1);
}

.gantt-supplier-cell-content.started-phase {
  border-color: rgba(40, 119, 90, 0.35);
}

.gantt-supplier-cell-content.completed-phase {
  background: #dfddd6;
  border-color: #c3bdb2;
}

.gantt-supplier-cell-content.raw-material-phase {
  background: #ecebe6;
  border-color: #cbc6ba;
}

.gantt-supplier-cell-content.raw-material-phase.phase-attention {
  background: #ecebe6;
  border-color: #cbc6ba;
}

.gantt-supplier-cell-content.raw-material-phase.phase-late {
  background: #fff1f0;
  border-color: #e9a8a0;
}

.gantt-supplier-cell-content input {
  width: 14px;
  height: 14px;
  accent-color: var(--brand);
}

.phase-main-check {
  display: contents;
}

.gantt-supplier-cell-content span,
.gantt-supplier-cell-content small {
  grid-column: 2;
}

.phase-supplier-main {
  grid-column: 1 / span 2;
  display: grid;
  min-width: 0;
  gap: 3px;
}

.phase-supplier-main > span {
  grid-column: auto;
}

.phase-supplier-main > small {
  grid-column: auto;
}

.phase-work-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.phase-work-checks.single-check {
  margin-top: 1px;
}

.phase-work-checks label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 760;
  line-height: 1;
  white-space: nowrap;
}

.phase-work-checks input {
  width: 11px;
  height: 11px;
}

.phase-work-checks span {
  grid-column: auto;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.phase-work-checks input:disabled + span {
  opacity: 0.45;
}

.gantt-supplier-cell-content .phase-date-button {
  grid-column: 3;
  grid-row: 1 / span 2;
}

.gantt-supplier-cell-content span {
  overflow: hidden;
  color: var(--ink);
  font-weight: 760;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-supplier-cell-content small,
.gantt-supplier-cell-content em,
.gantt-supplier-cell-content strong {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 680;
  line-height: 1.12;
}

.gantt-supplier-cell-content strong {
  color: #63736a;
}

.gantt-supplier-cell-content.phase-late strong {
  color: #a33b31;
}

.gantt-supplier-cell-content.phase-attention strong {
  color: #63736a;
}

.gantt-supplier-cell-content .phase-date-button {
  justify-self: start;
  min-height: 26px;
  padding: 5px 8px;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 760;
}

.gantt-supplier-cell-content.empty {
  display: flex;
  align-items: center;
}

.job-menu {
  position: relative;
  height: 100%;
}

.po-cell-content {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100%;
}

.job-menu summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  height: 100%;
  min-height: 68px;
  padding: 11px 12px;
  cursor: pointer;
  list-style: none;
}

.job-menu summary::-webkit-details-marker {
  display: none;
}

.job-menu summary span {
  display: grid;
  gap: 3px;
}

.job-menu summary strong {
  color: var(--ink);
  font-size: 15px;
}

.job-menu summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.job-menu summary em {
  min-width: 42px;
  padding: 5px 7px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand);
  font-size: 12px;
  font-style: normal;
  font-weight: 820;
  text-align: center;
}

.job-menu-panel {
  position: absolute;
  top: calc(100% - 4px);
  left: 10px;
  z-index: 8;
  display: grid;
  gap: 7px;
  width: min(420px, calc(100vw - 56px));
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13px;
}

.job-menu-panel strong {
  color: var(--ink);
}

.job-menu-panel button {
  justify-self: start;
  margin-top: 3px;
}

.finish-po-button {
  justify-self: start;
  min-width: 66px;
  min-height: 28px;
  margin: 0 8px 8px;
  padding: 5px 8px;
  background: #c9c5ba;
  color: #f8f6ef;
  font-size: 10px;
  letter-spacing: 0;
}

.finish-po-button:not(.ready) {
  background: #bdb8ad;
  color: #f8f6ef;
}

.finish-po-button.ready {
  background: var(--brand);
  color: #fff;
}

.finish-po-button.ready:hover {
  background: var(--brand-dark);
}

.finish-po-button:disabled {
  background: #bdb8ad;
  color: #f8f6ef;
  cursor: not-allowed;
  opacity: 0.78;
}

.finish-po-button:disabled:hover {
  background: #bdb8ad;
}

.gantt-week-cell {
  position: relative;
  min-height: 42px;
  background: linear-gradient(90deg, #fff 0%, #fff 50%, #f7f7f5 50%, #f7f7f5 100%);
}

.gantt-week-cell.company-closed {
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(120, 116, 105, 0.12) 0,
      rgba(120, 116, 105, 0.12) 6px,
      rgba(255, 255, 255, 0.3) 6px,
      rgba(255, 255, 255, 0.3) 12px
    ),
    #e4e1d8;
}

.gantt-week-cell.company-closed.active span {
  opacity: 0.4;
}

.gantt-week-cell.active span {
  position: absolute;
  inset: 14px -1px 14px -1px;
  min-width: 10px;
  border-radius: 0;
  box-shadow: inset 0 -1px 0 rgba(31, 36, 33, 0.12);
}

.gantt-week-cell.priority-target i {
  position: absolute;
  inset: 5px auto 5px 50%;
  width: 4px;
  transform: translateX(-50%);
  background: #c84f45;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(200, 79, 69, 0.18);
  z-index: 3;
}

.gantt-week-cell.priority-target::after {
  content: "P";
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  background: #c84f45;
  border-radius: 999px;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  z-index: 4;
}

.gantt-week-cell.active.bar-start span {
  left: 8px;
  border-radius: 999px 0 0 999px;
}

.gantt-week-cell.active.bar-end span {
  right: 8px;
  border-radius: 0 999px 999px 0;
}

.gantt-week-cell.active.bar-start.bar-end span {
  border-radius: 999px;
}

.gantt-week-cell.good span {
  background: #6fb7d4;
}

.gantt-week-cell.warning span {
  background: #f0a23a;
}

.gantt-week-cell.neutral span {
  background: #83c469;
}

.gantt-week-cell.late span {
  background: #d95a55;
}

.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 2px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.gantt-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gantt-legend i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-scheduled {
  background: #6fb7d4;
}

.legend-attention {
  background: #f0a23a;
}

.legend-late {
  background: #d95a55;
}

.legend-closed {
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(120, 116, 105, 0.55) 0,
      rgba(120, 116, 105, 0.55) 3px,
      rgba(228, 225, 216, 1) 3px,
      rgba(228, 225, 216, 1) 6px
    );
}

.empty {
  padding: 28px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-filter-bar button {
  background: #ece7dc;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
}

.history-filter-bar button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
}

.history-item > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.history-item strong {
  font-size: 16px;
}

.history-item span,
.history-item p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

@media (max-width: 980px) {
  .editor-panel {
    align-items: flex-start;
  }

  .stock-page {
    grid-template-columns: 1fr;
    padding-left: clamp(18px, 4vw, 32px);
  }

  .stock-categories {
    max-height: 182px;
    overflow: hidden;
    padding-right: 0;
    font-size: clamp(34px, 11vw, 62px);
  }

  .stock-content {
    padding-top: 22px;
  }

  .production-program-body {
    grid-template-columns: 1fr;
  }

  .production-program-selection {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body {
    background: #f7f5f0;
  }

  .authenticated {
    padding-top: 238px;
  }

  .login-screen {
    align-items: stretch;
    padding: 14px;
  }

  .login-panel {
    align-self: center;
    padding: 18px;
  }

  .team-login-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .job-top,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 14px;
    padding: 14px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .team-session {
    justify-content: space-between;
  }

  .tabs,
  .tabs a,
  .section-head button,
  .actions button {
    width: 100%;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tabs a {
    padding: 10px 8px;
    font-size: 13px;
    text-align: center;
  }

  .app-shell {
    padding: 16px 12px 28px;
  }

  .stock-mode .app-shell {
    padding: 0;
  }

  .stock-page {
    min-height: calc(100vh - 74px);
    padding: 22px 12px 16px;
  }

  .stock-toolbar,
  .stock-row {
    grid-template-columns: 1fr;
  }

  .stock-access-note {
    padding-bottom: 0;
    text-align: left;
  }

  .stock-row {
    gap: 7px;
    padding: 8px 0;
  }

  .stock-row-title span {
    font-size: 19px;
  }

  .stock-row select {
    width: 100%;
  }

  .stock-admin-row {
    grid-template-columns: 1fr;
  }

  .stock-admin-row button {
    width: 100%;
  }

  .section-head {
    gap: 10px;
  }

  .stats,
  .details,
  .field-grid,
  .time-grid,
  .production-filter-bar,
  .production-program-bar,
  .logistics-filter-bar,
  .analysis-filter-actions,
  .production-phase-checks,
  .supplier-grid,
  .article-row {
    grid-template-columns: 1fr;
  }

  .logistics-filter-bar {
    display: grid;
  }

  .stats,
  .stats.logistics-stats,
  .stats.program-stats,
  .stats.archive-year-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 12px;
  }

  .production-program-button {
    grid-column: auto;
    width: 100%;
  }

  .stat strong {
    font-size: 24px;
  }

  .job-card {
    padding: 14px;
    gap: 10px;
  }

  .job-actions {
    justify-content: stretch;
  }

  .job-actions button {
    flex: 1 1 130px;
  }

  .meta {
    gap: 6px;
  }

  .logistics-procedures {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }

  .logistics-procedures label {
    min-height: 42px;
  }

  .editor-panel {
    padding: 10px;
  }

  .editor-panel form {
    padding: 14px;
  }

  .form-head {
    align-items: flex-start;
  }

  .supplier-grid {
    grid-template-columns: 1fr 1fr;
  }

  .article-row button {
    width: 100%;
  }

  .gantt-board {
    padding: 10px;
    margin-inline: -4px;
  }

  .gantt-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-footer {
    padding: 12px;
  }

  .history-item > div {
    flex-direction: column;
  }

  .history-filter-bar button {
    flex: 1 1 140px;
  }

  .production-sort-direction {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
