:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --line: #d9dee7;
  --text: #17202a;
  --muted: #687385;
  --primary: #176b87;
  --primary-dark: #10516a;
  --accent: #5d7c2f;
  --danger: #b42318;
  --warning: #a15c07;
  --shadow: 0 10px 28px rgba(24, 33, 47, 0.08);
  --sidebar-width: 232px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 120;
  width: var(--sidebar-width);
  max-width: 100%;
  border-right: 1px solid var(--line);
  background: #202a35;
  color: #fff;
  padding: 22px 16px;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -5px;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resize-handle::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  margin-bottom: 28px;
}

.brand strong {
  display: grid;
  place-items: center;
  width: 40px;
  height: 32px;
  border-radius: 6px;
  background: #e7f2ed;
  color: #163328;
  font-size: 15px;
}

.brand span {
  font-size: 18px;
  font-weight: 700;
}

.system-shortcuts {
  width: 100%;
  margin: 0;
}

.system-shortcuts summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: #c8d1dc;
  font-size: 14px;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
  background: transparent;
}

.system-shortcuts summary::-webkit-details-marker {
  display: none;
}

.system-shortcuts summary::after {
  content: "^";
  font-size: 13px;
}

.system-shortcuts summary:hover,
.system-shortcuts[open] summary {
  background: #31404e;
  color: #fff;
}

.system-shortcuts[open] summary::after {
  transform: rotate(180deg);
}

.system-shortcut-list {
  display: grid;
  gap: 2px;
  margin: 4px 0 4px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #111c28;
}

.system-shortcut-list a,
.system-shortcut-list .pending-link {
  display: flex;
  align-items: center;
  min-height: 32px;
  border-radius: 6px;
  padding: 0 8px;
  color: #d8e4ee;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.system-shortcut-list .pending-link {
  color: #8ea0af;
  cursor: default;
}

.system-shortcut-list a:hover {
  background: #31404e;
  color: #fff;
}

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

.nav-item {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c8d1dc;
  text-align: left;
  padding: 0 12px;
  font-weight: 700;
}

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

.app {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 24px;
  max-width: calc(100% - var(--sidebar-width));
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.topbar-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sync-badge.server {
  border-color: #b7d7c6;
  background: #edf8f2;
  color: #16683f;
}

.sync-badge.error {
  border-color: #f2c4bf;
  background: #fff6f5;
  color: var(--danger);
}

.hidden-file {
  display: none;
}

.hidden {
  display: none !important;
}

.auth-screen,
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #f7f9fb;
  padding: 18px;
  overflow: auto;
}

.auth-screen {
  z-index: 80;
}

.modal {
  z-index: 200;
  background: rgba(18, 28, 38, 0.54);
}

.auth-panel {
  display: grid;
  gap: 12px;
  width: min(380px, 100%);
}

.auth-card,
.modal-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.auth-card h1 {
  margin: 0;
  font-size: 22px;
}

.auth-card > strong {
  display: grid;
  place-items: center;
  width: 44px;
  height: 34px;
  border-radius: 6px;
  background: #202a35;
  color: #fff;
}

.auth-card p,
.backup-actions span {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.auth-request {
  display: grid;
  gap: 4px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-request strong {
  color: var(--text);
  font-size: 14px;
}

.modal-card {
  width: min(920px, 100%);
  max-height: 86vh;
  overflow: hidden;
}

.guide-card {
  width: min(980px, 100%);
}

.guide-content {
  display: grid;
  gap: 16px;
  max-height: min(72vh, 720px);
  overflow: auto;
  padding: 18px;
}

.guide-content section {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid #edf0f4;
  padding-bottom: 14px;
}

.guide-content section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.guide-content h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.guide-content p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.backup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
  white-space: nowrap;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

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

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  border: 1px solid #f2c4bf;
  background: #fff6f5;
  color: var(--danger);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
  align-items: start;
}

.filters,
.metric-grid,
.content-grid,
.import-box {
  display: grid;
  gap: 14px;
}

.filters {
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(23, 107, 135, 0.16);
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.compact-metrics {
  padding: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.15;
}

.metric-link {
  display: block;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.metric-link:hover,
.metric-link:focus {
  color: var(--primary);
}

.metric.accent strong {
  color: var(--accent);
}

.metric.accent .metric-link {
  color: var(--accent);
}

#dashboardView .filters {
  display: inline-flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  inline-size: fit-content;
  max-inline-size: 100%;
}

#dashboardView .filters label {
  gap: 4px;
}

#dashboardView .filters input,
#dashboardView .filters select {
  min-height: 32px;
  padding: 0 8px;
}

