:root {
  --ink: #162029;
  --muted: #607080;
  --line: #d7dee5;
  --panel: #ffffff;
  --page: #f4f7f8;
  --blue: #1f6f9f;
  --green: #247a57;
  --amber: #a16207;
  --red: #b42318;
  --soft-blue: #e8f3f8;
  --soft-green: #e8f5ee;
  --shadow: 0 16px 36px rgba(24, 39, 52, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.35;
}

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

button {
  cursor: pointer;
}

.app-header {
  align-items: center;
  background: #132330;
  color: #fff;
  display: flex;
  justify-content: space-between;
  padding: 24px clamp(18px, 4vw, 48px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-block {
  align-items: center;
  display: flex;
  gap: 18px;
  min-width: 0;
}

.header-logo {
  display: block;
  height: auto;
  max-height: 42px;
  max-width: 158px;
  object-fit: contain;
  width: 158px;
}

.app-header h1,
.panel h2 {
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  letter-spacing: 0;
  margin: 0;
}

.eyebrow {
  color: #4b7286;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.app-header .eyebrow {
  color: #9fc2d4;
}

.header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-button,
.secondary-button {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 7px;
  display: inline-flex;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
}

.icon-button {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.secondary-button {
  background: var(--soft-blue);
  border-color: #bad8e8;
  color: #174963;
  font-weight: 700;
}

.primary-button {
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 7px;
  color: #fff;
  font-weight: 800;
  min-height: 42px;
  padding: 9px 14px;
}

.account-chip {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 9px 12px;
}

.hidden {
  display: none !important;
}

.store-tabs {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  padding: 12px clamp(14px, 3vw, 38px) 0;
}

.tab-button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px 7px 0 0;
  color: var(--muted);
  font-weight: 800;
  min-height: 42px;
  padding: 9px 14px;
}

.tab-button.active {
  background: var(--page);
  border-color: var(--line);
  border-bottom-color: var(--page);
  color: var(--ink);
}

.auth-screen {
  display: grid;
  min-height: calc(100vh - 88px);
  padding: 28px;
  place-items: center;
}

.auth-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 460px;
  padding: 24px;
  width: 100%;
}

.login-logo {
  display: block;
  height: auto;
  justify-self: center;
  margin: 0 auto 4px;
  max-width: min(320px, 100%);
  width: 78%;
}

.auth-panel h2 {
  font-size: 1.7rem;
  margin: 0;
}

.auth-panel p {
  color: var(--muted);
  margin: 0;
}

.auth-note {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.9rem;
  padding: 10px;
}

.admin-panel,
.store-plans-panel,
.admin-edit-bar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding: 18px clamp(14px, 3vw, 38px);
}

.admin-table,
.store-plans-table {
  min-width: 1260px;
}

.admin-actions {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(150px, 220px) minmax(120px, 160px) auto auto;
}

.admin-summary-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.admin-summary-card {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.admin-summary-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-summary-card strong {
  font-size: 1.55rem;
  line-height: 1;
}

.admin-edit-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.store-plan-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-table button,
.store-plans-table button {
  background: var(--soft-blue);
  border: 1px solid #bad8e8;
  border-radius: 6px;
  color: #174963;
  font-weight: 800;
  padding: 6px 10px;
}

.admin-table .danger-button,
.store-plans-table .danger-button {
  background: #fff2f0;
  border-color: #f2a29a;
  color: var(--red);
}

.planner {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1440px;
  padding: 22px clamp(14px, 3vw, 38px) 44px;
}

.summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.metric-card {
  border-top: 4px solid var(--blue);
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric-card span,
.stocking-band span,
label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  min-height: 18px;
}

.metric-card.over {
  border-top-color: var(--red);
}

.metric-card.under {
  border-top-color: var(--green);
}

.metric-card.needs-hours {
  border-top-color: var(--amber);
  background: #fff8e6;
}

.metric-card.needs-hours strong,
.metric-card.needs-hours small {
  color: var(--amber);
}

.panel {
  padding: 18px;
}

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

.field-grid,
.process-layout {
  display: grid;
  gap: 14px;
}

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

.process-layout {
  grid-template-columns: 1fr;
}

label,
.status-pill {
  display: grid;
  gap: 6px;
}

.status-pill {
  align-items: center;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  grid-template-columns: auto minmax(72px, 110px);
  padding: 8px 10px;
}

.section-note {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 8px 0 0;
  max-width: 760px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #c7d2dc;
  border-radius: 6px;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.locked-input {
  background: #edf3f6;
  color: #334756;
  cursor: not-allowed;
  font-weight: 800;
}

.time-selectors {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr 1fr;
}

textarea {
  resize: vertical;
}

.control-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 140px minmax(180px, 1fr) minmax(220px, 280px) 170px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  background: #edf3f6;
  font-weight: 800;
}

td input,
td select {
  border-color: transparent;
  border-radius: 4px;
  min-height: 34px;
}

td input:focus,
td select:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(31, 111, 159, 0.16);
}

.total-row th,
.total-row td,
tfoot th,
tfoot td {
  background: #f7fafb;
  font-weight: 800;
}

.variance-cell,
#totalVariance {
  font-weight: 800;
}

.positive {
  color: var(--red);
}

.negative {
  color: var(--green);
}

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

.caution {
  color: var(--amber);
}

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

.stocking-band div {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 14px;
}

.stocking-band strong {
  font-size: 1.5rem;
}

.stocking-band div.variance-caution {
  background: #fff8e6;
  border-color: #d69e2e;
}

.stocking-band div.variance-caution strong {
  color: var(--amber);
}

