/* Taviro — Zendrop-inspired light theme.
   Design language: white surfaces on a cool light-grey canvas, violet primary,
   rounded cards, soft borders, quiet shadows. */

:root {
  color-scheme: light;
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-tint: #f6f3fe;
  --line: #e8e8f1;
  --line-strong: #d9d9e6;
  --ink: #1d1b29;
  --muted: #6f6c82;
  --primary: #6e36e5;
  --primary-strong: #5a28c7;
  --primary-tint: #f1ebfe;
  --primary-tint-border: #ddcdfb;
  --green-ink: #11774f;
  --green-bg: #e3f6ec;
  --amber-ink: #8f5f0a;
  --amber-bg: #fdf1d8;
  --red-ink: #c03333;
  --red-bg: #fde9e9;
  --shadow-sm: 0 1px 2px rgba(28, 18, 65, 0.05);
  --shadow-md: 0 2px 4px rgba(28, 18, 65, 0.05), 0 12px 28px rgba(28, 18, 65, 0.07);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Hiragino Sans", "Noto Sans JP", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

/* ---------- App shell ---------- */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 8px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c4dff 0%, #5f2bd8 100%);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(110, 54, 229, 0.35);
}

.brand strong {
  display: block;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.role-tabs {
  display: grid;
  gap: 4px;
}

.role-tabs button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  transition: background 140ms ease, color 140ms ease;
}

.role-tabs button::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 140ms ease;
}

.role-tabs button:hover {
  background: var(--bg);
  color: var(--ink);
  transform: none;
}

.role-tabs button.active {
  background: var(--primary-tint);
  color: var(--primary);
}

.role-tabs button.active::before {
  background: var(--primary);
}

.ai-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  font-size: 12.5px;
}

.ai-status span:first-child {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2fbf71;
  box-shadow: 0 0 0 3px rgba(47, 191, 113, 0.18);
}

.ai-status span + span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-status.offline span:first-child {
  background: #d64545;
  box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.16);
}

/* ---------- Main / topbar ---------- */

main {
  padding: 26px 30px 60px;
  min-width: 0;
}

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

.topbar h1 {
  font-size: 21px;
  font-weight: 700;
  max-width: 560px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

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

.language-switcher,
.currency-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

select {
  appearance: none;
  padding: 8px 30px 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236f6c82' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(110, 54, 229, 0.14);
}

.account-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.account-switcher label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.account-switcher strong {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
}

/* ---------- Buttons ---------- */

button,
a[download] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

button:hover,
a[download]:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

button:disabled {
  cursor: default;
  opacity: 0.7;
}

button.primary {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(110, 54, 229, 0.28);
}

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

button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--bg);
  color: var(--ink);
}

button.small {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12px;
}

button:disabled,
button.is-imported {
  border-color: transparent;
  background: var(--green-bg);
  color: var(--green-ink);
  box-shadow: none;
}

button.is-imported::before {
  content: "✓";
  font-weight: 800;
}

.icon-button {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}

/* ---------- Shop strip & metrics ---------- */

.shop-strip {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.2fr 0.8fr;
  gap: 12px;
  margin-bottom: 14px;
}

.shop-strip div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.shop-strip small {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
}

