/* ============================================================
   MASSANGU GOODS GUARDIAN — Design System
   Custom responsive UI (mobile-first)
   ============================================================ */

:root {
  --primary: #123c5e;
  --primary-2: #1c5a8a;
  --primary-soft: #e8f1f9;
  --accent: #f0a93c;
  --accent-soft: #fdf3e2;
  --success: #1f9d55;
  --danger: #d64545;
  --warning: #e6a23c;
  --info: #2f8fc1;
  --ink: #1d2733;
  --muted: #6b7a8c;
  --line: #e4e9ef;
  --bg: #f5f7fa;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(18, 60, 94, 0.08);
  --shadow-lg: 0 8px 30px rgba(18, 60, 94, 0.14);
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}
img { max-width: 100%; }
a { color: var(--primary-2); text-decoration: none; }
a:hover { color: var(--primary); }
h1, h2, h3, h4, h5 { line-height: 1.25; margin: 0 0 .5em; color: var(--primary); }
p { margin: 0 0 1em; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 15px; font-weight: 600; cursor: pointer; text-align: center;
  transition: .15s; line-height: 1.2; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); color: #fff; }
.btn-accent { background: var(--accent); color: #3a2a00; }
.btn-accent:hover { background: #e09a25; color: #3a2a00; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line); color: var(--primary); }
.btn-outline:hover { border-color: var(--primary); background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--primary-2); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-light { background: #fff; color: var(--primary); border-color: var(--line); }
.btn-light:hover { background: var(--primary-soft); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn-danger-soft { background: #fdeaea; color: var(--danger); }
.btn-danger-soft:hover { background: #fbd4d4; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--ink); }
.form-control, .form-select, .form-textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: 15px; font-family: var(--font);
  background: #fff; color: var(--ink); transition: border .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(28, 90, 138, .15);
}
.form-textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 700px) { .form-grid-3 { grid-template-columns: 1fr; } }
.is-invalid { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; }

/* Checkboxes / radios */
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.check input { margin-top: 2px; width: 17px; height: 17px; accent-color: var(--primary); }

/* File drop */
.file-box {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--muted); cursor: pointer;
  transition: .15s; background: #fafbfc;
}
.file-box:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.file-box input[type=file] { display: none; }

/* ============ CARDS / PANELS ============ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-body { padding: 18px; }
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-weight: 700; color: var(--primary); display: flex;
  align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0; }

/* ============ ALERTS / FLASH ============ */
.alert {
  padding: 13px 16px; border-radius: 10px; margin-bottom: 16px;
  font-size: 14px; display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: #e8f7ee; color: #14532d; border: 1px solid #b8e6c8; }
.alert-danger { background: #fdeaea; color: #8a1e1e; border: 1px solid #f5c6c6; }
.alert-warning { background: #fdf3e2; color: #6b4a05; border: 1px solid #f0d9a8; }
.alert-info { background: #e8f1f9; color: #143d5e; border: 1px solid #c3dcf0; }
.alert .close { margin-left: auto; cursor: pointer; color: inherit; background: none; border: 0; font-size: 18px; }

/* ============ BADGES ============ */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap;
}

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 11px 12px; background: #f2f5f9;
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #fafbfd; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============ TIMELINE ============ */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding: 0 0 20px; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-dot {
  position: absolute; left: -26px; top: 2px; width: 20px; height: 20px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff;
}
.tl-dot.done { background: var(--success); }
.tl-dot.current { background: var(--accent); box-shadow: 0 0 0 4px rgba(240,169,60,.25); }
.tl-dot.pending { background: #cdd5dd; }
.tl-dot.danger { background: var(--danger); }
.tl-dot.warn { background: var(--warning); }
.tl-head { font-weight: 700; color: var(--ink); font-size: 14.5px; }
.tl-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tl-desc { font-size: 13.5px; margin-top: 4px; color: #37444f; }
.tl-img { max-width: 180px; border-radius: 8px; margin-top: 8px; }

/* ============ STAT CARDS ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stat-card .num { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-card .lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat-card .ico { font-size: 22px; float: right; opacity: .8; }

/* ============ LANDING / NAVBAR ============ */
.navbar {
  background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.navbar-inner { display: flex; align-items: center; gap: 16px; padding: 12px 16px; max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; text-decoration: none; }
.brand:hover { color: var(--accent); }
.brand .logo-box {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav-links a { color: #dbe7f2; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: #fff; background: rgba(255,255,255,.12); }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--primary); flex-direction: column; padding: 10px 16px 16px; gap: 2px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 12px; }
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff; padding: 70px 0 90px; position: relative; overflow: hidden;
}
.hero h1 { color: #fff; font-size: clamp(28px, 5vw, 46px); font-weight: 800; }
.hero p { color: #cfe0ee; font-size: 17px; max-width: 620px; }
.hero .btn { margin-top: 8px; }
.hero-track {
  background: #fff; border-radius: 16px; padding: 18px; margin-top: 36px;
  box-shadow: var(--shadow-lg); max-width: 720px;
}
.hero-track form { display: flex; gap: 10px; }
.hero-track input { flex: 1; }
@media (max-width: 560px) {
  .hero { padding: 48px 0 60px; }
  .hero-track form { flex-direction: column; }
}

/* Section */
.section { padding: 64px 0; }
.section-alt { background: #fff; }
.sec-head { text-align: center; max-width: 680px; margin: 0 auto 40px; }
.sec-head h2 { font-size: 30px; }
.sec-head p { color: var(--muted); }

/* Feature grid */
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; } }

.feature {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.feature .fi { font-size: 30px; margin-bottom: 10px; }
.feature h3 { font-size: 17px; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }

/* Steps */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
@media (max-width: 800px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .steps { grid-template-columns: 1fr; } }
.step {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-align: center; position: relative;
}
.step .num {
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary-2); font-weight: 800; display: inline-flex; align-items: center;
  justify-content: center; margin-bottom: 10px; font-size: 17px;
}
.step h4 { font-size: 15px; margin-bottom: 6px; }
.step p { font-size: 13px; color: var(--muted); margin: 0; }

/* Footer */
.footer { background: #0e2c44; color: #b8ccdd; padding: 46px 0 20px; }
.footer h4 { color: #fff; font-size: 15px; margin-bottom: 14px; }
.footer a { color: #b8ccdd; display: block; padding: 4px 0; font-size: 14px; }
.footer a:hover { color: var(--accent); }
.footer .fb { border-top: 1px solid rgba(255,255,255,.12); margin-top: 30px; padding-top: 18px; font-size: 13px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: 30px; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ============ AUTH / PAGE SHELL ============ */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 16px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 460px; }
.auth-card .brand { color: var(--primary); justify-content: center; margin-bottom: 18px; }
.auth-card .brand .logo-box { background: var(--accent); }
.page-head { padding: 26px 0 4px; }
.page-head h1 { font-size: 26px; }

/* ============ DASHBOARD SIDEBAR (ops + portal) ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; background: var(--primary); color: #cfe0ee; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar .nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7ea3c0; padding: 12px 12px 6px; }
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 10px; color: #cfe0ee; padding: 10px 12px;
  border-radius: 9px; font-size: 14px; font-weight: 500; margin-bottom: 2px;
}
.sidebar a.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar a.nav-item.active { background: var(--accent); color: #3a2a00; font-weight: 700; }
.sidebar .side-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line); padding: 12px 20px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 50;
}
.topbar .menu-btn { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--primary); }
.topbar .t-title { font-weight: 700; color: var(--primary); font-size: 17px; }
.topbar .t-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.content { padding: 20px; flex: 1; }
.side-backdrop { display: none; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; transition: left .2s; z-index: 200; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .topbar .menu-btn { display: block; }
  .side-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 150; }
  .side-backdrop.show { display: block; }
}

/* User chip */
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-2); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.user-chip .nm { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.user-chip .rl { font-size: 11.5px; color: var(--muted); }

/* ============ MOBILE AGENT UI ============ */
.agent-shell { max-width: 560px; margin: 0 auto; padding: 14px; }
.agent-action {
  display: block; width: 100%; text-align: left; padding: 16px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; margin-bottom: 12px; box-shadow: var(--shadow);
  color: var(--ink); cursor: pointer; font-size: 15px;
}
.agent-action .aa-title { font-weight: 700; color: var(--primary); font-size: 16px; }
.agent-action .aa-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.agent-action:hover { border-color: var(--primary-2); }

/* ============ MODALS ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none;
  align-items: flex-start; justify-content: center; z-index: 300; padding: 40px 16px; overflow-y: auto;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: modal-in .18s ease;
}
@keyframes modal-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; font-weight: 700; color: var(--primary); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }

/* ============ TABS / WIZARD ============ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 16px; font-weight: 600; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0;
}
.tab.active { color: var(--primary); border-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.wizard-steps { display: flex; gap: 8px; margin-bottom: 22px; overflow-x: auto; }
.wstep { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.wstep .n {
  width: 28px; height: 28px; border-radius: 50%; background: var(--line); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.wstep.active { color: var(--primary); font-weight: 700; }
.wstep.active .n { background: var(--primary); color: #fff; }
.wstep.done { color: var(--success); }
.wstep.done .n { background: var(--success); color: #fff; }
.wstep .sep { color: var(--line); margin-left: 8px; }

/* ============ MISC ============ */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.ms-auto { margin-left: auto; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 10px; }

.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; color: var(--primary);
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar .form-control, .filter-bar .form-select { width: auto; min-width: 150px; }

#toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 500; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); padding: 13px 16px;
  border-left: 4px solid var(--primary); font-size: 14px; animation: toast-in .2s ease;
}
.toast.success { border-color: var(--success); }
.toast.danger { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.map-box { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); min-height: 320px; }
.map-box .leaflet-container { min-height: 320px; }

/* Timeline (wizard) */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  border-radius: var(--radius); padding: 24px; margin-bottom: 22px;
}
.welcome-banner h2 { color: #fff; }

.cargo-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* Print */
@media print {
  .sidebar, .topbar, .no-print, .footer { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}