/* 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 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; }
