/* =================================================================
   Ngobe Exalt Group — shared stylesheet
   Brand colors pulled from the company logo:
     red  #ED1C24   blue #1B1FE0   black #141518
   ================================================================= */

:root {
  --red: #ED1C24;
  --red-dark: #c41219;
  --blue: #1B1FE0;
  --blue-dark: #1417b0;
  --ink: #141518;
  --white: #ffffff;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e4e8f0;
  --muted: #6b7280;
  --text: #1c2430;

  --ok: #17864a;
  --ok-bg: #e5f5ec;
  --warn: #a86400;
  --warn-bg: #fdf2df;
  --danger: var(--red);
  --danger-bg: #fdeaeb;
  --info: var(--blue);
  --info-bg: #e9eafe;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 21, 24, .06), 0 8px 24px rgba(20, 21, 24, .06);
  --shadow-sm: 0 1px 2px rgba(20, 21, 24, .08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  /* metric readout face — numbers as instrumentation, not marketing */
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* A single unbroken token — a run-together product name, an SKU, a long email —
     otherwise widens its grid track and scrolls the whole page sideways on a phone. */
  overflow-wrap: break-word;
}

/* Grid/flex children default to min-width:auto, which lets long content push a
   track wider than its share. Required for the rule above to actually contain it. */
.grid > *, .row > * { min-width: 0; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .4em; }

img { max-width: 100%; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--white);
  border-bottom: 3px solid var(--blue);
  position: sticky; top: 0; z-index: 40;
  box-shadow: var(--shadow-sm);
}
.topbar.admin { border-bottom-color: var(--red); }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 68px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 46px; width: auto; display: block; }
.brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand .brand-text strong { color: var(--ink); font-size: 1rem; letter-spacing: .3px; }
.brand .brand-text span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }

.nav { display: flex; gap: 4px; align-items: center; }
.nav a, .nav button.navlink {
  background: none; border: none; cursor: pointer;
  font: inherit; color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm);
}
.nav a:hover, .nav button.navlink:hover { background: var(--bg); text-decoration: none; }
.nav .navlink.active { background: var(--blue); color: #fff; }
.topbar.admin .nav .navlink.active { background: var(--red); color: #fff; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--blue); color: #fff;
  transition: filter .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.red { background: var(--red); }
.btn.dark { background: var(--ink); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--bg); filter: none; }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--danger-bg); filter: none; }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btn.block { width: 100%; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card h2 { font-size: 1.15rem; }

.grid { display: grid; gap: 18px; }
.grid.products { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* product card */
.product { display: flex; flex-direction: column; }
.product .thumb {
  height: 120px; border-radius: var(--radius-sm); margin-bottom: 14px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--ink) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2.2rem; font-weight: 700; letter-spacing: 1px;
}
.product h3 { font-size: 1.02rem; margin-bottom: 2px; }
.product .cat { font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.product .desc { font-size: .88rem; color: var(--muted); margin: 8px 0; flex: 1; }
.product .price { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.product .stock { font-size: .8rem; }

/* stat tile */
.stat { padding: 18px 20px; }
.stat .num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.9rem; font-weight: 700; color: var(--ink); line-height: 1; }
.stat .lbl { font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-top: 8px; }
.stat.b { border-left: 4px solid var(--blue); }
.stat.r { border-left: 4px solid var(--red); }
.stat.k { border-left: 4px solid var(--ink); }

/* ---------- forms ---------- */
label.field, div.field { display: block; margin-bottom: 14px; }
label.field > span, div.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27, 31, 224, .12);
}
textarea { min-height: 90px; resize: vertical; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .form-2col { grid-template-columns: 1fr; } }

