/* ============================================================
   Cut Room — design system
   Clean, professional analytics UI. Readable Inter type,
   calm neutral surfaces, one confident accent. Signature: the
   "cut chip" copyable phrase (the only dashed element).
   ============================================================ */

:root {
  /* neutrals — cool, near-white, professional */
  --paper: #f6f7f9;
  --card: #ffffff;
  --line: #e4e7ec;
  --line-strong: #d3d8df;
  --ink: #16191d;
  --ink-soft: #5b6472;
  --ink-faint: #8a93a1;

  /* accents */
  --spruce: #0f766e;       /* primary: teal-green — actions, active nav, links, "new" */
  --spruce-ink: #0b5a54;   /* pressed / hover-dark */
  --spruce-soft: #12897f;
  --coral: #e0523f;        /* the "money" color — sales numbers & deltas only */
  --wash: #e9f3f1;         /* selected / hover tint, chip fills */
  --wash-strong: #d6ebe7;

  --used-bg: #eef1f4;
  --amber-bg: #fdf4e3;
  --amber-line: #f2ddb0;
  --amber-ink: #8a5a10;

  --shadow-sm: 0 1px 2px rgb(20 26 33 / 6%);
  --shadow: 0 1px 3px rgb(20 26 33 / 8%), 0 1px 2px rgb(20 26 33 / 5%);
  --shadow-lg: 0 12px 32px rgb(20 26 33 / 14%);
  --radius: 12px;
  --radius-sm: 9px;

  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.55;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--spruce); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--spruce);
  outline-offset: 2px;
  border-radius: 5px;
}

/* ---------- Layout ---------- */
#app {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 244px;
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 6px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 20px;
}
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--spruce);
  color: #fff;
  font-size: 17px;
  flex: none;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: block;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 15.5px;
  transition: background 140ms ease-out, color 140ms ease-out;
}
.nav-item:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--wash); color: var(--spruce-ink); font-weight: 600; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 4px;
  font-size: 13.5px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}
.sync-line { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.logout-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  transition: background 140ms ease-out, color 140ms ease-out, border-color 140ms ease-out;
}
.logout-btn:hover { background: #fdece8; border-color: var(--coral); color: var(--coral); }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink-faint); flex: none;
}
.dot.busy { background: var(--coral); animation: pulse 1s infinite; }
.dot.ok { background: var(--spruce); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.content {
  grid-column: 2;
  padding: 40px 40px 80px;
  max-width: 1320px;
  width: 100%;
}

/* ---------- Typography helpers ---------- */
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}
.page-sub { color: var(--ink-soft); font-size: 16px; margin: 0 0 28px; }
.hero {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 32px;
  max-width: 860px;
}
.hero b { font-weight: 700; color: var(--spruce); }
.hero .money { color: var(--coral); }
.mono { font-family: var(--font-mono); }
.coral { color: var(--coral); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  transition: background 140ms ease-out, border-color 140ms ease-out, box-shadow 140ms ease-out;
}
.btn:hover { background: var(--paper); border-color: var(--ink-faint); }
.btn-primary {
  background: var(--spruce);
  border-color: var(--spruce);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--spruce-ink); border-color: var(--spruce-ink); }
