:root {
  --bg: #f7f4ee;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #25221d;
  --muted: #756f66;
  --line: #ded8ce;
  --brand: #0d766e;
  --brand-dark: #07544f;
  --accent: #b64036;
  --gold: #c38a1e;
  --green: #2f7a4f;
  --blue: #315f8f;
  --shadow: 0 18px 48px rgba(57, 47, 35, 0.12);
}

.auth-screen {
  display: grid;
  grid-column: 1 / -1;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(13, 118, 110, 0.1), transparent 360px),
    var(--bg);
}

.auth-panel,
.setup-panel {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.setup-panel {
  width: min(100%, 860px);
}

.auth-panel h1,
.setup-panel h1 {
  margin: 4px 0 10px;
  font-size: 28px;
  line-height: 1.15;
}

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

.stacked-form,
.grid-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

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

.grid-form.flat {
  margin: 0;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.toolbar input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  font-weight: 500;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input[readonly] {
  color: var(--muted);
  background: #f4f1ea;
}

.full-span {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.secondary-button,
.secondary-link {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 13px;
  color: var(--text);
  background: #fff;
  text-decoration: none;
}

.secondary-button:hover,
.secondary-link:hover {
  color: var(--brand-dark);
  background: #f4f1ea;
}

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

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
  text-decoration: none;
  font-weight: 800;
}

.form-switch {
  margin: 16px 0 0;
  color: var(--muted);
}

.form-switch a {
  color: var(--brand-dark);
  font-weight: 800;
}

.notice {
  border-radius: 8px;
  padding: 11px 13px;
  font-weight: 800;
}

.notice.error,
.inline-warning {
  border: 1px solid rgba(182, 64, 54, 0.35);
  color: #7a241d;
  background: #fff0ee;
}

.notice.success {
  border: 1px solid rgba(47, 122, 79, 0.3);
  color: #205537;
  background: #edf8f1;
}

.inline-warning {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 11px 13px;
  font-weight: 800;
}

.toolbar {
  margin-bottom: 14px;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.helper-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 8px;
  min-height: 210px;
  align-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.55);
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  color: var(--muted);
}

.calculation-card,
.detail {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.calculation-card span,
.detail span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calculation-card strong,
.detail strong {
  font-size: 20px;
}

.recipe-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.line-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.compact-header {
  padding: 0;
}

.recipe-line {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(110px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.totals-panel {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.total-row.strong {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 10px;
  color: var(--text);
  font-size: 18px;
}

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

.issue-columns {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.issue-columns span {
  min-height: 48px;
  border-right: 1px solid var(--line);
  padding: 14px;
  color: var(--muted);
  font-weight: 800;
  background: #fff;
}

button:disabled,
.button-link[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

@media (max-width: 980px) {
  .grid-form,
  .recipe-layout,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .totals-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .recipe-line {
    grid-template-columns: 1fr 1fr;
  }

  .recipe-line button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar-actions {
    width: 100%;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions button,
  .form-actions a {
    justify-content: center;
    width: 100%;
  }

  .recipe-line {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(13, 118, 110, 0.08), transparent 360px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--brand-dark);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

#app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 16px;
  color: #fff;
  background: #123f3d;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #123f3d;
  background: #f6cf72;
  font-weight: 900;
}

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

.brand span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 34px 18px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 30px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  display: grid;
  width: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
}

.account-chip {
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.account-chip strong,
.account-chip span {
  display: block;
}

.account-chip span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.content {
  display: grid;
  gap: 18px;
  padding: 0 34px 40px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.kpi-grid.compact {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.kpi,
.panel,
.kanban-column {
  border: 1px solid rgba(222, 216, 206, 0.9);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 128px;
  padding: 18px;
}

.kpi span,
.kpi small {
  display: block;
  color: var(--muted);
}

.kpi strong {
  display: block;
  margin: 10px 0;
  font-size: 30px;
  line-height: 1;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.wide {
  grid-column: span 2;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-header a,
.panel-header span {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.two-col,
.module-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.module-grid {
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
}

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

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

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td small {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  color: #453f36;
  background: #ece5d9;
  font-size: 12px;
  font-weight: 800;
}

.pill.good {
  color: #115a35;
  background: #dff1e6;
}

.pill.warning {
  color: #73500a;
  background: #f7e7bd;
}

.pill.danger {
  color: #873027;
  background: #f4d2ce;
}

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

.timeline-item,
.calendar-event,
.po-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.timeline-item time,
.calendar-event time {
  min-width: 96px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.timeline-item strong,
.timeline-item span,
.calendar-event strong,
.calendar-event span,
.po-card strong,
.po-card span {
  display: block;
}

.timeline-item span,
.calendar-event span,
.po-card span,
.muted,
.empty {
  color: var(--muted);
}

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

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

.usage div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.usage span,
.usage small {
  color: var(--muted);
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadfce;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

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

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

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

.supplier-card,
.task-card {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.supplier-card span,
.supplier-card small,
.task-card span,
.task-card small {
  color: var(--muted);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.metric-row span,
.metric-row strong {
  display: block;
}

.metric-row span {
  color: var(--muted);
  font-size: 12px;
}

.product-card {
  display: grid;
  gap: 12px;
}

.price-lockup {
  padding: 16px;
  border-radius: 8px;
  color: #fff;
  background: #1f5753;
}

.price-lockup span,
.price-lockup strong {
  display: block;
}

.price-lockup strong {
  margin-top: 4px;
  font-size: 32px;
}

.breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.breakdown div {
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.breakdown span {
  color: var(--muted);
  font-size: 12px;
}

.supplier-groups {
  display: grid;
  gap: 18px;
}

.supplier-groups h3 {
  margin: 0 0 8px;
}

.po-card {
  align-items: center;
  margin-bottom: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row button:nth-child(2n) {
  background: var(--blue);
}

.button-row button:nth-child(3n) {
  background: var(--gold);
}

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

.checklist label {
  display: flex;
  align-items: center;
  color: var(--text);
  font-weight: 500;
}

.checklist input {
  width: auto;
  min-height: auto;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  overflow: auto;
}

.kanban-column {
  min-height: 420px;
  padding: 14px;
}

.kanban-column h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.calendar-list {
  display: grid;
  gap: 10px;
}

.calendar-event {
  justify-content: flex-start;
  border-left: 5px solid var(--brand);
}

.calendar-event.production {
  border-left-color: var(--gold);
}

.calendar-event.stock {
  border-left-color: var(--blue);
}

@media (max-width: 1100px) {
  #app {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .brand div:last-child,
  .nav-item span {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

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

  .two-col,
  .module-grid,
  .cards {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  #app {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .topbar {
    display: grid;
    padding: 20px 16px 14px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .account-chip {
    min-width: 0;
    flex: 1;
  }

  .content {
    padding: 0 16px 28px;
  }

  .kpi-grid,
  .kpi-grid.compact,
  .usage-grid,
  .breakdown,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .kanban-board {
    grid-template-columns: repeat(4, 240px);
  }

  .po-card,
  .timeline-item {
    display: grid;
  }
}
