:root {
  color-scheme: light;
  --bg: #f1f4f2;
  --surface: #ffffff;
  --surface-soft: #f6f8f7;
  --surface-tint: #edf3f0;
  --ink: #17211d;
  --muted: #64716b;
  --line: #d6dfda;
  --line-strong: #acbbb4;
  --accent: #167568;
  --accent-strong: #0f544b;
  --accent-soft: #dff0eb;
  --accent-warm: #b96543;
  --gold: #b58b3c;
  --warn: #a36512;
  --warn-soft: #fff0d7;
  --danger: #b6423a;
  --danger-soft: #ffe8e5;
  --ok: #2f7b50;
  --ok-soft: #e4f4eb;
  --shadow-sm: 0 1px 2px rgba(24, 34, 31, 0.04), 0 5px 14px rgba(24, 34, 31, 0.04);
  --shadow: 0 1px 2px rgba(24, 34, 31, 0.05), 0 10px 26px rgba(24, 34, 31, 0.06);
  --shadow-strong: 0 22px 58px rgba(24, 34, 31, 0.16);
  --sidebar-collapsed-width: 72px;
  --sidebar-expanded-width: 256px;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body.is-image-viewer-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(22, 117, 104, 0.14);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  width: var(--sidebar-collapsed-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
  padding: 24px 14px;
  background: #14241e;
  color: #fbfffc;
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.06);
  transition: width 190ms ease 220ms, box-shadow 190ms ease 220ms;
}

.sidebar:hover,
.sidebar:has(:focus-visible) {
  width: var(--sidebar-expanded-width);
  box-shadow: 16px 0 34px rgba(16, 24, 21, 0.18), inset -1px 0 rgba(255, 255, 255, 0.06);
  transition-delay: 0s;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  width: 228px;
}

.brand-logo {
  display: block;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.brand-copy,
.side-nav,
.sidebar-footer {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity 110ms ease, transform 150ms ease, visibility 0s linear 110ms;
}

.brand-copy {
  overflow: hidden;
  white-space: nowrap;
}

.sidebar:hover .brand-copy,
.sidebar:hover .side-nav,
.sidebar:hover .sidebar-footer,
.sidebar:has(:focus-visible) .brand-copy,
.sidebar:has(:focus-visible) .side-nav,
.sidebar:has(:focus-visible) .sidebar-footer {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition-delay: 70ms, 70ms, 0s;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand-code {
  color: #d8b363;
  font-weight: 800;
}

.brand p {
  margin: 4px 0 0;
  color: rgba(251, 255, 252, 0.66);
  font-size: 12px;
}

.side-nav {
  display: grid;
  width: 228px;
  gap: 7px;
}

.nav-button,
.quiet-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: rgba(251, 255, 252, 0.76);
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-button svg,
.quiet-button svg,
button svg,
.search-box svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav-button:hover,
.quiet-button:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.nav-button.active {
  background: #f9fffc;
  color: var(--ink);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
}

.nav-button.active svg {
  color: var(--accent);
}

.sidebar-footer {
  display: grid;
  width: 228px;
  gap: 6px;
  margin-top: auto;
}

.quiet-button.danger {
  color: #ffd5cf;
}

.main {
  min-width: 0;
  padding: 20px 24px 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -20px -24px 16px;
  padding: 17px 24px 13px;
  border-bottom: 1px solid rgba(214, 223, 218, 0.9);
  background: rgba(248, 250, 249, 0.96);
  backdrop-filter: blur(10px);
}

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

.topbar h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

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

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 360px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 112, 0.12), var(--shadow-sm);
}

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

.save-state {
  min-width: 64px;
  color: var(--muted);
  font-size: 13px;
}

.user-menu {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 6px 0 12px;
  background: var(--surface);
}

