:root {
  color-scheme: light;
  --ink: #15171c;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --surface: #f4f6f8;
  --soft: #edf1f5;
  --blue: #2457a6;
  --blue-dark: #173e7a;
  --green: #148261;
  --red: #c14343;
  --yellow: #b7791f;
  --radius: 8px;
  --shadow: 0 12px 28px rgba(16, 24, 40, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--surface);
  color: var(--ink);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #11161f;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.login-brand {
  color: var(--ink);
  border-bottom-color: var(--line);
  padding: 0 0 16px;
  margin-bottom: 16px;
}

.login-brand span {
  color: var(--muted);
}

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

.login-error {
  margin: 0 0 12px;
  color: var(--red);
  font-weight: 800;
}

.logout-link {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  text-decoration: none;
}

.standalone-page {
  max-width: 1180px;
  margin: 0 auto;
}

.narrow-page {
  max-width: 720px;
}

.user-grid {
  grid-template-columns: minmax(280px, 0.7fr) minmax(420px, 1.3fr);
}

.notice {
  margin: 0 0 14px;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 800;
}

.notice.success {
  background: #e5f5ef;
  color: var(--green);
}

.notice.danger {
  background: #ffe7e7;
  color: var(--red);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #11161f;
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #f2f4f7;
  color: #11161f;
  border-radius: var(--radius);
  font-weight: 800;
}

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

.brand span {
  margin-top: 2px;
  color: #b9c0cc;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #dce2ea;
  text-align: left;
  padding: 0 10px;
}

.nav-item span:first-child {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: #9fb5d6;
}

.nav-item:hover,
.nav-item.active {
  background: #253143;
  color: #fff;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.panel p,
.live-summary p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.search {
  display: grid;
  grid-template-columns: 28px minmax(180px, 320px);
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
}

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

.search input,
label input,
label select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

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

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

.secondary-button {
  color: var(--ink);
  background: var(--soft);
  border-color: var(--line);
}

.table-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--blue);
  padding: 0 10px;
  font-weight: 800;
}

.table-button:hover {
  background: var(--soft);
}

.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.danger-action {
  color: var(--red);
}

.danger-action:hover {
  background: #ffe7e7;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--soft);
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.stat-card {
  min-height: 112px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  font-size: 30px;
  line-height: 1;
}

.stat-card small {
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

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

.panel-header.split {
  align-items: center;
}

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

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

.product-table {
  min-width: 1220px;
}

.product-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.filter-reset {
  align-self: end;
}

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

.quick-item,
.empty-preview {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 10px;
}

.quick-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
}

.quick-item:hover {
  border-color: #9fb5d6;
  background: #f6f9fd;
}

.quick-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #11161f;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.quick-photo {
  width: 38px;
  height: 50px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.quick-item strong,
.quick-item small,
.empty-preview strong,
.empty-preview span {
  display: block;
}

.quick-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-item small,
.empty-preview span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.empty-preview {
  grid-column: 1 / -1;
}

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

td small {
  display: block;
  max-width: 280px;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.ok {
  background: #e5f5ef;
  color: var(--green);
}

.status.warn {
  background: #fff3d6;
  color: var(--yellow);
}

.status.danger {
  background: #ffe7e7;
  color: var(--red);
}

.activity-list,
.live-product-list {
  display: grid;
  gap: 10px;
}

.activity-item,
.live-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.activity-item strong,
.activity-item span,
.live-item strong,
.live-item span {
  display: block;
}

.activity-item span,
.live-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

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

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

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

.photo-ai-module {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.photo-drop {
  display: grid;
  gap: 10px;
  align-content: start;
}

.photo-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-actions span {
  color: var(--muted);
  font-size: 13px;
}

.photo-preview {
  width: 110px;
  aspect-ratio: 5 / 7;
  border: 1px dashed #9aa7b8;
  border-radius: var(--radius);
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
}

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

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

label input,
label select,
label textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 10px;
  color: var(--ink);
  font-weight: 500;
}

label input[type="file"] {
  padding: 8px 10px;
}

label textarea {
  min-height: 88px;
  padding: 10px;
  resize: vertical;
}

.form-submit {
  align-self: end;
}

.label-layout,
.live-board {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1fr);
  gap: 18px;
}

.label-form {
  display: grid;
  gap: 12px;
  align-content: start;
}

.label-preview {
  min-height: 260px;
  border: 1px dashed #9aa7b8;
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  align-content: start;
  justify-content: start;
  gap: 10px;
  background: #fbfcfd;
}

.print-label {
  width: 4cm;
  height: 3cm;
  border: 2px solid #11161f;
  border-radius: 3px;
  background: #fff;
  padding: 2mm;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1mm;
  overflow: hidden;
  color: #11161f;
}

.label-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2mm;
  min-width: 0;
}

.label-topline strong,
.label-topline span {
  font-size: 6.6pt;
  line-height: 1;
  white-space: nowrap;
}

.label-name {
  display: block;
  font-size: 7.2pt;
  line-height: 1.05;
  max-height: 15pt;
  overflow: hidden;
}

.label-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13mm;
  gap: 1.5mm;
  min-height: 0;
}

.label-copy {
  display: grid;
  align-content: start;
  gap: 0.4mm;
  min-width: 0;
}

.label-copy span,
.print-label small {
  color: #303640;
  font-size: 4.6pt;
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.print-label small {
  display: block;
  color: #596170;
}

.qr-code {
  width: 13mm;
  height: 13mm;
  align-self: end;
  background:
    linear-gradient(90deg, #11161f 25%, transparent 25% 50%, #11161f 50% 75%, transparent 75%) 0 0 / 4mm 4mm,
    linear-gradient(#11161f 25%, transparent 25% 50%, #11161f 50% 75%, transparent 75%) 0 0 / 4mm 4mm,
    #fff;
  border: 1px solid #11161f;
}

.barcode {
  height: 42px;
  background: repeating-linear-gradient(
    90deg,
    #11161f 0 3px,
    #fff 3px 6px,
    #11161f 6px 8px,
    #fff 8px 12px
  );
}

.live-summary {
  min-height: 210px;
  border-radius: var(--radius);
  background: #11161f;
  color: #fff;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.live-summary span {
  color: #c8d3e3;
}

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

.shop-card {
  min-height: 150px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

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

.shop-card span {
  color: var(--muted);
}

.shop-meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.shop-meter div {
  height: 100%;
  background: var(--green);
}

dialog {
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  box-shadow: 0 28px 80px rgba(16, 24, 40, 0.24);
}

dialog::backdrop {
  background: rgba(17, 22, 31, 0.48);
}

.dialog-card {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 18px;
  background: #fff;
}

.dialog-submit {
  width: 100%;
  margin-top: 14px;
}

@media (max-width: 1100px) {
  .stats-grid,
  .shop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-filters,
  .quick-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .label-layout,
  .live-board {
    grid-template-columns: 1fr;
  }

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px;
  }

  .brand {
    padding-bottom: 10px;
  }

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

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    min-height: 52px;
    font-size: 12px;
  }

  .workspace {
    padding: 16px;
  }

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

  .search {
    grid-template-columns: 28px 1fr;
  }

  .stats-grid,
  .shop-grid,
  .product-filters,
  .quick-preview,
  .photo-ai-module,
  .form-grid,
  .form-grid.compact,
  .form-grid.product-details {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }
}
