/* ============================================================
   Reusable components
   ============================================================ */

/* ---------------- panel / card ---------------- */

.panel {
  background: var(--surface);
  border: var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.panel-pad { padding: var(--s-5); }
.panel-tight { padding: var(--s-4); }

.panel-dark {
  background: var(--dk-bg);
  border: 1px solid var(--dk-border);
  border-radius: var(--r-lg);
  color: var(--dk-text);
}
.panel-dark .h1, .panel-dark .h2, .panel-dark .h3 { color: #fff; }

.panel-gold {
  background: var(--gold-wash);
  border: 1px solid var(--gold-pale);
  border-radius: var(--r-lg);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: var(--hair);
  flex-wrap: wrap;
}
.panel-dark .panel-head { border-bottom-color: var(--dk-border); }
.panel-body { padding: var(--s-5); }
.panel-body-tight { padding: var(--s-4); }
.panel-foot {
  padding: var(--s-3) var(--s-5);
  border-top: var(--hair);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* accent-edged card, straight from the proposal's card treatment */
.card {
  background: var(--surface);
  border: var(--hair);
  border-left: var(--accent-edge) solid var(--gold);
  border-radius: var(--r);
  padding: var(--s-4);
}
.card.green { border-left-color: var(--green); }
.card.amber { border-left-color: var(--amber); }
.card.red   { border-left-color: var(--red); }
.card.plain { border-left: var(--hair); }

.callout {
  border-left: var(--accent-edge) solid var(--amber);
  background: var(--amber-wash);
  border-radius: var(--r);
  padding: var(--s-3) var(--s-4);
  font-size: var(--t-sm);
  line-height: 1.48;
}
.callout.green { border-left-color: var(--green); background: var(--green-wash); }
.callout.red   { border-left-color: var(--red);   background: var(--red-wash); }
.callout.gold  { border-left-color: var(--gold);  background: var(--gold-wash); }

/* ---------------- stat tiles ---------------- */

.tile {
  background: var(--surface);
  border: var(--hair);
  border-radius: var(--r);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-width: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.tile .tile-v {
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.tile .tile-l {
  font-size: var(--t-xs);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 700;
}
.tile .tile-sub { font-size: var(--t-xs); color: var(--text-3); }
.tile.accent { border-left: var(--accent-edge) solid var(--gold); }
.tile.is-alert { border-left: var(--accent-edge) solid var(--amber); background: var(--amber-wash); }
.tile.is-bad   { border-left: var(--accent-edge) solid var(--red);   background: var(--red-wash); }
.tile.is-good  { border-left: var(--accent-edge) solid var(--green); background: var(--green-wash); }

button.tile { width: 100%; text-align: left; }
button.tile:hover, a.tile:hover {
  border-color: var(--gold);
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
}

.tile-dark {
  background: var(--dk-surface);
  border: 1px solid var(--dk-border);
  border-radius: var(--r);
  padding: var(--s-4);
  min-width: 0;
}
.tile-dark .tile-v { color: var(--gold-lt); font-family: var(--serif); font-size: 1.6rem;
                     line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile-dark .tile-l { font-size: var(--t-xs); letter-spacing: var(--track-label);
                     text-transform: uppercase; color: var(--dk-text-3); font-weight: 700; }

/* ---------------- pills / badges ---------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
  white-space: nowrap;
  line-height: 1.5;
}
.pill.gold  { background: var(--gold);  color: #fff; }
.pill.green { background: var(--green); color: #fff; }
.pill.amber { background: var(--amber); color: #fff; }
.pill.red   { background: var(--red);   color: #fff; }
.pill.blue  { background: var(--st-reserved); color: #fff; }
.pill.plum  { background: var(--st-checkout); color: #fff; }
.pill.grey  { background: #E7E1D2; color: var(--charcoal); }
.pill.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-3); }
.pill.ghost-gold { background: transparent; border: 1px solid var(--gold); color: var(--gold); }

.dot { width: 7px; height: 7px; border-radius: 100px; flex: 0 0 auto; background: var(--grey-lt); }
.dot.gold { background: var(--gold); } .dot.green { background: var(--green); }
.dot.amber { background: var(--amber); } .dot.red { background: var(--red); }
.dot.blue { background: var(--st-reserved); } .dot.plum { background: var(--st-checkout); }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px rgba(79, 122, 91, 0.18); }

/* the discreet prototype marker */
.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--gold-lt);
  border: 1px solid rgba(217, 184, 92, 0.4);
  border-radius: 100px;
  padding: 3px 9px;
  background: rgba(217, 184, 92, 0.07);
  white-space: nowrap;
}
.demo-chip.on-light { color: var(--gold); border-color: var(--gold-pale); background: var(--gold-wash); }

.sim-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-wash);
  border: 1px dashed rgba(192, 122, 34, 0.45);
  border-radius: var(--r-sm);
  padding: 3px 8px;
}

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-4);
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--ivory); }
.btn-primary:hover { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }

