/* =====================================================
   SCS TMS — Professional Theme
   Brand: navy #0d3b6e / red #e8262b (from SCS logo)
   ===================================================== */
:root {
  --navy-900: #081c33;
  --navy-800: #0d3b6e;
  --navy-700: #11508f;
  --navy-100: #e8eff8;
  --red: #e8262b;
  --red-dark: #c41e23;
  --bg: #f2f5f9;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #1c2733;
  --muted: #64748b;
  --green: #15803d;
  --amber: #b45309;
  --violet: #6d28d9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(8,28,51,.08), 0 4px 16px rgba(8,28,51,.06);
  --side-w: 248px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-700); text-decoration: none; }
img { max-width: 100%; }
.ic { width: 19px; height: 19px; flex: 0 0 auto; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side-w); background: linear-gradient(180deg, var(--navy-900), #0a2747 70%);
  color: #cfdcec; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 50;
  transition: transform .25s ease;
}
.side-brand { padding: 18px 16px 10px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand img { max-height: 92px; object-fit: contain; filter: drop-shadow(0 2px 8px rgba(0,0,0,.35)); }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 10px; }
.side-nav::-webkit-scrollbar { width: 5px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px; margin: 2px 0;
  color: #b9c9dc; border-radius: 9px; font-size: .93rem; transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, var(--red), #ff5a3c); color: #fff; font-weight: 600; box-shadow: 0 3px 10px rgba(232,38,43,.35); }
.nav-item.danger:hover { background: rgba(232,38,43,.25); }
.side-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.nav-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--red); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700;
}

.main-wrap { flex: 1; margin-left: var(--side-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 10px 22px; min-height: 62px;
}
.top-search { flex: 1; max-width: 520px; position: relative; }
.top-search input {
  width: 100%; padding: 9px 14px 9px 38px; border: 1.5px solid var(--line); border-radius: 99px;
  font-size: .9rem; background: var(--bg); transition: border .15s;
}
.top-search input:focus { outline: none; border-color: var(--navy-700); background: #fff; box-shadow: 0 0 0 3px rgba(17,80,143,.12); }
.ts-ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.top-date { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700; color: var(--green); letter-spacing: .5px; }
.live-dot span { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .4; transform: scale(.8);} }
.user-chip { display: flex; align-items: center; gap: 9px; background: var(--bg); padding: 5px 12px 5px 6px; border-radius: 99px; border: 1px solid var(--line); }
.uc-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-800); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.uc-meta { display: flex; flex-direction: column; line-height: 1.15; }
.uc-meta b { font-size: .84rem; }
.uc-meta small { color: var(--muted); font-size: .72rem; text-transform: capitalize; }

