/* Modeste Clothing staff dashboard. Independent of the storefront styles. */

:root {
  --bg: #f6f2ec;
  --surface: #ffffff;
  --surface-2: #faf7f2;
  --surface-3: #f3ede4;
  --border: #e9e0d4;
  --border-strong: #dccfbf;
  --text: #2a1f16;
  --text-2: #5c4c3e;
  --muted: #8c7c6c;
  --brand: #75583a;
  --brand-hover: #604629;
  --brand-dark: #3c2a1b;
  --brand-tint: #f2e9de;
  --focus: rgba(117, 88, 58, 0.22);

  --success: #2f7a4b;   --success-bg: #e7f4ec;
  --warning: #9a6410;   --warning-bg: #fcf1dc;
  --danger: #b0392d;    --danger-bg: #fbe9e7;
  --info: #2d5f8b;      --info-bg: #e7eff8;
  --violet: #6a4a8c;    --violet-bg: #f1ebf8;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(42, 31, 22, 0.05);
  --shadow: 0 1px 3px rgba(42, 31, 22, 0.06), 0 6px 20px rgba(42, 31, 22, 0.05);
  --shadow-lg: 0 24px 60px rgba(42, 31, 22, 0.22);
  --sidebar-w: 248px;

  /* Names still used by inline styles in older dashboard templates */
  --white: #ffffff;
  --cream: var(--surface-2);
  --sand: var(--surface-3);
  --line: var(--border);
  --ink: var(--text);
  --brown: var(--brand);
  --brown-dark: var(--brand-dark);
  --brown-soft: #9a7b58;
  --brown-mid: #86684a;
  --radius-md: var(--radius);
  --radius-xl: 999px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body.dash {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--brand-dark); letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.ic {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Buttons (old class names kept: .btn.primary / .btn.ghost / .sm) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 650; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn .ic { width: 16px; height: 16px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand-dark); }
.btn.danger, .btn.ghost.danger { color: var(--danger); border-color: #ecc6c1; }
.btn.ghost.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--brand-dark); }

