:root {
  --white:      #ffffff;
  --bg:         #f0f2f7;
  --bg-2:       #ffffff;
  --bg-3:       #f5f6fa;
  --border:     #dde1ed;
  --border-2:   #c8cde0;

  --blue:       #1a73e8;
  --blue-h:     #1558b0;
  --blue-light: #e8f0fd;
  --green:      #1a9e5c;
  --green-light:#e6f7ee;
  --orange:     #d97706;
  --orange-light:#fef3c7;
  --red:        #dc2626;
  --red-light:  #fee2e2;
  --gray:       #64748b;
  --gray-light: #f1f5f9;
  --teal:       #0891b2;
  --teal-light: #e0f2fe;
  --purple:     #7c3aed;
  --purple-light:#ede9fe;
  --amber:      #b45309;
  --amber-light:#fef3c7;

  --text-1: #1e2332;
  --text-2: #4b5468;
  --text-3: #8e96b0;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --sidebar-w:  200px;
  --topbar-h:   44px;
  --radius:     6px;
  --radius-sm:  4px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 3px 10px rgba(0,0,0,.09), 0 1px 3px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── TOPBAR ──────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  z-index: 200; box-shadow: var(--shadow-sm);
}
.topbar-brand {
  width: var(--sidebar-w); padding: 0 1rem;
  font-weight: 700; font-size: .95rem;
  color: var(--blue); letter-spacing: -.01em;
  flex-shrink: 0; display: flex; align-items: center; gap: .4rem;
}
.topbar-brand .brand-sub { font-weight: 400; color: var(--text-3); font-size: .78rem; }
.topbar-title { font-size: .82rem; font-weight: 600; color: var(--text-2); padding-left: 1rem; }

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  overflow-y: auto; z-index: 100;
  padding: .75rem 0;
}
.nav-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .48rem 1rem;
  font-size: .8rem; color: var(--text-2); text-decoration: none;
  border-radius: 0; transition: background .1s, color .1s;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-3); color: var(--text-1); }
.nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }
.nav-item .nav-icon { font-size: .95rem; width: 18px; text-align: center; }
.nav-section {
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3);
  padding: .75rem 1rem .3rem;
}

/* ── MAIN ────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 1.2rem 1.4rem;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── CARDS / KPIs ────────────────────────────── */
.summary-bar { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .85rem; }
.kpi-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .85rem; }
.kpi-card {
  flex: 1; min-width: 120px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem 1rem;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: .3rem; }
.kpi-value { font-size: 1.3rem; font-weight: 700; color: var(--text-1); line-height: 1.1; }
.kpi-value.green  { color: var(--green); }
.kpi-value.red    { color: var(--red); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.blue   { color: var(--blue); }
.kpi-sub  { font-size: .68rem; color: var(--text-3); margin-top: .2rem; }

/* ── FILTERS BAR ─────────────────────────────── */
.filters-bar {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem 1rem;
  margin-bottom: .85rem; box-shadow: var(--shadow-sm);
}
.filters-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); margin-bottom: .55rem;
}
.filters-row { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }

/* Multi-select */
.ms-wrap { position: relative; }
.ms-btn {
  display: flex; align-items: center; gap: .4rem;
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: .3rem .7rem;
  font-size: .78rem; color: var(--text-2); font-family: var(--font);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: border-color .12s;
}
.ms-btn:hover { border-color: var(--blue); }
.ms-btn.active { background: var(--blue-light); border-color: rgba(26,115,232,.45); color: var(--blue); font-weight: 600; }
.ms-btn .ms-label { font-weight: 700; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; opacity: .65; margin-right: .1rem; }
.ms-btn .ms-arrow { font-size: .55rem; opacity: .5; transition: transform .15s; }
.ms-btn.open .ms-arrow { transform: rotate(180deg); }
.ms-count { background: var(--blue); color: white; border-radius: 100px; font-size: .62rem; font-weight: 700; padding: .05rem .35rem; margin-left: .15rem; }
.ms-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--white); border: 1px solid var(--border-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 500; min-width: 180px; overflow: hidden;
}
.ms-dropdown.open { display: block; }
.ms-options { max-height: 210px; overflow-y: auto; padding: .3rem 0; }
.ms-option {
  display: flex; align-items: center; gap: .5rem;
  padding: .38rem .75rem; cursor: pointer; font-size: .78rem;
  color: var(--text-2); transition: background .1s;
}
.ms-option:hover { background: var(--bg-3); }
.ms-option input[type=checkbox] { accent-color: var(--blue); width: 13px; height: 13px; flex-shrink: 0; cursor: pointer; }
.ms-option.checked { color: var(--text-1); font-weight: 500; }
.ms-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: .4rem .75rem; border-top: 1px solid var(--border); font-size: .72rem;
}
.ms-footer-clear { color: var(--text-3); cursor: pointer; text-decoration: underline; background: none; border: none; font-family: var(--font); }
.ms-footer-clear:hover { color: var(--red); }