#dashboardView .filters .check-label {
  min-height: 32px;
  align-self: end;
}

.content-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  align-items: start;
}

.panel {
  position: relative;
  min-width: min(100%, 320px);
  min-height: 140px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: auto;
}

.panel.resizable-panel,
.panel.user-resizable-panel {
  min-width: min(100%, 320px);
}

body.layout-resizing,
body.panel-layout-resizing {
  cursor: col-resize;
  user-select: none;
}

.panel-resize-handle {
  position: absolute;
  z-index: 5;
  border: 1px solid rgba(23, 107, 135, 0.28);
  border-radius: 999px;
  background: #ffffff;
  color: #176b87;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.panel:hover .panel-resize-handle,
.panel.panel-is-resizing .panel-resize-handle {
  opacity: 1;
}

.panel-resize-handle-bottom {
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  min-width: 42px;
  height: 20px;
  cursor: ns-resize;
}

.panel-resize-handle-right {
  top: 50%;
  right: 5px;
  transform: translateY(-50%) rotate(90deg);
  min-width: 42px;
  height: 20px;
  cursor: ew-resize;
}

.panel-resize-handle-left {
  top: 50%;
  left: 5px;
  transform: translateY(-50%) rotate(-90deg);
  min-width: 42px;
  height: 20px;
  cursor: ew-resize;
}

.panel-resize-handle:hover,
.panel-is-resizing .panel-resize-handle {
  background: #e8f8f7;
  border-color: rgba(23, 107, 135, 0.55);
}

.panel-resize-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}

.panel-resize-tools button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 6px;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.panel-resize-tools button:hover {
  border-color: #176b87;
  color: #176b87;
  background: #e8f8f7;
}

.panel-refresh-button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
}

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 8px 0 0 0;
  background:
    linear-gradient(135deg, transparent 0 43%, rgba(23, 107, 135, 0.55) 44% 49%, transparent 50%),
    linear-gradient(135deg, transparent 0 61%, rgba(23, 107, 135, 0.45) 62% 67%, transparent 68%);
  cursor: nwse-resize;
  opacity: 0;
  z-index: 8;
}

.panel:hover > .resize-handle,
.panel.panel-is-resizing > .resize-handle {
  opacity: 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
  padding: 16px;
}

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

.form-grid label:has(input[required])::after,
.form-grid label:has(select[required])::after {
  content: "필수";
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
  border-radius: 999px;
  background: #fff1f2;
  color: #be123c;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
}

.inline-input-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.manual-sale-form {
  grid-template-columns: repeat(8, minmax(96px, 1fr));
  gap: 12px 10px;
  padding: 12px 16px 14px;
  align-items: end;
}

.manual-sale-form label,
.manual-sale-form .product-picker-field {
  position: relative;
  display: grid;
  gap: 5px;
  color: #344256;
  font-size: 12px;
  font-weight: 800;
}

.manual-sale-form label:has(input[required])::after,
.manual-sale-form label:has(select[required])::after {
  position: absolute;
  top: 0;
  right: 0;
  margin-top: 0;
  font-size: 10px;
  line-height: 1;
  padding: 2px 6px;
}

.manual-sale-form input,
.manual-sale-form select {
  min-height: 32px;
  border-radius: 6px;
  padding: 5px 9px;
}

.manual-sale-form .compact-field {
  grid-column: span 1;
}

.manual-sale-form .postcode-field {
  grid-column: span 1;
}

.manual-sale-form .address-field {
  grid-column: span 4;
}

.manual-sale-form .message-field {
  grid-column: span 2;
}

.manual-sale-form .product-picker-field {
  grid-column: span 4;
  grid-template-columns: minmax(170px, 0.9fr) minmax(260px, 1.1fr);
  gap: 5px 8px;
}

