/* ==========================================================================
   SABECO FSM — design tokens
   The client's official palette had not been issued when this was built
   (see SABECO_Brand_Brief.md §5). Everything below is driven by these
   variables, so dropping in the real brand colours is a one-file change.
   ========================================================================== */
:root {
  --navy-900: #0b2233;
  --navy-800: #0f2f44;
  --navy-700: #17415b;
  --navy-100: #dce6ed;
  --teal-700: #0a6167;
  --teal-600: #0d7d84;
  --teal-100: #d6eef0;
  --sand-100: #f6f3ec;

  --bg: #f2f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #dfe6ea;
  --border-strong: #c6d2d9;
  --text: #10222e;
  --text-muted: #5b6b76;
  --text-faint: #8b9aa4;

  --amber: #b45309;
  --amber-bg: #fdf3e3;
  --blue: #1d4ed8;
  --blue-bg: #e6ecfd;
  --violet: #6d28d9;
  --violet-bg: #efe8fd;
  --green: #15803d;
  --green-bg: #e4f5e9;
  --red: #b3261e;
  --red-bg: #fceceb;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(16, 34, 46, .06), 0 1px 3px rgba(16, 34, 46, .04);
  --shadow-2: 0 4px 16px rgba(16, 34, 46, .10);
  --shadow-3: 0 18px 48px rgba(16, 34, 46, .22);

  --sidebar-w: 236px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
a { color: var(--teal-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- boot --- */
.app-loading { display: grid; place-items: center; min-height: 100vh; background: var(--navy-800); }
.boot { text-align: center; }
.boot-mark { color: #fff; font-size: 26px; font-weight: 700; letter-spacing: .22em; }
.boot-bar { width: 160px; height: 3px; background: rgba(255,255,255,.18); border-radius: 3px; margin: 18px auto 0; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; background: var(--teal-600); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* --------------------------------------------------------------- login --- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .login-wrap { grid-template-columns: 1.1fr .9fr; } }

.login-hero {
  background: linear-gradient(155deg, var(--navy-900), var(--navy-700) 70%, var(--teal-700));
  color: #fff; padding: 44px 40px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero .brand { font-size: 26px; font-weight: 700; letter-spacing: .18em; }
.login-hero .brand small { display: block; font-size: 11px; letter-spacing: .1em; opacity: .7; margin-top: 6px; font-weight: 400; }
.login-hero h1 { font-size: 30px; line-height: 1.25; margin: 40px 0 14px; max-width: 15ch; }
.login-hero p { color: rgba(255,255,255,.78); max-width: 46ch; }
.login-modules { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.login-modules span {
  font-size: 11.5px; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.16);
}
.login-foot { font-size: 11.5px; color: rgba(255,255,255,.55); margin-top: 40px; }

.login-panel { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 19px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-muted); margin-bottom: 22px; }
.demo-users { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 16px; }
.demo-users h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); margin-bottom: 10px; }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.demo-grid button {
  text-align: left; padding: 7px 9px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: 12px; line-height: 1.3;
}
.demo-grid button:hover { border-color: var(--teal-600); background: var(--teal-100); }
.demo-grid button b { display: block; font-weight: 600; }
.demo-grid button span { color: var(--text-faint); font-size: 11px; }

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

.sidebar {
  background: var(--navy-800); color: #fff; padding: 18px 12px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
@media (max-width: 860px) { .sidebar { display: none; } }

.sidebar .logo { padding: 6px 10px 20px; font-weight: 700; letter-spacing: .16em; font-size: 17px; }
.sidebar .logo small { display: block; font-size: 9.5px; letter-spacing: .08em; opacity: .55; font-weight: 400; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.72); font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--teal-600); color: #fff; font-weight: 550; }
.nav a .ico { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav a .badge {
  margin-left: auto; background: rgba(255,255,255,.16); border-radius: 999px;
  font-size: 10.5px; padding: 1px 6px; font-variant-numeric: tabular-nums;
}
.nav a.active .badge { background: rgba(0,0,0,.22); }
.nav-sep { font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: rgba(255,255,255,.35); padding: 16px 10px 6px; }

.sidebar-user { border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; margin-top: 10px; }
.sidebar-user .who { display: flex; align-items: center; gap: 9px; padding: 0 6px 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--teal-600); color: #fff;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 650; flex: none;
}
.sidebar-user .meta { min-width: 0; }
.sidebar-user .meta b { display: block; font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .meta span { font-size: 11px; color: rgba(255,255,255,.5); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 22px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { min-width: 0; }
.topbar .title h1 { font-size: 17px; }
.topbar .title p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-muted); }
.topbar .spacer { flex: 1; }
.topbar .mobile-brand { display: none; font-weight: 700; letter-spacing: .14em; color: var(--navy-800); }
@media (max-width: 860px) {
  .topbar { padding: 10px 14px; }
  .topbar .mobile-brand { display: block; }
}

.content { padding: 22px; flex: 1; }
@media (max-width: 860px) { .content { padding: 14px 14px 84px; } }

/* mobile bottom nav */
.tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
@media (max-width: 860px) { .tabbar { display: flex; } }
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10.5px; color: var(--text-muted); text-decoration: none; padding: 4px 2px; min-width: 0;
}
.tabbar a.active { color: var(--teal-700); font-weight: 600; }
.tabbar a .ico { width: 20px; height: 20px; }
.tabbar a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ---------------------------------------------------------------- bits --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 14px; }
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-head h2 { font-size: 14.5px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 10px 16px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* stat tiles */
.stat { padding: 14px 16px; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.stat .value { font-size: 26px; font-weight: 650; line-height: 1.15; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.stat.accent { border-left: 3px solid var(--teal-600); }
.stat.warn { border-left: 3px solid var(--amber); }
.stat.danger { border-left: 3px solid var(--red); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--teal-700); border-color: var(--teal-700); }
.btn.dark { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.btn.dark:hover:not(:disabled) { background: var(--navy-700); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); }
.btn svg, .btn .ico { width: 16px; height: 16px; flex: none; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.lg { padding: 11px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* forms */
label.field { display: block; margin-bottom: 12px; }
label.field > .lbl { display: block; font-size: 12px; font-weight: 550; color: var(--text-muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal-600); box-shadow: 0 0 0 3px var(--teal-100);
}
textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.chip.pending, .chip.open, .chip.requested { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.chip.approved, .chip.quoted, .chip.scheduled { background: var(--teal-100); color: var(--teal-700); border-color: transparent; }
.chip.issued, .chip.en_route, .chip.sent { background: var(--blue-bg); color: var(--blue); border-color: transparent; }
.chip.received, .chip.in_progress { background: var(--violet-bg); color: var(--violet); border-color: transparent; }
.chip.confirmed, .chip.completed, .chip.lpo_issued, .chip.delivered { background: var(--green-bg); color: var(--green); border-color: transparent; }
.chip.rejected, .chip.cancelled, .chip.emergency, .chip.flagged { background: var(--red-bg); color: var(--red); border-color: transparent; }
.chip.neutral { background: var(--navy-100); color: var(--navy-700); border-color: transparent; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 600; padding: 9px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
th.right, td.right { text-align: right; }

/* list rows (mobile-friendly alternative to tables) */
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row .lead { min-width: 0; flex: 1; }
.list-row .lead b { display: block; font-weight: 600; font-size: 13.5px; }
.list-row .lead span { font-size: 12.5px; color: var(--text-muted); }

/* misc */
.empty { padding: 40px 20px; text-align: center; color: var(--text-faint); }
.empty svg { width: 34px; height: 34px; opacity: .4; margin-bottom: 10px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.banner {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
}
.banner.info { background: var(--teal-100); color: var(--teal-700); }
.banner.warn { background: var(--amber-bg); color: var(--amber); }
.banner.danger { background: var(--red-bg); color: var(--red); }
.banner.ok { background: var(--green-bg); color: var(--green); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); margin-left: 5px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--teal-600); border: 2px solid var(--surface);
}
.timeline b { font-size: 13px; text-transform: capitalize; }
.timeline span { display: block; font-size: 12px; color: var(--text-muted); }

/* flow / stepper */
.flow { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.flow .step {
  font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border);
}
.flow .step.done { background: var(--green-bg); color: var(--green); border-color: transparent; }
.flow .step.current { background: var(--navy-800); color: #fff; border-color: var(--navy-800); font-weight: 600; }
.flow .arrow { color: var(--text-faint); font-size: 11px; }

/* catalog */
.catalog-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.item-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px;
  background: var(--surface); display: flex; flex-direction: column; gap: 8px;
}
.item-card .sku { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.item-card .nm { font-size: 13px; font-weight: 550; line-height: 1.35; }
.item-card .foot { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.item-card .price { font-weight: 650; font-variant-numeric: tabular-nums; }
.qty-input { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.qty-input button { width: 28px; height: 30px; border: none; background: var(--surface-2); cursor: pointer; font-size: 15px; line-height: 1; color: var(--text); }
.qty-input button:hover { background: var(--navy-100); }
.qty-input input { width: 44px; border: none; text-align: center; padding: 4px 0; font-size: 13px; }
.qty-input input:focus { box-shadow: none; }

.cart-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  box-shadow: var(--shadow-2); border-radius: 999px; padding: 12px 20px;
}
@media (max-width: 860px) { .cart-fab { bottom: 76px; } }

/* signature pad */
.sigpad {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); touch-action: none; width: 100%; height: 190px; display: block;
}
.sigpad.signed { border-style: solid; border-color: var(--teal-600); background: var(--surface); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 34, 51, .5); z-index: 60;
  display: grid; place-items: center; padding: 18px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-3); max-height: calc(100vh - 36px); display: flex; flex-direction: column;
}
.modal.wide { max-width: 780px; }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* toasts */
.toasts { position: fixed; top: 14px; right: 14px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 28px)); }
.toast {
  background: var(--navy-800); color: #fff; padding: 11px 14px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2); font-size: 13px; animation: toast-in .18s ease-out;
}
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* geofence visual */
.fence {
  position: relative; height: 150px; border-radius: var(--radius-sm);
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 9px, #eef3f5 9px, #eef3f5 18px);
  border: 1px solid var(--border); overflow: hidden; display: grid; place-items: center;
}
.fence .ring { width: 108px; height: 108px; border-radius: 50%; border: 2px dashed var(--teal-600); background: rgba(13,125,132,.07); position: relative; }
.fence .me { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--navy-800); border: 2px solid #fff; box-shadow: var(--shadow-1); transform: translate(-50%, -50%); }
.fence .me.out { background: var(--red); }
.fence .legend { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: var(--text-muted); }

.skeleton { background: linear-gradient(90deg, #eef2f4 25%, #e3e9ec 50%, #eef2f4 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 4px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

@media print {
  .sidebar, .topbar, .tabbar, .btn { display: none !important; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
}