.shop-strip strong {
  display: block;
  margin: 5px 0 2px;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.shop-strip span {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  word-break: break-all;
}

.shop-strip button {
  margin-top: 8px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metrics div {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.metrics div::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #7c4dff, #b388ff);
  opacity: 0.9;
}

.metrics span {
  display: block;
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.04em;
}

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

/* ---------- Section headings & views ---------- */

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.section-heading h2 {
  font-size: 18px;
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-in 220ms ease;
}

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

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #efeff5;
}

.segmented button {
  min-height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 14px;
  border-radius: 8px;
  box-shadow: none;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}

/* ---------- Product cards ---------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.product-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary-tint-border);
  box-shadow: var(--shadow-md);
}

.product-art {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--art, var(--surface-tint));
}

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

.product-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 16px;
  flex: 1;
}

.product-body h3 {
  font-size: 15.5px;
  font-weight: 650;
}

.meta-line {
  color: var(--muted);
  font-size: 12.5px;
}

.price-line {
  display: flex;
  gap: 22px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-tint);
  border: 1px solid var(--primary-tint);
}

.price-line small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.price-line strong {
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--primary-strong);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.card-actions .primary {
  flex: 1;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  width: fit-content;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: var(--primary-tint);
  color: var(--primary);
}

.badge.green {
  background: var(--green-bg);
  color: var(--green-ink);
}

.badge.amber {
  background: var(--amber-bg);
  color: var(--amber-ink);
}

.badge.red {
  background: var(--red-bg);
  color: var(--red-ink);
}

/* ---------- Table rows ---------- */

.table-list {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(4, minmax(100px, auto));
  gap: 14px;
  align-items: center;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.row:hover {
  border-color: var(--primary-tint-border);
  box-shadow: var(--shadow-md);
}

.row strong,
.row span,
.row small {
  display: block;
}

.row strong {
  font-size: 13.5px;
  font-weight: 650;
}

.row small {
  color: var(--muted);
  font-size: 12px;
}

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

.compact .row {
  grid-template-columns: 1fr auto;
}

.row-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--art, var(--surface-tint));
  border: 1px solid var(--line);
  overflow: hidden;
}

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

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

/* ---------- Admin / panels ---------- */

.admin-grid,
.supplier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.supplier-grid h3,
.panel h3 {
  font-size: 14.5px;
  font-weight: 650;
  margin: 0 0 12px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.panel .table-list .row {
  border-radius: var(--radius-sm);
  box-shadow: none;
  background: var(--bg);
  border-color: transparent;
}

.panel .table-list .row:hover {
  border-color: var(--primary-tint-border);
}

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

.flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.flow-step {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-tint);
  border: 1px solid var(--primary-tint);
}

.flow-step strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.flow-step span {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--primary-strong);
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ops-card {
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
}

.ops-card small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ops-card strong {
  display: block;
  margin: 3px 0 1px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

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

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.breakdown-grid h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.breakdown-list {
  display: grid;
  gap: 10px;
}

.breakdown-row strong {
  font-size: 13px;
}

.breakdown-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.breakdown-row .bar {
  height: 8px;
  border-radius: 999px;
  background: var(--primary-tint);
  overflow: hidden;
}

.breakdown-row .bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c4dff, #a06bff);
}

/* ---------- Drawer ---------- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(26, 18, 53, 0);
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  transition: background 200ms ease;
}

.drawer.open {
  background: rgba(26, 18, 53, 0.42);
  pointer-events: auto;
}

.drawer-card {
  position: relative;
  width: min(540px, 92vw);
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(28, 18, 65, 0.18);
  padding: 26px 26px 40px;
  transform: translateX(30px);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.drawer.open .drawer-card {
  transform: translateX(0);
  opacity: 1;
}

.drawer-card h2 {
  font-size: 19px;
  margin: 2px 0 12px;
}

.drawer-product-image {
  height: 210px;
  border-radius: var(--radius-md);
  background: var(--art, var(--surface-tint));
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 16px;
}

.drawer-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.variant-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.variant-list div {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12.5px;
}

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

.field-grid {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.field-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
}

.field-grid input,
.field-grid textarea,
.field-grid select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field-grid input:read-only {
  background: var(--bg);
  color: var(--muted);
}

.field-grid input:focus,
.field-grid textarea:focus,
.field-grid select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(110, 54, 229, 0.14);
}

.notice-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.notice-list div {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-tint);
  border: 1px solid var(--primary-tint);
  color: var(--ink);
  font-size: 12.5px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--shadow-md);
  animation: toast-in 180ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .product-grid,
  .ops-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    flex-direction: column;
    gap: 14px;
    padding: 14px;
  }

  .role-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .role-tabs button {
    justify-content: center;
    padding: 9px 8px;
    text-align: center;
  }

  .role-tabs button::before,
  .ai-status {
    display: none;
  }

  main {
    padding: 18px;
  }

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

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

  .shop-strip,
  .metrics,
  .product-grid,
  .supplier-grid,
  .ops-grid,
  .admin-grid,
  .breakdown-grid,
  .row {
    grid-template-columns: 1fr;
  }

  .variant-list div {
    grid-template-columns: 1fr;
  }
}

/* Brand logo (replaces the old gradient "D" mark) */
.brand-mark-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
