:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface2: #F5F0E8;
  --border: rgba(0,0,0,0.08);
  --border-mid: rgba(0,0,0,0.14);
  --text: #1C1714;
  --text-mid: #6B5F57;
  --text-light: #9C9089;
  --accent: #B84A1A;
  --accent-soft: #FDF1EC;
  --gold: #C4860A;
  --gold-soft: #FEF7E6;
  --olive: #4A5E28;
  --olive-soft: #EEF3E4;
  --score-high: #3B6D11;
  --score-mid: #BA7517;
  --score-low: #A32D2D;
  --incoming: #3C3489;
  --incoming-soft: #EEEDFE;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; height: 100%; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* ── Header ── */
.header { background: var(--text); color: #FAF7F2; padding: 1.5rem 2rem 1.25rem; display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.header-left h1 { font-family: 'DM Serif Display', serif; font-size: 2rem; font-weight: 400; letter-spacing: -.01em; line-height: 1.1; }
.header-left p { font-size: .78rem; color: rgba(250,247,242,.5); margin-top: .35rem; letter-spacing: .08em; text-transform: uppercase; }
.header-right { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.hbtn { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); color: #FAF7F2; padding: .45rem 1rem; border-radius: var(--radius-sm); font-size: .78rem; cursor: pointer; font-family: inherit; transition: background .15s; }
.hbtn:hover { background: rgba(255,255,255,.18); }
.hbtn.accent { background: var(--accent); border-color: var(--accent); }
.hbtn.accent:hover { background: #9e3d13; }

/* ── Metrics ── */
.metrics-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--border); border-bottom: 1px solid var(--border); }
.metric { background: var(--surface); padding: 1.1rem 1.5rem; }
.metric-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-light); margin-bottom: .3rem; }
.metric-value { font-size: 1.6rem; font-weight: 300; color: var(--text); line-height: 1; }
.metric-sub { font-size: .72rem; color: var(--text-light); margin-top: .2rem; }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search-wrap { flex: 1; min-width: 200px; position: relative; }
.search-wrap input { width: 100%; padding: .55rem .9rem .55rem 2.2rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .82rem; font-family: inherit; background: var(--bg); color: var(--text); outline: none; }
.search-wrap input:focus { border-color: var(--accent); }
.search-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); font-size: .85rem; opacity: .4; pointer-events: none; }
.filter-tag { padding: .38rem .8rem; border: 1px solid var(--border-mid); border-radius: 20px; font-size: .75rem; font-family: inherit; background: var(--bg); color: var(--text-mid); cursor: pointer; transition: all .15s; white-space: nowrap; }
.filter-tag:hover { border-color: var(--text); color: var(--text); }
.filter-tag.active { background: var(--text); color: #FAF7F2; border-color: var(--text); }
.filter-btn { padding: .38rem .8rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .75rem; font-family: inherit; background: var(--bg); color: var(--text-mid); cursor: pointer; transition: all .15s; white-space: nowrap; }
.filter-btn:hover, .filter-btn.active { background: var(--text); color: #FAF7F2; border-color: var(--text); }
.toolbar-sep { width: 1px; height: 20px; background: var(--border-mid); flex-shrink: 0; }
.sort-select { padding: .38rem .8rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .75rem; font-family: inherit; background: var(--bg); color: var(--text-mid); cursor: pointer; outline: none; }

/* ── Main layout ── */
.main { padding: 1rem 1.25rem; max-width: 1400px; margin: 0 auto; }

/* ── Section ── */
.section { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 1rem; overflow: hidden; box-shadow: var(--shadow); }
.sec-header { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.25rem; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); transition: background .15s; }
.sec-header:hover { background: var(--bg); }
.sec-title { font-size: .9rem; font-weight: 500; }
.sec-right { display: flex; align-items: center; gap: .75rem; }
.sec-count { font-size: .75rem; color: var(--text-light); }
.chevron { font-size: .7rem; color: var(--text-light); transition: transform .2s; display: inline-block; }
.chevron.open { transform: rotate(90deg); }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); padding: .55rem 1rem; text-align: left; background: var(--surface2); border-bottom: 1px solid var(--border); }
td { font-size: .8rem; padding: .6rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); line-height: 1.35; }
tr:last-child td { border-bottom: none; }
tr.item-row:hover td { background: var(--bg); }
.col-name { width: 26%; }
.col-brand { width: 11%; }
.col-color { width: 14%; }
.col-score { width: 13%; }
.col-notes { width: 28%; }
.col-act { width: 8%; }
.grp-row td { font-size: .67rem; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); background: var(--surface2); padding: .35rem 1rem; border-bottom: 1px solid var(--border); }
.row-flag { background: rgba(252,235,235,.25); }
.row-star { background: rgba(234,243,222,.25); }
.row-updated { background: rgba(250,238,218,.25); }
.row-incoming { background: rgba(238,237,254,.25); }