.manual-sale-form .product-picker-field .field-label {
  grid-column: 1 / -1;
}

.manual-sale-form .amount-field {
  grid-column: span 1;
}

.manual-sale-form .compact-action {
  grid-column: span 1;
  align-self: end;
}

.manual-sale-form .manual-items-wrap {
  grid-column: span 6;
  max-height: 150px;
  margin-top: 2px;
  overflow: auto;
}

.manual-sale-form .manual-items-wrap table th,
.manual-sale-form .manual-items-wrap table td {
  padding: 7px 10px;
}

.manual-sale-form .save-row {
  grid-column: span 1;
  align-self: end;
  justify-content: flex-end;
}

.manual-sale-form .save-row .primary-button,
.manual-sale-form .compact-action .ghost-button {
  width: 100%;
  min-height: 32px;
}

.compact-form {
  margin: 12px 0 16px;
}

.inline-input {
  width: 100%;
  min-width: 92px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
  background: #fff;
}

.wide-inline-input {
  min-width: 220px;
}

.issue-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.issue-tags span {
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.file-inline-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
}

.file-inline-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.import-box {
  grid-template-columns: minmax(280px, 1fr) minmax(220px, auto);
  align-items: center;
  padding: 16px;
}

.file-drop {
  min-height: 74px;
  border: 1px dashed #aeb9c8;
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
  color: var(--text);
}

.file-drop span {
  font-size: 15px;
}

.file-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.file-drop input {
  margin-top: 10px;
  padding: 7px;
  width: 100%;
  max-width: 100%;
}

.import-summary {
  display: grid;
  gap: 5px;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.import-summary strong {
  font-size: 20px;
}

.import-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.report-strip {
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 800;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}

.review-toolbar {
  padding: 0 0 0;
}

.bottom-toolbar {
  margin-top: 14px;
}

.reference-note {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.reference-note strong {
  color: var(--text);
  font-size: 15px;
}

.reference-note span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-summary {
  border-left: 0;
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

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

.form-hint {
  min-height: 22px;
  align-self: end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-hint.error {
  color: #b42318;
}

.form-hint.warning {
  color: var(--warning);
}

.selected-product-box {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px dashed #aeb9c8;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 800;
}

.selected-product-box.selected {
  border-style: solid;
  border-color: #b7d7c6;
  background: #edf8f2;
  color: #16683f;
}

.inline-warning {
  display: inline-flex;
  margin-left: 6px;
  border-radius: 999px;
  background: #fff3dc;
  color: var(--warning);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
}

.search-input {
  max-width: 320px;
}

.page-size-select {
  width: auto;
  min-width: 86px;
}

.page-info {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

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

th,
td {
  height: 38px;
  border-bottom: 1px solid #edf0f4;
  padding: 6px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td.numeric,
th.numeric {
  text-align: right;
}

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

.status.ok {
  background: #e8f5ee;
  color: #16683f;
}

.status.stop {
  background: #fff3dc;
  color: var(--warning);
}

.status.warn {
  background: #eef4ff;
  color: #315f99;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.small-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

#reviewView .panel {
  min-height: 0;
}

#reviewView.view.active {
  gap: 8px;
}

#reviewView .panel-head {
  min-height: 38px;
  padding: 4px 10px;
  align-items: center;
  flex-wrap: nowrap;
}

#reviewView .panel-head h2 {
  font-size: 16px;
}

#reviewView .topbar-actions {
  gap: 6px;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
}

#reviewView .search-input {
  max-width: 220px;
  min-height: 32px;
}

#reviewView .check-label {
  min-height: 30px;
  white-space: nowrap;
  font-size: 12px;
}

#reviewView .panel-refresh-button,
#reviewView .panel-resize-tools button {
  min-height: 24px;
  padding: 2px 6px;
  font-size: 10px;
}

#reviewView .panel-resize-tools {
  gap: 3px;
  flex-wrap: nowrap;
}

#reviewView .report-strip {
  padding: 4px 12px;
  font-size: 12px;
}

#reviewView .compact-form {
  margin: 0;
}

#reviewView .form-grid {
  gap: 6px;
  padding: 5px 12px;
}