/* ---------- Form controls ---------- */
.form-input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.form-input { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; }
select.form-input {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c7c6c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.form-input::placeholder { color: #b3a595; }
.form-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.file-input { height: auto; padding: 8px; font-size: 13px; }
.select-sm { height: 34px; font-size: 12.5px; width: auto; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.field > span small { font-weight: 500; color: var(--muted); }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-actions, .modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.checkbox-field { display: flex; align-items: center; gap: 10px; align-self: end; height: 40px; font-weight: 600; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--brand); }
fieldset.inset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; background: var(--surface-2); }
fieldset.inset legend { font-size: 12.5px; font-weight: 700; color: var(--text-2); padding: 0 6px; }
fieldset.inset legend small { font-weight: 500; color: var(--muted); }
fieldset.inset .muted { margin-bottom: 10px; }

.form-message { font-size: 13px; font-weight: 600; padding: 10px 12px; border-radius: var(--radius-sm); }
.form-message.error { color: var(--danger); background: var(--danger-bg); }
.form-message.success { color: var(--success); background: var(--success-bg); }

/* ---------- Sign in ---------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, #efe3d3 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #eadccb 0%, transparent 60%),
    var(--bg);
}
.auth-panel { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.auth-logo { width: 132px; height: auto; }
.auth-card {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.auth-card h1 { font-size: 24px; font-weight: 800; }
.auth-card > p.muted { margin: -10px 0 6px; font-size: 13.5px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; }
.auth-links.center { justify-content: center; }
.auth-links a { text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-store-link { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.auth-store-link:hover { color: var(--brand); }

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

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 14px;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 18px; border-bottom: 1px solid var(--border); }
.sidebar-brand img { width: 104px; height: auto; }
.brand-tag { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); background: var(--brand-tint); padding: 4px 9px; border-radius: 999px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding-top: 14px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #b0a090; padding: 14px 12px 6px; }
.nav-label:first-child { padding-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font-size: 13.5px; font-weight: 600;
  text-align: left; text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item .ic { color: var(--muted); }
.nav-item:hover { background: var(--surface-2); color: var(--brand-dark); }
.nav-item.active { background: var(--brand-tint); color: var(--brand-dark); }
.nav-item.active .ic { color: var(--brand); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); background: var(--surface-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-meta strong { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }

.sidebar-backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 32px; background: rgba(246, 242, 236, 0.92);
  backdrop-filter: blur(10px); border-bottom: 1px solid transparent;
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 22px; font-weight: 800; }
.topbar-title p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
#syncStatus {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--muted) !important;
  background: var(--surface); border: 1px solid var(--border); padding: 6px 11px; border-radius: 999px;
}
#syncStatus::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
#syncStatus.error { color: var(--danger) !important; }
#syncStatus.error::before { background: var(--danger); }
.menu-btn { display: none; }

.content { padding: 4px 32px 48px; display: flex; flex-direction: column; gap: 22px; }
.view { display: flex; flex-direction: column; gap: 22px; }
.view[style*="display: none"], .view[style*="display:none"] { display: none !important; }

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card.sticky { position: sticky; top: 92px; }
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 16px; font-weight: 750; display: flex; align-items: center; gap: 10px; }
.card-header p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.card-body { padding: 20px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.grid-sidebar { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 22px; align-items: start; }
.grid-sidebar.reverse { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
.stack { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.count-badge { font-size: 11.5px; font-weight: 700; color: var(--brand); background: var(--brand-tint); padding: 3px 9px; border-radius: 999px; }

.search { position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search .form-input { height: 34px; padding-left: 34px; width: 240px; font-size: 13px; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tint); color: var(--brand);
}
.kpi:nth-child(2) .kpi-icon { background: var(--info-bg); color: var(--info); }
.kpi:nth-child(3) .kpi-icon { background: var(--warning-bg); color: var(--warning); }
.kpi:nth-child(4) .kpi-icon { background: var(--success-bg); color: var(--success); }
.kpi-icon .ic { width: 21px; height: 21px; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--brand-dark); letter-spacing: -0.02em; margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.scroll-y { max-height: 420px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #fcfaf7; }
.data-table strong { color: var(--text); font-weight: 650; }
.data-table .right, .data-table th.right { text-align: right; }
.data-table .center, .data-table th.center { text-align: center; }
.data-table td.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-weight: 500; }
.cell-main { font-weight: 650; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cell-note { font-size: 12px; color: var(--muted); margin-top: 6px; max-width: 320px; line-height: 1.45; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 320px; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }

.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); flex-shrink: 0; }
.media { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Status pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.plain::before { display: none; }
.pill.success { background: var(--success-bg); color: var(--success); }
.pill.warning { background: var(--warning-bg); color: var(--warning); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.brand { background: var(--brand-tint); color: var(--brand); }
.pill.violet { background: var(--violet-bg); color: var(--violet); }

.money { font-weight: 750; color: var(--text); white-space: nowrap; }
.pay-line { font-size: 12px; margin-top: 3px; white-space: nowrap; }
.pay-line.ok { color: var(--success); font-weight: 650; }
.pay-line.due { color: var(--danger); font-weight: 650; }
.pay-line.muted { color: var(--muted); }

/* Stage dropdown styled as a coloured pill */
select.status-select-btn {
  appearance: none; height: 32px; padding: 0 30px 0 12px; border-radius: 999px;
  border: 1px solid transparent; font-size: 12.5px; font-weight: 650; cursor: pointer; outline: none;
  background-repeat: no-repeat; background-position: right 10px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c4c3e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-color: var(--surface-3); color: var(--text-2); min-width: 170px;
}
select.status-select-btn:focus { box-shadow: 0 0 0 3px var(--focus); }
select.status-select-btn[data-stage="0"] { background-color: var(--danger-bg); color: var(--danger); }
select.status-select-btn[data-stage="1"] { background-color: var(--warning-bg); color: var(--warning); }
select.status-select-btn[data-stage="2"] { background-color: var(--info-bg); color: var(--info); }
select.status-select-btn[data-stage="3"], select.status-select-btn[data-stage="4"],
select.status-select-btn[data-stage="5"], select.status-select-btn[data-stage="6"],
select.status-select-btn[data-stage="7"] { background-color: var(--violet-bg); color: var(--violet); }
select.status-select-btn[data-stage="8"] { background-color: var(--success-bg); color: var(--success); }
select.status-select-btn option { background: #fff; color: var(--text); }

/* Row action dropdown */
select.action-select-btn {
  appearance: none; height: 32px; padding: 0 30px 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background-color: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer; outline: none;
  background-repeat: no-repeat; background-position: right 10px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c7c6c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
select.action-select-btn:hover { border-color: var(--brand); }
select.action-select-btn:focus { box-shadow: 0 0 0 3px var(--focus); }

/* Featured star toggle */
.star-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.star-toggle:hover { border-color: var(--brand); color: var(--brand-dark); }
.star-toggle.on { background: var(--warning-bg); border-color: #efd9ad; color: var(--warning); }

/* ---------- Segmented sub-navigation (Purchases) ---------- */
.segmented { display: flex; gap: 4px; padding: 10px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.segmented button {
  height: 34px; padding: 0 14px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.segmented button:hover { background: var(--surface-2); }
.segmented button.active { background: var(--brand-tint); color: var(--brand-dark); }

/* ---------- Dialogs ---------- */
dialog.modal {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal.modal-lg { width: min(680px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(42, 31, 22, 0.42); backdrop-filter: blur(2px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; font-weight: 750; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-actions { padding-top: 6px; }

.summary-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.summary-row strong { color: var(--text); }
.summary-row.total { border-top: 1px solid var(--border); padding-top: 8px; color: var(--text-2); font-weight: 650; }
.summary-row.total strong { font-size: 16px; }
.summary-row.balance { background: var(--brand-tint); padding: 10px 14px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 650; }
.summary-row.balance strong { color: var(--brand-dark); font-size: 15px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-row .btn { flex: 1; }

.gallery-strip { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; min-height: 8px; }
.upload-zone {
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  height: 46px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: 13px; background: var(--surface-2);
}
.upload-zone:hover { border-color: var(--brand); color: var(--brand-dark); }
.upload-zone input { display: none; }
.line-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.line-items input, .line-items select { height: 38px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 10px; background: var(--surface); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-sidebar, .grid-sidebar.reverse { grid-template-columns: minmax(0, 1fr); }
  .card.sticky { position: static; }
}

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(42, 31, 22, 0.38); }
  body.nav-open .sidebar-backdrop { display: block; }
  .menu-btn { display: inline-flex; color: var(--brand-dark); border: 1px solid var(--border); background: var(--surface); }
  .topbar { padding: 14px 16px; }
  .topbar-title h1 { font-size: 19px; }
  .topbar-title p { display: none; }
  .content { padding: 4px 16px 32px; gap: 16px; }
  .view { gap: 16px; }
}

@media (max-width: 640px) {
  .kpi-grid { gap: 10px; }
  .kpi { padding: 14px; gap: 10px; }
  .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }
  .kpi-value { font-size: 18px; }
  .card-header { padding: 16px; }
  .card-body, .modal-body { padding: 16px; }
  .toolbar { width: 100%; }
  .search, .search .form-input { width: 100%; }
  .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  #syncStatus { display: none; }
  .data-table td, .data-table th { padding-left: 12px; padding-right: 12px; }
}

/* ---------- Product photo tiles & line items (dialogs) ---------- */
.photo-tile {
  position: relative; flex-shrink: 0; width: 108px; height: 132px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  background: var(--surface-3);
}
.photo-tile.main { border: 2px solid var(--brand); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(42, 31, 22, 0.72); color: #fff; font-size: 15px; line-height: 1; cursor: pointer;
}
.photo-remove:hover { background: var(--danger); }
.photo-badge, .photo-set {
  position: absolute; left: 6px; right: 6px; bottom: 6px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 11px; font-weight: 700;
}
.photo-badge { background: var(--brand); color: #fff; }
.photo-set { border: 0; background: rgba(255, 255, 255, 0.92); color: var(--brand-dark); cursor: pointer; }
.photo-set:hover { background: #fff; }

.line-item { display: grid; grid-template-columns: minmax(0, 1fr) 80px 120px 36px; gap: 8px; align-items: center; }
.line-item .form-input { height: 38px; font-size: 13px; }
@media (max-width: 640px) {
  .line-item { grid-template-columns: minmax(0, 1fr) 64px 96px 32px; }
}

/* Long names and refs wrap instead of widening tables */
.data-table .cell-main { overflow-wrap: break-word; word-break: break-word; }
.data-table td:has(.clamp-2) { min-width: 180px; }
@media (max-width: 1360px) {
  .data-table th, .data-table td { padding-left: 12px; padding-right: 12px; }
  select.status-select-btn { min-width: 150px; }
}
select.action-select-btn { width: 128px; }
.data-table .cell-sub { overflow-wrap: normal; }
@media (max-width: 960px) {
  .data-table { min-width: 780px; }
  .table-wrap.scroll-y .data-table { min-width: 520px; }
  .toolbar .btn.primary { margin-left: auto; }
}
.file-input::file-selector-button {
  height: 30px; margin-right: 10px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
