/* IFS Trade B2B — single stylesheet, no build step */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-soft: #eff4ff;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --warn: #b45309;
  --warn-soft: #fff8eb;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
code { background: #f1f3f6; padding: 1px 5px; border-radius: 4px; }
pre.example { background: #f1f3f6; padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.top-gap { margin-top: 1rem; }
.top-pad { padding-top: 1.6rem; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 20px; padding-bottom: 90px; min-height: calc(100vh - 120px); }
.footer { color: var(--muted); font-size: .8rem; padding-bottom: 24px; }

/* ---------- top bar */
.topbar { background: #0f172a; color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 6px; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--primary); color: #fff; border-radius: 6px; padding: 2px 7px; font-weight: 800; letter-spacing: .5px; }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav a, .nav .linklike { color: #cbd5e1; padding: 8px 11px; border-radius: 8px; font-size: .95rem; }
.nav a:hover, .nav .linklike:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255,255,255,.14); }
.nav a.nav-cta { background: var(--primary); color: #fff; font-weight: 600; }
.nav a.nav-cta:hover { background: var(--primary-dark); }
.nav-sep { flex: 1; }
.nav-user { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; padding: 6px 10px; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }
.pill { background: #ef4444; color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; }

.viewas-bar { background: #fef3c7; border-bottom: 1px solid #f5d77a; color: #78350f; position: sticky; top: 56px; z-index: 19; }
.viewas-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }

/* ---------- cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; }
.card.narrow { max-width: 720px; }
.card.callout { border-left: 4px solid var(--primary); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head p { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; font-size: .9rem; margin-bottom: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-2.tight { gap: 12px; }
.grid-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.info { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.info span { display: block; color: var(--muted); font-size: .8rem; }
.note { border-left: 4px solid #94a3b8; }
.note-supplier { border-left-color: var(--warn); background: var(--warn-soft); }
.steps li { margin-bottom: 6px; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-n { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-l { color: var(--muted); font-size: .9rem; }
.stat-warn { background: var(--warn-soft); border-color: #fcd9a6; }
.stat-warn .stat-n { color: var(--warn); }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: .92rem; }
label small { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=number], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; font-weight: 400; color: var(--text);
  background: #fff; border: 1px solid #cbd2dc; border-radius: 8px; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93b4ff; outline-offset: 0; border-color: var(--primary); }
input:disabled { background: #f3f4f6; color: var(--muted); }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; }
legend { font-weight: 600; font-size: .92rem; padding: 0 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; }
.stack > * + * { margin-top: 14px; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.wrap-form input { flex: 1; min-width: 180px; margin-top: 0; }
.big-search { font-size: 1.05rem !important; padding: 12px 14px !important; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 200px; margin-top: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.toolbar input, .toolbar select { margin-top: 0; width: auto; }
.toolbar .grow { flex: 1; min-width: 220px; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 38px; font: inherit; font-weight: 600; font-size: .92rem;
  color: var(--text); background: #fff; border: 1px solid #cbd2dc; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f8fafc; text-decoration: none; border-color: #9aa5b5; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-primary:disabled { background: #9db3ea; border-color: #9db3ea; cursor: not-allowed; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef1f5; }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn-lg { padding: 12px 22px; min-height: 48px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.chip { border: 1px solid #c7d6fb; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 2px 10px; font: inherit; font-weight: 600; cursor: pointer; }
.chip:hover { background: #dce7ff; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.table tbody tr:hover { background: #fafcff; }
.table .num { text-align: right; }
.table-compact td { padding: 6px 8px; }
.table tfoot td { border-top: 2px solid var(--border); }
.card > .table:not(.flush) { margin: 0; }
.rowlink { cursor: pointer; }
.row-low { background: var(--warn-soft); }
.row-low:hover { background: #fff2d9 !important; }
.row-inactive { opacity: .55; }
.row-hidden { display: none; }

/* ---------- order form */
.order-table td { padding-top: 7px; padding-bottom: 7px; }
.qty-col { width: 230px; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty input, .qty-input { width: 90px; text-align: right; margin: 0; font-size: 1.02rem; font-weight: 600; min-height: 40px; display: inline-block; }
.qty-input { width: 110px; }
.qty input.has-qty { background: var(--primary-soft); border-color: var(--primary); }
.qty-input.changed { background: var(--warn-soft); border-color: var(--warn); }
.qty-btn { width: 36px; height: 40px; border: 1px solid #cbd2dc; background: #fff; border-radius: 8px; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.qty-btn:hover { background: #f1f5f9; color: var(--text); }
.unit { color: var(--muted); font-size: .85rem; min-width: 30px; }
tr.has-qty-row { background: #f5f8ff; }
.order-extra { display: flex; gap: 16px; flex-wrap: wrap; }
.order-extra label { min-width: 220px; }
.order-extra .grow { flex: 1; }
.sticky-bar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.06);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px max(16px, calc((100vw - 1280px) / 2 + 16px)); z-index: 15; }

/* ---------- badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eef1f5; color: #475569; white-space: nowrap; vertical-align: middle; }
.badge-sent { background: #e0eaff; color: #1d4ed8; }
.badge-confirmed { background: #e6f6ec; color: #15803d; }
.badge-shipped { background: #efe7ff; color: #6d28d9; }
.badge-delivered { background: #e5e7eb; color: #374151; }
.badge-rejected, .badge-cancelled { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: #ffedd5; color: var(--warn); }

/* ---------- flash */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash-success { background: var(--ok-soft); border-color: #a6e3bd; color: #14532d; }
.flash-error { background: var(--bad-soft); border-color: #f5b5b5; color: #7f1d1d; }
.flash-info { background: var(--primary-soft); border-color: #c7d6fb; color: #1e3a8a; }

/* ---------- tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { padding: 7px 13px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.tab:hover { background: #e9edf3; text-decoration: none; color: var(--text); }
.tab.active { background: var(--text); color: #fff; }
.filters .tabs { margin-bottom: 0; margin-right: 8px; }

/* ---------- tiles (supplier picker) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--primary); text-decoration: none; box-shadow: 0 4px 14px rgba(29,78,216,.12); }
.tile-title { font-weight: 700; font-size: 1.08rem; }
.tile-meta { color: var(--muted); font-size: .88rem; }

/* ---------- supplier order cards */
.order-cards { display: grid; gap: 10px; }
.order-card { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; color: var(--text); box-shadow: var(--shadow); }
.order-card:hover { border-color: var(--primary); text-decoration: none; }
.order-card.is-new { border-left: 5px solid var(--primary); }
.oc-top { font-size: 1.05rem; min-width: 220px; }
.oc-meta { display: flex; gap: 6px 16px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; flex: 1; }
.oc-cta { color: var(--primary); font-weight: 700; }
.confirm-box { border: 2px solid var(--primary); }

/* ---------- misc */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f2f5; }
.list li > a:first-child { flex: 1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 3px solid var(--border); margin-left: 4px; }
.timeline .tl-msg { color: #374151; font-size: .92rem; margin-top: 2px; }
.timeline .tl-confirmed { border-color: var(--ok); }
.timeline .tl-rejected, .timeline .tl-cancelled, .timeline .tl-integration_failed { border-color: var(--bad); }
.timeline .tl-shipped { border-color: #7c3aed; }
.timeline .tl-comment { border-color: #94a3b8; }
details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.danger-zone { margin-top: 12px; }
.danger-zone form { margin-top: 10px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 14px 0; }
.apikey { display: inline-block; word-break: break-all; font-size: .95rem; background: #fff; margin: 6px 0; }
.secret { filter: blur(4px); cursor: pointer; }
.secret.revealed { filter: none; }

/* ---------- auth pages */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: linear-gradient(160deg, #0f172a, #1e3a8a); }
.auth-card { width: 100%; max-width: 460px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card h1 { font-size: 1.4rem; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 18px; font-size: 1.05rem; }

/* ---------- responsive */
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 56px; left: 0; right: 0; background: #0f172a; flex-direction: column; align-items: stretch; padding: 8px 16px 14px; }
  .nav.open { display: flex; }
  .nav-sep { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .filters input, .filters select { min-width: 0; flex: 1; }
  .qty-col { width: auto; }
  .sticky-bar { flex-direction: column; align-items: stretch; text-align: center; }
  .order-table th:nth-child(4), .order-table td:nth-child(4), .order-table th:nth-child(5), .order-table td:nth-child(5) { display: none; }
}

@media print {
  .topbar, .footer, .no-print, .actions, .back, .sticky-bar, .flash { display: none !important; }
  body { background: #fff; }
  .card, .info { box-shadow: none; border-color: #ccc; }
  .main { padding: 0; }
}