.content { padding: 22px; flex: 1; }
.app-foot { padding: 14px 22px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); text-align: center; background: #fff; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.35rem; color: var(--navy-900); display: flex; align-items: center; gap: 10px; }
.page-head h1 .ic { color: var(--red); width: 24px; height: 24px; }
.page-head .spacer { flex: 1; }
.page-sub { color: var(--muted); font-size: .88rem; margin-top: 3px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h2 { font-size: 1.02rem; color: var(--navy-900); }
.card-h .spacer { flex: 1; }
.card-b { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Stat cards ---------- */
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--navy-800); }
.stat-card.red::before { background: var(--red); }
.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.violet::before { background: var(--violet); }
.stat-ic { width: 46px; height: 46px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--navy-100); color: var(--navy-800); }
.stat-ic .ic { width: 23px; height: 23px; }
.stat-card.red .stat-ic { background: #fdecec; color: var(--red); }
.stat-card.green .stat-ic { background: #e8f7ee; color: var(--green); }
.stat-card.amber .stat-ic { background: #fdf3e3; color: var(--amber); }
.stat-card.violet .stat-ic { background: #f1ebfd; color: var(--violet); }
.stat-meta b { font-size: 1.5rem; display: block; line-height: 1.1; }
.stat-meta small { color: var(--muted); font-size: .8rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .89rem; }
.tbl th {
  text-align: left; padding: 10px 12px; background: #f8fafc; color: #475569; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
.tbl tr:hover td { background: #f8fafd; }
.tbl .actions { white-space: nowrap; display: flex; gap: 6px; }
.lr-no { font-weight: 700; color: var(--navy-800); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .74rem; font-weight: 600; }
.badge-navy   { background: var(--navy-100); color: var(--navy-800); }
.badge-green  { background: #e8f7ee; color: var(--green); }
.badge-amber  { background: #fdf3e3; color: var(--amber); }
.badge-red    { background: #fdecec; color: #b91c1c; }
.badge-violet { background: #f1ebfd; color: var(--violet); }
.badge-gray   { background: #eef2f6; color: #475569; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 9px; border: 1.5px solid transparent;
  font-size: .88rem; font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; text-decoration: none;
}
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--navy-700); color: var(--navy-800); }
.btn-green { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .78rem; border-radius: 7px; }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-icon { padding: 7px; border-radius: 8px; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text); padding: 6px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: var(--bg); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .half { grid-column: span 2; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .half { grid-column: 1 / -1; } }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-size: .8rem; font-weight: 600; color: #3b4a5c; margin-bottom: 5px; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 8px; font-size: .9rem;
  font-family: inherit; background: #fff; transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(17,80,143,.12); }
.field textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.section-title {
  grid-column: 1 / -1; font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; color: var(--red);
  font-weight: 700; border-bottom: 1px dashed var(--line); padding-bottom: 6px; margin-top: 6px;
}

/* permission checkboxes */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.perm-item { display: flex; align-items: center; gap: 9px; background: var(--bg); border: 1px solid var(--line); padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: .87rem; }
.perm-item input { accent-color: var(--red); width: 16px; height: 16px; }
.perm-item:hover { border-color: var(--navy-700); }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .9rem; border: 1px solid; }
.alert .ic { width: 18px; height: 18px; }
.alert-success { background: #e8f7ee; border-color: #bbe5cb; color: #14532d; }
.alert-error   { background: #fdecec; border-color: #f5c2c2; color: #7f1d1d; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: ""; position: absolute; left: -24px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--navy-800); border: 2.5px solid #fff; box-shadow: 0 0 0 2px var(--navy-800);
}
.tl-item.reached::before { background: var(--violet); box-shadow: 0 0 0 2px var(--violet); }
.tl-item.delivered::before { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.tl-item.cancelled::before { background: var(--red); box-shadow: 0 0 0 2px var(--red); }
.tl-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tl-head b { color: var(--navy-900); }
.tl-time { color: var(--muted); font-size: .78rem; }
.tl-note { color: var(--muted); font-size: .85rem; margin-top: 3px; }

/* ---------- Login ---------- */
.public-body { background: linear-gradient(135deg, var(--navy-900) 0%, #0a2747 55%, #123a63 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-wrap { width: 100%; max-width: 430px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo img { max-height: 110px; filter: drop-shadow(0 4px 14px rgba(0,0,0,.45)); }
.auth-card { background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card h1 { font-size: 1.25rem; color: var(--navy-900); margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: .87rem; margin-bottom: 20px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: .85rem; color: var(--muted); }

/* ---------- Public tracking ---------- */
.public-hero { max-width: 760px; margin: 0 auto; width: 100%; }
.public-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.public-topbar img { max-height: 84px; }
.public-card { background: #fff; border-radius: 16px; padding: 30px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.track-input-row { display: flex; gap: 10px; }
.track-input-row input { flex: 1; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 1rem; text-transform: uppercase; letter-spacing: .5px; }
.track-input-row input:focus { outline: none; border-color: var(--navy-700); }
.notice-arrived {
  background: linear-gradient(90deg, #e8f7ee, #f2fbf5); border: 1px solid #bbe5cb; color: #14532d;
  padding: 14px 18px; border-radius: 12px; margin-top: 16px; font-size: .95rem; display: flex; gap: 10px; align-items: flex-start;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,28,51,.55); z-index: 100; display: none;
  align-items: flex-start; justify-content: center; padding: 60px 16px;
}
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-h { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-h h3 { font-size: 1rem; color: var(--navy-900); }
.modal-h .close { margin-left: auto; }
.modal-b { padding: 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- QR ---------- */
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: inline-block; }
.qr-box svg { display: block; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mt-2 { margin-top: 16px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .field { min-width: 150px; flex: 1; max-width: 230px; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-state .ic { width: 42px; height: 42px; opacity: .35; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 170px 1fr; row-gap: 9px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; row-gap: 2px; } .kv dd { margin-bottom: 8px; } }

.mobile-only { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .main-wrap { margin-left: 0; }
  .mobile-only { display: inline-flex; }
  .top-date, .live-dot { display: none; }
  .content { padding: 14px; }
  .uc-meta { display: none; }
}
