/* BlueHorizon Log — minimal dark UI */

:root {
  --bg: #060a16;
  --bg-raise: #0c1426;
  --bg-card: #101a30;
  --line: rgba(120, 150, 255, 0.10);
  --text: #e8edf6;
  --text-dim: #8d9cc0;
  --accent: #3d64ff;
  --accent-soft: rgba(61, 100, 255, 0.14);
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius: 14px;
  --tabbar-h: 64px;
  --display: 'Orbitron', -apple-system, sans-serif;
  --body-font: 'Exo 2', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 680px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer;
  font-family: var(--display); letter-spacing: 0.14em; font-weight: 500; }
.brand svg { color: var(--accent); }
.brand b { font-weight: 900; color: var(--accent); }
.page-title, .home-welcome, .sheet-title, .empty-title { font-family: var(--display); letter-spacing: 0.04em; }
.home-head h3, .res-group h3, .result-group { font-family: var(--display); font-weight: 500; }
.tab span { font-family: var(--display); letter-spacing: 0.08em; font-size: 9.5px; }
.btn-primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 12px; font: inherit; font-weight: 700; cursor: pointer; font-family: var(--display); letter-spacing: 0.06em; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  padding: 8px; border-radius: 10px; color: var(--text-dim);
  display: flex; align-items: center;
}
.icon-btn:active, .icon-btn:hover { background: var(--bg-raise); color: var(--text); }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
main { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + 32px); }
.page-title { font-size: 22px; margin: 6px 0 14px; }

/* ---------- Filter chips ---------- */
.feed-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.feed-filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 999px;
  background: var(--bg-raise); color: var(--text-dim);
  border: 1px solid var(--line); font-size: 13.5px; white-space: nowrap;
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(77,163,255,0.35); }

/* ---------- Cards / feed ---------- */
.feed-list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  transition: border-color 0.15s;
}
.card:hover { border-color: rgba(77,163,255,0.35); }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; flex-wrap: wrap; }
.badge {
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.badge.journal { background: rgba(74, 222, 128, 0.12); color: var(--ok); }
.card-title { font-size: 16.5px; font-weight: 650; margin-bottom: 3px; }
.card-body { color: var(--text-dim); font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.card-body.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-photos { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.card-photos::-webkit-scrollbar { display: none; }
.card-photos img {
  height: 96px; width: 128px; object-fit: cover; border-radius: 8px;
  background: var(--bg-raise); flex: 0 0 auto;
}

/* ---------- Photo grid ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
@media (min-width: 560px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px;
  background: var(--bg-raise); cursor: pointer;
}

/* ---------- Projects ---------- */
.project-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.project-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
}
.project-card:hover { border-color: rgba(77,163,255,0.35); }
.project-name { font-weight: 650; }
.project-count { font-size: 13px; color: var(--text-dim); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-dim); font-size: 10.5px; padding: 6px 12px; border-radius: 10px;
}
.tab.active { color: var(--accent); }
.fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #04101f;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(77, 163, 255, 0.45);
  transform: translateY(-10px);
}
.fab:active { transform: translateY(-8px) scale(0.96); }

