:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --ink: #1c211c;
  --muted: #667066;
  --line: #d9ded8;
  --accent: #116149;
  --accent-2: #df7a23;
  --danger: #b3261e;
  --warning: #8a5a00;
  --ok: #136f3a;
  --shadow: 0 18px 50px rgba(23, 31, 23, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 10px 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.password-field {
  display: flex;
  gap: 8px;
  position: relative;
}

.password-field input {
  min-width: 0;
}

.password-toggle {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 42px;
  min-width: 52px;
  padding: 8px 10px;
  position: static;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

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

.hidden {
  display: none !important;
}

.auth-shell {
  align-items: center;
  display: grid;
  gap: 36px;
  grid-template-columns: minmax(0, 1fr) 390px;
  margin: 0 auto;
  max-width: 1040px;
  min-height: 100vh;
  padding: 32px;
}

.brand-block h1 {
  font-size: clamp(42px, 7vw, 84px);
  letter-spacing: 0;
  line-height: 0.95;
  margin: 8px 0 18px;
  max-width: 680px;
}

.brand-block p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
  max-width: 540px;
}

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

.login-card,
.panel-card,
.product-card,
.sale-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.login-card h2 {
  margin: 0;
}

.form-message {
  color: var(--danger);
  margin: 0;
  min-height: 20px;
}

.form-message.ok {
  color: var(--ok);
}

.setup-note {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
  padding: 10px 12px;
}

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

.sidebar {
  background: #18251f;
  color: #fff;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar h2 {
  margin: 6px 0 8px;
}

.sidebar p {
  color: #c9d3cb;
}

.sidebar #roleLabel {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sidebar nav {
  display: grid;
  align-content: start;
  gap: 8px;
  margin: 0;
}

.tab-button,
.ghost-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  text-align: left;
}

.tab-button.active {
  background: #fff;
  color: var(--ink);
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.workspace.compact-workspace {
  padding-top: 16px;
}

.topbar {
  display: none;
  align-items: end;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 4px 0 0;
}

.summary-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  min-width: min(640px, 100%);
}

.history-summary {
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  font-size: 22px;
  margin-top: 4px;
}

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

.panel-card {
  box-shadow: none;
  padding: 18px;
}

.panel-card h2,
.panel-card h3 {
  margin: 0 0 14px;
}

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

.section-header h2 {
  margin: 0;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.segmented-control button {
  background: var(--surface-2);
  color: var(--ink);
}

.segmented-control button.active {
  background: var(--accent);
  color: #fff;
}

.search-field {
  margin-bottom: 16px;
  max-width: 420px;
}

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

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

.product-form {
  display: grid;
  gap: 16px;
}

.size-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(64px, 1fr));
}

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

.photo-upload-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.photo-upload-card input[type="file"] {
  background: #fff;
  font-size: 12px;
  min-height: 38px;
  padding: 8px;
}

.photo-remove-button {
  min-height: 34px;
  padding: 7px 10px;
}

.photo-preview-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(8, minmax(82px, 1fr));
  margin-top: 12px;
}

.photo-preview {
  align-items: center;
  aspect-ratio: 1;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  place-items: center;
  text-align: center;
}

.photo-preview img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.product-list {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 320px));
  justify-content: start;
}

.product-card {
  box-shadow: none;
  overflow: hidden;
}

.product-photo {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}

.photo-button {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  display: block;
  height: 100%;
  min-height: 0;
  padding: 0;
  width: 100%;
}

.product-photo img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.product-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

.product-title h3 {
  margin: 0;
}

.product-name,
.product-style {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: 3px 0 0;
}

.product-name {
  color: var(--ink);
}

.pill,
.danger-pill,
.ok-pill,
.warning-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.pill {
  background: var(--surface-2);
  color: var(--muted);
}

.danger-pill {
  background: #fce8e6;
  color: var(--danger);
}

.ok-pill {
  background: #e5f4ea;
  color: var(--ok);
}

.warning-pill {
  background: #fff4d6;
  color: var(--warning);
}

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

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

.price-grid div {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 9px;
}

.price-grid span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 800;
}

.price-grid strong {
  display: block;
  margin-top: 3px;
}

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

.secondary-button {
  background: var(--surface-2);
  color: var(--ink);
}

.danger-button {
  background: var(--danger);
}

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

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

.low-stock-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.low-stock-row h3 {
  margin: 0;
}

.low-size-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
}

.low-size-cell {
  background: #fff4d6;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.low-size-cell.negative {
  background: #fce8e6;
  color: var(--danger);
}

.low-size-cell strong,
.low-size-cell span {
  display: block;
}

.low-size-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.mini-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--danger);
  font-size: 12px;
  margin-top: 8px;
  min-height: 30px;
  padding: 4px 8px;
}