/* ── Tag chips (on rows) ── */
.item-tags { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 3px; }
.tag-chip { font-size: .63rem; padding: 1px 6px; border-radius: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 2px; }
.tag-context { background: var(--olive-soft); color: var(--olive); }
.tag-type { background: #E6F1FB; color: #185FA5; }
.tag-custom { background: var(--surface2); color: var(--text-mid); }

/* ── Score bar ── */
.score-bar { display: flex; align-items: center; gap: 6px; }
.bar-track { flex: 1; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 2px; }
.score-num { font-size: .72rem; font-weight: 500; min-width: 24px; }
.swatch-cell { display: flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); flex-shrink: 0; }

/* ── Status badges ── */
.badge { display: inline-block; font-size: .65rem; padding: 1px 6px; border-radius: 4px; font-weight: 500; margin-left: 4px; }
.badge-incoming { background: var(--incoming-soft); color: var(--incoming); }
.badge-updated { background: var(--gold-soft); color: var(--gold); }

/* ── Action buttons ── */
.act-wrap { display: flex; gap: 4px; }
.act-btn { background: transparent; border: 1px solid var(--border-mid); color: var(--text-mid); border-radius: var(--radius-sm); padding: 3px 7px; font-size: .72rem; cursor: pointer; transition: all .15s; }
.act-btn:hover { background: var(--bg); color: var(--text); }
.act-btn.del:hover { background: #FCEBEB; color: #A32D2D; border-color: #F09595; }
.add-row { padding: .65rem 1rem; }
.add-row button { width: 100%; padding: .5rem; font-size: .78rem; color: var(--text-light); border: 1px dashed var(--border-mid); border-radius: var(--radius-sm); background: transparent; cursor: pointer; font-family: inherit; transition: background .15s; }
.add-row button:hover { background: var(--bg); color: var(--text); }

/* ── Gap analysis ── */
.gap-list { padding: .75rem 1.25rem; }
.gap-item { display: flex; align-items: flex-start; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .8rem; color: var(--text-mid); line-height: 1.5; }
.gap-item:last-child { border-bottom: none; }
.gpri { font-size: .65rem; font-weight: 500; padding: 2px 6px; border-radius: 4px; min-width: 40px; text-align: center; flex-shrink: 0; margin-top: 2px; }
.gph { background: #FCEBEB; color: #A32D2D; }
.gpl { background: var(--olive-soft); color: var(--olive); }

/* ── Legend ── */
.legend { display: flex; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.5rem; font-size: .73rem; color: var(--text-light); border-top: 1px solid var(--border); align-items: center; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); margin-top: 1rem; }
.li { display: flex; align-items: center; gap: 4px; }
.li-dot { width: 8px; height: 8px; border-radius: 50%; }
.li-box { width: 8px; height: 8px; border-radius: 2px; }

/* ── Modal ── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(28,23,20,.45); z-index: 200; align-items: center; justify-content: center; padding: 1rem; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 1.75rem; width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 40px rgba(0,0,0,.18); }
.modal h3 { font-family: 'DM Serif Display', serif; font-size: 1.3rem; font-weight: 400; margin-bottom: 1.25rem; color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-full { grid-column: 1/-1; }
.form-row label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: .55rem .8rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .82rem; font-family: inherit; background: var(--bg); color: var(--text); outline: none; transition: border-color .15s; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--accent); }
.form-row textarea { height: 64px; resize: vertical; }
.color-row { display: flex; align-items: flex-end; gap: .6rem; }
.color-row input[type=text] { flex: 1; }
.color-row input[type=color] { width: 44px; height: 36px; padding: 2px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border-mid); }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.btn-cancel { padding: .55rem 1.2rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .82rem; font-family: inherit; background: transparent; color: var(--text-mid); cursor: pointer; }
.btn-save { padding: .55rem 1.4rem; border: none; border-radius: var(--radius-sm); font-size: .82rem; font-family: inherit; background: var(--accent); color: #fff; cursor: pointer; font-weight: 500; }
.btn-save:hover { background: #9e3d13; }

/* ── Tag picker (in modal form) ── */
.tag-picker { border: 1px solid var(--border-mid); border-radius: var(--radius-sm); padding: .75rem; background: var(--bg); }
.tag-picker-group { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: .5rem; }
.tag-picker-group:last-of-type { margin-bottom: 0; }
.tpl { font-size: .63rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); min-width: 52px; }
.tag-pick-btn { padding: .28rem .7rem; border: 1px solid var(--border-mid); border-radius: 20px; font-size: .73rem; font-family: inherit; background: var(--surface); color: var(--text-mid); cursor: pointer; transition: all .15s; }
.tag-pick-btn:hover { border-color: var(--text); color: var(--text); }
.tag-pick-btn.selected { background: var(--text); color: #FAF7F2; border-color: var(--text); }
.tag-custom-display { display: flex; flex-wrap: wrap; gap: 4px; margin: .4rem 0 0; }
.tag-custom-display .tag-chip button { background: none; border: none; cursor: pointer; color: inherit; font-size: .75rem; padding: 0 0 0 2px; line-height: 1; opacity: .7; }
.tag-custom-display .tag-chip button:hover { opacity: 1; }
.tag-picker-input { display: flex; gap: .4rem; margin-top: .5rem; }
.tag-picker-input input { flex: 1; padding: .4rem .7rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .78rem; font-family: inherit; background: var(--surface); color: var(--text); outline: none; }
.tag-picker-input input:focus { border-color: var(--accent); }
.tag-picker-input button { padding: .4rem .8rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .73rem; font-family: inherit; background: var(--surface); color: var(--text-mid); cursor: pointer; white-space: nowrap; }

/* ── Loading / empty ── */
.empty { padding: 1.5rem; text-align: center; color: var(--text-light); font-size: .82rem; }
.loading { padding: 3rem; text-align: center; color: var(--text-light); font-size: .85rem; }

/* ── Toast ── */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--text); color: #FAF7F2; padding: .6rem 1.1rem; border-radius: var(--radius-sm); font-size: .78rem; opacity: 0; transform: translateY(8px); transition: all .25s; pointer-events: none; z-index: 300; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: 0; background: var(--surface); border-bottom: 2px solid var(--border); padding: 0 1.5rem; }
.tab { padding: .65rem 1.25rem; font-size: .8rem; font-weight: 500; color: var(--text-light); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; font-family: inherit; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Outfit card grid ── */
.outfit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; padding: 1rem 1.25rem; }
.outfit-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .45rem; }
.outfit-card-date { font-size: .72rem; color: var(--text-light); }
.outfit-swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.outfit-swatch { width: 18px; height: 18px; border-radius: 3px; border: 1px solid rgba(0,0,0,.1); flex-shrink: 0; }
.outfit-rating { font-size: .8rem; font-weight: 600; }
.outfit-notes { font-size: .75rem; color: var(--text-mid); font-style: italic; line-height: 1.4; }