/* checkbox list — used for picking a job's crew */
.check-list {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff;
  padding: 6px; max-height: 190px; overflow-y: auto;
}
.check { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: .92rem; }
.check:hover { background: var(--bg); }
/* the shared input rule stretches every control to 100%; a checkbox must not stretch */
.check input[type="checkbox"] { width: auto; flex: none; margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table { border-collapse: collapse; width: 100%; min-width: 560px; }
/* Narrow key/value tables (e.g. EFT bank details) — opt out of the 560px floor
   so they don't force the page sideways on a phone. */
table.table-plain { min-width: 0; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
th { background: #fafbfe; font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
}
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.ink { background: #eceef2; color: var(--ink); }

/* ---------- alerts / toast ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 14px; }
.alert.error { background: var(--danger-bg); color: var(--red-dark); border: 1px solid #f4c9cc; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe6cd; }

#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-size: .9rem; max-width: 340px;
  animation: slidein .18s ease;
}
.toast.ok { background: var(--ok); }
.toast.error { background: var(--red-dark); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 21, 24, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60;
}
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 440px;
  box-shadow: var(--shadow); max-height: 92vh; overflow-y: auto;
}
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 22px; }
.modal .close { margin-left: auto; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); line-height: 1; }

/* tabs inside modal (login/register) */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--bg); padding: 4px; border-radius: var(--radius-sm); }
.tabs button { flex: 1; background: none; border: none; padding: 8px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- section headers ---------- */
.section-head { display: flex; align-items: center; gap: 12px; margin: 26px 0 16px; }
.section-head h1 { font-size: 1.5rem; margin: 0; }

/* ---------- hero (customer home) ---------- */
.hero {
  background: linear-gradient(120deg, var(--ink) 0%, var(--blue-dark) 60%, var(--blue) 100%);
  color: #fff; border-radius: var(--radius); margin-top: 26px;
  padding: clamp(24px, 5vw, 40px) clamp(20px, 4vw, 34px);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px;
  border: 14px solid var(--red); transform: rotate(45deg); opacity: .18; border-radius: 24px;
}
.hero h1 { color: #fff; font-size: clamp(1.45rem, 5.2vw, 2rem); max-width: 620px; }
.hero p { max-width: 560px; opacity: .92; }

/* ---------- cart badge ---------- */
.cart-count {
  background: var(--red); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700;
  min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
  margin-left: 6px;
}

/* ---------- empty state ---------- */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .big { font-size: 2.4rem; margin-bottom: 8px; }
.empty svg { color: #c4cbd8; margin-bottom: 12px; }

/* ---------- dashboard status bars ---------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 108px 1fr 32px; align-items: center; gap: 12px; }
.bar-row .lbl2 { font-size: .8rem; font-weight: 600; color: var(--ink); }
.bar-track { background: var(--bg); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--blue); transition: width .3s ease; }
.bar-fill.red { background: var(--red); }
.bar-fill.ink { background: var(--ink); }
.bar-fill.ok { background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-row .cnt { text-align: right; font-weight: 700; color: var(--ink); font-size: .9rem; }

/* two-column dashboard blocks */
.dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .dash-2col { grid-template-columns: 1fr; } }

/* nav icon alignment */
.side button svg { flex: none; }

/* ---------- dashboard command bar (the one bold element) ---------- */
.cmdbar {
  position: relative; overflow: hidden;
  background: var(--ink); color: #fff;
  border-radius: var(--radius); padding: clamp(18px, 4vw, 24px) clamp(18px, 4vw, 28px);
  margin-bottom: 8px;
}
.cmdbar .hex {
  position: absolute; right: -34px; top: 50%; transform: translateY(-50%);
  width: 230px; height: 230px; opacity: .22; pointer-events: none;
}
.cmdbar .eyebrow { font-size: .72rem; letter-spacing: 2.5px; text-transform: uppercase; color: #8b93a3; }
.cmdbar .headline {
  display: flex; align-items: baseline; gap: 14px; margin-top: 6px;
  font-size: 1.35rem; font-weight: 700; color: #fff; position: relative; z-index: 1;
}
.cmdbar .headline .n { font-family: var(--mono); font-size: clamp(2rem, 7vw, 2.6rem); font-weight: 700; color: #fff; line-height: 1; }
.cmdbar .headline.clear .n { color: var(--ok); }
.cmdbar .clock { font-family: var(--mono); font-size: .78rem; color: #8b93a3; margin-top: 10px; position: relative; z-index: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; position: relative; z-index: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.16); color: #fff;
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .84rem; cursor: pointer;
}
.chip:hover { background: rgba(255,255,255,.15); }
.chip .c { font-family: var(--mono); font-weight: 700; }
.chip.red { border-color: rgba(237,28,36,.55); }
.chip.red .c { color: #ff6b70; }

/* eyebrow labels that group the KPI tiles */
.dash-group-label {
  font-size: .72rem; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin: 24px 0 12px;
}

/* ---------- footer ---------- */
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 40px 20px 30px; }

/* ---------- admin login screen ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, var(--ink) 0%, #23262e 100%);
}
.login-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 400px; padding: 34px 30px; }
.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card .badge-admin { display: inline-block; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: 1px; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; }

/* ---------- admin layout ---------- */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 68px); }
.side { background: #fff; border-right: 1px solid var(--border); padding: 18px 12px; }
.side button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; font: inherit; cursor: pointer; color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 2px;
}
.side button:hover { background: var(--bg); }
.side button.active { background: var(--red); color: #fff; }
.admin-main { padding: 24px; overflow-x: hidden; }
@media (max-width: 780px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side { display: flex; flex-wrap: wrap; gap: 6px; border-right: none; border-bottom: 1px solid var(--border); }
  .side button { width: auto; margin: 0; }
}

/* row actions */
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* =================================================================
   Phone layout
   The topbar previously had no breakpoint at all: brand + nav +
   account area sat in one fixed-height, non-wrapping flex row, which
   overflowed any screen narrower than roughly 700px.
   ================================================================= */
@media (max-width: 720px) {
  .container { padding: 0 14px; }

  /* Let the bar grow to two rows: brand + account on top, nav beneath. */
  .topbar-inner {
    height: auto; min-height: 60px;
    flex-wrap: wrap; gap: 10px; padding-top: 10px; padding-bottom: 10px;
  }
  .topbar-inner .spacer { display: none; }
  .brand { flex: 1; min-width: 0; padding-right: 6px; }
  .brand img { height: 30px; }
  /* min-width:0 + ellipsis so a long company name truncates instead of colliding
     with the account button on narrow (320px) handsets. */
  .brand .brand-text { min-width: 0; }
  .brand .brand-text strong {
    font-size: .86rem; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  /* Drop the "Procurement & Services" tagline — it wrapped to a third line and
     pushed the sticky header to ~125px, eating the top of every screen. */
  .brand .brand-text span { display: none; }
  #accountArea { margin-left: auto; }

  /* Nav becomes a full-width, horizontally swipeable strip rather than
     wrapping into a tall ragged block. */
  .nav {
    order: 3; width: 100%;
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav button.navlink { white-space: nowrap; padding: 8px 12px; }

  /* Product tiles: 240px minimum left a dead gutter on a 360px screen. */
  .grid.products { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

  .section-head { flex-wrap: wrap; gap: 8px; margin: 20px 0 14px; }
  .section-head h1 { font-size: 1.3rem; }
  .card { padding: 16px; }
  .bar-row { grid-template-columns: 84px 1fr 28px; gap: 8px; }

  /* Full-bleed toasts and roomier modals on small screens. */
  #toasts { right: 12px; left: 12px; bottom: 12px; }
  .toast { max-width: none; }
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal { max-height: 88vh; }

  /* Row action buttons were below a comfortable tap target. */
  .actions .btn.sm { min-height: 36px; }

  /* Topbar is taller here, so the fixed 68px offset no longer applies. */
  .admin-shell { min-height: 0; }
  .admin-main { padding: 16px 14px; }
}