.stocking-band div.variance-over {
  background: #fff2f0;
  border-color: #f2a29a;
}

.stocking-band div.variance-over strong {
  color: var(--red);
}

.stocking-band div.variance-ok {
  background: var(--soft-green);
  border-color: #8cc7a8;
}

.stocking-band div.variance-ok strong {
  color: var(--green);
}

.remove-row {
  background: #fff5f3;
  border: 1px solid #f2b6ad;
  border-radius: 6px;
  color: var(--red);
  font-size: 1.2rem;
  height: 34px;
  line-height: 1;
  width: 34px;
}

.toast {
  background: #132330;
  border-radius: 8px;
  bottom: 20px;
  color: #fff;
  left: 50%;
  padding: 10px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 10;
}

@media (max-width: 980px) {
  .app-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-block {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .header-logo {
    max-width: 132px;
    width: 132px;
  }

  .summary-grid,
  .field-grid,
  .process-layout,
  .stocking-band {
    grid-template-columns: 1fr;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .admin-actions {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 160px);
    width: 100%;
  }

  .admin-actions .secondary-button {
    justify-content: center;
  }

  .admin-edit-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .store-tabs {
    align-items: stretch;
    flex-direction: column;
    padding-bottom: 12px;
  }

  .tab-button,
  .tab-button.active {
    border-radius: 7px;
    border-color: var(--line);
    text-align: left;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 15px;
  }

  .app-header {
    gap: 14px;
    padding: 14px;
    position: static;
  }

  .app-header h1 {
    font-size: 1.15rem;
  }

  .app-header .eyebrow {
    font-size: 0.65rem;
  }

  .header-logo {
    max-width: 110px;
    width: 110px;
  }

  .header-actions,
  .store-plan-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .icon-button,
  .secondary-button,
  .primary-button {
    justify-content: center;
    min-height: 44px;
    padding: 9px 10px;
    width: 100%;
  }

  .account-chip {
    grid-column: 1 / -1;
    text-align: center;
  }

  .auth-screen {
    min-height: auto;
    padding: 18px 12px;
  }

  .auth-panel {
    border-radius: 7px;
    padding: 18px;
  }

  .login-logo {
    max-width: 260px;
    width: 88%;
  }

  .admin-panel,
  .store-plans-panel,
  .admin-edit-bar {
    padding: 14px 12px;
  }

  .admin-actions {
    grid-template-columns: 1fr;
  }

  .admin-summary-grid,
  .summary-grid {
    gap: 10px;
  }

  .planner {
    gap: 12px;
    padding: 14px 12px 28px;
  }

  .panel {
    padding: 14px;
  }

  .control-row {
    grid-template-columns: 1fr;
  }

  .metric-card {
    padding: 14px;
  }

  .metric-card strong {
    font-size: 2rem;
  }

  input,
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }

  .status-pill {
    grid-template-columns: 1fr;
    width: 100%;
  }

  th,
  td {
    padding: 7px;
  }

  td input,
  td select {
    min-width: 94px;
  }

  .remove-row {
    height: 40px;
    width: 40px;
  }
}

@media print {
  @page {
    margin: 0.18in;
    size: letter landscape;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  html,
  body {
    background: #fff;
    font-size: 10px;
    line-height: 1.15;
    margin: 0;
  }

  .app-header,
  .no-print,
  .header-actions,
  .store-tabs,
  .store-plans-panel,
  #addRow {
    display: none !important;
  }

  .planner {
    display: grid;
    gap: 3px;
    max-width: none;
    padding: 0;
    width: 100%;
  }

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

  .metric-card {
    border-radius: 0;
    border-top-width: 2px;
    gap: 1px;
    min-height: auto;
    padding: 3px 4px;
  }

  .metric-card span,
  .stocking-band span,
  label span,
  .eyebrow {
    font-size: 7px;
    line-height: 1;
  }

  .metric-card strong {
    font-size: 18px;
  }

  .metric-card small {
    font-size: 7px;
    min-height: 0;
  }

  .panel,
  .metric-card {
    border-color: #777;
    box-shadow: none;
    break-inside: avoid;
  }

  .panel {
    border-radius: 0;
    padding: 4px;
  }

  .panel-heading {
    align-items: center;
    flex-direction: row;
    gap: 4px;
    margin-bottom: 3px;
  }

  .panel h2 {
    font-size: 12px;
  }

  .section-note {
    font-size: 8px;
    margin: 1px 0 0;
    max-width: none;
  }

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

  .process-layout {
    gap: 3px;
    grid-template-columns: 1fr 1fr;
  }

  .process-panel .panel-heading {
    border-bottom: 1px solid #999;
    padding-bottom: 2px;
  }

  .process-panel .panel-heading strong {
    font-size: 14px;
  }

  .control-row {
    gap: 5px;
    grid-template-columns: 58px 1fr 150px 96px;
    margin-bottom: 0;
  }

  .time-selectors {
    gap: 2px;
  }

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

  .stocking-band div {
    border-radius: 0;
    gap: 1px;
    padding: 3px;
  }

  .stocking-band strong {
    font-size: 14px;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  th,
  td {
    padding: 2px 3px;
  }

  th {
    font-size: 8px;
  }

  .carton-table input,
  .schedule-table input,
  .schedule-table select {
    min-height: 15px;
  }

  .schedule-table th,
  .schedule-table td {
    font-size: 8px;
    padding: 2px;
  }

  .schedule-table tbody tr {
    height: 18px;
  }

  input,
  select,
  textarea {
    background: transparent;
    border-color: transparent;
    min-height: 18px;
    padding: 0;
  }

  textarea {
    height: 28px;
  }

  .toast {
    display: none !important;
  }
}