.btn-danger:hover { background: #fdece8; border-color: var(--coral); color: var(--coral); }
.btn-sm { padding: 7px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.spacer { flex: 1; }

/* ---------- Inputs ---------- */
input[type="text"], input[type="number"], input[type="search"], input[type="password"], textarea, select {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  width: 100%;
  transition: border-color 140ms ease-out, box-shadow 140ms ease-out;
}
textarea.mono { font-family: var(--font-mono); font-size: 14px; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  border-color: var(--spruce);
  outline: none;
  box-shadow: 0 0 0 3px rgb(15 118 110 / 12%);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
label.field { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 7px; }
.field-hint { color: var(--ink-soft); font-size: 13.5px; margin-top: 5px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.section { margin-bottom: 40px; }
.section-head {
  display: flex; align-items: center; gap: 11px;
  margin-bottom: 16px; cursor: pointer; user-select: none;
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 700; font-size: 20px; letter-spacing: -0.02em; margin: 0;
}
.section-head .cat-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.section-head .count { color: var(--ink-soft); font-weight: 500; font-size: 14.5px; }
.section-head .chev { margin-left: auto; color: var(--ink-faint); transition: transform 140ms ease-out; }
.section.collapsed .chev { transform: rotate(-90deg); }
.section.collapsed .section-body { display: none; }

/* ---------- Shop card ---------- */
.shop-card { display: flex; flex-direction: column; gap: 12px; }
.shop-card .row { display: flex; gap: 13px; align-items: center; }
.shop-avatar {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  background: var(--wash); flex: none;
}
.shop-card .name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.shop-card .sales { font-family: var(--font-mono); color: var(--coral); font-weight: 600; font-size: 15px; }
.shop-card .meta { color: var(--ink-soft); font-size: 13.5px; }
.delta-badge {
  display: inline-block;
  background: var(--wash); color: var(--coral);
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
.tag-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.tag {
  background: var(--wash); color: var(--spruce-ink);
  font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.tag .x { cursor: pointer; opacity: .6; }
.tag .x:hover { opacity: 1; }
.tag-add {
  border: 1px dashed var(--line-strong); background: transparent; color: var(--ink-soft);
  font-size: 12.5px; padding: 3px 9px; border-radius: 999px;
}
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* ============================================================
   CUT CHIP — the signature. Only dashed border on the page.
   ============================================================ */
.cut-chip {
  --dash: var(--line-strong);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1px dashed var(--dash);
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
  position: relative;
  transition: color 140ms ease-out, background 140ms ease-out, border-color 140ms ease-out;
}
.cut-chip:hover { background: var(--wash); --dash: var(--spruce); }
.cut-chip .sciss {
  opacity: 0;
  font-size: 13px;
  color: var(--spruce);
  transition: opacity 140ms ease-out;
}
.cut-chip:hover .sciss { opacity: 1; }
.cut-chip.cut { color: var(--spruce); --dash: var(--spruce); }

/* the animated dashed path overlay — runs the "blade" on click */
.cut-chip .blade {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  border: 1px dashed var(--spruce);
  opacity: 0;
}
.cut-chip.cutting .blade {
  opacity: 1;
  animation: bladerun 420ms linear;
}
@keyframes bladerun {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

/* ---------- Tables ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .05em; cursor: pointer; user-select: none;
  background: var(--paper);
}
table.data td { font-size: 15px; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--paper); }
table.data td.num { font-family: var(--font-mono); }
table.data td.sales { font-family: var(--font-mono); color: var(--coral); font-weight: 600; }
tr.selected { background: var(--wash) !important; }

.status-pill {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  text-transform: capitalize;
}
.status-new { background: var(--wash); color: var(--spruce-ink); }
.status-used { background: var(--used-bg); color: var(--ink-soft); }
.status-ignored { background: transparent; color: var(--ink-soft); opacity: .55; }
.validated { color: var(--spruce); cursor: help; }

/* Segmented control (status tabs) */
.segmented { display: inline-flex; background: var(--used-bg); border-radius: 999px; padding: 4px; }
.segmented button {
  border: none; background: transparent; color: var(--ink-soft);
  padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
  transition: color 140ms ease-out;
}
.segmented button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Product grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}
.product {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm);
  transition: box-shadow 140ms ease-out, border-color 140ms ease-out;
}
.product:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.product .thumb {
  aspect-ratio: 1 / 1; background: var(--wash); position: relative; overflow: hidden;
}
.product .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product .sales-badge {
  position: absolute; top: 9px; left: 9px;
  background: rgb(255 255 255 / 94%); color: var(--coral);
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.product .body { padding: 12px 13px; display: flex; flex-direction: column; gap: 9px; }
.product .p-title {
  font-size: 14px; line-height: 1.45; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product .thumb-link { position: absolute; inset: 0; display: block; }
.product.selected { outline: 2px solid var(--spruce); outline-offset: -1px; }
.product .sel-wrap {
  position: absolute; top: 9px; right: 9px; z-index: 3;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: rgb(255 255 255 / 94%); border-radius: 7px; box-shadow: var(--shadow-sm); cursor: pointer;
}
.product .sel-wrap input { width: 17px; height: 17px; cursor: pointer; margin: 0; }
.product .p-foot { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.product .kw-slot { min-width: 0; overflow: hidden; }
.kw-tag { max-width: 100%; }
.kw-tag .kw-x { margin-left: 5px; cursor: pointer; opacity: .5; font-weight: 700; }
.kw-tag .kw-x:hover { opacity: 1; color: var(--coral); }
.icon-btn {
  border: none; background: transparent; cursor: pointer; opacity: .5;
  font-size: 14px; padding: 3px 6px; border-radius: 6px; flex: none; line-height: 1;
}
.icon-btn:hover { opacity: 1; background: #fdece8; }

/* ---------- Bulk bar ---------- */
.bulk-bar {
  position: fixed; left: 268px; right: 40px; bottom: 24px;
  background: var(--ink); color: #fff;
  border-radius: var(--radius); padding: 14px 20px;
  display: flex; align-items: center; gap: 18px; font-size: 15px;
  box-shadow: 0 8px 28px rgb(20 26 33 / 22%);
  transform: translateY(160%); transition: transform 180ms ease-out;
  z-index: 30;
}
.bulk-bar.show { transform: translateY(0); }
.bulk-bar .btn { background: transparent; color: #fff; border-color: rgb(255 255 255 / 26%); }
.bulk-bar .btn:hover { background: rgb(255 255 255 / 12%); border-color: rgb(255 255 255 / 40%); }

/* ---------- Pager ---------- */
.pager {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
}
.pager-info { font-size: 13px; color: var(--ink-soft); }
.pager-size { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.pager-size select { padding: 5px 8px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgb(16 22 28 / 46%);
  display: flex; align-items: center; justify-content: center; z-index: 40; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); border-radius: 14px;
  width: 100%; max-width: 480px; padding: 28px;
  box-shadow: var(--shadow-lg);
}
.modal h3 {
  font-family: var(--font-display); font-weight: 700; font-size: 23px; letter-spacing: -0.02em; margin: 0 0 18px;
}
.modal .row { display: flex; gap: 11px; align-items: center; margin: 14px 0; }
.modal-actions { display: flex; gap: 11px; justify-content: flex-end; margin-top: 24px; }

/* progress */
.progress-track { height: 8px; background: var(--wash); border-radius: 999px; overflow: hidden; margin: 18px 0 12px; }
.progress-fill { height: 100%; background: var(--spruce); width: 0%; transition: width 300ms ease-out; }
.progress-counters { font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft); display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 9px; z-index: 60; align-items: center;
}
.toast {
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px;
  animation: toastin 150ms ease-out;
}
.toast.err { background: var(--coral); }
.toast.ok .ic { color: #7fd8c6; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty / loading ---------- */
.empty {
  text-align: center; padding: 72px 20px; color: var(--ink-soft);
}
.empty .headline {
  font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.02em;
  color: var(--ink); margin-bottom: 16px;
}
.skeleton-page { color: var(--ink-soft); padding: 40px 0; font-size: 16px; }
.skel {
  background: linear-gradient(90deg, var(--wash) 25%, #f0f4f3 50%, var(--wash) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.error-box {
  background: #fdece8; border: 1px solid #f6c7bc; color: #a8321d;
  border-radius: var(--radius-sm); padding: 13px 15px; font-size: 14px; margin: 12px 0;
}
.warn-box {
  background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--amber-ink);
  border-radius: var(--radius-sm); padding: 13px 15px; font-size: 14px; margin: 12px 0;
}

/* rows / small utils */
.stat-inline { display: flex; gap: 9px; align-items: baseline; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.muted { color: var(--ink-soft); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.chk { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 15px; }
.form-card { display: grid; gap: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .content { padding: 32px 24px 80px; }
}
@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; width: 100%; height: auto;
    flex-direction: row; align-items: center; padding: 6px;
    border-right: none; border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgb(20 26 33 / 6%);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 2px; }
  .nav-item { padding: 10px 12px; font-size: 14px; }
  .content { grid-column: 1; padding: 24px 16px 96px; }
  .page-title { font-size: 28px; }
  .hero { font-size: 24px; }
  .bulk-bar { left: 16px; right: 16px; bottom: 80px; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .nav-item { font-size: 13px; padding: 9px 7px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .cut-chip.cutting .blade { animation: none; opacity: 0; }
}

/* ============================================================
   Sign-in screen (custom — not a browser modal)
   ============================================================ */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--paper);
  background-image:
    radial-gradient(rgb(20 26 33 / 4%) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: center;
  animation: authIn 200ms ease-out;
}
.auth-screen.auth-out { opacity: 0; transition: opacity 240ms ease-out; }
@keyframes authIn { from { opacity: 0; } to { opacity: 1; } }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 30px;
  text-align: center;
}
.auth-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  background: var(--spruce);
  border-radius: 15px;
}
.auth-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
}
.auth-sub { color: var(--ink-soft); margin: 0 0 26px; font-size: 15px; }

.auth-card form { text-align: left; }
.auth-card .field { font-size: 14px; }
.auth-input-wrap { position: relative; }
.auth-input-wrap input {
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  padding-right: 44px;
}
.auth-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 16px;
  opacity: 0.55;
  padding: 6px;
  line-height: 1;
}
.auth-eye:hover { opacity: 1; }

.auth-error {
  color: var(--coral);
  background: #fdece8;
  border: 1px solid #f6c7bc;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  margin-top: 13px;
}
.auth-btn { width: 100%; justify-content: center; margin-top: 18px; padding: 13px; font-size: 16px; }
.auth-foot {
  margin-top: 22px;
  color: var(--ink-soft);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

@media (prefers-reduced-motion: reduce) {
  .auth-screen, .auth-screen.auth-out { animation: none; transition: none; }
}

img { max-width: 100%; }
