:root {
  --navy: #0f2540;
  --navy-light: #16345c;
  --accent: #ff7a1a;
  --accent-dark: #e6690f;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1c2733;
  --text-muted: #6b7686;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15,37,64,0.08), 0 1px 2px rgba(15,37,64,0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar { background: var(--navy); color: #fff; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; }
.brand:hover { text-decoration: none; opacity: 0.9; }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a { color: #dbe4f0; }
.topnav a:hover { color: #fff; }
.topnav .btn-link {
  background: var(--accent); color: #fff; padding: 7px 14px; border-radius: 6px;
}
.topnav .btn-link:hover { background: var(--accent-dark); text-decoration: none; }
.topnav-user { color: #fff; font-size: 0.9rem; }
.role-chip {
  background: rgba(255,255,255,0.15); padding: 2px 8px; border-radius: 20px;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; margin-left: 6px;
}

/* ---------- Layout ---------- */
.page-wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.with-sidebar { display: flex; gap: 24px; align-items: flex-start; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--navy); color: #fff;
  border-radius: var(--radius); padding: 16px 0; position: sticky; top: 20px;
}
.sidebar h4 {
  color: #8fa3bd; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px;
  padding: 14px 18px 6px; margin: 0;
}
.sidebar a {
  display: block; color: #dbe4f0; padding: 9px 18px; font-size: 0.92rem;
}
.sidebar a:hover, .sidebar a.active { background: var(--navy-light); color: #fff; text-decoration: none; }
.sidebar .sub { padding-left: 30px; font-size: 0.86rem; }
.content { flex: 1; min-width: 0; }

/* ---------- Cards / Stats ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .num { font-size: 1.7rem; font-weight: 700; color: var(--navy); }
.stat-card .label { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }

h1, h2, h3 { color: var(--navy); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.muted { color: var(--text-muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: 1 / -1; }
label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
input, select, textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.95rem;
  font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
legend { font-weight: 700; color: var(--navy); padding: 0 6px; }

.btn {
  display: inline-block; background: var(--navy); color: #fff; border: none;
  padding: 10px 18px; border-radius: 7px; font-size: 0.95rem; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--navy-light); text-decoration: none; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); }
.btn-outline { background: #fff; color: var(--navy); border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; font-size: 0.83rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: #fafbfd; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-neutral { background: #e5e7eb; color: #374151; }

/* ---------- Flash messages ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.92rem; }
.flash-success { background: #dcfce7; color: #15803d; }
.flash-error { background: #fee2e2; color: #b91c1c; }
.flash-info { background: #dbeafe; color: #1d4ed8; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 14px; padding-bottom: 24px; position: relative; }
.timeline li:not(:last-child)::before {
  content: ''; position: absolute; left: 10px; top: 24px; bottom: 0; width: 2px; background: var(--border);
}
.timeline .dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: #fff;
}
.timeline li.done .dot { background: var(--success); }
.timeline li.current .dot { background: var(--accent); }
.timeline .step-title { font-weight: 600; }
.timeline .step-meta { color: var(--text-muted); font-size: 0.83rem; }

/* ---------- Tracking hero ---------- */
.track-hero {
  background: linear-gradient(135deg, var(--navy), var(--navy-light)); color: #fff;
  border-radius: var(--radius); padding: 32px; text-align: center; margin-bottom: 24px;
}
.track-hero form { display: flex; gap: 10px; max-width: 460px; margin: 18px auto 0; }
.track-hero input { flex: 1; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.pagination a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 24px; color: var(--text-muted); font-size: 0.83rem; }

/* ---------- Auth pages ---------- */
.auth-box { max-width: 440px; margin: 40px auto; }

/* ---------- Print label preview (screen) ---------- */
.label-preview {
  max-width: 480px; margin: 0 auto; border: 2px dashed var(--border); border-radius: var(--radius); padding: 20px;
}

/* Responsive tables -> stacked cards on very small screens */
@media (max-width: 560px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead tr { position: absolute; top: -9999px; left: -9999px; }
  tr { margin-bottom: 14px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  td { border: none; border-bottom: 1px solid var(--border); position: relative; padding-left: 46%; }
  td::before {
    content: attr(data-label); position: absolute; left: 12px; width: 40%; white-space: nowrap;
    font-weight: 600; color: var(--text-muted); font-size: 0.78rem;
  }
}