#reviewView .table-wrap {
  max-height: calc(100vh - 184px);
}

#reviewView table {
  min-width: 1500px;
}

#reviewView th,
#reviewView td {
  padding: 3px 6px;
  height: 30px;
  font-size: 12px;
  vertical-align: middle;
}

#reviewView .inline-input {
  min-height: 26px;
  padding: 3px 6px;
  font-size: 12px;
}

#reviewView .review-toolbar {
  margin: 4px 0;
  padding: 0 12px;
  gap: 5px;
}

#reviewView .review-toolbar .small-button,
#reviewView .review-toolbar .ghost-button,
#reviewView .review-toolbar .primary-button,
#reviewView .review-toolbar select {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

#reviewAddProductForm.review-add-product-form {
  grid-template-columns: minmax(150px, 0.9fr) minmax(220px, 1.2fr) minmax(210px, 1fr) minmax(72px, 0.35fr) minmax(100px, 0.45fr) auto;
  align-items: end;
  border-top: 1px solid #edf0f4;
  border-bottom: 1px solid #edf0f4;
  background: #fbfcfe;
}

#reviewAddProductForm.review-add-product-form label {
  display: grid;
  gap: 3px;
  font-size: 12px;
  font-weight: 800;
  color: #344256;
}

#reviewAddProductForm.review-add-product-form input,
#reviewAddProductForm.review-add-product-form select {
  min-height: 28px;
  padding: 4px 8px;
}

#reviewAddProductForm.review-add-product-form .form-actions {
  align-self: end;
}

#reviewAddProductForm.review-add-product-form .primary-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  white-space: nowrap;
}

#reviewView .wms-customer-row td {
  height: 28px;
  padding: 4px 10px;
}

#reviewView th:nth-child(18),
#reviewView td:nth-child(18) {
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  white-space: nowrap;
}

#reviewView td:nth-child(18) {
  padding: 3px 4px;
}

#reviewView td:nth-child(18) .small-button {
  display: block;
  width: 64px;
  min-height: 22px;
  margin: 2px auto;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 20px;
  white-space: nowrap;
}

#reviewView .status {
  padding: 3px 7px;
  font-size: 11px;
  white-space: nowrap;
}

.small-button.danger {
  border-color: #f2c4bf;
  color: var(--danger);
}

.selected-row {
  outline: 2px solid rgba(23, 107, 135, 0.36);
  outline-offset: -2px;
  background: #f2f8fa;
}

.candidate-products-row td {
  background: #f8fbfc;
  border-top: 0;
}

.candidate-products {
  display: grid;
  gap: 8px;
}

.candidate-products > strong {
  font-size: 13px;
}

.candidate-product-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px;
}

.candidate-product-button {
  display: grid;
  gap: 3px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.candidate-product-button.score-high {
  border-color: #16a34a;
  background: #f0fdf4;
  box-shadow: inset 4px 0 0 #22c55e;
}

.candidate-product-button.score-mid {
  border-color: #60a5fa;
  background: #eff6ff;
  box-shadow: inset 4px 0 0 #3b82f6;
}

.candidate-product-button.score-low {
  border-color: #fed7aa;
  background: #fff7ed;
  box-shadow: inset 4px 0 0 #f97316;
}

.candidate-product-button span {
  font-size: 13px;
  font-weight: 800;
}

.candidate-product-button em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.candidate-product-button:hover {
  border-color: rgba(23, 107, 135, 0.45);
  background: #eef8fa;
}

.candidate-product-button.pending-selected {
  border-color: #176b87;
  background: #e8f8f7;
  box-shadow: inset 0 0 0 1px rgba(23, 107, 135, 0.25);
}

.score-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 900;
}

.score-badge.score-high {
  background: #dcfce7;
  color: #166534;
}

.score-badge.score-mid {
  background: #dbeafe;
  color: #1d4ed8;
}

.score-badge.score-low {
  background: #ffedd5;
  color: #9a3412;
}

.recommendation-row.score-high td {
  background: #f0fdf4;
}

.recommendation-row.score-mid td {
  background: #eff6ff;
}

.recommendation-row.score-low td {
  background: #fff7ed;
}

