 :root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #16202a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #ff6a00;
  --navy: #142638;
  --blue: #0284c7;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, system-ui, -apple-system, sans-serif; }
header { background: var(--navy); color: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 18px; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; font-size: 9px; letter-spacing: .12em; color: #94a3b8; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.view-switch { display: flex; background: #0d1b2a; padding: 3px; border-radius: 8px; gap: 4px; }
.view-btn { background: transparent; color: #94a3b8; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.view-btn.active { background: var(--accent); color: #fff; }
.key-pill { font-size: 11px; padding: 4px 10px; border-radius: 20px; background: #1e344b; color: #cbd5e1; font-weight: 700; }
.key-pill.ok { background: #14532d; color: #86efac; }
.export-link { color: #fb923c; font-weight: 700; font-size: 12px; text-decoration: none; }

main { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }

.track-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.03); margin-bottom: 22px; }
.quick-form { display: grid; grid-template-columns: 1fr 420px; gap: 16px; }
.quick-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.quick-side { display: flex; flex-direction: column; gap: 10px; }
.quick-side input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; width: 100%; }

/* Item Builder */
.item-builder { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.ib-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12px; color: #334155; }
.ib-list { display: grid; gap: 6px; }
.ib-row { display: grid; grid-template-columns: 1fr 75px 50px 75px 28px; gap: 6px; align-items: center; }
.ib-row input { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; background: #fff; width: 100%; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { background: #e2e8f0; color: #334155; border: 0; border-radius: 8px; padding: 8px 13px; font-weight: 700; font-size: 12px; cursor: pointer; }
.tab span { background: rgba(255,255,255,.7); padding: 1px 6px; border-radius: 10px; margin-left: 4px; font-size: 11px; }
.tab.active { background: var(--navy); color: #fff; }
.tab.active span { background: var(--accent); color: #fff; }
.actions { display: flex; gap: 8px; }
.search { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; background: #fff; }

button { border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 700; font-size: 12px; cursor: pointer; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: #e05d00; }
.secondary { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.small-btn { padding: 5px 9px; font-size: 11px; }
.full { width: 100%; margin-top: 10px; }

.banner { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.hidden { display: none !important; }

.shipments { display: grid; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; border-left: 5px solid #94a3b8; }
.card.transit { border-left-color: var(--blue); }
.card.delivered { border-left-color: var(--green); }
.card.exception { border-left-color: var(--red); }
.card.pending { border-left-color: var(--amber); }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tn { font: 800 16px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }
.carrier-tag { background: #f1f5f9; color: #475569; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.note-tag { background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.profit-tag { background: #dcfce7; color: #166534; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }

.badge { font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.badge.transit { background: #e0f2fe; color: #0369a1; }
.badge.delivered { background: #dcfce7; color: #15803d; }
.badge.exception { background: #fee2e2; color: #b91c1c; }
.badge.pending { background: #fef3c7; color: #b45309; }

.items-preview { margin: 10px 0; background: #f8fafc; border-radius: 8px; padding: 8px 12px; font-size: 12px; display: grid; gap: 4px; }
.item-pill { display: flex; justify-content: space-between; color: #334155; border-bottom: 1px dashed #e2e8f0; padding-bottom: 3px; }
.item-pill:last-child { border-bottom: 0; padding-bottom: 0; }

.latest-scan { margin-top: 10px; padding-top: 10px; border-top: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.scan-text strong { display: block; font-size: 14px; color: var(--ink); }
.scan-text small { color: var(--muted); font-size: 12px; }

.card-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.mini { background: #f8fafc; border: 1px solid var(--line); color: #334155; padding: 6px 10px; font-size: 11px; }
.mini:hover { background: #f1f5f9; }
.mini.danger { color: var(--red); }

.timeline { margin-top: 14px; padding: 12px 14px 4px 22px; background: #f8fafc; border-radius: 8px; border-left: 2px solid #cbd5e1; }
.tl-item { position: relative; padding-bottom: 12px; }
.tl-item::before { content: ""; position: absolute; left: -27px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.tl-item:first-child::before { background: var(--accent); box-shadow: 0 0 0 3px #ffedd5; }
.tl-item strong { display: block; font-size: 13px; }
.tl-item small { color: var(--muted); font-size: 11px; }

.card-foot { margin-top: 10px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* Margins View */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.kpi span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi strong { display: block; font-size: 24px; margin-top: 4px; color: var(--ink); }
.kpi strong.pos { color: var(--green); }
.kpi strong.neg { color: var(--red); }

.table-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.margin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.margin-table th { background: #f8fafc; text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); }
.margin-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.pos-txt { color: var(--green); font-weight: 700; }
.neg-txt { color: var(--red); font-weight: 700; }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .85); display: grid; place-items: center; padding: 16px; z-index: 100; }
.dialog { width: min(460px, 100%); background: #fff; border-radius: 14px; padding: 24px; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.wide-dialog { width: min(650px, 100%); }
.dialog h2 { margin: 0 0 12px; font-size: 20px; }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: var(--muted); margin: 0 0 4px; }
.close { position: absolute; right: 14px; top: 12px; background: transparent; font-size: 22px; color: var(--muted); }
.dialog label { display: block; font-size: 12px; font-weight: 700; margin: 11px 0; color: #334155; }
.dialog input, .dialog select { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; margin-top: 5px; font: 13px inherit; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.empty { text-align: center; padding: 40px; background: #fff; border: 1px dashed #cbd5e1; border-radius: 12px; color: var(--muted); }
@media (max-width: 820px) { .quick-form { grid-template-columns: 1fr; } .kpi-grid { grid-template-columns: 1fr 1fr; } .two { grid-template-columns: 1fr; } }


/* ParcelsApp Style Hero Search Bar */
.hero-search-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: 0 4px 20px rgba(0,0,0,.04); margin-bottom: 22px; }
.hero-input-group { display: flex; gap: 10px; }
.hero-input-group input { flex: 1; border: 2px solid var(--line); border-radius: 10px; padding: 14px 18px; font: 16px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; outline: none; transition: border-color .2s; }
.hero-input-group input:focus { border-color: var(--accent); }
.hero-track-btn { padding: 0 28px; font-size: 15px; border-radius: 10px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.hero-options-row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.hero-options-row input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; }

.hero-search-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 32px 24px; box-shadow: 0 4px 20px rgba(0,0,0,.04); text-align: center; max-width: 700px; margin: 40px auto; }
.hero-title { margin: 0 0 8px; font-size: 26px; }
.hero-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.hero-input-group { display: flex; gap: 10px; max-width: 600px; margin: 0 auto; }
.hero-input-group input { flex: 1; border: 2px solid var(--line); border-radius: 10px; padding: 14px 18px; font: 16px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; outline: none; }
.hero-input-group input:focus { border-color: var(--accent); }
.hero-track-btn { padding: 0 28px; font-size: 15px; border-radius: 10px; font-weight: 800; cursor: pointer; white-space: nowrap; }

.pro-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.danger-txt { color: var(--red) !important; }