/* ============================================================
   Black Unicorn — Apparel Bid Marketplace (demo)
   ============================================================ */
:root {
  --ink:        #14131a;
  --ink-2:      #2a2833;
  --paper:      #f6f4ef;
  --paper-2:    #fffdf9;
  --line:       #e3ded3;
  --line-2:     #d4cdbe;
  --muted:      #7a7568;
  --muted-2:    #9a9486;
  --accent:     #6d4aff;   /* buyer */
  --accent-2:   #1f9d63;   /* factory */
  --accent-3:   #b8862f;   /* admin / escrow gold */
  --danger:     #c0392b;
  --warn:       #c98a16;
  --ok:         #1f9d63;
  --chip:       #efeadf;
  --shadow:     0 1px 2px rgba(20,19,26,.04), 0 8px 24px rgba(20,19,26,.06);
  --shadow-lg:  0 12px 48px rgba(20,19,26,.18);
  --radius:     14px;
  --radius-sm:  9px;
  --font:       'Inter', system-ui, sans-serif;
  --serif:      'Fraunces', Georgia, serif;
  --mono:       'JetBrains Mono', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
}
[data-role-theme="buyer"]   { --accent: #6d4aff; }
[data-role-theme="factory"] { --accent: #1f9d63; }
[data-role-theme="admin"]   { --accent: #b8862f; }

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  height: 62px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px;
  background: var(--ink);
  color: #f3f0e9;
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: baseline; gap: 9px; cursor: pointer; user-select: none; }
.brand-mark { color: var(--accent); font-size: 17px; transform: translateY(1px); transition: color .3s; }
.brand-name { font-weight: 700; letter-spacing: .14em; font-size: 15px; }
.brand-sub  { font-family: var(--serif); font-style: italic; font-size: 12.5px; color: #a9a394; font-weight: 400; }
@media (max-width: 720px){ .brand-sub { display:none; } }

.role-switch {
  margin-left: auto;
  display: flex; gap: 3px;
  background: rgba(255,255,255,.06);
  padding: 4px; border-radius: 999px;
}
.role-btn {
  border: 0; background: transparent; color: #cfc9bb;
  padding: 7px 17px; border-radius: 999px; font-weight: 600; font-size: 13px;
  transition: all .18s;
}
.role-btn:hover { color: #fff; }
.role-btn.active { background: var(--accent); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.25); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.ghost-btn {
  border: 1px solid rgba(255,255,255,.16); background: transparent; color: #cfc9bb;
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
  transition: all .15s;
}
.ghost-btn:hover { border-color: rgba(255,255,255,.4); color: #fff; }
.user-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: #e8e4da;
}
.user-pill .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff;
  background: var(--accent);
}
@media (max-width:560px){ .user-pill .uname{ display:none; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 234px 1fr; min-height: calc(100vh - 62px); }
@media (max-width: 860px){ .shell { grid-template-columns: 1fr; } .sidebar { display:none; } }

.sidebar {
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky; top: 62px; height: calc(100vh - 62px); overflow-y: auto;
}
.side-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted-2); font-weight: 700; padding: 6px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-weight: 500; color: var(--ink-2); border: 0; background: transparent;
  width: 100%; text-align: left; font-size: 13.5px; transition: all .14s;
}
.nav-item .ico { width: 17px; text-align: center; opacity: .7; }
.nav-item:hover { background: var(--chip); }
.nav-item.active { background: var(--ink); color: #fff; }
.nav-item.active .ico { opacity: 1; }
.nav-item .badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 19px; height: 19px;
  border-radius: 999px; display: grid; place-items: center; padding: 0 5px;
}
.nav-item.active .badge { background: rgba(255,255,255,.22); }

.sidebar-foot {
  margin-top: 14px; padding: 12px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); line-height: 1.55;
}

/* ---------- Main ---------- */
.main { padding: 26px 30px 60px; max-width: 1180px; }
@media (max-width: 600px){ .main { padding: 18px 16px 50px; } }

.page-head { margin-bottom: 22px; }
.page-head h1 {
  font-family: var(--serif); font-weight: 600; font-size: 27px; margin: 0 0 4px;
  letter-spacing: -.01em;
}
.page-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
.crumb { font-size: 12px; color: var(--muted-2); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 7px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px){ .g-3,.g-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 620px){ .g-2,.g-3,.g-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card.tight { padding: 14px 16px; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-h .sub { font-size: 12.5px; color: var(--muted); }
.card-h .spacer { margin-left: auto; }

/* stat */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .value { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.stat .delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }

/* ---------- Badges / chips ---------- */
.badge-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--chip); color: var(--ink-2); white-space: nowrap;
}
.badge-pill.ok    { background: #e0f3e8; color: #146b41; }
.badge-pill.warn  { background: #fbeed2; color: #946012; }
.badge-pill.info  { background: #e7e2fb; color: #4a31b8; }
.badge-pill.danger{ background: #fbe3df; color: #962419; }
.badge-pill.gold  { background: #f6ead0; color: #8a6418; }
.badge-pill.mut   { background: #ececec; color: #6a6458; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display:inline-block; }

.verify { color: var(--accent-2); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 13.5px;
  transition: all .15s; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn.gold   { background: var(--accent-3); border-color: var(--accent-3); }
.btn.outline { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.outline:hover { border-color: var(--ink); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted-2); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover { background: var(--chip); }
.tbl .num { font-family: var(--mono); font-size: 13px; }

/* ---------- Workflow timeline ---------- */
.timeline { position: relative; padding-left: 4px; }
.tl-step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding-bottom: 4px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-node {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; border: 2px solid var(--line-2); background: var(--paper-2); color: var(--muted);
  flex: none; z-index: 1;
}
.tl-step.done .tl-node { background: var(--ok); border-color: var(--ok); color: #fff; }
.tl-step.active .tl-node { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.tl-line { width: 2px; flex: 1; background: var(--line); margin: 3px 0; min-height: 14px; }
.tl-step.done .tl-line { background: var(--ok); }
.tl-body { padding-bottom: 18px; }
.tl-body .t { font-weight: 600; font-size: 14px; }
.tl-body .who { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.tl-body .d { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tl-gate { margin-top: 7px; }

/* lane swimlanes for full workflow */
.lanes { display:grid; grid-template-columns: repeat(3,1fr); gap:0; border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; background:var(--paper-2); }
.lane-h { padding:11px 14px; font-weight:700; font-size:13px; color:#fff; text-align:center; letter-spacing:.03em; }
.lane-h.buyer{ background:var(--accent);} .lane-h.admin{ background:var(--accent-3);} .lane-h.factory{ background:var(--accent-2);}
.lane-col { border-right:1px solid var(--line); padding:10px; display:flex; flex-direction:column; gap:9px; }
.lane-col:last-child{ border-right:0; }
.flow-card { border:1px solid var(--line); border-radius:10px; padding:9px 11px; font-size:12.5px; background:var(--paper); }
.flow-card .n { font-weight:700; font-size:11px; color:var(--muted-2); }
.flow-card.gate { border-color: var(--accent-3); background:#fbf5e8; }
.flow-card .gate-tag { color:var(--accent-3); font-weight:700; font-size:11px; margin-top:4px; }

/* ---------- Matrix ---------- */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; font-weight: 600; }
.cell-own  { color: var(--accent); font-weight: 600; }
.cell-none { color: var(--muted-2); }
.cell-all  { color: var(--accent-3); font-weight: 700; }
.cell-pub  { color: var(--accent-2); font-weight: 600; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 9px;
  font-family: inherit; font-size: 13.5px; background: var(--paper-2); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kan-col { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.kan-col h4 { margin: 2px 4px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); display:flex; gap:7px; align-items:center; }
.kan-col h4 .cnt { margin-left:auto; background:var(--chip); border-radius:999px; padding:1px 7px; font-size:11px; color:var(--ink-2); }
.kan-card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; margin-bottom: 9px; font-size: 12.5px; cursor: pointer; transition: all .14s; }
.kan-card:hover { border-color: var(--ink); transform: translateY(-1px); box-shadow: var(--shadow); }
.kan-card .title { font-weight: 600; margin-bottom: 4px; }
.kan-card .meta { color: var(--muted); font-size: 11.5px; }

/* ---------- Factory profile ---------- */
.hero {
  border-radius: var(--radius); overflow: hidden; border:1px solid var(--line);
  background:
    linear-gradient(120deg, rgba(20,19,26,.78), rgba(31,157,99,.55)),
    repeating-linear-gradient(45deg, #1d1b24 0 22px, #24222d 22px 44px);
  color: #fff; padding: 26px; position: relative;
}
.hero h2 { font-family: var(--serif); font-size: 30px; margin: 0 0 6px; font-weight: 600; }
.hero .loc { color: #d8d3c7; font-size: 14px; }
.hero .stars { font-size: 16px; color: #ffd76a; letter-spacing: 2px; }
.snapshot { display:flex; flex-wrap:wrap; gap: 8px; margin-top: 14px; }
.swatch { width: 100%; aspect-ratio: 1; border-radius: 8px; border:1px solid var(--line); }
.cert-badge { display:flex; align-items:center; gap:8px; padding:9px 11px; border:1px solid var(--line); border-radius:10px; background:var(--paper-2); font-size:12.5px; font-weight:600; }

/* ---------- Empty / misc ---------- */
.empty { text-align:center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; opacity:.5; }
.divider { height:1px; background: var(--line); margin: 18px 0; border:0; }
.note {
  display:flex; gap:10px; padding:12px 14px; border-radius:10px; font-size:13px;
  background:#fbf5e8; border:1px solid #ecd9ad; color:#74561c;
}
.note.info { background:#eef0fb; border-color:#cdd2f1; color:#3a3d75; }
.kv { display:flex; justify-content:space-between; padding:7px 0; border-bottom:1px solid var(--line); font-size:13px; }
.kv:last-child{ border-bottom:0; } .kv .k{ color:var(--muted); } .kv .v{ font-weight:600; }
.actions-row { display:flex; gap:9px; flex-wrap:wrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* action item */
.action-item { display:flex; align-items:center; gap:12px; padding:12px 14px; border:1px solid var(--line); border-radius:11px; background:var(--paper-2); margin-bottom:9px; }
.action-item .ai-ico { width:34px; height:34px; border-radius:9px; display:grid; place-items:center; flex:none; background:var(--chip); font-size:16px; }
.action-item .ai-body{ flex:1; } .action-item .ai-t{ font-weight:600; font-size:13.5px; } .action-item .ai-d{ font-size:12px; color:var(--muted); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 11px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 340px;
  display: flex; gap: 10px; align-items: flex-start; animation: slideIn .25s ease;
}
.toast .tco { color: var(--accent-2); font-size: 16px; }
.toast .tt { font-weight: 600; } .toast .td { color: #cfc9bb; font-size: 12.5px; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,19,26,.5); backdrop-filter: blur(3px); z-index: 80; display: grid; place-items: center; padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--paper-2); border-radius: 16px; max-width: 540px; width: 100%; box-shadow: var(--shadow-lg); max-height: 88vh; overflow-y: auto; }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.modal-h .x { margin-left: auto; border: 0; background: var(--chip); width: 30px; height: 30px; border-radius: 8px; font-size: 16px; color: var(--ink-2); }
.modal-b { padding: 20px 22px; }
.modal-f { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* receipt / escrow visual */
.escrow-flow { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.escrow-node { flex:1; min-width:120px; text-align:center; padding:14px 10px; border:1px solid var(--line); border-radius:12px; background:var(--paper-2); }
.escrow-node .en-amt{ font-family:var(--serif); font-size:20px; font-weight:600; }
.escrow-node .en-l{ font-size:11.5px; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; font-weight:700; }
.escrow-arrow{ color:var(--muted-2); font-size:18px; }

.progress-bar { height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display:block; height:100%; background: var(--accent); border-radius:999px; transition: width .4s; }

.seg { display:inline-flex; border:1px solid var(--line-2); border-radius:8px; overflow:hidden; }
.seg button { border:0; background:var(--paper-2); padding:6px 12px; font-size:12.5px; font-weight:600; color:var(--muted); border-right:1px solid var(--line-2); }
.seg button:last-child{ border-right:0; }
.seg button.on { background:var(--ink); color:#fff; }

.fade-in { animation: fadeUp .3s ease; }
@keyframes fadeUp { from { opacity:0; transform: translateY(6px);} to { opacity:1; transform:none; } }