.mapping-save-bar-row td {
  background: #f5fbfb;
}

.mapping-save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
}

.wms-customer-row td {
  background: #eef8fa;
  border-top: 2px solid rgba(23, 107, 135, 0.2);
  color: var(--text);
}

.wms-customer-row strong {
  margin-right: 8px;
}

.wms-customer-row span,
.wms-customer-row em {
  margin-right: 8px;
  color: var(--muted);
  font-style: normal;
}

.compact-button {
  min-height: 32px;
  padding: 7px 12px;
}

.inline-empty {
  color: var(--muted);
  font-size: 13px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.check-label input {
  width: auto;
  min-height: auto;
}

.role-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.role-list p {
  color: var(--muted);
  line-height: 1.5;
}

.role-list strong {
  color: var(--text);
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  :root {
    --sidebar-width: 100%;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 120;
    width: 100%;
    padding: 14px;
    border-right: 0;
  }

  .auth-screen {
    align-items: start;
    padding-top: 360px;
  }

  .app {
    margin-left: 0;
    padding: 16px;
    width: 100%;
    max-width: 100%;
  }

  .sidebar-resize-handle {
    display: none;
  }

  .panel-resize-handle {
    display: none;
  }

  .panel-resize-tools,
  .resize-handle {
    display: none;
  }

  .panel {
    width: auto !important;
    height: auto !important;
    resize: none;
  }

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

  .content-grid,
  .metric-grid,
  .filters,
  .form-grid,
  .import-box {
    grid-template-columns: 1fr;
  }

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

  .manual-sale-form .compact-field,
  .manual-sale-form .postcode-field,
  .manual-sale-form .address-field,
  .manual-sale-form .message-field,
  .manual-sale-form .product-picker-field,
  .manual-sale-form .manual-items-wrap,
  .manual-sale-form .compact-action,
  .manual-sale-form .save-row {
    grid-column: 1 / -1;
  }

  .manual-sale-form .amount-field {
    grid-column: span 1;
  }

  #reviewAddProductForm.review-add-product-form {
    grid-template-columns: 1fr;
  }

  .import-summary {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
  }

  .topbar {
    display: grid;
  }
}

