/* ============================================================================
   Trade Portal — "Ledger / ERP" design system (Concept E from the mockups).
   Brand colours are runtime CSS variables injected from Admin → Settings →
   Branding (--c-primary / --c-secondary / --c-accent). Never hardcode a brand.
   ========================================================================== */

:root {
  /* brand tokens — overridden at runtime by the branding <style> block */
  --c-primary: #C8102E;
  --c-secondary: #C99A2E;
  --c-accent: #2E2E30;
  /* derived */
  --c-primary-dark: color-mix(in srgb, var(--c-primary), black 22%);
  --c-secondary-soft: color-mix(in srgb, var(--c-secondary), white 78%);
  /* neutrals (fixed) */
  --ink: #3A3A3C; --grey: #6E6E70; --grey2: #8a847c;
  --cream: #FBFAF8; --cream2: #F4F2EE;
  --border: #E0DCD4; --border2: #D8D4CC;
  --white: #FFFFFF;
  --ok: #1d7a4d; --warn: #b4790b; --danger: #C8102E; --info: #2c5f8a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--white);
  font-family: 'IBM Plex Sans', 'Inter', system-ui, sans-serif;
  color: var(--ink); font-size: 13px; -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ---------------- top utility bar (E-util) ---------------- */
.E-util { background: var(--c-accent); color: #d6d3ce; display: flex; align-items: center; padding: 0 26px; height: 46px; gap: 24px; }
.E-util .lg { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; color: #fff; white-space: nowrap; }
.E-util .lg .crest { width: 26px; height: 26px; border-radius: 5px; background: var(--c-primary); display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff; font-weight: 700; overflow: hidden; }
.E-util .lg .crest img { width: 100%; height: 100%; object-fit: cover; }
.E-util nav { display: flex; gap: 2px; height: 100%; overflow-x: auto; }
.E-util nav a { display: flex; align-items: center; padding: 0 13px; font-size: 13px; color: #b4b0aa; height: 100%; border-bottom: 2px solid transparent; white-space: nowrap; }
.E-util nav a:hover { color: #fff; }
.E-util nav a.on { color: #fff; border-bottom-color: var(--c-primary); }
.E-util .r { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 12px; white-space: nowrap; }
.E-util .r .acct { display: flex; align-items: center; gap: 8px; }
.E-util .r .av { width: 28px; height: 28px; border-radius: 5px; background: var(--c-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px; }
.E-util .r form { display: inline; }
.E-util .r button { color: #b4b0aa; font-size: 12px; }
.E-util .r button:hover { color: #fff; }
.bell { position: relative; font-size: 16px; color: #d6d3ce; display: inline-flex; }
.bell .bdg { position: absolute; top: -7px; right: -9px; background: var(--c-primary); color: #fff; font-size: 9px; font-weight: 700; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }

/* ---------------- sub band (E-strip) ---------------- */
.E-strip { background: var(--cream2); border-bottom: 1px solid var(--border); padding: 9px 26px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.E-strip .t { font-size: 12px; color: var(--grey); }
.E-strip .t b { color: var(--c-accent); font-size: 15px; font-weight: 600; margin-right: 8px; }

/* ---------------- content ---------------- */
.E-cont { padding: 18px 26px; }
.E-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.E-bar .left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.E-bar .right { display: flex; align-items: center; gap: 10px; }
.E-bar .search { position: relative; }
.E-bar .search input { border: 1px solid var(--border2); border-radius: 6px; padding: 7px 11px 7px 30px; font-size: 13px; font-family: inherit; width: 260px; }
.E-bar .search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--grey2); font-size: 13px; font-style: normal; }
.E-bar .cats { display: flex; gap: 5px; flex-wrap: wrap; }
.E-bar .cats a { font-size: 12.5px; padding: 7px 12px; border: 1px solid var(--border2); border-radius: 6px; color: var(--grey); font-weight: 500; }
.E-bar .cats a.on { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.E-bar .filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.E-bar .filterbar select,
.E-bar .filterbar input[type="month"],
.E-bar .filterbar input[type="date"] { border: 1px solid var(--border2); border-radius: 6px; padding: 7px 9px; font-size: 13px; font-family: inherit; background: #fff; color: var(--ink); max-width: 220px; }
.E-bar .filterbar .chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--grey); white-space: nowrap; cursor: pointer; }
.E-bar .filterbar .chk input { accent-color: var(--c-primary); }
th a.sortlink { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sortlink:hover { color: var(--c-primary); }
.E-tablewrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }

/* ---------------- KPI cards ---------------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.kpi .l { font-size: 11.5px; color: var(--grey); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 25px; font-weight: 700; color: var(--c-accent); margin-top: 7px; }
.kpi .d { font-size: 11.5px; margin-top: 3px; font-weight: 600; color: var(--grey); }
.kpi .d.up { color: var(--ok); } .kpi .d.wn { color: var(--warn); } .kpi .d.dn { color: var(--c-primary-dark); }

/* ---------------- panels + dense tables ---------------- */
.panel { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.panel .ph { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.panel .ph h3 { font-size: 14px; font-weight: 600; color: var(--c-accent); }
.panel .ph .tools { display: flex; gap: 8px; align-items: center; }
.panel .pb { padding: 16px 18px; }
.dtbl { font-size: 13px; }
.dtbl th { text-align: left; padding: 11px 18px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--grey2); background: var(--cream2); font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dtbl th.num, .dtbl td.num { text-align: right; }
.dtbl th.ctr, .dtbl td.ctr { text-align: center; }
.dtbl td { padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--ink); vertical-align: middle; }
.dtbl tr:last-child td { border-bottom: none; }
.dtbl tr:hover td { background: #fcfbf9; }
.dtbl .empty { text-align: center; color: var(--grey2); padding: 28px 18px; }
.mono { font-family: ui-monospace, Consolas, monospace; color: var(--grey); font-size: 12px; }

/* ---------------- pills / status ---------------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.pill .dotc { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.pill.in { background: #e7f3ec; color: var(--ok); } .pill.in .dotc { background: var(--ok); }
.pill.low { background: #fbf0d9; color: var(--warn); } .pill.low .dotc { background: var(--warn); }
.pill.out { background: #fbe7e9; color: var(--c-primary-dark); } .pill.out .dotc { background: var(--c-primary); }
.pill.neutral { background: var(--cream2); color: var(--grey); } .pill.neutral .dotc { background: var(--grey2); }
.soh { font-weight: 600; color: var(--ink); }
.soh.low { color: var(--warn); } .soh.out { color: var(--c-primary-dark); }
.soh small { display: block; font-weight: 400; color: var(--grey2); font-size: 10px; }
.sb { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 4px; white-space: nowrap; }
.sb-info { background: #e8eff5; color: var(--info); }
.sb-warning { background: #fbf0d9; color: var(--warn); }
.sb-error { background: #fbe7e9; color: var(--c-primary-dark); }
.sb-ok { background: #e7f3ec; color: var(--ok); }
.lnk { font-size: 12px; color: var(--c-primary-dark); font-weight: 600; }
.lnk:hover { text-decoration: underline; }

/* ---------------- buttons ---------------- */
.btn { background: var(--c-primary); color: #fff; font-size: 13px; font-weight: 600; padding: 9px 15px; border-radius: 7px; display: inline-flex; align-items: center; gap: 7px; }
.btn:hover { background: var(--c-primary-dark); }
.btn.ghost { background: #fff; color: var(--c-accent); border: 1px solid var(--border2); }
.btn.ghost:hover { background: var(--cream2); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { background: #eceae5; color: var(--grey2); cursor: not-allowed; }

/* ---------------- forms ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--grey); margin-bottom: 5px; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number],
.field select, .field textarea {
  width: 100%; border: 1px solid var(--border2); border-radius: 6px; padding: 8px 11px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--c-primary), white 60%); border-color: var(--c-primary); }
.field .hint { font-size: 11.5px; color: var(--grey2); margin-top: 4px; }
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; color: var(--ink); }
.field input[type=checkbox] { accent-color: var(--c-primary); width: 15px; height: 15px; }
.field input[type=color] { width: 44px; height: 32px; border: 1px solid var(--border2); border-radius: 6px; padding: 2px; background: #fff; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=text] { width: 110px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; flex-wrap: wrap; }
.validation-error, .field-validation-error { color: var(--danger); font-size: 12px; display: block; margin-top: 4px; }
.validation-summary-errors { background: #fbe7e9; border: 1px solid #f3c2c9; color: var(--c-primary-dark); border-radius: 7px; padding: 10px 14px; margin-bottom: 14px; font-size: 12.5px; }
.validation-summary-errors ul { margin-left: 16px; }
.validation-summary-valid { display: none; }

/* ---------------- banners ---------------- */
.banner { border-radius: 7px; padding: 11px 15px; font-size: 12.5px; margin-bottom: 14px; border: 1px solid; display: flex; gap: 9px; align-items: flex-start; }
.banner.error { background: #fbe7e9; border-color: #f3c2c9; color: var(--c-primary-dark); }
.banner.warn { background: #fbf0d9; border-color: #ecd9a6; color: var(--warn); }
.banner.info { background: #e8eff5; border-color: #c6d8e6; color: var(--info); }
.banner.success { background: #e7f3ec; border-color: #bcdccb; color: var(--ok); }
.banner b { font-weight: 700; }

/* ---------------- auth (login / forced change) ---------------- */
.auth-wrap { min-height: 100vh; background: var(--c-accent); display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: #fff; border-radius: 10px; box-shadow: 0 22px 64px rgba(0,0,0,.45); width: 100%; max-width: 420px; padding: 32px; }
.auth-card .lg { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--c-accent); margin-bottom: 6px; }
.auth-card .lg .crest { width: 32px; height: 32px; border-radius: 7px; background: var(--c-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; overflow: hidden; }
.auth-card .lg .crest img { width: 100%; height: 100%; object-fit: cover; }
.auth-card .sub { font-size: 12.5px; color: var(--grey); margin-bottom: 22px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
.auth-card h1 { font-size: 18px; color: var(--c-accent); margin-bottom: 4px; }

/* split sign-in card: form left, branding image right (only when an image is uploaded) */
.auth-card.split { max-width: 880px; padding: 0; display: grid; grid-template-columns: minmax(0, 10fr) minmax(0, 9fr); overflow: hidden; }
.auth-card.split .auth-form { padding: 40px 36px; }
.auth-card.split h1 { font-size: 22px; letter-spacing: .02em; }
.auth-visual { background: var(--c-accent); min-height: 480px; }
.auth-visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 760px) {
    .auth-card.split { grid-template-columns: 1fr; max-width: 420px; }
    .auth-card.split .auth-form { padding: 32px; }
    .auth-visual { display: none; }
}

/* ---------------- maintenance / status page ---------------- */
.status-card { max-width: 560px; }
.status-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.status-row:last-child { border-bottom: none; }
.status-row .k { color: var(--grey); }
.status-row .v { font-weight: 600; color: var(--c-accent); }

/* ---------------- pagination ---------------- */
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; color: var(--grey); }
.pager a, .pager span.cur { padding: 6px 11px; border: 1px solid var(--border2); border-radius: 6px; font-weight: 500; }
.pager span.cur { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.pager a:hover { background: var(--cream2); }
.pager .dis { opacity: .45; pointer-events: none; }
.pager .pagesize select { border: 1px solid var(--border2); border-radius: 6px; padding: 6px 8px; font-size: 12.5px; font-family: inherit; background: #fff; color: var(--ink); }

/* ---------------- audit diff ---------------- */
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diff-grid h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--grey2); margin-bottom: 7px; }
.diff-grid pre { background: var(--cream); border: 1px solid var(--border); border-radius: 7px; padding: 12px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, monospace; }
.diff-grid .old pre { background: #fbe7e9; border-color: #f3c2c9; }
.diff-grid .new pre { background: #e7f3ec; border-color: #bcdccb; }

/* ---------------- notifications ---------------- */
.notif-row td { position: relative; }
.notif-row.unread td { background: var(--c-secondary-soft); }
.notif-row.unread .nt { font-weight: 700; }

/* ---------------- customer catalogue: shared bits ---------------- */
.E-cont-banner { padding: 14px 26px 0; }
.E-cont-banner .banner { margin-bottom: 0; }

/* grid view (product cards — dense 5-across per the Ledger/ERP concept) */
.cardgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 11px; }
.pcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; transition: .15s; }
.pcard:hover { border-color: var(--border2); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.pcard .th { height: 104px; background: var(--cream2); display: flex; align-items: center; justify-content: center; font-size: 34px; border-bottom: 1px solid var(--border); position: relative; overflow: hidden; }
.pcard .th img { width: 100%; height: 100%; object-fit: cover; }
.pcard .th .sku { position: absolute; bottom: 6px; left: 8px; font-size: 10px; font-family: ui-monospace, Consolas, monospace; color: var(--grey2); background: rgba(255,255,255,.85); padding: 1px 5px; border-radius: 3px; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .bd { padding: 11px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard h3 { font-size: 12.5px; font-weight: 600; color: var(--c-accent); line-height: 1.25; min-height: 30px; }
.pcard .meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; gap: 6px; }
.pcard .price b { font-size: 15px; color: var(--c-accent); font-weight: 700; }
.pcard .price s { font-weight: 400; font-size: 11px; color: var(--grey2); margin-left: 4px; }
.pcard .stockline { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--grey); border-top: 1px dashed var(--border); margin-top: 2px; padding-top: 7px; }
.pcard .addrow { display: flex; gap: 7px; margin-top: 4px; }
.pcard .qty { display: flex; align-items: center; border: 1px solid var(--border2); border-radius: 6px; }
.pcard .qty button { padding: 6px 9px; color: var(--grey); font-size: 13px; }
.pcard .qty input { width: 38px; border: none; text-align: center; font-size: 12px; font-weight: 600; font-family: inherit; }
.pcard .add { flex: 1; background: var(--c-primary); color: #fff; font-size: 12.5px; font-weight: 600; padding: 8px; border-radius: 6px; }
.pcard .add:hover { background: var(--c-primary-dark); }
.pcard .add:disabled { background: #eceae5; color: var(--grey2); cursor: not-allowed; }

/* list view */
table.plist { font-size: 13px; }
table.plist th { text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--grey2); background: var(--cream2); font-weight: 700; border-bottom: 1px solid var(--border); }
table.plist th.num, table.plist td.num { text-align: right; }
table.plist th.ctr, table.plist td.ctr { text-align: center; }
table.plist td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.plist tr:last-child td { border-bottom: none; }
table.plist tr:hover td { background: #fcfbf9; }
.pname { display: flex; align-items: center; gap: 12px; }
.pname .nm b { display: block; font-weight: 600; color: var(--c-accent); font-size: 13.5px; }
.pname .nm span { font-size: 11px; color: var(--grey2); font-family: ui-monospace, Consolas, monospace; }
.li-price { font-weight: 700; color: var(--c-accent); font-size: 15px; white-space: nowrap; }
.li-price s { font-weight: 400; font-size: 11px; color: var(--grey2); margin-left: 5px; }
.li-qty { display: inline-flex; align-items: center; border: 1px solid var(--border2); border-radius: 6px; }
.li-qty button { padding: 5px 8px; color: var(--grey); }
.li-qty input { width: 38px; border: none; text-align: center; font-size: 12px; font-weight: 600; font-family: inherit; }
.li-add { background: var(--c-primary); color: #fff; font-size: 12px; font-weight: 600; padding: 7px 14px; border-radius: 6px; white-space: nowrap; }
.li-add:hover { background: var(--c-primary-dark); }
.li-add:disabled { background: #eceae5; color: var(--grey2); cursor: not-allowed; }

/* view toggle */
.viewtoggle { display: inline-flex; border: 1px solid var(--border2); border-radius: 7px; overflow: hidden; }
.viewtoggle a { padding: 7px 11px; font-size: 12px; font-weight: 500; color: var(--grey); display: flex; align-items: center; gap: 6px; background: #fff; }
.viewtoggle a.on { background: var(--c-accent); color: #fff; }

@media (max-width: 1100px) {
  .cardgrid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------------- placeholder panels ---------------- */
.placeholder { border: 2px dashed var(--border2); border-radius: 10px; padding: 48px 24px; text-align: center; color: var(--grey2); }
.placeholder b { display: block; color: var(--grey); font-size: 15px; margin-bottom: 6px; }

/* ---------------- misc ---------------- */
.cmini { display: flex; align-items: center; gap: 9px; }
.cmini .av { width: 28px; height: 28px; border-radius: 6px; background: var(--cream2); color: var(--c-primary-dark); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; border: 1px solid var(--border); }
.cat-label { font-size: 10px; color: var(--c-secondary); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--grey2); }
.small { font-size: 11.5px; }
.thumb-mini { width: 44px; height: 44px; border-radius: 6px; background: var(--cream2); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; border: 1px solid var(--border); overflow: hidden; }
.thumb-mini img { width: 100%; height: 100%; object-fit: cover; }
.img-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.img-tile { border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; text-align: center; }
.img-tile img { width: 120px; height: 120px; object-fit: contain; display: block; margin-bottom: 6px; }
.txt-ok { color: var(--ok); font-weight: 600; }
.txt-warn { color: var(--warn); font-weight: 600; }
.txt-danger { color: var(--c-primary-dark); font-weight: 600; }
.txt-info { color: var(--info); font-weight: 600; }
.w-140 { width: 140px; }
.logo-preview { max-height: 60px; max-width: 220px; border: 1px solid var(--border); border-radius: 7px; padding: 6px; background: #fff; }
.qr-holder { display: flex; justify-content: center; margin: 14px 0; }
.qr-holder #qr { padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; background: var(--cream); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; margin: 12px 0; }
.lost-device { margin-top: 14px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .diff-grid { grid-template-columns: 1fr; }
}