.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: #A57F26; border-color: #A57F26; color: #fff; box-shadow: var(--sh-gold); }

.btn-approve { background: var(--green); border-color: var(--green); color: #fff; }
.btn-approve:hover { background: #416749; border-color: #416749; color: #fff; }

.btn-decline { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn-decline:hover { background: var(--red); color: #fff; }

.btn-ghost { background: transparent; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--text-3); }
.btn-quiet:hover { color: var(--gold); background: var(--gold-wash); border-color: var(--gold-pale); }

.btn-sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--t-xs); }
.btn-lg { min-height: 50px; padding: 0 var(--s-5); font-size: var(--t-body); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.42; }
.btn:disabled:hover { border-color: var(--border); color: var(--text); transform: none; }

.btn-on-dark { background: transparent; border-color: var(--dk-border); color: var(--dk-text); }
.btn-on-dark:hover { border-color: var(--gold-lt); color: var(--gold-lt); background: rgba(217,184,92,0.08); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r);
  border: 1px solid transparent; color: var(--text-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  position: relative; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-3); color: var(--gold); }
.icon-btn.on-dark { color: var(--dk-text-2); }
.icon-btn.on-dark:hover { background: rgba(255,255,255,0.07); color: var(--gold-lt); }
.icon-btn svg { width: 19px; height: 19px; }

.badge-count {
  position: absolute; top: 3px; right: 3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 100px; background: var(--red); color: #fff;
  font-size: 0.5625rem; font-weight: 700; line-height: 17px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* segmented control */
.seg {
  display: flex;
  border: var(--hair);
  border-radius: var(--r);
  background: var(--surface-2);
  padding: 2px;
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  flex: 0 1 auto;
  width: fit-content;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.seg::-webkit-scrollbar { display: none; }
.seg > * { flex: 0 0 auto; }

/* On a phone a chip row takes the full width and scrolls inside itself, rather
   than stretching the layout and putting its last options off-screen. */
@media (max-width: 860px) {
  .seg { width: 100%; }
}
.seg button {
  padding: 7px 13px;
  border-radius: 3px;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  min-height: 34px;
}
.seg button:hover { color: var(--gold); }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--ivory); }

/* ---------------- inputs ---------------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > .label { margin-bottom: 1px; }
.input, .select, .textarea {
  min-height: 42px;
  padding: 9px var(--s-3);
  border: var(--hair);
  border-radius: var(--r);
  background: var(--surface);
  font-size: var(--t-body);
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 145, 47, 0.13);
  outline: none;
}
.textarea { min-height: 78px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: var(--s-6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%236E6A62' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }

.stepper { display: inline-flex; align-items: center; border: var(--hair); border-radius: var(--r); overflow: hidden; }
.stepper button { width: 36px; height: 36px; display: grid; place-items: center; font-size: 1rem;
  font-weight: 700; color: var(--text-2); background: var(--surface-2); }
.stepper button:hover { background: var(--gold); color: #fff; }
.stepper .qty { min-width: 38px; text-align: center; font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: var(--t-sm); }

/* ---------------- tables ---------------- */

