/* ==========================================================================
   Ragtrail Portal styles (builds on ../assets/css/style.css)
   ========================================================================== */
body.portal { background: var(--paper); }
.p-wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.p-narrow { max-width: 640px; margin: 0 auto; }
.p-main { padding: 32px 0 80px; min-height: 70vh; }

/* Header */
.p-header { position: sticky; top: 0; z-index: 40; background: var(--ink); color: var(--paper); border-bottom: 1px solid var(--line-dark); }
.p-header .p-wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.p-header .logo { color: var(--paper); }
.p-header .logo em { font: 500 0.66rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--clay-300); font-style: normal; margin-left: 4px; }
.p-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.p-nav a { padding: 8px 12px; border-radius: var(--radius); text-decoration: none; font-size: 0.9rem; color: var(--ink-300); transition: background 0.2s, color 0.2s; }
.p-nav a:hover { color: var(--paper); background: rgba(243, 239, 231, 0.06); }
.p-nav a[aria-current="page"] { color: var(--paper); background: rgba(243, 239, 231, 0.1); }
.p-user { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.p-who { display: flex; flex-direction: column; font-size: 0.85rem; line-height: 1.2; text-align: right; }
.p-who small { font: 0.68rem var(--mono); color: var(--ink-400); text-transform: uppercase; letter-spacing: 0.08em; }
.p-out { font-size: 0.85rem; color: var(--ink-300); text-decoration: none; border: 1px solid var(--line-dark); padding: 6px 12px; border-radius: var(--radius); }
.p-out:hover { color: var(--paper); border-color: var(--ink-400); }
.p-bell { position: relative; display: inline-flex; color: var(--ink-300); }
.p-bell svg { width: 22px; height: 22px; }
.p-bell b { position: absolute; top: -6px; right: -8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--clay); color: #fff; font: 600 0.68rem/18px var(--sans); text-align: center; }
.p-menu { display: none; margin-left: auto; background: none; border: 1px solid var(--line-dark); color: var(--paper); padding: 6px 12px; border-radius: var(--radius); font: inherit; font-size: 0.85rem; cursor: pointer; }
@media (max-width: 960px) {
  .p-menu { display: inline-block; }
  .p-nav { display: none; order: 3; flex-basis: 100%; padding-bottom: 12px; }
  .p-nav.open { display: flex; }
  .p-user { margin-left: 0; }
  .p-who { display: none; }
}

/* Footer */
.p-footer { border-top: 1px solid var(--line); padding: 24px 0; font-size: 0.82rem; color: var(--ink-500); }
.p-footer .p-wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.p-footer a { color: var(--ink-600); }

/* Page head, sections */
.p-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.p-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.p-card { background: var(--paper-50); border: 1px solid var(--line); border-radius: 6px; padding: 22px; }
.p-callout { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; border-left: 3px solid var(--clay); margin-bottom: 20px; }
.p-callout > div { flex: 1; min-width: 240px; }
.p-empty { border: 1px dashed var(--ink-300); border-radius: 6px; padding: 32px; text-align: center; color: var(--ink-600); }
.p-empty h3 { font-size: 1.35rem; }
.p-empty p { margin-top: 6px; }
.p-help { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 20px 22px; border-radius: 6px; background: var(--ink); color: var(--paper); }
.p-help a:not(.btn) { color: var(--paper); }
.p-help .eyebrow { color: var(--ink-300); }
.p-help .btn.secondary { color: var(--paper); border-color: rgba(243, 239, 231, 0.5); }

/* Flash */
.p-flash { padding: 12px 16px; border-radius: 4px; margin-bottom: 16px; font-size: 0.93rem; border: 1px solid; }
.p-flash.ok { background: var(--moss-100); border-color: rgba(63, 94, 74, 0.35); color: var(--moss); }
.p-flash.bad { background: var(--clay-100); border-color: rgba(154, 74, 42, 0.4); color: var(--clay-600); }

/* Forms */
.p-form { display: grid; gap: 16px; }
.p-form fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin: 0; display: grid; gap: 8px; }
.p-form legend { font-weight: 500; padding: 0 6px; }
.p-form .field label { display: block; margin-bottom: 6px; font-size: 0.88rem; font-weight: 500; }
.upload-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upload-inline .input { width: auto; flex: 1; min-width: 180px; }
.upload-inline input[type="file"] { font-size: 0.85rem; max-width: 100%; }
.btn.small { padding: 7px 12px; font-size: 0.82rem; }
.linkbtn { background: none; border: 0; padding: 0; margin-left: 8px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
details summary { cursor: pointer; display: inline-block; }
.decide { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.decide .input { width: 160px; padding: 6px 8px; font-size: 0.85rem; }

/* Auth */
.p-auth { display: grid; gap: 32px; max-width: 980px; margin: 24px auto; }
@media (min-width: 860px) { .p-auth { grid-template-columns: 1.1fr 0.9fr; align-items: start; } }
.p-auth-side { background: var(--ink); color: var(--paper); border-radius: 6px; padding: 32px; }
.p-auth-side a:not(.btn) { color: var(--paper); }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--paper-50); border: 1px solid var(--line); border-radius: 6px; text-decoration: none; transition: transform 0.3s var(--ease), box-shadow 0.3s; }
a.tile[href]:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -22px rgba(27, 26, 23, 0.5); }
.tile .n { font: 400 2.4rem/1 var(--serif); }
.tile .l { font-size: 0.85rem; color: var(--ink-600); }