.sale-row {
  align-items: center;
  box-shadow: none;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.2fr 0.6fr 0.6fr 0.8fr 0.8fr;
  padding: 12px;
}

.sale-row > div {
  min-width: 0;
}

.sale-row-ok {
  background: #f0fbf4;
  border-color: #bfe6cc;
}

.sale-row-warning {
  background: #fff8e6;
  border-color: #f0d99a;
}

.sale-row-under {
  background: #fff0f0;
  border-color: #f1b8b8;
}

.sale-extra {
  background: var(--surface-2);
  border-radius: 8px;
  grid-column: 1 / -1;
  padding: 10px 12px;
}

.sale-extra strong,
.sale-extra span {
  display: inline;
}

.sale-extra span {
  margin-right: 16px;
}

.sale-extra p {
  margin: 8px 0 0;
}

.sale-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
}

.price-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: -6px 0 0;
}

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

.bill-fields {
  align-content: start;
  display: grid;
  gap: 14px;
}

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

.bill-preview {
  align-self: start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 520px;
  overflow: hidden;
}

.empty-preview {
  color: var(--muted);
  display: grid;
  font-weight: 700;
  place-items: center;
}

.bill-preview-photo {
  background: var(--surface);
  border-radius: 6px;
  display: grid;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  place-items: center;
}

.bill-preview-photo img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.sale-row strong,
.sale-row span,
.sale-row em {
  display: block;
  overflow-wrap: anywhere;
}

.sale-row em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  margin-top: 2px;
}

.sale-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.sale-row .ok-pill,
.sale-row .danger-pill,
.sale-row .warning-pill {
  justify-content: center;
  max-width: 100%;
  text-align: center;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.photo-modal {
  align-items: center;
  background: rgba(11, 17, 13, 0.72);
  bottom: 0;
  display: grid;
  left: 0;
  padding: 22px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.photo-dialog {
  background: var(--surface);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-height: calc(100vh - 44px);
  max-width: 1180px;
  overflow: auto;
  padding: 18px;
  width: min(100%, 1180px);
}

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

.photo-header h2 {
  margin: 0;
}

.photo-detail-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
}

.photo-stage {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.photo-stage img {
  background: var(--surface-2);
  border-radius: 8px;
  cursor: zoom-in;
  max-height: 62vh;
  object-fit: contain;
  width: 100%;
}

.photo-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.photo-thumb {
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 8px;
  height: 72px;
  min-height: 72px;
  padding: 0;
  width: 72px;
}

.photo-thumb.active {
  border-color: var(--accent);
}

.photo-thumb img {
  border-radius: 6px;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.photo-product-detail {
  border-left: 1px solid var(--line);
  display: grid;
  gap: 18px;
  padding-left: 20px;
}

.photo-product-detail h3 {
  font-size: 30px;
  margin: 0;
}

.photo-product-detail .sizes {
  gap: 10px;
}

.photo-product-detail .pill,
.photo-product-detail .danger-pill {
  font-size: 14px;
  padding: 8px 12px;
}

.photo-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.full-photo-viewer {
  align-items: center;
  background: rgba(7, 10, 8, 0.94);
  bottom: 0;
  display: grid;
  left: 0;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 40;
}

.full-photo-viewer img {
  border-radius: 8px;
  cursor: zoom-out;
  height: 100%;
  max-height: calc(100vh - 36px);
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.full-photo-close {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 41;
}

.full-photo-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 41;
}

.full-photo-prev {
  left: 18px;
}

.full-photo-next {
  right: 18px;
}

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

  .auth-shell {
    align-content: center;
  }

  .sidebar {
    gap: 14px;
    height: auto;
    position: static;
    grid-template-rows: auto auto auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 10px 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-strip,
  .grid-2,
  .grid-3,
  .photo-grid,
  .photo-preview-grid {
    grid-template-columns: 1fr;
  }

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

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

  .bill-split-layout,
  .bill-small-grid {
    grid-template-columns: 1fr;
  }

  .bill-preview,
  .bill-preview-photo {
    min-height: 320px;
  }

  .photo-detail-layout,
  .photo-stage {
    grid-template-columns: 1fr;
  }

  .full-photo-nav {
    bottom: 18px;
    top: auto;
    transform: none;
  }

  .photo-product-detail {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 16px;
  }
}

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

  .sale-row {
    gap: 10px;
    grid-template-columns: minmax(120px, 1.1fr) minmax(52px, 0.45fr) minmax(52px, 0.45fr) minmax(90px, 0.7fr) minmax(130px, 0.9fr);
  }
}

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

@media (max-width: 560px) {
  .auth-shell,
  .workspace,
  .sidebar {
    padding: 18px;
  }

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

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .product-list {
    grid-template-columns: 1fr;
  }

  .product-card {
    width: 100%;
  }
}
