:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #d9e1e8;
  --line-strong: #b7c3cf;
  --nav: #101828;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --accent: #b45309;
  --danger: #b91c1c;
  --success: #15803d;
  --warning: #b45309;
  --info: #1d4ed8;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), transparent 38%),
    linear-gradient(315deg, rgba(180, 83, 9, 0.08), transparent 42%),
    #f7fafc;
}

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

.login-brand,
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand {
  margin-bottom: 22px;
}

.login-brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.login-brand p {
  margin: 5px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--nav);
  color: #f8fafc;
}

.brand {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #14b8a6;
  color: #06221f;
  font-weight: 900;
}

.brand-mark.large {
  width: 48px;
  height: 48px;
  font-size: 24px;
}

.brand-title {
  font-size: 16px;
  font-weight: 850;
}

.brand-subtitle {
  color: #aeb9c8;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 12px 10px;
}

.nav-item {
  min-height: 39px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  padding: 0 12px;
  text-align: left;
}

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

.nav-item.active {
  background: #ecfeff;
  color: var(--brand);
  font-weight: 800;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.current-user {
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.sync-state {
  color: #aeb9c8;
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.2;
}

.topbar p,
.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.topbar-actions,
.button-row,
.dialog-actions,
.settings-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.file-button,
.icon-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 13px;
  white-space: nowrap;
}

.primary-button {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

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

.secondary-button,
.file-button,
.icon-button {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--text);
}

.secondary-button:hover,
.file-button:hover,
.icon-button:hover {
  background: var(--panel-soft);
}

.danger-button {
  border-color: #fecaca;
  background: #fff;
  color: var(--danger);
  font-weight: 800;
}

.icon-button {
  display: grid;
  width: 38px;
  padding: 0;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
}

.full {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric-card {
  min-height: 108px;
  padding: 15px;
}

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

.metric-card strong {
  display: block;
  margin-top: 9px;
  font-size: 28px;
  line-height: 1.1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  margin-bottom: 14px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.field {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

.field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.compact {
  width: 148px;
}

.search {
  width: min(320px, 100%);
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 750;
}

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

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

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

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

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

.upload-card {
  min-height: 154px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.upload-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.image-preview {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.dialog-preview {
  max-height: 260px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

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

.product-form > label,
.product-form > .button-row {
  padding: 0;
}

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

.score-strip > div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 11px;
}

.score-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-strip strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.profit-box {
  display: grid;
  gap: 10px;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  padding: 13px;
}

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

.profit-main > div {
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 7px;
  background: #fff;
  padding: 10px;
}

.profit-main span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.profit-main strong {
  display: block;
  margin-top: 5px;
  color: #0f766e;
  font-size: 22px;
}

.formula-line {
  overflow-wrap: anywhere;
  color: #134e4a;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.55;
}

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

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

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

th {
  background: var(--panel-soft);
  color: #475569;
  font-weight: 850;
}

td {
  color: #1f2937;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 9px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

.tag.warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--warning);
}

.tag.danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.tag.info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--info);
}

.todo-list,
.review-list,
.pipeline-list,
.inventory-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.todo-item,
.review-card,
.pipeline-card,
.daily-card,
.inventory-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
}

.todo-item {
  display: grid;
  gap: 8px;
}

.todo-item h3,
.review-card h3,
.pipeline-card h3,
.daily-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.todo-item p,
.review-card p,
.pipeline-card p,
.daily-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.meta-row,
.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions {
  margin-top: 10px;
}

.review-card {
  display: grid;
  gap: 10px;
}

.review-head,
.pipeline-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.review-metrics.rich {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.review-metrics div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 8px;
}

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

.review-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 11px;
}

.analysis-grid p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
}

.analysis-grid strong {
  color: #111827;
}

.score-detail,
.image-panel,
.listing-status,
.muted-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 11px;
}

.score-detail {
  display: grid;
  gap: 10px;
}

.score-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #334155;
  font-size: 13px;
}

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

.score-breakdown div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 8px;
}

.score-breakdown span,
.score-breakdown small {
  display: block;
}

.score-breakdown span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.score-breakdown strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.score-breakdown strong.plus {
  color: var(--success);
}

.score-breakdown strong.minus {
  color: var(--danger);
}

.score-breakdown small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

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

.image-panel.compact-images {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.image-tile,
.listing-shot {
  display: grid;
  gap: 7px;
  color: var(--text);
  text-decoration: none;
}

.image-tile img,
.listing-shot img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.compact-images .image-tile img {
  height: 110px;
}

.image-tile span,
.listing-shot span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.listing-status.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.listing-status strong,
.listing-status span {
  display: block;
}

.listing-status span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.listing-status p {
  margin-top: 6px;
}

.listing-shot img {
  height: 96px;
}

.inventory-card {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  gap: 14px;
}

.inventory-card.locked {
  border-color: #fecaca;
  background: #fffafa;
}

.inventory-media img,
.image-placeholder {
  width: 100%;
  height: 156px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.inventory-media img {
  object-fit: contain;
}

.image-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.inventory-body {
  display: grid;
  gap: 10px;
}

.inventory-note {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 9px;
}

.inventory-note p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.5;
}

.lock-log-list {
  display: grid;
  gap: 7px;
  border: 1px solid #fed7aa;
  border-radius: 7px;
  background: #fff7ed;
  padding: 9px;
}

.lock-log-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px 10px;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.4;
}

.lock-log-row strong {
  color: #7c2d12;
}

.lock-log-row small {
  grid-column: 2;
  color: #9a3412;
}

.compact-list .daily-card {
  display: grid;
  gap: 9px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.timeline-step {
  position: relative;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 8px;
}

.timeline-step.active {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: #0f766e;
}

.timeline-step.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

.timeline-step.blocked {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.timeline-step span {
  display: block;
  font-size: 12px;
  font-weight: 850;
}

.timeline-step small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.history {
  display: grid;
  gap: 6px;
  margin-top: 11px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.history-row {
  display: grid;
  grid-template-columns: 128px 110px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.module-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
  font-weight: 800;
}

.warehouse-dashboard {
  padding: 14px;
}

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

.warehouse-task-card,
.warehouse-inventory-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.warehouse-task-card span,
.warehouse-inventory-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.warehouse-task-card strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.warehouse-task-card p {
  margin: 7px 0 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}

.warehouse-inventory-list {
  display: grid;
  gap: 8px;
  background: #fff;
}

.warehouse-inventory-row {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.warehouse-inventory-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.24);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.dialog-card {
  display: grid;
  gap: 0;
  background: #fff;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

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

.dialog-header p {
  margin: 5px 0 0;
  color: var(--muted);
}

.dialog-actions {
  justify-content: flex-end;
  padding: 14px 18px 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 10px 13px;
  font-size: 13px;
  transition: 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 218px minmax(0, 1fr);
  }

  .kpi-grid,
  .score-strip,
  .profit-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-grid {
    grid-template-columns: 1fr;
  }

  .form-grid.three,
  .upload-grid,
  .review-metrics.rich {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .main {
    padding: 14px;
  }

  .topbar,
  .panel-header,
  .review-head,
  .pipeline-head {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
  }

  .compact,
  .topbar-actions .secondary-button {
    width: 100%;
  }

  .kpi-grid,
  .form-grid,
  .form-grid.three,
  .score-strip,
  .profit-main,
  .review-metrics,
  .review-metrics.rich,
  .analysis-grid,
  .upload-grid,
  .score-breakdown,
  .image-panel,
  .image-panel.compact-images,
  .listing-status,
  .timeline,
  .inventory-card,
  .module-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

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