/* ── Item picker (outfit modal) ── */
.item-picker { display: flex; flex-direction: column; gap: .4rem; }
.item-picker input { width: 100%; padding: .55rem .8rem; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); font-size: .82rem; font-family: inherit; background: var(--bg); color: var(--text); outline: none; }
.item-picker input:focus { border-color: var(--accent); }
.item-dropdown { border: 1px solid var(--border-mid); border-radius: var(--radius-sm); background: var(--surface); max-height: 160px; overflow-y: auto; box-shadow: var(--shadow); }
.item-dropdown-row { display: flex; align-items: center; gap: .5rem; padding: .45rem .75rem; font-size: .8rem; cursor: pointer; }
.item-dropdown-row:hover { background: var(--bg); }
.item-picker-brand { font-size: .72rem; color: var(--text-light); margin-left: auto; }
.selected-items { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 0; }
.selected-chip { display: flex; align-items: center; gap: .3rem; background: var(--surface2); border: 1px solid var(--border-mid); border-radius: 20px; padding: .2rem .6rem .2rem .4rem; font-size: .75rem; color: var(--text); }
.selected-chip button { background: none; border: none; cursor: pointer; color: var(--text-light); font-size: .85rem; line-height: 1; padding: 0; margin-left: 1px; }
.selected-chip button:hover { color: var(--accent); }
