@font-face { font-family: "Inter"; src: url("/desk/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e1e5ea;
  --line-strong: #c9d0d8;
  --text: #171d23;
  --muted: #55606b;
  --accent: #147bb2;
  --accent-strong: #0f6291;
  --accent-soft: #e6f2f9;
  --accent-ink: #ffffff;
  --ok: #17794a;
  --warn: #7a4a00;
  --warn-bg: #fdf0d5;
  --warn-line: #e3bd72;
  --risk: #a8231b;
  --risk-bg: #fde7e4;
  --risk-line: #eaa49d;
  --info-bg: #e6f2f9;
  --sample-h: 32px;
  --side-w: 244px;
  --radius: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 96px; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--accent-strong); }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- shell ---------- */
.sample-bar { position: fixed; inset: 0 0 auto 0; height: var(--sample-h); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 0 12px; background: #1c2630; color: #eef2f5; text-align: center; }
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; padding-top: var(--sample-h); }
.side { position: sticky; top: var(--sample-h); height: calc(100vh - var(--sample-h)); background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); padding: 0 6px; }
.brand img { width: 40px; height: 40px; flex: none; }
.brand b { display: block; font-size: 15px; font-weight: 700; letter-spacing: 0.01em; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500; }
.nav a:hover { background: #f1f4f7; color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav svg, .search svg, .user-btn svg, .icon-btn svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: var(--sample-h); z-index: 20; height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-logo { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 12px 0 40px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.search input::placeholder { color: #66717c; }
.user { position: relative; margin-left: auto; }
.user-btn { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 6px; border: 1px solid transparent; border-radius: var(--radius); background: none; cursor: pointer; font-weight: 500; }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: #f1f4f7; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-weight: 700; }
.menu { position: absolute; right: 0; top: 46px; min-width: 220px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(23, 29, 35, 0.12); padding: 6px; z-index: 50; }
.menu-head { padding: 8px 10px; font-weight: 600; }
.menu-head small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; }
.menu-item:hover { background: #f1f4f7; }

#view { padding: 24px; display: flex; flex-direction: column; gap: 20px; outline: none; }
.page-head h1 { font-size: 22px; line-height: 1.3; font-weight: 650; }
.page-head p { color: var(--muted); margin-top: 2px; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.kpi dt { color: var(--muted); }
.kpi dd { font-size: 28px; line-height: 1.25; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.num { text-align: right; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
.t-enq tbody tr { cursor: pointer; }
.t-enq tbody tr:hover td { background: #f7f9fb; }
.t-enq tbody tr.is-open td { background: var(--accent-soft); }
.row-link { font-weight: 600; text-decoration: none; color: var(--accent-strong); white-space: nowrap; }
.row-link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.sub { display: block; color: var(--muted); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ---------- status ---------- */
.chip { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 500; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.chip.tone-info .dot { background: var(--accent); }
.chip.tone-ok .dot { background: var(--ok); }
.chip.tone-work .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.chip.pill { padding: 2px 10px; border-radius: 999px; }
.chip.pill.tone-attention { background: var(--warn-bg); color: var(--warn); }
.chip.pill.tone-attention .dot { background: #b26a00; }
.chip.pill.tone-risk { background: var(--risk-bg); color: var(--risk); }
.chip.pill.tone-risk .dot { background: var(--risk); }
.chip.pill.tone-info { background: var(--info-bg); color: var(--accent-strong); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); }
.btn:hover { background: #f1f4f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.small { min-height: 32px; padding: 0 12px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid transparent; border-radius: var(--radius); background: none; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: #f1f4f7; color: var(--text); }
.icon-btn .back { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }
.field textarea, .price-input input { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); padding: 8px 10px; }
.field textarea { width: 100%; min-height: 76px; resize: vertical; }
.field-error { color: var(--risk); font-weight: 500; }
.price-input { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.price-input input { width: 112px; height: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.price-input input[aria-invalid="true"] { border-color: var(--risk); }

/* ---------- detail panel ---------- */
.scrim { position: fixed; inset: var(--sample-h) 0 0 0; background: rgba(23, 29, 35, 0.3); z-index: 30; }
.panel { position: fixed; top: var(--sample-h); right: 0; bottom: 0; width: min(920px, 100vw); z-index: 40; background: var(--surface); border-left: 1px solid var(--line-strong); box-shadow: -8px 0 24px rgba(23, 29, 35, 0.12); display: flex; flex-direction: column; animation: slide-in 0.22s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }
.p-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 24px 12px 16px; }
.p-title { flex: 1; min-width: 0; }
.p-title h2 { font-size: 18px; line-height: 1.35; font-weight: 650; outline: none; overflow-wrap: anywhere; }
.p-title h2 span { font-weight: 500; color: var(--muted); }
.p-title p { color: var(--muted); }
.p-side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.tabs { display: flex; gap: 24px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 2px 12px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-weight: 500; color: var(--muted); margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 600; }
.p-body { flex: 1; overflow: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* email */
.msg { border: 1px solid var(--line); border-radius: var(--radius); }
.msg > header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: #fafbfc; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.msg-subject { font-weight: 600; padding: 12px 16px 0; overflow-wrap: anywhere; }
.msg-body { padding: 8px 16px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-note { padding: 0 16px 12px; color: var(--muted); }
.msg.out { background: #fbfcfd; }
mark { background: #cfe8f5; color: var(--text); border-radius: 3px; padding: 0 2px; }

/* agent's work */
.read-block { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.box { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.box h3 { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.box .msg-body { padding: 0; }
.fields { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.fields dt { color: var(--muted); }
.fields dd { font-weight: 500; overflow-wrap: anywhere; }
.fields .missing { color: var(--risk); font-weight: 600; }
.steps { display: flex; flex-direction: column; gap: 14px; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; animation: step-in 0.18s ease-out; }
@keyframes step-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.steps .n { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.steps b { display: block; }
.steps ul { margin-top: 6px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.steps ul li { display: block; animation: none; padding-left: 14px; position: relative; }
.steps ul li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.outcome { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fafbfc; }
.draft { white-space: pre-wrap; overflow-wrap: anywhere; background: #fafbfc; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.box > .card-actions { padding-top: 12px; }

/* quote */
.q-top { display: flex; flex-direction: column; gap: 16px; }
.q-head h3 { font-size: 16px; font-weight: 650; }
.q-head p { color: var(--muted); }
.approval { border: 1px solid var(--warn-line); background: #fff9ea; border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.approval.risk { border-color: var(--risk-line); background: #fff4f2; }
.approval.calm { border-color: var(--line-strong); background: #fafbfc; }
.approval h4 { margin: 0; font-size: 16px; font-weight: 650; }
.reasons { display: flex; flex-direction: column; gap: 4px; }
.reasons li { padding-left: 16px; position: relative; font-weight: 500; }
.reasons li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: #b26a00; }
.reasons small { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }
.lines th, .lines td { padding: 10px 12px; }
.lines td { border-bottom: 1px solid var(--line); }
.lines .item { min-width: 230px; }
.lines .item small, .lines .item .tag { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.lines .tag.flag { color: var(--warn); font-weight: 600; }
.lines tfoot td { border-bottom: 0; padding: 6px 12px; }
.lines tfoot tr:first-child td { padding-top: 12px; border-top: 1px solid var(--line); }
.lines tfoot .total td { font-weight: 700; font-size: 16px; padding-bottom: 12px; }
.supplier-box { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius); display: flex; flex-direction: column; gap: 8px; background: #fafbfc; }
.supplier-box details summary { cursor: pointer; color: var(--accent-strong); font-weight: 500; }
.supplier-box .draft { margin-top: 6px; }
.doc-section h4 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.doc-section ul { display: flex; flex-direction: column; gap: 2px; }
.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
s { color: var(--muted); }

/* follow-ups, rules */
.followups { display: flex; flex-direction: column; gap: 16px; }
.followup { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.followup header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.followup h2 { font-size: 16px; font-weight: 650; }
.followup h2 span { font-weight: 500; color: var(--muted); }
.rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.rule-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.rule-card h2 { font-size: 16px; font-weight: 650; }
.rule-card ul { display: flex; flex-direction: column; gap: 8px; }
.rule-card li { padding-left: 16px; position: relative; }
.rule-card li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.rule-wide { grid-column: 1 / -1; padding: 0; }
.rule-wide h2 { padding: 18px 20px 4px; font-size: 16px; font-weight: 650; }
.rule-wide p { padding: 0 20px 12px; color: var(--muted); }

.toast { position: fixed; left: 16px; bottom: 16px; z-index: 90; background: #1c2630; color: #fff; padding: 10px 16px; border-radius: var(--radius); max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.toast.show { opacity: 1; }

.fallback { max-width: 940px; margin: calc(var(--sample-h) + 24px) auto 24px; padding: 0 16px; }
.fallback p { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.fallback img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); }

@media (max-width: 1240px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .t-enq th:nth-child(2), .t-enq td:nth-child(2), .t-enq th:nth-child(7), .t-enq td:nth-child(7) { display: none; }
}

/* ---------- phone: bottom bar, cards, full-screen sheet ---------- */
@media (max-width: 760px) {
  :root { --sample-h: 30px; }
  body { font-size: 14px; }
  .sample-bar { font-size: 12px; }
  .app { display: block; padding-bottom: 68px; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 64px; z-index: 70; flex-direction: row; padding: 0; gap: 0; border-right: 0; border-top: 1px solid var(--line); }
  .brand { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 0; }
  .nav a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 2px; border-radius: 0; font-size: 12px; min-height: 44px; }
  .top { padding: 0 12px; gap: 10px; height: 56px; }
  .top-logo { display: block; flex: none; }
  .user-name { display: none; }
  .user-btn { padding: 0 6px; }
  #view { padding: 16px 12px; gap: 16px; }
  .page-head h1 { font-size: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi dt { font-size: 12px; }
  .kpi dd { font-size: 22px; }
  .kpi:last-child { grid-column: 1 / -1; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }

  .table-wrap { overflow: visible; }
  .surface.cards { background: none; border: 0; }
  table.stack, table.stack tbody, table.stack tr, table.stack td, table.stack tfoot { display: block; }
  table.stack thead { display: none; }
  table.stack tr { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 8px 14px; }
  table.stack td { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border: 0; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; padding-top: 2px; }
  table.stack td.num { text-align: right; }

  .t-enq td:nth-child(2), .t-enq td:nth-child(7) { display: block; }
  table.t-enq tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "id status status" "vessel vessel vessel" "buyer buyer buyer" "port eta lines" "received owner owner"; gap: 2px 12px; padding: 14px; }
  table.t-enq td { display: block; padding: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  table.t-enq td::before { display: none; }
  .t-enq td.c-port::before, .t-enq td.c-eta::before, .t-enq td.c-lines::before, .t-enq td.c-received::before, .t-enq td.c-owner::before { display: block; font-size: 12px; margin-bottom: 1px; }
  table.t-enq td.num { text-align: left; }
  .c-id { grid-area: id; }
  .c-status { grid-area: status; text-align: right !important; justify-self: end; max-width: 100%; }
  .c-status .chip { max-width: 100%; white-space: normal; text-align: left; }
  .c-vessel { grid-area: vessel; font-weight: 600; font-size: 16px; margin-top: 6px; }
  .c-buyer { grid-area: buyer; color: var(--muted); margin-bottom: 8px; }
  .c-port { grid-area: port; }
  .c-eta { grid-area: eta; }
  .c-lines { grid-area: lines; }
  .c-received { grid-area: received; margin-top: 8px; }
  .c-owner { grid-area: owner; margin-top: 8px; }

  .toast { bottom: 76px; right: 16px; }
  .rules { grid-template-columns: minmax(0, 1fr); }
  .doc-grid { grid-template-columns: minmax(0, 1fr); }

  .scrim { display: none !important; }
  .panel { top: var(--sample-h); width: 100%; border-left: 0; box-shadow: none; z-index: 75; }
  .p-head { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .p-head .p-title { flex: 1 1 calc(100% - 60px); }
  .p-side { width: 100%; justify-content: space-between; }
  .p-side .btn { flex: 1; }
  .icon-btn .back { display: block; }
  .icon-btn .x { display: none; }
  .tabs { padding: 0 12px; gap: 18px; overflow-x: auto; }
  .tab { min-height: 44px; white-space: nowrap; }
  .p-body { padding: 16px 12px; }
  .read-block { grid-template-columns: minmax(0, 1fr); }
  .approval { padding: 14px; }
  .card-actions .btn { flex: 1 1 100%; }
  body.panel-open { overflow: hidden; }

  .lines.stack tr { padding: 12px 14px; }
  .lines.stack td { text-align: right; }
  .lines.stack td.item, .lines.stack td.buyer { display: block; text-align: left; }
  .lines.stack td.item::before, .lines.stack td.buyer::before { display: block; margin-bottom: 2px; }
  .lines.stack tfoot tr { background: var(--surface); }
  .lines.stack tfoot td { display: flex; }
  .lines.stack tfoot td:empty { display: none; }
  .lines .item { min-width: 0; }
  .price-input { align-items: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .steps li { animation: none; }
  .chip.tone-work .dot { animation: none; }
  .toast { transition: none; }
}
