:root {
  --teal: #2F5D62;
  --teal-deep: #244a4e;
  --ink: #24303A;
  --slate: #4A5A63;
  --mist: #F4F7F7;
  --pale: #BCD8D6;
  --warm: #FFF8E7;
  --paper: #ffffff;
  --line: #dde5e5;
  --amber: #c9772e;
  --red: #b3452f;
  --shadow: 0 1px 2px rgba(36,48,58,.06), 0 8px 24px rgba(36,48,58,.06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--mist); color: var(--ink); line-height: 1.5; }
a { color: var(--teal-deep); }
header.site { background: var(--paper); border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; }
header.site .wrap { max-width: 1000px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
header.site .brand { font-weight: 700; font-size: 1.15rem; color: var(--teal-deep); text-decoration: none; }
header.site .brand span { color: var(--slate); font-weight: 400; font-size: .8rem; display: block; }
header.site nav a { margin-left: 1.2rem; font-size: .9rem; font-weight: 500; text-decoration: none; color: var(--slate); }
main { max-width: 640px; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
main.wide { max-width: 900px; }
h1 { font-size: 2rem; margin: 0 0 .5rem; }
h1 + p.lede { color: var(--slate); margin: 0 0 1.8rem; font-size: 1.08rem; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: .88rem; font-weight: 600; color: var(--slate); }
.field input, .field select {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--warm); color: var(--ink); width: 100%;
}
.row3 { display: grid; grid-template-columns: 2fr 1fr 1.2fr; gap: .8rem; }
@media (max-width: 560px) { .row3 { grid-template-columns: 1fr; } }
button.btn {
  font: inherit; font-weight: 600; padding: .65rem 1.2rem; border-radius: 8px; border: none;
  background: var(--teal); color: #fff; cursor: pointer;
}
button.btn:hover { background: var(--teal-deep); }
button.btn.secondary { background: transparent; color: var(--teal-deep); border: 1px solid var(--line); }
.item-row {
  display: grid; grid-template-columns: 1.6fr .9fr .9fr auto; gap: 1rem; align-items: center;
  padding: .8rem 0; border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: none; }
.item-name { font-weight: 600; }
.item-stock { font-variant-numeric: tabular-nums; }
.item-stock.low { color: var(--red); font-weight: 700; }
.item-badge { font-size: .72rem; font-weight: 700; background: rgba(179,69,47,.12); color: var(--red);
  padding: .15rem .5rem; border-radius: 999px; display: inline-block; margin-left: .4rem; }
.entry-empty { color: var(--slate); font-size: .9rem; margin: .5rem 0; }
.note { color: var(--slate); font-size: .85rem; margin-top: .6rem; }
.status-msg { font-size: .9rem; color: var(--slate); min-height: 1.2rem; margin-top: .6rem; }
.status-msg.ok { color: var(--teal-deep); font-weight: 600; }
.status-msg.error { color: var(--red); font-weight: 600; }
footer.site { max-width: 900px; margin: 0 auto; padding: 2rem 1.25rem 3rem; color: var(--slate); font-size: .85rem; }

/* ---- app nav ---- */
.member-tabs { display: flex; gap: 1.4rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1.6rem; padding-bottom: .8rem; }
.member-tabs a { font-size: .92rem; font-weight: 600; color: var(--slate); text-decoration: none; }
.member-tabs a[aria-current="page"] { color: var(--teal-deep); border-bottom: 2px solid var(--teal); padding-bottom: .3rem; }

/* ---- data tables ---- */
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .78rem; text-transform: uppercase; color: var(--slate); padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
table.data td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.status-pill { font-size: .74rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; display: inline-block; }
.status-pill.ordered { background: var(--warm); color: #8a6a1f; }
.status-pill.received, .status-pill.fulfilled { background: var(--pale); color: var(--teal-deep); }
.status-pill.cancelled { background: rgba(179,69,47,.12); color: var(--red); }
.icon-btn { border: none; background: transparent; color: var(--slate); cursor: pointer; font-size: 1.05rem; padding: .1rem .3rem; }
.icon-btn:hover { color: var(--red); }

/* ---- dashboard KPI cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.kpi .label { font-size: .78rem; color: var(--slate); text-transform: uppercase; }
.kpi .value { font-size: 1.35rem; font-weight: 700; color: var(--teal-deep); font-variant-numeric: tabular-nums; margin-top: .2rem; }
.kpi.warn .value { color: var(--amber); }
.kpi.bad .value { color: var(--red); }

/* ---- order line builder (purchase/sales orders) ---- */
.line-builder { display: grid; gap: .6rem; margin: .8rem 0; }
.line-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: .6rem; align-items: end; }
@media (max-width: 640px) { .line-row { grid-template-columns: 1fr; } }
.bom-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: .6rem; align-items: end; margin-bottom: .6rem; }

/* ---- chat placeholder (floating, every /app/ page) ---- */
.soon { font-size: .68rem; font-weight: 700; color: var(--amber); background: rgba(201,119,46,.12);
  padding: .1rem .5rem; border-radius: 999px; margin-left: .5rem; vertical-align: middle; }
.ch-chat-fab {
  position: fixed; bottom: 1.4rem; right: 1.4rem; width: 3.2rem; height: 3.2rem; border-radius: 50%;
  background: var(--teal); color: #fff; border: none; font-size: 1.4rem; cursor: pointer;
  box-shadow: 0 4px 16px rgba(36,48,58,.25); z-index: 40;
}
.ch-chat-fab:hover { background: var(--teal-deep); }
.ch-chat-panel {
  position: fixed; bottom: 5rem; right: 1.4rem; width: min(320px, calc(100vw - 2.8rem));
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 1rem 1.1rem; z-index: 40;
}
.ch-chat-head { font-weight: 700; margin-bottom: .5rem; }
.ch-chat-body { font-size: .85rem; color: var(--slate); margin: 0 0 .8rem; }
.ch-chat-input { width: 100%; font: inherit; padding: .55rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--mist); color: var(--slate); margin-bottom: .6rem; }
.ch-chat-input:disabled, .ch-chat-panel button:disabled { opacity: .6; cursor: not-allowed; }

/* ---- import placeholder (dashboard, materials, purchase orders) ---- */
.ch-import {
  display: flex; gap: 1rem; align-items: flex-start; border: 1px dashed var(--line);
  border-radius: 12px; padding: 1rem 1.2rem; background: var(--mist); margin-bottom: 1.4rem;
}
.ch-import-icon { font-size: 1.6rem; }
.ch-import strong { display: block; margin-bottom: .2rem; }
.ch-import p { margin: 0; font-size: .87rem; color: var(--slate); }