.tbl-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; font-size: var(--t-sm); }
table.tbl th {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--gold);
  text-align: left;
  padding: 0 var(--s-3) var(--s-2) 0;
  border-bottom: 1px solid var(--gold);
  white-space: nowrap;
  vertical-align: bottom;
}
table.tbl td {
  padding: 10px var(--s-3) 10px 0;
  border-bottom: var(--hair-soft);
  vertical-align: middle;
  line-height: 1.4;
}
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl th:last-child, table.tbl td:last-child { padding-right: 0; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl tbody tr.clickable { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
table.tbl tbody tr.clickable:hover { background: var(--gold-wash); }

/* Tables become cards on small screens — never a sideways scroll. */
.cardify { display: none; }
@media (max-width: 720px) {
  .tbl-wrap.has-cardify { display: none; }
  .cardify { display: grid; gap: var(--s-2); }
  .cardify-row {
    border: var(--hair);
    border-left: var(--accent-edge) solid var(--gold);
    border-radius: var(--r);
    background: var(--surface);
    padding: var(--s-3);
    display: grid;
    gap: 5px;
  }
  .cardify-row .cr-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
  .cardify-row .cr-line { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--t-sm); }
  .cardify-row .cr-line > span:first-child { color: var(--text-3); font-size: var(--t-xs);
    letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
}

/* ---------------- list rows ---------------- */

.rows { display: grid; }
.rows > * + * { border-top: var(--hair-soft); }
.rw {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0; min-width: 0;
  transition: background var(--dur-fast) var(--ease);
}
button.rw, a.rw { width: 100%; }
button.rw:hover, a.rw:hover { background: var(--gold-wash); }
.rw-main { flex: 1 1 auto; min-width: 0; }
.rw-title { font-weight: 700; font-size: var(--t-sm); line-height: 1.3; }
.rw-sub { font-size: var(--t-xs); color: var(--text-3); line-height: 1.4; }
.rw-end { flex: 0 0 auto; text-align: right; }

.avatar {
  width: 34px; height: 34px; border-radius: 100px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--cream); color: var(--gold);
  font-family: var(--serif); font-size: var(--t-sm); font-weight: 700;
  border: 1px solid var(--gold-pale);
}
.avatar.dark { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--gold-lt); }

/* ---------------- drawer ---------------- */