.current-user {
  max-width: 130px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

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

.metric-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card::before {
  display: none;
}

.metric-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.metric-card strong {
  display: block;
  font-size: 26px;
  line-height: 1;
}

.metric-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.work-section {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

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

.section-tools {
  display: flex;
  min-width: 0;
  max-width: 78%;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

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

.bulk-actions .secondary-button {
  min-height: 36px;
}

.selected-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.operation-launcher .section-heading {
  min-height: 64px;
  border-bottom: 0;
}

.entry-panel.is-collapsed {
  display: none;
}

.entry-panel:not(.is-collapsed) {
  animation: panelReveal 160ms ease;
}

@keyframes panelReveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-heading h3 {
  margin: 0;
  font-size: 17px;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

.field span {
  color: #52615a;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.filter-group input,
.filter-group select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.field input:hover,
.field select:hover,
.filter-group input:hover,
.filter-group select:hover,
.table-input:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.field input:focus,
.field select:focus,
.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 122, 112, 0.12);
}

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

.option-add-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.option-add-field .icon-button {
  min-height: 40px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(22, 117, 104, 0.18);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(22, 117, 104, 0.22);
}

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

.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.secondary-button.is-active {
  border-color: rgba(31, 122, 112, 0.36);
  background: #e9f4f1;
  color: var(--accent-strong);
}

.icon-button {
  width: 40px;
  padding: 0;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.wide-filter-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-group select {
  width: 132px;
}

.filter-group input:not([type="date"]) {
  width: 132px;
}

.filter-group input[type="date"] {
  width: 150px;
}

.filter-search-field {
  position: relative;
  display: block;
  width: 176px;
  min-width: 0;
}

.filter-search-field > i,
.filter-search-field > svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.filter-group .filter-search-field input {
  width: 100%;
  padding-right: 28px;
  padding-left: 34px;
}

.table-wrap {
  overflow: auto;
}

.table-wrap.compact {
  max-height: 330px;
}

.tracking-table-wrap {
  max-height: calc(100vh - 190px);
}

.sync-status-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.sync-status-bar.is-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.sync-status-bar.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.sync-status-bar.is-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.sync-status-copy,
.sync-status-actions,
.supplier-chip-list {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-status-copy {
  min-width: 0;
  font-weight: 600;
}

.sync-status-copy svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.sync-status-actions {
  flex: 0 0 auto;
}

.sync-status-actions .icon-button {
  width: 34px;
  min-height: 34px;
}

.icon-button.is-syncing svg {
  animation: syncStatusSpin 900ms linear infinite;
}

@keyframes syncStatusSpin {
  to {
    transform: rotate(360deg);
  }
}

.supplier-chip-list {
  min-width: 150px;
  max-width: 340px;
  flex-wrap: wrap;
}

.supplier-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid #c9ddd7;
  border-radius: 6px;
  padding: 2px 7px;
  background: #eef7f4;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.tracking-spec-cell,
.tracking-note-cell {
  min-width: 180px;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.tracking-qty-cell {
  min-width: 88px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.tracking-inbound-qty {
  color: var(--ok);
}

.tracking-pending-qty {
  color: var(--danger);
}

.purchase-detail-cell {
  min-width: 390px;
  white-space: normal;
}

.purchase-detail-count {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.purchase-detail-list {
  display: grid;
  gap: 7px;
}

.purchase-detail-summary {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.purchase-detail-summary:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.purchase-detail-copy {
  min-width: 0;
}

.purchase-detail-title,
.purchase-detail-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
}

.purchase-detail-title {
  margin-bottom: 3px;
  font-weight: 700;
}

.purchase-detail-metrics {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.purchase-detail-arrived,
.purchase-detail-complete {
  color: var(--ok);
  font-weight: 700;
}

.purchase-detail-pending {
  color: var(--danger);
  font-weight: 700;
}

.purchase-detail-reference {
  color: var(--accent-strong);
}

tbody tr.is-overdue-row {
  background: #fff7f5;
}

tbody tr.is-overdue-row:hover {
  background: #fff1ee;
}

tbody tr.is-overdue-row td:first-child {
  box-shadow: inset 3px 0 var(--danger);
}

.selection-column {
  width: 44px;
  min-width: 44px;
  padding-right: 6px;
  padding-left: 12px;
  text-align: center;
}

.selection-column input,
.movement-select {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

tbody tr.is-offset-row {
  background: #f5f8f7;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f3;
  color: #44534c;
  font-weight: 700;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #f5faf7;
}

tbody tr.is-voided-row {
  color: var(--muted);
  background: #fafafa;
}

tbody tr.is-voided-row td {
  text-decoration-color: rgba(104, 115, 110, 0.38);
}

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

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

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.style-no-cell {
  min-width: 120px;
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.row-actions button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.row-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.line-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.line-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.line-editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.line-editor h4 {
  margin: 0;
  font-size: 14px;
}

.line-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.purchase-line {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(110px, 0.75fr) minmax(110px, 0.75fr) minmax(170px, 1fr) 40px;
  gap: 8px;
  align-items: end;
}

.style-material-line {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) 40px;
  gap: 8px;
  align-items: end;
}

.purchase-line button,
.style-material-line button {
  width: 40px;
  height: 40px;
}

.style-purchase-panel {
  display: grid;
  grid-template-columns: 1.4fr minmax(220px, 1fr) minmax(130px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid #b9d6cf;
  border-radius: 8px;
  padding: 14px;
  background: #edf7f4;
}

.style-purchase-panel h4 {
  margin: 0;
  font-size: 14px;
}

.style-purchase-panel p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.ai-style-workflow {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.ai-paste-zone {
  display: grid;
  min-height: 220px;
  place-items: center;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
}

.ai-paste-zone svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.ai-paste-zone strong {
  font-size: 18px;
}

.ai-paste-zone span {
  color: var(--muted);
  font-size: 13px;
}

.ai-paste-zone.is-dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(31, 122, 112, 0.12);
}

.ai-image-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.ai-image-preview img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

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

.ai-result-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ai-result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-style-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.ai-note-field {
  grid-column: 1 / -1;
}

.record-image-registration {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(320px, 1.3fr);
  align-items: center;
  gap: 18px;
  min-height: 128px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.record-image-copy h4 {
  margin: 0;
  font-size: 15px;
}

.record-image-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.record-image-editor {
  display: flex;
  min-height: 94px;
  align-items: center;
  gap: 14px;
}

.record-image-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.record-image-editor-status {
  flex-basis: 100%;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.record-image-paste-target {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  line-height: 0;
  cursor: copy;
  outline: 0;
}

.record-image-paste-target:focus,
.record-image-paste-target:focus-within {
  box-shadow: 0 0 0 3px rgba(22, 117, 104, 0.18);
}

.record-image-paste-badge {
  position: absolute;
  right: -7px;
  bottom: -7px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

.record-image-paste-badge svg {
  width: 13px;
  height: 13px;
}

.is-spinning {
  animation: imageUploadSpin 800ms linear infinite;
}

@keyframes imageUploadSpin {
  to {
    transform: rotate(360deg);
  }
}

.record-thumbnail,
.record-image-placeholder {
  display: inline-grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: #f7f9f8;
  color: var(--muted);
  vertical-align: middle;
}

.record-thumbnail {
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.record-thumbnail:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 117, 104, 0.1);
}

.record-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-image-placeholder svg {
  width: 18px;
  height: 18px;
}

.record-thumbnail.style-photo,
.record-image-placeholder.style-photo {
  width: 76px;
  height: 94px;
}

.record-thumbnail.tracking-style-photo,
.record-image-placeholder.tracking-style-photo {
  width: 48px;
  height: 60px;
}

.record-thumbnail.material-mini,
.record-image-placeholder.material-mini {
  width: 30px;
  height: 30px;
  border-radius: 5px;
}

.material-image-editor {
  display: flex;
  min-width: 86px;
  align-items: center;
  gap: 5px;
}

.image-cell-actions {
  display: grid;
  gap: 4px;
}

.image-cell-action {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: var(--surface);
  color: var(--muted);
}

.image-cell-action:hover {
  border-color: var(--line-strong);
  color: var(--accent-strong);
}

.image-cell-action svg {
  width: 15px;
  height: 15px;
}

.material-component-summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.material-component-summary + .material-component-summary {
  margin-top: 4px;
}

.table-input {
  width: 100%;
  min-width: 130px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.table-input.compact {
  min-width: 82px;
}

.receiver-line-select {
  min-width: 118px;
}

.table-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 112, 0.12);
}

.table-action-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.compact-heading {
  min-height: 62px;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 220px;
  max-width: 360px;
  transform: translateY(20px);
  border-radius: 8px;
  padding: 12px 14px;
  background: #17211d;
  color: #fff;
  box-shadow: var(--shadow-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(25, 34, 31, 0.46);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-heading h3 {
  margin: 0;
  font-size: 18px;
}

.modal-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

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

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.image-viewer {
  z-index: 50;
}

.image-viewer-panel {
  width: min(1040px, 100%);
}

.image-viewer-body {
  display: grid;
  min-height: 300px;
  max-height: calc(100vh - 150px);
  place-items: center;
  overflow: auto;
  padding: 18px;
  background: #eef2f0;
}

.image-viewer-body img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 190px);
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #e9eeeb;
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}

.login-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.login-heading h1 {
  margin: 0;
  font-size: 22px;
}

.login-logo {
  width: 52px;
  height: 52px;
  flex-basis: 52px;
  box-shadow: 0 10px 22px rgba(20, 37, 31, 0.18);
}

.login-heading p,
.login-hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.login-form .primary-button {
  width: 100%;
}

.permission-form .form-actions {
  gap: 10px;
}

.toggle-field {
  align-content: start;
}

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--ink);
}

.switch-line input {
  width: 18px;
  height: 18px;
}

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

.permission-block h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.permission-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.permission-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.permission-check input {
  width: 16px;
  height: 16px;
}

.permission-tags {
  display: flex;
  max-width: 360px;
  flex-wrap: wrap;
  gap: 5px;
}

.permission-tag {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface-tint);
  color: var(--accent-strong);
  font-size: 12px;
}

.is-permission-hidden {
  display: none !important;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 24px 18px;
    transition: none;
  }

  .sidebar:hover,
  .sidebar:has(:focus-visible) {
    width: auto;
  }

  .brand {
    width: auto;
  }

  .brand-copy,
  .side-nav,
  .sidebar-footer {
    width: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: none;
  }

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

  .main {
    padding: 18px;
  }

  .topbar {
    position: static;
    margin: -18px -18px 18px;
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .split-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .user-menu {
    width: 100%;
    justify-content: space-between;
  }

  .search-box {
    width: 100%;
  }

  .metric-grid,
  .form-grid,
  .ai-style-fields {
    grid-template-columns: 1fr;
  }

  .record-image-registration {
    grid-template-columns: 1fr;
  }

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

  .purchase-line,
  .style-material-line,
  .style-purchase-panel {
    grid-template-columns: 1fr;
  }

  .line-editor-head,
  .line-editor-actions,
  .section-actions,
  .section-tools,
  .bulk-actions,
  .modal-actions,
  .ai-result-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .section-tools {
    max-width: none;
  }

  .filter-group,
  .wide-filter-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-group input,
  .filter-group select,
  .filter-group input[type="date"] {
    width: 100%;
  }

  .filter-search-field {
    width: 100%;
  }

  .tracking-table-wrap {
    max-height: none;
  }

  .sync-status-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .sync-status-actions {
    align-self: flex-end;
  }

  .modal-form {
    grid-template-columns: 1fr;
  }

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