@media (max-width: 560px) {
  body {
    background: var(--surface);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 120;
    padding: 8px;
    overflow: hidden;
    transition: max-height 0.18s ease, padding 0.18s ease, box-shadow 0.18s ease;
  }

  .brand {
    height: 30px;
    margin-bottom: 8px;
    transition: height 0.18s ease, margin 0.18s ease, opacity 0.18s ease;
  }

  .brand strong {
    width: 34px;
    height: 28px;
    font-size: 13px;
  }

  .brand span {
    font-size: 15px;
  }

  .system-shortcuts {
    grid-column: 1 / -1;
    margin-bottom: 4px;
  }

  .system-shortcuts summary {
    height: 32px;
    font-size: 12px;
  }

  .system-shortcut-list {
    width: 100%;
    padding: 8px;
  }

  .nav {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
    transition: opacity 0.18s ease, max-height 0.18s ease;
  }

  .nav-item {
    min-width: 0;
    height: 38px;
    padding: 0 2px;
    text-align: center;
    font-size: 10px;
    line-height: 1.1;
    white-space: normal;
    word-break: keep-all;
  }

  .app {
    padding: 10px;
  }

  h1 {
    font-size: 19px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 12px;
    transition: padding 0.18s ease, margin 0.18s ease;
  }

  .topbar p {
    display: none;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    transition: opacity 0.18s ease, max-height 0.18s ease;
  }

  .topbar-actions > button,
  .topbar-actions > .sync-badge,
  .topbar-actions > select,
  .topbar-actions > input,
  .topbar-actions > .page-info,
  .form-actions > button {
    min-width: 0;
    width: 100%;
    justify-content: center;
    padding: 0 8px;
    font-size: 12px;
  }

  body.mobile-top-collapsed .sidebar {
    max-height: 48px;
    padding-top: 6px;
    padding-bottom: 6px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
  }

  body.mobile-top-collapsed .brand {
    height: 28px;
    margin-bottom: 0;
  }

  body.mobile-top-collapsed .system-shortcuts,
  body.mobile-top-collapsed .nav {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
  }

  body.mobile-top-collapsed .topbar {
    margin-bottom: 6px;
  }

  body.mobile-top-collapsed .topbar h1 {
    font-size: 16px;
  }

  body.mobile-top-collapsed .topbar-actions {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    gap: 0;
  }

  .manual-sale-form {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .manual-sale-form .amount-field {
    grid-column: 1 / -1;
  }

  .manual-sale-form .product-picker-field {
    grid-template-columns: 1fr;
  }

  #reviewView .panel-head,
  #reviewView .review-toolbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  #reviewView .table-wrap {
    max-height: none;
  }

  .search-input {
    max-width: none;
  }

  .guide-content {
    max-height: 76vh;
    padding: 14px;
  }

  .guide-content h3 {
    font-size: 14px;
  }

  .guide-content p {
    font-size: 13px;
    line-height: 1.58;
  }

  .panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
    width: 100% !important;
    max-width: 100%;
    resize: vertical;
  }

  .form-grid,
  .import-box {
    padding: 12px;
  }

  .file-drop {
    padding: 12px;
  }

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

  .search-input {
    max-width: none;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
  }

  .metric strong,
  .metric-link {
    font-size: 20px;
  }

  .metric {
    min-height: 74px;
    padding: 14px;
  }

  .table-wrap {
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  table {
    display: block;
    min-width: 0;
    width: 100%;
    border-collapse: separate;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  tr {
    display: grid;
    gap: 0;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: minmax(86px, 34%) minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
    height: auto;
    padding: 9px 10px;
    border-bottom: 1px solid #edf0f4;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 13px;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  td.numeric,
  th.numeric {
    text-align: left;
  }

  td.empty {
    display: block;
    text-align: center;
  }

  td.empty::before {
    content: "";
  }

  td .row-actions,
  td.row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .candidate-products-row {
    margin-top: -8px;
    border-top: 0;
    background: #f8fbfc;
  }

  .candidate-products-row td {
    padding-top: 10px;
  }

  .candidate-products-row td::before {
    display: none;
  }

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

  td select,
  td input {
    min-width: 0;
  }
}

@media (max-width: 360px) {
  .nav {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
  }

  .nav-item {
    height: 40px;
    font-size: 9px;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.common-system-shortcuts{display:block;width:100%;margin:0 0 8px;border:1px solid #d9e1ec;border-radius:8px;overflow:hidden;background:#fff;box-shadow:none;position:relative;z-index:20}.common-system-shortcuts__summary{display:flex;align-items:center;justify-content:space-between;width:100%;min-height:38px;padding:8px 10px;background:#f8fafc;color:#0f172a;font-size:13px;font-weight:800;cursor:pointer;list-style:none;user-select:none}.common-system-shortcuts__summary::-webkit-details-marker{display:none}.common-system-shortcuts__summary::after{content:"v";color:#64748b;font-size:12px;margin-left:8px}.common-system-shortcuts[open] .common-system-shortcuts__summary::after{content:"^"}.common-system-shortcuts__menu{display:grid;gap:2px;padding:8px;border-top:1px solid #e5e7eb;background:#fff}.common-system-shortcuts__link{display:block;border-radius:6px;color:#475569;padding:7px 8px;font-size:12px;font-weight:700;text-decoration:none;white-space:nowrap}.common-system-shortcuts__link:hover{background:#f6f8fb;color:#0f172a}.common-system-shortcuts__link.is-active{background:#174a7c;color:#fff}.common-system-shortcuts__link.is-active:hover{background:#174a7c;color:#fff}@media(max-width:980px){.common-system-shortcuts{display:block!important;position:sticky!important;top:0!important;margin:0 0 8px!important;z-index:3000!important;background:#fff!important;box-shadow:0 2px 8px rgba(15,23,42,.08)}.common-system-shortcuts__summary{min-height:42px;font-size:14px}.common-system-shortcuts__menu{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;max-height:min(52vh,420px);overflow:auto;-webkit-overflow-scrolling:touch}.common-system-shortcuts__link{min-height:36px;display:flex;align-items:center;justify-content:center;text-align:center;white-space:normal}}
