/* Innovative Design Photographers CRM — Clean white UI */
:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --warning: #a16207;
  --warning-bg: #fefce8;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --font: "Plus Jakarta Sans", "Circular Std", "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 250px;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
img, svg, video, canvas { max-width: 100%; height: auto; }
button, input, select, textarea { touch-action: manipulation; }

a { color: var(--blue-700); text-decoration: none; }
a:hover { color: var(--blue-900); }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  max-width: 86vw;
  background: #fff;
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-900));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-logo-lg {
  width: 72px;
  height: 72px;
  display: block;
}
.logo-preview {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.logo-preview img {
  max-height: 64px;
  max-width: 160px;
  object-fit: contain;
}
.color-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}
.color-row input[type="color"] {
  width: 52px;
  height: 44px;
  padding: 0.2rem;
  border-radius: 10px;
  cursor: pointer;
}
.color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.25rem;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  padding: 0;
}
.shade-bar {
  display: flex;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.shade-bar span { flex: 1; }
.brand strong { display: block; font-size: 0.95rem; color: var(--text); }
.brand span { display: block; font-size: 0.72rem; color: var(--muted); }

.nav { padding: 1rem 0.85rem; display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.nav a {
  display: block;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav a:hover { background: var(--blue-50); color: var(--blue-800); }
.nav a.active { background: var(--blue-100); color: var(--blue-900); font-weight: 600; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.user-chip strong { display: block; font-size: 0.9rem; }
.user-chip span { font-size: 0.75rem; color: var(--muted); }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem clamp(1rem, 2.5vw, 1.5rem);
  padding-top: max(1.1rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}
.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.menu-btn:hover { background: var(--surface); }
.content {
  padding: clamp(1rem, 2.2vw, 1.5rem);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  max-width: 1200px;
  width: 100%;
}
.content-wide { max-width: 1500px; }

/* Cards & layout */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card, .panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card { padding: 1.15rem 1.25rem; }
.stat-card .label { color: var(--muted); font-size: 0.82rem; font-weight: 500; margin: 0 0 0.35rem; }
.stat-card .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; margin: 0; color: var(--blue-900); }
.stat-card .sub { margin: 0.35rem 0 0; font-size: 0.78rem; color: var(--muted); }

.panel { padding: 1.25rem; }
.panel-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.panel-h h2 { margin: 0; font-size: clamp(0.95rem, 2vw, 1.05rem); font-weight: 600; }
.export-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.chart-wrap { position: relative; height: clamp(200px, 32vw, 280px); min-height: 200px; }

/* Dashboard order pipeline */
.pipeline-panel { padding-bottom: 1rem; }
.pipeline-h { flex-wrap: wrap; gap: 0.75rem; }
.period-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.period-tab {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.period-tab:hover { color: var(--blue-800); background: #fff; }
.period-tab.active {
  background: var(--blue-700);
  color: #fff;
}
.period-tab.active:hover { color: #fff; background: var(--blue-800); }
.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}
.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.95rem 0.85rem;
  text-align: center;
}
.pipeline-card .value {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--blue-900);
  line-height: 1.1;
}
.pipeline-card .label {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.25;
}
.pipeline-total {
  background: linear-gradient(160deg, var(--blue-50), #fff);
  border-color: var(--blue-200);
}
.pipeline-total .value { color: var(--blue-700); font-size: 1.85rem; }
.pipeline-hint {
  margin: 0.85rem 0 0;
  font-size: 0.8rem;
}

.top-designer-card {
  background: linear-gradient(160deg, #fff7ed, #fff);
  border-color: #fed7aa;
}
.top-designer-card .label { color: #9a3412; font-weight: 700; }
.top-designer-card .value { color: #9a3412; font-size: 1.7rem; }
.dept-card .value { color: var(--blue-800); }
.today-prod-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.today-prod-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.today-prod-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.today-prod-list li:first-child { padding-top: 0; }
.today-prod-list span {
  font-weight: 700;
  color: var(--blue-800);
  white-space: nowrap;
}
.profit-positive { color: var(--success); }
.profit-negative { color: var(--danger); }
table tfoot th {
  border-top: 2px solid var(--border);
  font-weight: 700;
}

/* Forms */
.form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  box-shadow: var(--shadow);
  max-width: min(720px, 100%);
  width: 100%;
}
.form-card-wide { max-width: min(920px, 100%); }
.section-title {
  font-size: 1rem;
  margin: 1.25rem 0 1rem;
}
.section-title:first-child { margin-top: 0; }

.items-panel { padding: 1rem; margin: 0 0 1.1rem; }
.items-table { min-width: 480px; }
.items-table input[type="text"],
.items-table input[type="number"] {
  margin: 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
}
.items-table .col-num,
.items-table td:nth-child(2),
.items-table td:nth-child(3),
.items-table td:nth-child(4),
.items-table th:nth-child(2),
.items-table th:nth-child(3),
.items-table th:nth-child(4) { text-align: right; width: 1%; white-space: nowrap; }
.items-table .item-amount { font-weight: 600; color: var(--blue-900); }
.items-table tfoot th { background: var(--blue-50); color: var(--blue-900); text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
.items-total-label { text-align: right !important; }
.items-table-readonly { min-width: 360px; }
.category-fields[hidden] { display: none !important; }
label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.field { margin-bottom: 1.1rem; }
.hint { display: block; margin-top: 0.3rem; font-size: 0.78rem; color: var(--muted); }
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px var(--blue-100);
}
textarea { min-height: 100px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--blue-700); color: #fff; }
.btn-primary:hover { background: var(--blue-900); color: #fff; }
.btn-secondary { background: var(--blue-50); color: var(--blue-800); border-color: var(--blue-200); }
.btn-secondary:hover { background: var(--blue-100); color: var(--blue-900); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
.btn-lg { padding: 0.9rem 1.5rem; font-size: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.5rem; }

/* Table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 0 -0.15rem;
  padding-bottom: 0.15rem;
  background:
    linear-gradient(90deg, #fff 30%, transparent),
    linear-gradient(90deg, transparent, #fff 70%) 100% 0,
    linear-gradient(90deg, rgba(15, 23, 42, 0.08), transparent),
    linear-gradient(90deg, transparent, rgba(15, 23, 42, 0.08)) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 560px; }
th, td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table:not(.product-tree-table) th,
table:not(.product-tree-table) td {
  white-space: nowrap;
}
table:not(.product-tree-table) td:nth-child(2),
table:not(.product-tree-table) td:nth-child(3),
table:not(.product-tree-table) td:nth-child(4) {
  white-space: normal;
  min-width: 7rem;
  max-width: 16rem;
}
th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:hover td { background: #fbfdff; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--blue-50); color: var(--blue-800); }
.badge-muted { background: var(--surface); color: var(--muted); }

/* Alerts */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.alert-info { background: var(--blue-50); color: var(--blue-800); border-color: var(--blue-200); }

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: end;
}
.filters .field { margin: 0; min-width: min(160px, 100%); flex: 1 1 140px; }
.filters .btn { flex: 0 0 auto; }

/* Detail */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem 1.5rem;
}
.detail-item label { margin: 0; color: var(--muted); font-weight: 500; font-size: 0.78rem; }
.detail-item div { font-weight: 600; margin-top: 0.15rem; }
.detail-item-wide { grid-column: 1 / -1; }
.detail-item-wide .progress-summary { font-weight: 500; }

.progress-summary { display: grid; gap: 0.7rem; }
.progress-meter { min-width: 0; }
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--blue-900);
}
.progress-meta span:last-child { color: var(--muted); font-weight: 500; }
.progress-track {
  height: 8px;
  background: var(--blue-50);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  background: var(--blue-600);
  border-radius: 999px;
  min-width: 0;
}
.progress-fill.is-complete { background: var(--success); }
.progress-cell { font-size: 0.85rem; line-height: 1.35; white-space: nowrap; }
.progress-log { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.progress-log li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.progress-log li:last-child { border-bottom: 0; }
.progress-log time { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 1rem; }
.muted { color: var(--muted); }
.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.activity-list li:last-child { border-bottom: 0; }
.activity-list time { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

/* Auth */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 1.5rem);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at top right, var(--blue-100), transparent 45%),
    radial-gradient(circle at bottom left, var(--blue-50), transparent 40%),
    #fff;
}
.auth-box {
  width: 100%;
  max-width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: var(--shadow);
}
.auth-box h1 { margin: 0 0 0.35rem; font-size: clamp(1.15rem, 4vw, 1.4rem); }
.auth-box .tagline { margin: 0 0 1.5rem; color: var(--muted); font-size: 0.9rem; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 40;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.nav-open { overflow: hidden; touch-action: none; }

/* Product tree + cascade */
.products-layout {
  align-items: start;
  grid-template-columns: minmax(320px, 380px) 1fr;
}
.products-layout > * { min-width: 0; }
.product-tree-table td { font-size: 0.88rem; padding: 0.45rem 0.6rem; vertical-align: middle; }
.product-tree-table th:last-child { width: 1%; }
.product-tree-table .actions { flex-wrap: nowrap; }
.product-tree-table .actions .btn { padding: 0.3rem 0.55rem; font-size: 0.78rem; white-space: nowrap; }
.product-tree-table tbody tr { border-left: 3px solid transparent; }
.product-tree-table tbody tr:hover td { background: var(--blue-50); }
.product-tree-table tr.product-root td { background: var(--blue-50); }
.product-tree-table tr.product-root { border-left-color: var(--blue-600); }
.product-tree-table tr.product-root .tree-name { font-weight: 700; color: var(--blue-900); }
.product-tree-table tr[data-depth="1"] { border-left-color: var(--blue-200); }
.product-tree-table tr[data-depth="1"] .tree-name { font-weight: 600; }
.product-tree-table tr[data-active="0"] .tree-name { color: var(--muted); text-decoration: line-through; }
.product-tree-table tr.search-hit .tree-name {
  background: #fef9c3;
  border-radius: 4px;
  padding: 0 0.2rem;
}

.tree-indent {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  min-width: 0;
  padding-left: calc(var(--tree-depth, 0) * 1.35rem);
}
.tree-indent > .badge, .tree-indent > .tree-icon, .tree-indent > .tree-toggle { flex: none; }
.tree-indent .badge { white-space: nowrap; }
.product-tree-table td:nth-child(2),
.product-tree-table td:nth-child(3) { white-space: nowrap; width: 1%; }
.product-tree-table .badge { white-space: nowrap; }
.tree-toggle {
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--blue-700);
  font-size: 0.7rem;
  cursor: pointer;
}
.tree-toggle:hover { background: var(--blue-100); }
.tree-toggle i { transition: transform .15s; }
.tree-toggle[aria-expanded="true"] i { transform: rotate(90deg); }
.tree-toggle-empty { border-color: transparent; background: none; cursor: default; }
.tree-icon { color: var(--blue-500); font-size: 0.8rem; width: 1rem; text-align: center; }
tr.is-leaf .tree-icon { color: var(--muted); }
.tree-name { font-weight: 500; flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
tr.has-kids .tree-name { cursor: pointer; }
.tree-note {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--warning);
  background: var(--warning-bg);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rate-tag {
  display: inline-block;
  font-weight: 600;
  color: var(--success);
  background: var(--success-bg);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

/* Icon-only action buttons */
.btn-icon {
  padding: 0.35rem;
  width: 30px;
  height: 30px;
  font-size: 0.78rem;
  border-radius: 8px;
}
.icon-actions { gap: 0.3rem; }

/* Search box + tree toolbar */
.search-box { position: relative; display: block; }
.search-box > i.fa-magnifying-glass {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}
.search-box input {
  padding-left: 2.2rem !important;
  padding-right: 2.2rem !important;
}
.search-box-sm input { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.85rem;
}
.search-clear:hover { color: var(--danger); }

.tree-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}
.tree-toolbar .search-box { flex: 3 1 220px; min-width: 0; }
.tree-toolbar select {
  flex: 1 1 150px;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  text-overflow: ellipsis;
}
.tree-toolbar-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; margin-left: auto; }
.tree-result-count { font-size: 0.8rem; margin: 0 0 0.5rem; min-height: 1.1rem; }

.parent-select {
  padding: 0.4rem !important;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.parent-select option { padding: 0.25rem 0.35rem; }
.parent-select option[data-depth="0"] { font-weight: 700; color: var(--blue-900); }
.parent-context {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  background: var(--blue-50);
  color: var(--blue-800);
  border: 1px solid var(--blue-200);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  margin: 0 0 0.9rem;
}

.product-cascade {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.product-cascade .cascade-level { margin-bottom: 0.85rem; }
.product-notes {
  margin-top: 0.25rem;
  padding: 0.75rem 0.9rem;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.product-notes[hidden] { display: none; }
.product-notes .summary-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.product-notes .summary-path {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--blue-900);
  line-height: 1.45;
}
.product-notes .summary-note {
  font-size: 0.82rem;
  padding: 0.5rem 0.7rem;
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  border-radius: 8px;
  color: var(--warning);
}

/* ========== Responsive: phones → tablets → MacBook Air → laptops ========== */

/* Large laptops / MacBook Pro 14–16″ CSS widths */
@media (min-width: 1440px) {
  .content { max-width: 1280px; }
  .content-wide { max-width: 1600px; }
}

/* MacBook Air 13″ / smaller laptops (~1280 CSS px) */
@media (max-width: 1366px) {
  :root { --sidebar-w: 230px; }
  .stat-card .value { font-size: 1.4rem; }
  .pipeline-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* iPad Pro landscape / compact laptop */
@media (max-width: 1180px) {
  .products-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* Tablets & small laptops — drawer navigation */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.12);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .nav a { padding: 0.8rem 0.95rem; font-size: 1rem; }
  .period-tabs { width: 100%; justify-content: stretch; }
  .period-tab { flex: 1; text-align: center; }
}

/* iPad portrait / large phones landscape */
@media (max-width: 900px) {
  .grid-2:not(.products-layout) { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .filters .field { flex: 1 1 calc(50% - 0.75rem); min-width: 140px; }
}

/* Phones & small tablets */
@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .row-2,
  .detail-grid { grid-template-columns: 1fr; }

  .content { padding: 0.9rem; }
  .panel, .stat-card { padding: 1rem; }
  .panel-h { align-items: flex-start; }
  .export-actions { width: 100%; }
  .export-actions .btn { flex: 1 1 auto; }

  .filters { gap: 0.65rem; }
  .filters .field { flex: 1 1 100%; min-width: 0; }
  .filters .btn { width: 100%; }

  .actions { gap: 0.5rem; }
  .actions .btn { flex: 1 1 auto; min-height: 44px; }

  .stat-card .value { font-size: 1.35rem; }
  .pipeline-grid { grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
  .pipeline-card { padding: 0.8rem 0.6rem; }
  .pipeline-card .value { font-size: 1.4rem; }
  .pipeline-total .value { font-size: 1.55rem; }

  .period-tabs {
    display: flex;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table { font-size: 0.82rem; min-width: 520px; }
  .items-table { min-width: 0; width: 100%; }
  .items-table thead { display: none; }
  .items-table tbody tr.item-row,
  .items-table-readonly tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.6rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
  }
  .items-table td {
    display: block;
    width: auto !important;
    max-width: none;
    padding: 0.15rem 0;
    border: 0;
    white-space: normal;
    text-align: left !important;
  }
  .items-table td:first-child { grid-column: 1 / -1; }
  .items-table tfoot tr {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0 0;
  }
  .items-table tfoot th { background: transparent; padding: 0.2rem 0; }
  th, td { padding: 0.6rem 0.65rem; }

  .product-tree-table { min-width: 640px; }
  .product-tree-table .actions { flex-wrap: wrap; }
  .tree-toolbar { flex-direction: column; align-items: stretch; }
  .tree-toolbar .search-box,
  .tree-toolbar select { flex: 1 1 auto; width: 100%; }
  .tree-toolbar-actions { margin-left: 0; width: 100%; }
  .tree-toolbar-actions .btn { flex: 1; }

  .color-row { flex-wrap: wrap; }
  .logo-preview { flex-wrap: wrap; }

  .btn, .btn-lg { min-height: 44px; }
  .btn-sm { min-height: 36px; }
}

/* Compact phones */
@media (max-width: 480px) {
  body { font-size: 14px; }
  .brand strong { font-size: 0.88rem; }
  .brand span { font-size: 0.68rem; }
  .topbar { padding: 0.85rem 0.75rem; gap: 0.55rem; }
  .content { padding: 0.75rem; }
  .auth-box { padding: 1.1rem; border-radius: 14px; }

  .pipeline-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .value { font-size: 1.25rem; }

  .panel-h h2 { width: 100%; }
  .export-actions .btn { font-size: 0.78rem; padding: 0.45rem 0.55rem; }

  table { min-width: 480px; font-size: 0.78rem; }
  .tree-note { max-width: 8rem; }
  .tree-indent { padding-left: calc(var(--tree-depth, 0) * 0.85rem); }
}

/* Very small phones */
@media (max-width: 360px) {
  .pipeline-grid { grid-template-columns: 1fr; }
  .menu-btn { width: 40px; height: 40px; }
}

/* Landscape phones — keep content usable */
@media (max-height: 480px) and (orientation: landscape) {
  .auth-page { align-items: start; padding-top: 1rem; }
  .sidebar { padding-top: 0.75rem; padding-bottom: 0.75rem; }
  .chart-wrap { height: 180px; min-height: 160px; }
}

/* Print */
@media print {
  .sidebar, .menu-btn, .sidebar-overlay, .topbar .menu-btn { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { max-width: none; padding: 0; }
  .panel, .stat-card { box-shadow: none; break-inside: avoid; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  html { scroll-behavior: auto; }
}