/* Search chip */
.search-chip {
  display: flex; align-items: center; gap: .35rem;
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: .28rem .7rem;
  font-size: .78rem; transition: border-color .12s;
}
.search-chip:focus-within { border-color: var(--blue); background: var(--blue-light); }
.search-chip input { background: transparent; border: none; outline: none; font-size: .78rem; color: var(--text-1); font-family: var(--font); width: 200px; }
.search-chip input::placeholder { color: var(--text-3); }

.filters-actions { display: flex; gap: .45rem; align-items: center; margin-left: auto; }
.btn-apply  { background: var(--blue); color: white; border: none; border-radius: var(--radius-sm); padding: .33rem .9rem; font-size: .78rem; font-weight: 600; font-family: var(--font); cursor: pointer; }
.btn-apply:hover { background: var(--blue-h); }
.btn-clear-all { background: var(--white); border: 1px solid var(--border-2); color: var(--text-2); border-radius: var(--radius-sm); padding: .31rem .75rem; font-size: .76rem; font-weight: 500; font-family: var(--font); cursor: pointer; }
.btn-clear-all:hover { border-color: var(--red); color: var(--red); }

/* ── CATEGORY TREE ───────────────────────────── */
.cat-search-wrap { padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
.cat-search-input {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: .3rem .55rem; font-size: .78rem; font-family: var(--font);
  outline: none; color: var(--text-1); background: var(--bg-3);
}
.cat-search-input:focus { border-color: var(--blue); background: var(--white); }
.cat-tree-item {
  display: flex; align-items: center; gap: .4rem;
  padding: .38rem .75rem; cursor: pointer; font-size: .78rem;
  color: var(--text-2); transition: background .1s;
}
.cat-tree-item:hover { background: var(--bg-3); }
.cat-tree-item.has-children { color: var(--text-1); font-weight: 500; }
.cat-dot { color: var(--blue); font-size: .5rem; flex-shrink: 0; line-height: 1; }
.cat-arrow { margin-left: auto; color: var(--text-3); font-size: .9rem; flex-shrink: 0; }
.cat-name { flex: 1; }
.cat-path { flex: 1; font-size: .75rem; }
.cat-breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: .2rem;
  padding: .35rem .75rem; font-size: .72rem;
  border-bottom: 1px solid var(--border); background: var(--bg-3);
}
.cat-bc-item { color: var(--blue); cursor: pointer; }
.cat-bc-item:hover { text-decoration: underline; }
.cat-bc-sep { color: var(--text-3); }
.cat-select-level {
  padding: .3rem .75rem; font-size: .72rem; color: var(--green);
  cursor: pointer; border-bottom: 1px solid var(--border);
}
.cat-select-level:hover { background: var(--green-light); }
.cat-empty { padding: .5rem .75rem; font-size: .75rem; color: var(--text-3); }
mark.cat-hl { background: #fef08a; border-radius: 2px; padding: 0 1px; font-style: normal; }

/* ── BULK ACTION BAR ─────────────────────────── */
.bulk-bar {
  display: none; align-items: center; gap: .6rem;
  background: var(--blue-light); border: 1px solid rgba(26,115,232,.3);
  border-radius: var(--radius); padding: .55rem 1rem;
  margin-bottom: .6rem;
}
.bulk-bar.visible { display: flex; }
.bulk-count { font-size: .8rem; font-weight: 600; color: var(--blue); }
.bulk-actions { display: flex; gap: .4rem; margin-left: auto; }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  border: none; border-radius: var(--radius-sm);
  padding: .32rem .85rem; font-size: .78rem; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: background .15s;
  text-decoration: none;
}
.btn-sm { padding: .22rem .6rem; font-size: .72rem; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-h); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #168a4f; }
.btn-danger  { background: var(--red); color: white; }
.btn-danger:hover  { background: #b91c1c; }
.btn-outline { background: var(--white); border: 1px solid var(--border-2); color: var(--text-2); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost  { background: transparent; color: var(--text-2); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg-3); border-color: var(--border-2); }

/* ── TABLES ──────────────────────────────────── */
.table-wrap {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--bg-3); border-bottom: 1px solid var(--border);
  padding: .55rem .75rem; text-align: left;
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3); white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-1); }
td {
  padding: .55rem .75rem; border-bottom: 1px solid var(--border);
  font-size: .8rem; color: var(--text-2); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-3); }