.scrim {
  position: fixed; inset: 0;
  background: rgba(14, 14, 17, 0.52);
  backdrop-filter: blur(2px);
  z-index: var(--z-drawer);
  animation: fade var(--dur) var(--ease) both;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  background: var(--bg);
  border-left: var(--hair);
  box-shadow: var(--sh-4);
  z-index: var(--z-drawer);
  display: flex; flex-direction: column;
  animation: slideIn var(--dur-slow) var(--ease-out) both;
}
@keyframes slideIn { from { transform: translateX(26px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.drawer-head {
  padding: var(--s-4) var(--s-5);
  border-bottom: var(--hair);
  background: var(--ink);
  color: var(--dk-text);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  flex: 0 0 auto;
}
.drawer-body { padding: var(--s-5); overflow-y: auto; flex: 1 1 auto; }
.drawer-foot {
  padding: var(--s-3) var(--s-5);
  border-top: var(--hair);
  background: var(--surface);
  flex: 0 0 auto;
  display: flex; gap: var(--s-2); flex-wrap: wrap;
}
.drawer-foot .btn { flex: 1 1 auto; }

@media (max-width: 620px) {
  .drawer {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: 92vh;
    border-left: 0; border-top: 2px solid var(--gold);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: slideUp var(--dur-slow) var(--ease-out) both;
  }
  @keyframes slideUp { from { transform: translateY(34px); opacity: 0.7; } to { transform: none; opacity: 1; } }
  .drawer-head { border-radius: var(--r-xl) var(--r-xl) 0 0; }
}

/* ---------------- modal ---------------- */

.modal-wrap {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: var(--gutter);
  background: rgba(14, 14, 17, 0.58);
  backdrop-filter: blur(3px);
  animation: fade var(--dur) var(--ease) both;
  overflow-y: auto;
}
.modal {
  background: var(--bg);
  border-radius: var(--r-xl);
  border: var(--hair);
  box-shadow: var(--sh-4);
  width: min(560px, 100%);
  max-height: min(88vh, 900px);
  display: flex; flex-direction: column;
  animation: pop var(--dur-slow) var(--ease-out) both;
  overflow: hidden;
}
.modal.wide { width: min(880px, 100%); }
@keyframes pop { from { transform: scale(0.975) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: var(--s-5) var(--s-5) var(--s-4); border-bottom: var(--hair); flex: 0 0 auto; }
.modal-body { padding: var(--s-5); overflow-y: auto; flex: 1 1 auto; }
.modal-foot {
  padding: var(--s-4) var(--s-5); border-top: var(--hair); background: var(--surface);
  display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; flex: 0 0 auto;
}
@media (max-width: 560px) {
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* ---------------- toast ---------------- */

.toasts {
  position: fixed; z-index: var(--z-toast);
  right: var(--gutter); bottom: var(--gutter);
  display: grid; gap: var(--s-2);
  width: min(390px, calc(100vw - 2 * var(--gutter)));
  pointer-events: none;
}
@media (max-width: 860px) {
  .toasts { left: var(--gutter); right: var(--gutter); bottom: calc(var(--s-8) + 34px); width: auto; }
}
.toast {
  background: var(--ink);
  color: var(--dk-text);
  border: 1px solid var(--dk-border);
  border-left: var(--accent-edge) solid var(--green);
  border-radius: var(--r);
  padding: var(--s-3) var(--s-4);
  box-shadow: var(--sh-4);
  animation: toastIn var(--dur-slow) var(--ease-out) both;
  pointer-events: auto;
  display: flex; gap: var(--s-3); align-items: flex-start;
}
@keyframes toastIn { from { transform: translateY(12px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.is-leaving { animation: toastOut var(--dur) var(--ease) both; }
@keyframes toastOut { to { transform: translateY(6px); opacity: 0; } }
.toast.amber { border-left-color: var(--amber); }
.toast.red   { border-left-color: var(--red); }
.toast.gold  { border-left-color: var(--gold); }
.toast-t { font-weight: 700; font-size: var(--t-sm); color: #fff; }
.toast-b { font-size: var(--t-xs); color: var(--dk-text-2); line-height: 1.45; margin-top: 2px; }
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }

/* ---------------- skeleton ---------------- */

.sk { background: linear-gradient(90deg, #EDE7DA 25%, #F6F1E6 37%, #EDE7DA 63%);
  background-size: 400% 100%; animation: shimmer 1.35s ease-in-out infinite;
  border-radius: var(--r-sm); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.sk-line { height: 11px; }
.sk-title { height: 20px; width: 55%; }
.sk-tile { height: 84px; border-radius: var(--r); }

.spinner {
  width: 15px; height: 15px; flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,0.28); border-top-color: #fff;
  border-radius: 100px; animation: spin 620ms linear infinite;
}
.spinner.dark { border-color: rgba(14,14,17,0.16); border-top-color: var(--gold); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- empty state ---------------- */

.empty {
  text-align: center;
  padding: var(--s-7) var(--s-4);
  color: var(--text-3);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.empty .h3 { color: var(--text-2); margin-bottom: 4px; }

/* ---------------- progress / meter ---------------- */

.meter { height: 6px; border-radius: 100px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 100px; background: var(--gold);
  transition: width var(--dur-slow) var(--ease); }
.meter.green > i { background: var(--green); }
.meter.amber > i { background: var(--amber); }
.meter.red > i { background: var(--red); }
.meter.on-dark { background: var(--dk-surface-2); }

/* ---------------- step trail (workflows) ---------------- */

.trail { display: grid; gap: 0; }
.trail-step { display: grid; grid-template-columns: 26px 1fr; gap: var(--s-3); }
.trail-step .tk { display: grid; grid-template-rows: 26px 1fr; justify-items: center; }
.trail-step .tk i {
  width: 22px; height: 22px; border-radius: 100px; display: grid; place-items: center;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 0.5625rem; font-weight: 700; color: var(--text-3); font-style: normal;
}
.trail-step .tk s { width: 1.5px; background: var(--border); justify-self: center; height: 100%; min-height: 12px; }
.trail-step:last-child .tk s { display: none; }
.trail-step .tb { padding-bottom: var(--s-4); min-width: 0; }
.trail-step:last-child .tb { padding-bottom: 0; }
.trail-step.done .tk i { border-color: var(--green); background: var(--green); color: #fff; }
.trail-step.done .tk s { background: var(--green); }
.trail-step.active .tk i { border-color: var(--gold); background: var(--gold); color: #fff;
  box-shadow: 0 0 0 3px rgba(184,145,47,0.17); }
.trail-step.wait .tb { opacity: 0.5; }

/* ---------------- kv list ---------------- */

.kv { display: grid; gap: 0; font-size: var(--t-sm); }
.kv > div { display: flex; justify-content: space-between; gap: var(--s-4);
  padding: 8px 0; border-bottom: var(--hair-soft); }
.kv > div:last-child { border-bottom: 0; }
.kv dt, .kv .k { color: var(--text-3); font-size: var(--t-xs); letter-spacing: 0.05em;
  text-transform: uppercase; font-weight: 700; flex: 0 0 auto; }
.kv dd, .kv .v { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; }
.kv.on-dark > div { border-bottom-color: var(--dk-border); }
.kv.on-dark dt, .kv.on-dark .k { color: var(--dk-text-3); }
.kv.on-dark dd, .kv.on-dark .v { color: var(--dk-text); }
