:root {
  color-scheme: light;
  --black: #080808;
  --near-black: #171717;
  --text: #1f1f1f;
  --muted: #6c6c6c;
  --line: #dedede;
  --soft-line: #ededed;
  --surface: #ffffff;
  --background: #f6f6f6;
  --panel: #fbfbfb;
  --success: #195f38;
  --error: #9f1f1f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 246, 246, 0.98)),
    var(--background);
}

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

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 16px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
}

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

.brand strong,
.brand small {
  display: block;
  line-height: 1.05;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  border-radius: 8px;
  font-weight: 650;
}

.nav-links a:hover {
  color: var(--black);
  background: #efefef;
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  color: var(--black);
  background: #f0f0f0;
  border: 1px solid #dadada;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(430px, 100%);
  padding: 32px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 30px;
}

.page-heading,
.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-heading h1,
.section-title h2,
.error-panel h1 {
  margin: 0;
  color: var(--black);
  letter-spacing: 0;
}

.page-heading h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.98;
}

.section-title h2 {
  font-size: 1.25rem;
}

.section-title.tight {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.flash,
.form-errors {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 650;
}

.flash-success {
  color: var(--success);
  border-color: rgba(25, 95, 56, 0.28);
  background: #f6fbf7;
}

.flash-error,
.form-errors {
  color: var(--error);
  border-color: rgba(159, 31, 31, 0.28);
  background: #fff8f8;
}

.form-errors p {
  margin: 0;
}

.form-errors p + p {
  margin-top: 6px;
}

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

.kpi,
.surface,
.entry-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
}

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

.kpi strong {
  color: var(--black);
  font-size: 2.8rem;
  line-height: 1;
}

.surface {
  padding: 22px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  margin-bottom: 18px;
}

.users-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

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

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

.dense-table {
  min-width: 820px;
}

th,
td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--soft-line);
  white-space: nowrap;
}

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

tfoot th {
  color: var(--black);
  border-bottom: 0;
  border-top: 1px solid var(--line);
}

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

.empty-cell {
  text-align: center;
}

.bar-list {
  display: grid;
  gap: 15px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 58px;
  align-items: center;
  gap: 12px;
}

.bar-row span,
.bar-row small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.bars {
  display: grid;
  gap: 5px;
}

.bars i,
.bars b {
  display: block;
  height: 9px;
  border-radius: 999px;
}

.bars i {
  background: var(--black);
}

.bars b {
  background: #8e8e8e;
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-black {
  background: var(--black);
}

.legend-gray {
  background: #8e8e8e;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.entry-card {
  padding: 16px;
  background: var(--panel);
}

.entry-card header,
.entry-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.entry-card header span,
.entry-card p {
  color: var(--muted);
}

.entry-card p {
  margin: 12px 0 0;
}

.entry-totals {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.entry-totals strong {
  color: var(--black);
}

.stage-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  background: #eeeeee;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  color: var(--black);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail-color {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.detail-color i {
  width: 18px;
  height: 18px;
  border: 1px solid #cfcfcf;
  border-radius: 999px;
}

.stack-form,
.production-form {
  display: grid;
  gap: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(220px, 1fr);
  align-items: end;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  color: var(--black);
  background: #fff;
  border: 1px solid #d2d2d2;
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(8, 8, 8, 0.1);
}

.weekday-preview {
  min-height: 46px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 9px 13px;
  background: #f7f7f7;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}

.weekday-preview span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.weekday-preview strong {
  color: var(--black);
  font-size: 0.98rem;
}

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

.production-grid section {
  padding: 18px;
  background: #f7f7f7;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}

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

.size-input input {
  min-height: 62px;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
}

.line-capture {
  display: grid;
  gap: 14px;
}

.line-items {
  display: grid;
  gap: 12px;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(190px, 1.1fr) minmax(150px, 0.8fr) minmax(92px, 0.45fr) minmax(120px, 0.55fr) 40px;
  align-items: end;
  gap: 12px;
  padding: 14px;
  background: #f7f7f7;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}

.color-preview {
  min-height: 46px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  column-gap: 10px;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid #d2d2d2;
  border-radius: 8px;
}

.color-preview i {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  border: 1px solid #cfcfcf;
  border-radius: 999px;
}

.color-preview span,
.color-preview small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-preview span {
  color: var(--black);
  font-weight: 800;
  line-height: 1;
}

.color-preview small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.remove-line {
  align-self: end;
  font-size: 1.35rem;
  line-height: 1;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.48);
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-dialog {
  width: min(520px, 100%);
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.confirm-dialog h2 {
  margin: 0 0 16px;
  color: var(--black);
  font-size: 1.35rem;
}

.confirm-list {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.confirm-line {
  display: grid;
  grid-template-columns: 24px 96px 1fr;
  align-items: center;
  gap: 10px;
  padding: 11px;
  background: #f7f7f7;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}

.confirm-line i {
  width: 22px;
  height: 22px;
  border: 1px solid #cfcfcf;
  border-radius: 999px;
}

.confirm-line span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.confirm-line strong {
  color: var(--black);
  font-size: 0.95rem;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.date-filter,
.form-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.date-filter label {
  min-width: 170px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--black);
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

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

.secondary-button {
  color: var(--black);
  background: #fff;
  border-color: #cfcfcf;
}

.primary-button:hover {
  background: var(--near-black);
}

.secondary-button:hover {
  background: #f0f0f0;
}

.compact {
  min-height: 38px;
  padding-inline: 14px;
  font-size: 0.9rem;
}

.error-panel {
  max-width: 620px;
  margin: 48px auto;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .nav-links {
    grid-column: 1 / -1;
    overflow-x: auto;
  }

  .kpi-grid,
  .split-layout,
  .production-grid,
  .form-row,
  .line-item {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 24px;
  }

  .topbar {
    padding: 12px;
    gap: 12px;
  }

  .logout-form span {
    display: none;
  }

  .page-heading,
  .section-title,
  .date-filter,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading h1 {
    font-size: 2.2rem;
  }

  .kpi {
    min-height: 110px;
  }

  .kpi strong {
    font-size: 2.25rem;
  }

  .bar-row {
    grid-template-columns: 82px 1fr;
  }

  .bar-row small {
    grid-column: 2;
  }

  .surface,
  .auth-panel {
    padding: 18px;
  }

  .confirm-line {
    grid-template-columns: 24px 1fr;
  }

  .confirm-line strong {
    grid-column: 1 / -1;
  }

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