/* Tables */
.p-table { width: 100%; border-collapse: collapse; background: var(--paper-50); border: 1px solid var(--line); border-radius: 6px; font-size: 0.92rem; }
.p-table th, .p-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.p-table th { font: 500 0.7rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-500); background: var(--paper-200); }
.p-table tr:last-child td { border-bottom: 0; }

/* Pills */
.pill.bad { background: var(--clay-100); color: var(--clay-600); }

/* Meter */
.meter { height: 6px; background: var(--paper-200); border-radius: 3px; overflow: hidden; max-width: 420px; }
.meter i { display: block; height: 100%; background: var(--moss); border-radius: 3px; transition: width 0.6s var(--ease); }

/* Stage bar */
.stagebar { list-style: none; display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-top: 12px; }
.stagebar li { position: relative; border-top: 3px solid var(--line); padding-top: 8px; font-size: 0.72rem; color: var(--ink-400); }
.stagebar li span { font: 600 0.66rem var(--mono); }
.stagebar li em { display: block; font-style: normal; line-height: 1.2; margin-top: 2px; }
.stagebar li.done { border-color: var(--moss-300); color: var(--ink-600); }
.stagebar li.now { border-color: var(--clay); color: var(--ink); font-weight: 500; }
@media (max-width: 760px) { .stagebar li em { display: none; } .stagebar li.now em { display: block; position: absolute; white-space: nowrap; } .stagebar { padding-bottom: 18px; } }
.trade-row { display: block; text-decoration: none; margin-bottom: 10px; transition: border-color 0.2s, transform 0.3s var(--ease); }
.trade-row:hover { border-color: var(--ink-300); transform: translateY(-1px); }
.tr-top { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.stage-now { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-end; }
.stage-form { display: flex; gap: 8px; flex-wrap: wrap; }
.stage-form .input { width: auto; min-width: 180px; }

/* KYB */
.kyb-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.kyb-check { border-top: 3px solid var(--line); }
.kyb-check.approved { border-top-color: var(--moss); }
.kyb-check.submitted { border-top-color: var(--ochre); }
.kyb-check.rejected { border-top-color: var(--clay); }
.kc-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kc-head .h3 { font-size: 1.2rem; flex: 1; }
.doclist { list-style: none; display: grid; gap: 6px; font-size: 0.88rem; }
.doclist em { display: block; color: var(--ink-500); }

/* Lots and offers */
.lot-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.lot { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.lot-media { position: relative; aspect-ratio: 16 / 10; background: var(--paper-200); display: flex; align-items: center; justify-content: center; color: var(--ink-400); font-size: 0.85rem; }
.lot-media img { width: 100%; height: 100%; object-fit: cover; }
.lot-media b { position: absolute; right: 10px; bottom: 10px; background: rgba(27, 26, 23, 0.75); color: #fff; font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; }
.lot-body { padding: 16px 18px 18px; }
.lot-body .h3 { font-size: 1.25rem; margin-top: 6px; }
.lot-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.offer-list { display: grid; gap: 12px; }
.offer { display: grid; gap: 16px; }
@media (min-width: 860px) { .offer { grid-template-columns: 1fr 260px; } }
.offer-act { display: flex; flex-direction: column; justify-content: center; }
.offer-act .input { margin-top: 4px; }
dl.mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 20px; margin: 10px 0 0; }
dl.mini dt { font: 500 0.66rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-500); }
dl.mini dd { margin: 2px 0 0; font-size: 0.93rem; }

/* Trade page */
.trade-grid { display: grid; gap: 16px; }
@media (min-width: 960px) { .trade-grid { grid-template-columns: 1fr 1fr; } }
.vessel-frame { position: relative; aspect-ratio: 4 / 3; border-radius: 4px; overflow: hidden; background: #0b1520; }
.vessel-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pay-list { list-style: none; display: grid; gap: 10px; }
.pay-list li { display: grid; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.pay-amt { font-variant-numeric: tabular-nums; }
.pay-form { display: flex; gap: 6px; flex-wrap: wrap; }
.pay-form .input { width: auto; flex: 1; min-width: 110px; padding: 6px 8px; font-size: 0.85rem; }
.claim { padding: 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.timeline { list-style: none; display: grid; gap: 12px; max-height: 420px; overflow: auto; }
.timeline li { padding-left: 14px; border-left: 2px solid var(--line); }
.timeline p { margin: 2px 0; }
.record { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.record .eyebrow, .record .muted { color: var(--ink-300); }
.record a.link { color: var(--paper); }
.record .btn.secondary { color: var(--paper); border-color: rgba(243, 239, 231, 0.5); }
.fp { word-break: break-all; font-size: 0.85rem; padding: 12px; background: rgba(243, 239, 231, 0.06); border-radius: 4px; color: var(--clay-300); }

/* Bars (sort outcome) */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 170px 1fr 52px; gap: 10px; align-items: center; font-size: 0.88rem; }
.bar i { height: 10px; background: var(--moss-300); border-radius: 5px; display: block; min-width: 2px; }
.bar b { text-align: right; font-variant-numeric: tabular-nums; }

/* Market */
.range { position: relative; height: 10px; background: var(--paper-200); border-radius: 5px; min-width: 140px; }
.range i { position: absolute; top: 0; bottom: 0; background: var(--clay-300); border-radius: 5px; }
.range b { position: absolute; top: -3px; width: 3px; height: 16px; background: var(--ink); }
.colchart { display: flex; align-items: flex-end; gap: 10px; height: 220px; padding-top: 20px; overflow-x: auto; }
.col { position: relative; flex: 1; min-width: 42px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.col i { width: 100%; background: linear-gradient(var(--clay-300), var(--clay)); border-radius: 3px 3px 0 0; }
.col span { font: 0.66rem var(--mono); color: var(--ink-500); margin-top: 6px; }
.col b { position: absolute; top: 0; font: 500 0.7rem var(--mono); }

/* Notifications */
.notes { list-style: none; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--paper-50); }
.notes li { border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
.notes a { display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; text-decoration: none; flex-wrap: wrap; }
.notes li.unread { background: #fff; }
.notes li.unread span { font-weight: 600; }
.notes li.unread a { border-left: 3px solid var(--clay); }

/* Report printing */
@media print { .noprint { display: none !important; } body.report { background: #fff; } }

/* ---------- App shell: install button, bottom tabs on phones, safe areas ---------- */
.p-header { padding-top: env(safe-area-inset-top); }
.p-install { margin-left: 10px; font: inherit; font-size: 0.78rem; border: 1px solid var(--line); background: transparent; color: var(--ink-700, inherit); padding: 4px 10px; border-radius: 999px; cursor: pointer; }
.p-install[hidden] { display: none; }
.p-tabs { display: none; }
@media (max-width: 760px) {
  .p-tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 60;
    background: rgba(27, 26, 23, 0.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,0.08); }
  .p-tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: #B9B3A6; text-decoration: none; font-size: 0.68rem; padding: 4px 0; border-radius: 8px; }
  .p-tabs a svg { width: 22px; height: 22px; }
  .p-tabs a[aria-current="page"] { color: #F3EEE4; background: rgba(201, 139, 110, 0.18); }
  body.portal { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .fab, .to-top { display: none !important; }
}
@media print { .p-tabs, .p-install { display: none !important; } }