/* ── SCORE BAR ───────────────────────────────── */
.score-wrap { display: flex; align-items: center; gap: .5rem; min-width: 120px; }
.score-bar-bg {
  flex: 1; height: 6px; background: var(--border);
  border-radius: 100px; overflow: hidden;
}
.score-bar-fill { height: 100%; border-radius: 100px; transition: width .3s; }
.score-bar-fill.critical { background: var(--red); }
.score-bar-fill.warning  { background: var(--orange); }
.score-bar-fill.good     { background: var(--blue); }
.score-bar-fill.complete { background: var(--green); }
.score-pct { font-size: .75rem; font-weight: 700; white-space: nowrap; min-width: 34px; text-align: right; }
.score-pct.critical { color: var(--red); }
.score-pct.warning  { color: var(--orange); }
.score-pct.good     { color: var(--blue); }
.score-pct.complete { color: var(--green); }

/* ── BADGES ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: .68rem; font-weight: 600; padding: .15rem .55rem;
  border-radius: 100px; white-space: nowrap;
}
.badge-pending  { background: var(--orange-light); color: var(--orange); }
.badge-approved { background: var(--blue-light);   color: var(--blue); }
.badge-applied   { background: var(--green-light);  color: var(--green); }
.badge-complete  { background: var(--green); color: #fff; font-weight: 700; }
.badge-rejected { background: var(--gray-light);   color: var(--gray); }
.badge-error    { background: var(--red-light);    color: var(--red); }
.badge-required { background: var(--purple-light); color: var(--purple); }
.badge-optional { background: var(--gray-light);   color: var(--gray); }

/* ── PAGINATION ──────────────────────────────── */
.pagination {
  display: flex; flex-direction: column; align-items: center;
  gap: .45rem; padding: .75rem 1rem .6rem;
  border-top: 1px solid var(--border);
}
.pagination-info { font-size: .72rem; color: var(--text-3); }
.pagination-nav { display: flex; align-items: center; gap: .35rem; }
.pg-pages { display: flex; gap: .3rem; align-items: center; }
.pg-btn {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-1); border-radius: var(--radius-sm);
  padding: .3rem .65rem; font-size: .78rem;
  font-family: var(--font); cursor: pointer;
  transition: background .15s; white-space: nowrap;
}
.pg-btn:hover:not(:disabled) { background: var(--bg-3); border-color: var(--blue); color: var(--blue); }
.pg-btn.active { background: var(--blue); color: white; border-color: var(--blue); font-weight: 700; }
.pg-btn:disabled { opacity: .4; cursor: default; }
.pg-ellipsis { color: var(--text-3); padding: 0 .2rem; font-size: .78rem; }

/* ── TOAST ───────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.2rem; right: 1.2rem;
  display: flex; flex-direction: column; gap: .4rem;
  z-index: 9999;
}
.toast {
  background: var(--text-1); color: white;
  padding: .6rem 1rem; border-radius: var(--radius);
  font-size: .8rem; box-shadow: var(--shadow);
  animation: toast-in .2s ease;
  max-width: 340px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--orange); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── MISC ────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}
.page-title { font-size: 1.1rem; font-weight: 700; color: var(--text-1); }
.page-subtitle { font-size: .8rem; color: var(--text-3); margin-top: .1rem; }
.page-actions { margin-left: auto; display: flex; gap: .45rem; }

.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1rem;
}
.card-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: .75rem; }

.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-3); font-size: .85rem;
}
.empty-icon { font-size: 2rem; margin-bottom: .5rem; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-2); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td { text-align: center; padding: 2rem; color: var(--text-3); }

/* ── FORM ────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-2); margin-bottom: .3rem; }
.form-hint  { font-size: .72rem; color: var(--text-3); margin-top: .2rem; }
.form-input, .form-select {
  width: 100%; padding: .42rem .65rem;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  font-size: .82rem; font-family: var(--font); color: var(--text-1);
  background: var(--white); outline: none; transition: border-color .12s;
}
.form-input:focus, .form-select:focus { border-color: var(--blue); }

/* ── DETAIL TABLE ────────────────────────────── */
.attr-table td { vertical-align: top; }
.attr-value-current { color: var(--text-3); font-style: italic; font-size: .78rem; }
.attr-value-proposed { color: var(--text-1); font-weight: 500; }

/* Score header */
.score-header {
  display: flex; align-items: center; gap: 1.2rem;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1.2rem;
  box-shadow: var(--shadow-sm); margin-bottom: .85rem;
}
.score-header .product-title { font-size: .95rem; font-weight: 700; color: var(--text-1); }
.score-header .product-sku   { font-size: .75rem; color: var(--text-3); margin-top: .1rem; }
.score-big {
  text-align: center; min-width: 80px;
}
.score-big .score-num { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.score-big .score-lbl { font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-top: .1rem; }
