/*
 * BRIGHTS LIGHT CARGO — admin dashboard & customer portal styles.
 * Colour tokens copied from the public website (src/styles.css):
 * deep marine navy + signal cyan, Sora headings, Manrope body, IBM Plex Mono codes.
 */
:root {
  --radius: 0.5rem;
  --background: oklch(0.985 0.004 250);
  --foreground: oklch(0.21 0.045 254);
  --card: oklch(1 0 0);
  --primary: oklch(0.29 0.083 256);
  --primary-foreground: oklch(0.985 0.005 240);
  --secondary: oklch(0.965 0.01 250);
  --muted: oklch(0.965 0.008 250);
  --muted-foreground: oklch(0.53 0.03 253);
  --accent: oklch(0.68 0.15 232);
  --accent-strong: oklch(0.55 0.15 235);
  --accent-foreground: oklch(0.18 0.05 255);
  --destructive: oklch(0.577 0.225 25);
  --success: oklch(0.6 0.14 158);
  --warning: oklch(0.76 0.15 78);
  --warning-foreground: oklch(0.24 0.05 70);
  --navy: oklch(0.235 0.07 258);
  --navy-foreground: oklch(0.97 0.008 240);
  --navy-soft: oklch(0.32 0.075 257);
  --border: oklch(0.9 0.012 250);
  --sidebar-accent: oklch(0.3 0.075 257);
  --shadow-card: 0 1px 2px oklch(0.2 0.06 250 / 0.06), 0 8px 24px oklch(0.2 0.06 250 / 0.07);
  --font-sans: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Sora", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: 15px; line-height: 1.5; color: var(--foreground); background: var(--background); }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 0.98rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted-foreground); }
.small { font-size: 0.83rem; }
.xs { font-size: 0.75rem; }
.bold { font-weight: 700; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: var(--navy-foreground); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy-foreground); padding: 4px 8px; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 8px; background: #fff; object-fit: contain; }
.brand strong { font-family: var(--font-display); font-size: 0.95rem; display: block; line-height: 1.1; }
.brand span { font-size: 0.7rem; opacity: 0.7; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.55; padding: 10px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; color: oklch(0.93 0.012 245); padding: 9px 10px; border-radius: var(--radius); font-weight: 500; font-size: 0.92rem; }
.nav a:hover { background: var(--sidebar-accent); text-decoration: none; }
.nav a.active { background: var(--sidebar-accent); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav .count { margin-left: auto; background: var(--accent); color: var(--accent-foreground); border-radius: 999px; font-size: 0.7rem; padding: 0 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; font-size: 0.75rem; opacity: 0.6; padding: 0 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar form { flex: 1; max-width: 420px; }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 0.88rem; }
.topbar .user .role { font-size: 0.72rem; color: var(--muted-foreground); display: block; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; cursor: pointer; }
.content { padding: 28px; max-width: 1400px; width: 100%; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head p { color: var(--muted-foreground); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-card); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); padding: 16px 18px; box-shadow: var(--shadow-card); display: block; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat .label { font-size: 0.8rem; color: var(--muted-foreground); font-weight: 600; }
.stat .value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; margin-top: 4px; }
.stat.tone-warning { border-left: 4px solid var(--warning); }
.stat.tone-danger { border-left: 4px solid var(--destructive); }
.stat.tone-success { border-left: 4px solid var(--success); }
.stat.tone-accent { border-left: 4px solid var(--accent); }
.stat.tone-navy { background: var(--navy); color: var(--navy-foreground); border-color: var(--navy); }
.stat.tone-navy .label { color: oklch(0.85 0.02 245); }

.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.dl div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.dl dt { color: var(--muted-foreground); }
.dl dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.dl.one { grid-template-columns: 1fr; }
.section-title { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-foreground); font-weight: 700; margin: 18px 0 6px; }
.section-title:first-child { margin-top: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-foreground); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--muted); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: oklch(0.98 0.006 250); }
.table .primary-cell a { font-weight: 700; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted-foreground); }
.empty strong { display: block; color: var(--foreground); font-family: var(--font-display); margin-bottom: 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.badge-accent { background: oklch(0.68 0.15 232 / 0.14); color: oklch(0.42 0.12 240); }
.badge-success { background: oklch(0.6 0.14 158 / 0.15); color: oklch(0.4 0.11 158); }
.badge-warning { background: oklch(0.76 0.15 78 / 0.2); color: oklch(0.42 0.1 70); }
.badge-danger { background: oklch(0.577 0.225 25 / 0.13); color: oklch(0.48 0.19 25); }
.badge-muted { background: var(--muted); color: var(--muted-foreground); border-color: var(--border); }
.badge-navy { background: var(--navy); color: var(--navy-foreground); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: var(--radius); padding: 9px 16px; font: 600 0.88rem var(--font-sans); border: 1px solid transparent; cursor: pointer; background: var(--primary); color: var(--primary-foreground); text-decoration: none; line-height: 1.2; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(1.12); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.btn svg { width: 16px; height: 16px; }
.btn-accent { background: var(--accent); color: var(--accent-foreground); }
.btn-outline { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn-outline:hover { background: var(--muted); filter: none; }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--muted); filter: none; }
.btn-danger { background: var(--destructive); color: #fff; }
.btn-danger-outline { background: var(--card); color: var(--destructive); border-color: oklch(0.577 0.225 25 / 0.4); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-strong); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.inline { display: inline; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label, .label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 5px; }
.field .hint { font-size: 0.76rem; color: var(--muted-foreground); margin-top: 4px; }
.req { color: var(--destructive); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font: 0.92rem var(--font-sans); background: var(--card); color: var(--foreground); }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px oklch(0.68 0.15 232 / 0.2); }
.input.is-invalid { border-color: var(--destructive); }
.field-error { color: var(--destructive); font-size: 0.8rem; margin-top: 4px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--primary); }
fieldset { border: 0; padding: 0; margin: 0; }
.form-section { padding: 20px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section > h2 { margin-bottom: 4px; }
.form-section > p.muted { margin-bottom: 16px; font-size: 0.86rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; background: var(--muted); border-top: 1px solid var(--border); border-radius: 0 0 calc(var(--radius) + 4px) calc(var(--radius) + 4px); position: sticky; bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .field { min-width: 150px; flex: 1; }
.filters .field.grow { flex: 2; min-width: 220px; }
.filters .input { padding: 8px 10px; font-size: 0.86rem; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 0.9rem; border: 1px solid; }
.alert-success { background: oklch(0.6 0.14 158 / 0.1); border-color: oklch(0.6 0.14 158 / 0.35); color: oklch(0.35 0.1 158); }
.alert-error { background: oklch(0.577 0.225 25 / 0.08); border-color: oklch(0.577 0.225 25 / 0.35); color: oklch(0.42 0.17 25); }
.alert-warning { background: oklch(0.76 0.15 78 / 0.14); border-color: oklch(0.76 0.15 78 / 0.5); color: var(--warning-foreground); }
.alert-info { background: oklch(0.68 0.15 232 / 0.08); border-color: oklch(0.68 0.15 232 / 0.35); color: oklch(0.35 0.1 245); }
.alert ul { margin: 6px 0 0 18px; padding: 0; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--accent); }
.timeline li.voided { opacity: 0.55; }
.timeline li.voided .dot { background: var(--muted-foreground); box-shadow: 0 0 0 1px var(--muted-foreground); }
.timeline li.internal .dot { background: var(--warning); box-shadow: 0 0 0 1px var(--warning); }
.timeline .title { font-weight: 700; }
.timeline .meta { font-size: 0.8rem; color: var(--muted-foreground); }
.timeline .desc { font-size: 0.88rem; margin-top: 3px; }
.milestones { display: flex; gap: 4px; margin-bottom: 8px; }
.milestones div { flex: 1; text-align: center; font-size: 0.68rem; font-weight: 600; color: var(--muted-foreground); }
.milestones div::before { content: ""; display: block; height: 6px; border-radius: 3px; background: var(--border); margin-bottom: 6px; }
.milestones .done::before { background: var(--accent); }
.milestones .current::before { background: var(--primary); }
.milestones .done, .milestones .current { color: var(--foreground); }

/* ---------- Charts (server-rendered) ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 44px; align-items: center; gap: 10px; font-size: 0.84rem; }
.bar-row .track { background: var(--muted); border-radius: 4px; height: 12px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.bar-row .fill.tone-success { background: var(--success); }
.bar-row .fill.tone-warning { background: var(--warning); }
.bar-row .fill.tone-danger { background: var(--destructive); }
.bar-row .fill.tone-muted { background: oklch(0.7 0.03 253); }
.bar-row .fill.tone-accent { background: var(--accent); }
.bar-row .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.columns { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-top: 10px; border-bottom: 1px solid var(--border); }
.columns .col { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.columns .col:hover { background: var(--primary); }
.columns-labels { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted-foreground); margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 0.78rem; color: var(--muted-foreground); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 0.85rem; }
.pagination .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span.page { min-width: 34px; text-align: center; padding: 5px 9px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--foreground); background: var(--card); }
.pagination a:hover { text-decoration: none; background: var(--muted); }
.pagination .current { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.pagination .disabled { opacity: 0.45; }

/* ---------- Dialog ---------- */
dialog.confirm { border: 0; border-radius: 12px; padding: 0; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 24px 60px oklch(0.18 0.06 250 / 0.3); }
dialog.confirm::backdrop { background: oklch(0.2 0.05 255 / 0.55); }
dialog.confirm .body { padding: 22px; }
dialog.confirm .body p { margin-top: 8px; color: var(--muted-foreground); }
dialog.confirm .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; background: var(--muted); }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--navy-soft), var(--navy)); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 16px; padding: 30px; box-shadow: 0 24px 60px oklch(0.1 0.05 255 / 0.4); }
.auth-card .brand { color: var(--foreground); padding: 0; margin-bottom: 22px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.auth-links { display: flex; justify-content: space-between; font-size: 0.85rem; margin-top: 16px; }

/* ---------- Portal ---------- */
.portal-top { background: var(--navy); color: var(--navy-foreground); }
.portal-top .inner { max-width: 1100px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.portal-top nav { display: flex; gap: 4px; }
.portal-top nav a { color: var(--navy-foreground); padding: 7px 12px; border-radius: var(--radius); font-weight: 600; font-size: 0.9rem; }
.portal-top nav a.active, .portal-top nav a:hover { background: var(--sidebar-accent); text-decoration: none; }
.portal-top .user { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 0.88rem; }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 28px 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-side { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform 0.2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax oklch(0.1 0.05 255 / 0.45); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar .user .who { display: none; }
  .content { padding: 18px 16px; }
  .grid-2, .grid-3, .form-grid, .form-grid-3, .dl { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 36px; }
  .table-stack thead { display: none; }
  .table-stack tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table-stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 14px; }
  .table-stack td::before { content: attr(data-label); font-size: 0.75rem; color: var(--muted-foreground); font-weight: 600; }
}

@media print {
  .sidebar, .topbar, .no-print, .filters, .pagination, .form-actions { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
