/* PandaTrade Sourcing — ink-navy sidebar, warm paper canvas, white cards, one vermilion accent. */
:root {
  --ink: #1a1f2b;
  --ink-2: #4b5263;
  --ink-3: #7d8494;
  --paper: #f5f3ee;
  --card: #ffffff;
  --line: #e3e0d8;
  --line-soft: #efece6;
  --side: #17213a;
  --side-2: #101828;
  --accent: #b8322a;
  --accent-hover: #9a2921;
  --accent-soft: #fbeceb;
  --blue: #2f5d8a;
  --blue-soft: #e8f0f8;
  --good: #23784b;
  --good-soft: #e7f4ec;
  --warn: #9a6300;
  --warn-soft: #fbf1dc;
  --bad: #a8261d;
  --r: 8px;
  --shadow: 0 1px 2px rgba(26, 31, 43, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 28px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; line-height: 20px; font-weight: 650; margin: 0 0 10px; }
h3 { font-size: 13px; font-weight: 650; margin: 14px 0 6px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; line-height: 17px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.cn { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* shell */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(170deg, var(--side), var(--side-2)); color: #eef0f5; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 0 14px; }
.side-top { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 18px 18px; color: inherit; }
.brand:hover { text-decoration: none; }
.mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 700 17px/1 "PingFang SC", "Microsoft YaHei", serif; flex: none; }
.brand b { display: block; font-size: 13px; line-height: 16px; letter-spacing: .2px; }
.brand small { display: block; font-size: 11px; color: rgba(238, 240, 245, .55); }
.menu-btn { display: none; }
.side-menu { display: flex; flex-direction: column; flex: 1; }
.nav { display: flex; flex-direction: column; }
.nav a, .side-bottom a, .side-bottom button { display: flex; align-items: center; height: 36px; padding: 0 18px; color: #eef0f5; font: 500 14px/20px inherit; font-family: inherit; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; }
.nav a:hover, .side-bottom a:hover, .side-bottom button:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a.active, .side-bottom a.active { background: rgba(255, 255, 255, .1); box-shadow: inset 3px 0 0 #e8786f; }
.side-bottom { margin-top: auto; }
.side-bottom a, .side-bottom button { font-size: 13px; color: rgba(238, 240, 245, .8); }
.side-bottom form { margin: 0; }
.who { padding: 10px 18px 0; margin-top: 8px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 11px; color: rgba(238, 240, 245, .5); word-break: break-all; }
.content { padding: 28px 32px 56px; min-width: 0; max-width: 1360px; }

/* page */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.back { display: inline-block; font-size: 13px; margin-bottom: 6px; }
.flash { background: var(--good-soft); color: var(--good); border: 1px solid #c3e3cf; padding: 10px 14px; border-radius: var(--r); margin-bottom: 16px; font-weight: 500; }
.alert { background: var(--accent-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--r); margin: 0 0 14px; font-size: 13px; }
.note { background: var(--blue-soft); color: var(--blue); padding: 10px 12px; border-radius: var(--r); margin: 0 0 14px; font-size: 13px; }
.preview-bar { background: var(--warn-soft); color: var(--warn); border: 1px dashed #e2c27a; padding: 8px 12px; border-radius: var(--r); margin-bottom: 16px; font-size: 13px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--accent); background: var(--accent); color: #fff; font: 600 13px/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-danger { background: var(--card); color: var(--bad); border-color: #e7c3bf; }
.btn-danger:hover { background: var(--accent-soft); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--bad); }
input, select, textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; width: 100%; }
input, select { height: 36px; }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
input[type=file] { height: auto; padding: 6px; }
textarea { resize: vertical; min-height: 64px; }
label > span { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.form label { display: block; margin: 0 0 12px; }
label.check { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; }
label.check span { display: inline; margin: 0; font-size: 13px; color: var(--ink); }
.grid { display: grid; gap: 0 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters label { margin: 0; }
.filters label.grow { flex: 1; min-width: 200px; }
.inline-form { display: inline; margin: 0; }
.inline-form select { height: 30px; padding: 2px 6px; font-size: 12px; width: auto; }
details > summary { cursor: pointer; color: var(--blue); font-size: 13px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 10px; }
.fold { border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 10px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; line-height: 28px; font-weight: 650; }
.stat span { font-size: 12px; color: var(--ink-3); }
dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; word-break: break-word; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }
tr.dim td { opacity: .55; }
td .sub { display: block; font-size: 12px; color: var(--ink-3); }

/* status badges */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--line-soft); color: var(--ink-2); }
.st-nowa { background: #eef0f4; color: #555d6e; }
.st-kontakt { background: var(--blue-soft); color: var(--blue); }
.st-oferta { background: #efe9fb; color: #5b3fa0; }
.st-wizyta { background: var(--warn-soft); color: var(--warn); }
.st-odwiedzona { background: #e3f3f2; color: #1d6b66; }
.st-wybrana { background: var(--good-soft); color: var(--good); }
.st-odrzucona { background: #f6e9e8; color: #9b4a43; text-decoration: line-through; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink-3); }
.pill.hidden { border-color: #e2c27a; color: var(--warn); background: var(--warn-soft); }

/* progress bar */
.pbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line-soft); margin: 6px 0; }
.pbar i { display: block; height: 100%; }
.p-nowa { background: #c4c9d3; } .p-kontakt { background: #7aa3cc; } .p-oferta { background: #9a82d1; }
.p-wizyta { background: #e0b04f; } .p-odwiedzona { background: #4fa59f; } .p-wybrana { background: #2f9a5f; }
.p-odrzucona { background: #e3c8c5; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-3); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* factory cards (portal) */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.fcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); }
.fcard h4 { margin: 0 0 2px; font-size: 15px; }
.fcard .meta { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.qlist { margin: 8px 0 0; padding: 0; list-style: none; }
.qlist li { padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.qlist .price { font-weight: 650; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs a.thumb { width: 96px; height: 72px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); display: block; background: var(--line-soft); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.filelist { list-style: none; padding: 0; margin: 0; }
.filelist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 13px; flex-wrap: wrap; }
.filelist li:first-child { border-top: 0; }
.filelist .fthumb { width: 56px; height: 42px; border-radius: 4px; object-fit: cover; border: 1px solid var(--line); }

/* plan */
.day { margin-bottom: 14px; }
.day-head { font-weight: 650; font-size: 13.5px; padding: 6px 0; border-bottom: 2px solid var(--ink); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 10px; }
.day-head.today { border-color: var(--accent); color: var(--accent); }
.pitem { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.pitem .time { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pitem .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.pitem.done .title { text-decoration: line-through; color: var(--ink-3); }

/* diary */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.feed li:first-child { border-top: 0; }
.feed .when { font-size: 11.5px; color: var(--ink-3); }

/* tabs (anchor nav) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--ink-2); font-weight: 500; font-size: 13.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; border-color: var(--line); }

/* secret box */
.secret { background: #fffbea; border: 1px solid #ecd889; border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; }
.secret code { font-size: 15px; background: #fff; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); user-select: all; word-break: break-all; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: linear-gradient(160deg, #1b2742, #0f1626); }
.login-card { background: var(--card); width: 100%; max-width: 380px; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.login-card .brand { padding: 0 0 18px; color: var(--ink); }
.login-card .brand small { color: var(--ink-3); }
.login-card .btn { width: 100%; height: 40px; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 40px; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); font-weight: 600; background: #fff; }
.google-btn:hover { background: var(--line-soft); text-decoration: none; }
.or { text-align: center; font-size: 12px; color: var(--ink-3); margin: 16px 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 10px 0; }
  .brand { padding: 0 16px; }
  .menu-btn { display: inline-flex; margin-right: 16px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .25); background: none; color: #fff; font: inherit; cursor: pointer; }
  .side-menu { display: none; padding-top: 10px; }
  .side-menu.open { display: flex; }
  .content { padding: 18px 16px 40px; }
  .cols, .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  dl.kv { grid-template-columns: 1fr; gap: 0 0; }
  dl.kv dt { margin-top: 8px; }
  .pitem { grid-template-columns: 70px minmax(0, 1fr); }
  .pitem > :last-child { grid-column: 2; }
  .fgrid { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .head-actions, .preview-bar, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .card, .fcard { box-shadow: none; break-inside: avoid; }
}

/* trip view: factory cards first */
.fgrid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); margin-bottom: 18px; }
.fcard { display: flex; flex-direction: column; gap: 8px; }
.fcard.rejected { opacity: .6; }
.fcard-top { display: flex; gap: 12px; align-items: flex-start; }
.fcard-title { min-width: 0; }
.fcard-title .pin-no { float: right; margin: 4px 0 0 8px; }
.fcard-title h4 { font-size: 16px; line-height: 21px; }
.fcard-title h4 a { color: var(--ink); }
.fcard .meta { margin: 2px 0 0; }
.visit { flex: none; width: 58px; text-align: center; border-radius: 8px; background: var(--accent); color: #fff; padding: 6px 0 5px; line-height: 1.1; }
.visit b { display: block; font-size: 17px; }
.visit span { display: block; font-size: 11px; opacity: .9; }
.visit.done { background: var(--good); }
.visit.none { background: var(--line-soft); color: var(--ink-3); border: 1px dashed var(--line); }
.visit.none:hover { text-decoration: none; color: var(--accent); border-color: var(--accent); }
.fcard-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.st-select { height: 30px; width: auto; padding: 2px 8px; font-size: 12px; font-weight: 600; border-radius: 15px; }
.st-select.st-nowa { background: #eef0f4; } .st-select.st-kontakt { background: var(--blue-soft); color: var(--blue); }
.st-select.st-oferta { background: #efe9fb; color: #5b3fa0; } .st-select.st-wizyta { background: var(--warn-soft); color: var(--warn); }
.st-select.st-odwiedzona { background: #e3f3f2; color: #1d6b66; } .st-select.st-wybrana { background: var(--good-soft); color: var(--good); }
.st-select.st-odrzucona { background: #f6e9e8; color: #9b4a43; }
.contact-line { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-2); }
.fcard .qlist { margin: 0; }
.note-client, .note-internal { margin: 0; color: var(--ink-2); }
.fcard-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.fcard-add { align-items: center; justify-content: center; min-height: 160px; border-style: dashed; color: var(--ink-3); box-shadow: none; background: transparent; }
.fcard-add b { font-size: 28px; line-height: 1; }
.fcard-add:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.empty-trip { text-align: center; padding: 34px 20px; }
.empty-trip .btn { margin: 6px 0 10px; }
.rejected-list { margin-bottom: 18px; }
.trip-card .flist { list-style: none; margin: 10px 0 0; padding: 0; }
.trip-card .flist li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.trip-card .flist .when { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.trips { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; margin-bottom: 18px; }
.trip-card { margin: 0; }
.trip-card h2 a { color: var(--ink); }
.summary-line { color: var(--ink-2); font-size: 13px; margin: -8px 0 16px; }
@media (max-width: 900px) { .fgrid, .trips { grid-template-columns: 1fr; } }
dl.kv.kv-tight { grid-template-columns: 96px minmax(0, 1fr); gap: 4px 10px; }
@media (max-width: 900px) { dl.kv.kv-tight { grid-template-columns: 84px minmax(0, 1fr); } dl.kv.kv-tight dt { margin-top: 0; } }
details.pw-reset { flex-basis: 100%; }
details.pw-reset[open] { padding: 8px 0 2px; }
details.pw-reset form { max-width: 320px; }

/* Chinese name: the one used in China, so larger than the English one, with a copy button */
.cn-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 2px; }
.cn-name .cn { font-size: 21px; line-height: 28px; font-weight: 650; color: var(--ink); letter-spacing: .02em; }
.page-head .cn-name .cn { font-size: 24px; line-height: 32px; }
.copy-btn { height: 26px; padding: 0 9px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font: 600 11.5px/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap; }
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { background: var(--good-soft); border-color: #c3e3cf; color: var(--good); }
.fcard h4.en-name, .fcard-title h4.en-name { font-size: 13.5px; line-height: 19px; font-weight: 600; color: var(--ink-2); }
.fcard h4.en-name a { color: var(--ink-2); }

/* client card: short by default, details on demand */
details.more { border-top: 1px solid var(--line-soft); padding-top: 8px; }
details.more > summary { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--blue); cursor: pointer; }
details.more > summary::after { content: "▾"; font-size: 11px; transition: transform .15s; }
details.more[open] > summary::after { transform: rotate(180deg); }
details.more[open] > summary { margin-bottom: 8px; }

/* trip map */
.trip-map { height: 420px; border-radius: 8px; border: 1px solid var(--line); z-index: 0; }
.pin { background: none; border: 0; }
.pin span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pin b { transform: rotate(45deg); color: #fff; font: 700 13px/1 Inter, sans-serif; }
.map-pop { min-width: 210px; }
.map-pop .cn-name .cn { font-size: 16px; line-height: 22px; }
.map-pop .en { font-size: 12.5px; color: var(--ink-2); margin: 2px 0 6px; }
.map-pop .links { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.map-pop .btn { color: #fff; }
.pin-no { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 11.5px/1 Inter, sans-serif; flex: none; }
@media (max-width: 900px) { .trip-map { height: 320px; } }

/* simple notes */
.note-form { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 6px; }
.note-form textarea { flex: 1; min-height: 44px; }
.note-form .btn { flex: none; margin-top: 4px; }
.feed.notes .note-del { float: right; }
@media (max-width: 900px) { .note-form { flex-direction: column; } }

/* photo viewer */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 14, 22, .92); display: flex; align-items: center; justify-content: center; padding: 48px 64px; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff; }
.lightbox figcaption { color: rgba(255,255,255,.85); font-size: 13px; text-align: center; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 28px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.lightbox button:hover { background: rgba(255,255,255,.25); }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
body.lb-open { overflow: hidden; }
@media (max-width: 900px) { .lightbox { padding: 56px 8px 24px; } .lb-prev, .lb-next { top: auto; bottom: 10px; transform: none; } }

.cn-name a.cn { color: var(--ink); }
.cn-name a.cn:hover { color: var(--accent); text-decoration: none; }

.trip-card .trip-name { font-size: 24px; line-height: 30px; font-weight: 700; margin: 0 0 4px; }
.trip-card .trip-name a { color: var(--ink); }
.trip-card .trip-name a:hover { color: var(--accent); text-decoration: none; }

/* quick photo upload on factory cards */
.thumbs .add-thumb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border: 1px dashed var(--line); background: transparent; color: var(--ink-3); cursor: pointer; text-align: center; line-height: 1.1; }
.thumbs .add-thumb b { font-size: 20px; }
.thumbs .add-thumb span { font-size: 11.5px; font-weight: 600; }
.thumbs .add-thumb small { font-size: 10px; opacity: .8; }
.thumbs .add-thumb:hover { border-color: var(--accent); color: var(--accent); }
.fcard-admin:hover .add-thumb { border-color: var(--accent); color: var(--accent); }
.fcard-admin.dragging { outline: 2px dashed var(--accent); outline-offset: 3px; }
.fcard-admin.uploading { opacity: .6; pointer-events: none; }
.fcard-admin.uploading .add-thumb span::after { content: "…"; }
[data-href] { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
[data-href]:hover { border-color: #d8cfc0; box-shadow: 0 4px 14px rgba(26, 31, 43, .08); }
.lightbox .lb-actions { position: absolute; bottom: 16px; right: 16px; display: flex; gap: 8px; }
.lightbox .lb-actions button { position: static; width: auto; height: 36px; border-radius: 18px; padding: 0 16px; font: 600 13px/1 Inter, sans-serif; }
.lightbox .lb-delete { background: rgba(184, 50, 42, .85); }
.lightbox .lb-toggle[hidden] { display: none; }
.lightbox .lb-delete:hover { background: #b8322a; }
.lightbox .lb-delete[hidden] { display: none; }
@media (max-width: 900px) { .lightbox .lb-actions { bottom: auto; top: 14px; right: 70px; } }

/* factory page: gallery */
.page-head .en-title { font-size: 17px; line-height: 23px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery .g-item { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--line-soft); }
.gallery .g-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.gallery a.g-item:hover img { transform: scale(1.04); }
.gallery .g-item.is-hidden img { opacity: .55; }
.gallery .g-badge { position: absolute; left: 6px; bottom: 6px; font-size: 10.5px; font-weight: 600; background: var(--warn-soft); color: var(--warn); padding: 2px 6px; border-radius: 8px; }
.gallery .add-thumb { width: auto; height: auto; }
.gallery.dragging { outline: 2px dashed var(--accent); outline-offset: 4px; }
.gallery.uploading { opacity: .6; pointer-events: none; }
.page-head .cn-name .cn { font-size: 30px; line-height: 38px; }
.gallery .add-thumb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px dashed var(--line); background: transparent; color: var(--ink-3); cursor: pointer; text-align: center; line-height: 1.1; }
.gallery .add-thumb b { font-size: 26px; }
.gallery .add-thumb span { font-size: 12.5px; font-weight: 600; }
.gallery .add-thumb small { font-size: 11px; opacity: .8; }
.gallery .add-thumb:hover, .gallery:hover .add-thumb { border-color: var(--accent); color: var(--accent); }
/* mini gallery: just thumbnails */
.mini-gallery { margin: 0 0 16px; }
.mini-gallery .gallery { grid-template-columns: repeat(auto-fill, 112px); gap: 8px; }
.mini-gallery .g-item { width: 112px; height: 84px; aspect-ratio: auto; }
.mini-gallery .add-thumb b { font-size: 22px; }
.mini-gallery .doc-line { margin-top: 6px; display: flex; gap: 10px; align-items: center; }
/* inline edit panel on the factory card */
details.edit-panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
details.edit-panel > summary h2 { margin: 0; color: var(--blue); font-size: 14px; }
details.edit-panel > summary::after { content: "▾"; color: var(--blue); font-size: 11px; }
details.edit-panel[open] > summary { margin-bottom: 14px; }
details.edit-panel h3 { margin-top: 0; }

/* add-photo tile: a quiet square with a "+" in a circle; instructions live in the tooltip */
.thumbs .add-thumb, .gallery .add-thumb { display: grid; place-items: center; gap: 0; border: 1.5px dashed #d9d3c7; background: #faf8f4; color: var(--ink-3); }
.thumbs .add-thumb:hover, .gallery .add-thumb:hover, .fcard-admin:hover .add-thumb, .gallery:hover .add-thumb { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.add-thumb .plus { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid currentColor; position: relative; opacity: .8; }
.add-thumb .plus::before, .add-thumb .plus::after { content: ""; position: absolute; left: 50%; top: 50%; background: currentColor; border-radius: 1px; transform: translate(-50%, -50%); }
.add-thumb .plus::before { width: 12px; height: 2px; }
.add-thumb .plus::after { width: 2px; height: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.thumbs .add-thumb { width: 96px; height: 72px; border-radius: 6px; flex: none; }

/* factory card: main column + sticky notes on the right */
.factory-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.factory-notes { position: sticky; top: 16px; margin: 0; max-height: calc(100vh - 32px); overflow: auto; }
.factory-notes h2 { margin-bottom: 10px; }
.quick-note textarea { min-height: 40px; height: 40px; resize: none; overflow: hidden; line-height: 1.45; }
.quick-note textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.factory-notes .notes { margin-top: 6px; }
.factory-notes .notes li { padding: 10px 0; }
.factory-notes .note-del button { font-size: 16px; line-height: 1; padding: 0 2px; opacity: .5; }
.factory-notes .notes li:hover .note-del button { opacity: 1; }
@media (max-width: 900px) { .factory-layout { grid-template-columns: 1fr; } .factory-notes { position: static; max-height: none; order: -1; } }
.trip-card .flist-cn { display: block; font-size: 17px; line-height: 24px; font-weight: 650; color: var(--ink); }
.trip-card .flist-cn:hover { color: var(--accent); text-decoration: none; }
.trip-card .flist-en { display: block; font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 900px) {
  /* the page grid must not stretch the top bar on phones */
  .app { grid-template-rows: auto 1fr; min-height: 100vh; }
  .sidebar { align-self: start; }
  .side-menu { flex: none; }
  .page-head { align-items: center; }
  .trip-card .trip-name { font-size: 22px; line-height: 28px; }
}

/* thumbnails: always an even grid of 3 per row that fills the card */
.thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.thumbs a.thumb, .thumbs .add-thumb { width: auto; height: auto; aspect-ratio: 4 / 3; border-radius: 6px; }
.mini-gallery .gallery { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.mini-gallery .g-item { width: auto; height: auto; aspect-ratio: 4 / 3; }
@media (max-width: 900px) { .mini-gallery .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* hover tint only where there is a mouse (on touch it sticks after a tap) */
@media (hover: none) {
  .fcard-admin:hover .add-thumb, .gallery:hover .add-thumb, .thumbs .add-thumb:hover, .gallery .add-thumb:hover {
    border-color: #d9d3c7; background: #faf8f4; color: var(--ink-3);
  }
}

/* card header = one big link to the factory card, set apart from the rest */
.fcard-admin .fcard-head { margin: -16px -16px 2px; padding: 16px 40px 14px 16px; border-bottom: 1px solid var(--line-soft); border-radius: 10px 10px 0 0; position: relative; }
.fcard-admin .fcard-head[data-href]:hover { border-color: var(--line-soft); box-shadow: none; background: #faf8f4; }
.fcard-admin .fcard-head::after { content: "›"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 26px; line-height: 1; color: var(--ink-3); transition: transform .15s, color .15s; }
.fcard-admin .fcard-head:hover::after { color: var(--accent); transform: translate(3px, -50%); }
.fcard-admin .fcard-head:hover .cn-name .cn { color: var(--accent); }
.fcard-admin .fcard-head .pin-no { position: absolute; right: 14px; top: 14px; float: none; margin: 0; }
.fcard-admin .fcard-links:empty { display: none; }

/* quiet notes on the trip cards */
.card-notes { display: flex; flex-direction: column; gap: 4px; }
.card-notes .cnote { font-size: 12.5px; line-height: 17px; color: var(--ink-2); padding-left: 8px; border-left: 2px solid var(--line); }
.card-notes .cnote .when { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.card-notes .cnote-more { font-size: 12px; padding-left: 10px; }
.card-note-form textarea { min-height: 30px; height: 30px; padding: 5px 8px; font-size: 12.5px; line-height: 18px; resize: none; overflow: hidden;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); border-radius: 6px; transition: background .15s, border-color .15s; }
.card-note-form textarea::placeholder { color: var(--ink-3); opacity: .75; }
.fcard-admin:hover .card-note-form textarea { background: #faf8f4; }
.card-note-form textarea:focus { background: #fff; border-color: var(--line); outline: none; color: var(--ink); }
.card-note-form.saving { opacity: .5; pointer-events: none; }

/* copy icon right after the Chinese name, in the same line (wraps with the text) */
.cn-name { display: block; }
.cn-name .cn { display: inline; }
.copy-ico { display: inline-block; vertical-align: middle; position: relative; width: 26px; height: 26px; margin: -4px 0 0 4px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; cursor: pointer; color: var(--ink-3); }
.copy-ico::before, .copy-ico::after { content: ""; position: absolute; width: 10px; height: 12px; border: 1.6px solid currentColor; border-radius: 2px; box-sizing: border-box; }
.copy-ico::before { left: 6px; top: 5px; }
.copy-ico::after { left: 10px; top: 9px; background: var(--card); }
.copy-ico:hover { color: var(--accent); background: var(--accent-soft); }
.copy-ico:hover::after { background: var(--accent-soft); }
.copy-ico.copied { color: var(--good); background: var(--good-soft); }
.copy-ico.copied::before { border: 0; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; width: 7px; height: 13px; left: 9px; top: 4px; transform: rotate(45deg); border-radius: 0; }
.copy-ico.copied::after { display: none; }
.fcard-head:hover .copy-ico::after { background: #faf8f4; }
.fcard-head .copy-ico:hover::after { background: var(--accent-soft); }
.map-pop .copy-ico { width: 22px; height: 22px; margin-top: -3px; }
#notatki .note-del button { font-size: 16px; line-height: 1; padding: 0 2px; opacity: .5; }
#notatki .notes li:hover .note-del button { opacity: 1; }
#notatki .quick-note { max-width: 720px; }
/* client card: the whole card opens the factory page (thumbnails and the copy icon keep their own action) */
.fcard-client[data-href]:hover { border-color: #d8cfc0; box-shadow: 0 4px 14px rgba(26, 31, 43, .08); }
.fcard-client:hover .fcard-head { background: #faf8f4; }
.fcard-client:hover .fcard-head::after { color: var(--accent); transform: translate(3px, -50%); }
.fcard-client:hover .fcard-head .cn-name .cn { color: var(--accent); }
.fcard-client .thumbs a { cursor: zoom-in; }
.page-foot { display: flex; justify-content: flex-end; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.page-foot form { margin: 0; }
/* client factory page: cards stacked in the main column (no cramped third column) */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > .card { margin: 0; }
.factory-main dl.kv { grid-template-columns: 140px minmax(0, 1fr); }
@media (max-width: 900px) { .factory-main dl.kv { grid-template-columns: 1fr; } }

/* trip page: factories split by product category */
.cat-group { margin-bottom: 26px; }
.cat-group .fgrid { margin-bottom: 0; }
.cat-head { display: flex; align-items: baseline; gap: 8px; font-size: 19px; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.cat-head .count { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.fcard-add small { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-3); }