/* ---------- Sheets ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 8, 16, 0.6); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  animation: slideup 0.22s ease-out;
}
@media (min-width: 720px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 18px; max-height: 85vh; }
}
@keyframes slideup { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-raise);
  border-bottom: 1px solid var(--line);
}
.sheet-title { font-weight: 650; font-size: 15.5px; }
.sheet-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.text-btn { color: var(--text-dim); font-size: 15px; padding: 4px 6px; }
.text-btn.primary { color: var(--accent); font-weight: 700; }
.text-btn:disabled { opacity: 0.45; }

/* segmented control */
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; border: 1px solid var(--line); }
.seg-btn { padding: 5px 12px; border-radius: 8px; font-size: 13px; color: var(--text-dim); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- Inputs ---------- */
.input {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font: inherit; outline: none;
}
.input:focus { border-color: rgba(77,163,255,0.5); }
.input::placeholder { color: #5b6a7f; }
.textarea { resize: vertical; min-height: 110px; }
.select { appearance: none; }
.field-label { font-size: 13px; font-weight: 650; color: var(--text-dim); margin-top: 4px; }
.field-label .hint { font-weight: 400; opacity: 0.75; }
.settings-note { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }

/* ---------- Compose photos ---------- */
.photo-row { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-add {
  width: 84px; height: 84px; border-radius: 10px;
  border: 1.5px dashed rgba(77,163,255,0.45); color: var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; cursor: pointer;
}
.photo-thumb { position: relative; width: 84px; height: 84px; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.photo-thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.compose-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); }

/* ---------- Entry detail ---------- */
.detail-meta { font-size: 13px; color: var(--text-dim); }
.detail-body { white-space: pre-wrap; font-size: 15.5px; word-break: break-word; }
.detail-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.detail-photos img { width: 100%; border-radius: 10px; cursor: pointer; background: var(--bg); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(2, 5, 10, 0.95);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.lightbox img { max-width: 96vw; max-height: 84vh; border-radius: 8px; }
.lightbox-caption { color: var(--text-dim); font-size: 13px; margin-top: 10px; padding: 0 16px; text-align: center; }
.lightbox-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 16px;
  font-size: 34px; color: #fff; line-height: 1;
}

/* ---------- Misc ---------- */
.back-btn { color: var(--accent); font-size: 14.5px; padding: 4px 0; margin-bottom: 4px; }
.ghost-btn {
  width: 100%; padding: 12px; border-radius: var(--radius);
  border: 1.5px dashed var(--line); color: var(--text-dim); font-size: 14.5px;
}
.ghost-btn:hover { color: var(--accent); border-color: rgba(77,163,255,0.4); }
.empty { text-align: center; color: var(--text-dim); padding: 56px 20px; font-size: 14.5px; }
.empty-title { font-size: 17px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
.toast {
  position: fixed; bottom: calc(var(--tabbar-h) + 20px); left: 50%; transform: translateX(-50%);
  background: #1d2c49; border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 70;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4); max-width: 90vw; text-align: center;
}
.toast.err { border-color: rgba(255,107,107,0.5); color: #ffb4b4; }
.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(100deg, var(--bg-card) 40%, #1a2947 50%, var(--bg-card) 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- v2: home / tasks / goals ---------- */
.home-welcome { font-size: 20px; font-weight: 700; margin: 4px 0 16px; }
.home-welcome .sub { display: block; font-size: 13.5px; font-weight: 400; color: var(--text-dim); margin-top: 2px; }
.home-section { margin-bottom: 22px; }
.home-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.home-head h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 700; }
.mini-btn { font-size: 12.5px; color: var(--accent); background: var(--accent-soft); padding: 4px 11px; border-radius: 999px; font-weight: 600; }

.goal-list, .task-list { display: flex; flex-direction: column; gap: 8px; }
.goal-item, .task-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px;
}
.goal-item.done .g-text, .task-item.done .t-title { text-decoration: line-through; opacity: 0.55; }
.check {
  flex: 0 0 auto; width: 21px; height: 21px; margin-top: 1px;
  border: 2px solid var(--text-dim); border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: transparent; font-size: 13px;
}
.check.on { background: var(--ok); border-color: var(--ok); color: #04101f; }
.t-main { flex: 1; cursor: pointer; min-width: 0; }
.t-title { font-weight: 600; font-size: 15px; }
.t-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.t-due { font-weight: 600; }
.t-due.overdue { color: var(--danger); }
.t-due.soon { color: #fbbf24; }
.g-text { flex: 1; font-size: 15px; }

.assignee-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.assignee-chip {
  padding: 6px 13px; border-radius: 999px; font-size: 13.5px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text-dim); cursor: pointer;
}
.assignee-chip.on { background: var(--accent-soft); color: var(--accent); border-color: rgba(77,163,255,0.4); }

/* ---------- v2: more menu / who ---------- */
.more-menu { display: flex; flex-direction: column; gap: 6px; }
.more-item {
  text-align: left; padding: 14px 16px; border-radius: 12px; font-size: 16px;
  background: var(--bg-card); border: 1px solid var(--line);
}
.more-item:active, .more-item:hover { border-color: rgba(77,163,255,0.4); }

/* ---------- v2: attachments ---------- */
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; cursor: pointer;
}
.file-chip .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.file-chip .f-size { color: var(--text-dim); font-size: 12px; }
.file-chip button { color: var(--danger); font-size: 15px; }
.file-btn { display: block; text-align: center; cursor: pointer; }

/* ---------- v2: tables (PO + sheet viewer) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 8px 10px; white-space: nowrap;
  color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-raise);
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr.arrived td { opacity: 0.5; }
.data-table tr.arrived td:first-child { opacity: 1; }
.po-progress { height: 6px; border-radius: 999px; background: var(--bg-card); overflow: hidden; margin-bottom: 14px; }
.po-progress div { height: 100%; background: var(--ok); border-radius: 999px; transition: width 0.3s; width: 0; }
.sheet-card.wide { max-width: 980px; }

/* ---------- v2: search ---------- */
.result-group { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 700; margin: 10px 0 2px; }
.result-item {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 13px; cursor: pointer; font-size: 14px;
}
.result-item:hover { border-color: rgba(77,163,255,0.4); }
.result-item .r-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
mark { background: rgba(77,163,255,0.3); color: inherit; border-radius: 3px; }

.text-btn.danger { color: var(--danger); }
#searchInput { flex: 1; }

/* ---------- v3: avatars / profile ---------- */
.avatar-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft) center/cover no-repeat;
  color: var(--accent); font-size: 12.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(77,163,255,0.4); margin-right: 2px;
}
.avatar-big {
  width: 92px; height: 92px; border-radius: 50%;
  background: var(--accent-soft) center/cover no-repeat;
  color: var(--accent); font-size: 32px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(77,163,255,0.4); cursor: pointer;
}
.avatar-sm {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent-soft) center/cover no-repeat;
  color: var(--accent); font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- v3: resources ---------- */
.res-group { margin-bottom: 18px; }
.res-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 8px; }
.res-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 15px; margin-bottom: 8px; cursor: pointer;
}
.res-item:hover { border-color: rgba(77,163,255,0.4); }
.res-item .r-title { flex: 1; font-weight: 600; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-item .r-kind { font-size: 12px; color: var(--text-dim); }

/* ---------- v3: onboarding ---------- */
.ob-hero { text-align: center; padding: 12px 0; }
.ob-hero .ob-emoji { font-size: 44px; }
.ob-hero h2 { font-size: 21px; margin: 8px 0 6px; }
.ob-hero p { color: var(--text-dim); font-size: 14.5px; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin-top: 4px; }
.ob-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.ob-dots span.on { background: var(--accent); }
.ob-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.ob-card .ob-t { font-weight: 650; }
.ob-card .ob-s { font-size: 13px; color: var(--text-dim); }

img.avatar-sm, img.avatar-big { object-fit: cover; padding: 0; }

/* ---------- v4: PO builder ---------- */
.poi-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.poi-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.poi-name { font-weight: 650; }
.poi-price { font-weight: 700; color: var(--accent); white-space: nowrap; }
.poi-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; }
.poi-just { font-size: 13px; color: var(--text-dim); margin-top: 5px; font-style: italic; }
.poi-actions { margin-top: 7px; display: flex; gap: 12px; }
.poi-actions button { font-size: 13px; color: var(--accent); }
.poi-actions .del { color: var(--danger); }
.vendor-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.vendor-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.vendor-name { font-weight: 700; }
.s889 { padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.s889.ok { background: rgba(74,222,128,0.14); color: var(--ok); }
.s889.bad { background: rgba(255,107,107,0.14); color: var(--danger); }
.s889.unk { background: rgba(251,191,36,0.14); color: #fbbf24; }
.vendor-ship { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 13.5px; color: var(--text-dim); }
.vendor-ship input { width: 110px; padding: 7px 10px; }
.s889-results { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.s889-results button {
  text-align: left; font-size: 13px; padding: 8px 11px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
}
.s889-results button:hover { border-color: rgba(77,163,255,0.4); }

/* ---------- v3: video ---------- */
.video-embed { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 12px; background: #000; }
video.video-embed { object-fit: contain; }
