/* INCO — UI styled after the IncoDocs look: navy gradient sidebar, Inter, white canvas, blue primary. */
:root {
  --ink: #031b4e;
  --ink-2: #42547a;
  --ink-3: rgba(3, 27, 78, .55);
  --line: #e1e4ea;
  --line-soft: #eef0f4;
  --wash: rgba(3, 27, 78, .07);
  --wash-2: rgba(3, 27, 78, .035);
  --primary: #3370eb;
  --primary-hover: #2a62d6;
  --primary-soft: #eaf1fe;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --ok: #12825b;
  --ok-soft: #e7f6ef;
  --side-a: #031b4e;
  --side-b: #081336;
  --btn-border: rgba(3, 27, 78, .2);
  --shadow-btn: 0 1px 4px rgba(0, 0, 0, .04);
  --shadow-pop: 0 12px 32px rgba(3, 27, 78, .16), 0 2px 6px rgba(3, 27, 78, .08);
  --r: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 Inter, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink); background: #fff;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; line-height: 24px; font-weight: 600; margin: 0; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; line-height: 16px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ico { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(140deg, var(--side-a), var(--side-b));
  color: #fff; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.workspace { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.workspace .mark {
  width: 32px; height: 32px; border-radius: 7px; background: #fff; color: var(--side-a);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -.02em;
}
.workspace .name { font-size: 12px; line-height: 16px; font-weight: 600; }
.workspace .sub { font-size: 10px; line-height: 16px; font-weight: 500; color: rgba(255,255,255,.55); }
.nav { padding: 8px 0; }
.nav-group + .nav-group { margin-top: 14px; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 18px;
  color: #fff; font-size: 14px; line-height: 20px; font-weight: 500;
}
.nav a .ico { opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.07); }
.nav a .plus { margin-left: auto; opacity: .8; }
.side-bottom { margin-top: auto; padding: 0 0 6px; }
.side-bottom a, .side-bottom button {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 34px; padding: 0 18px;
  color: rgba(255,255,255,.85); font: 500 13px/20px inherit; font-family: inherit; background: none; border: 0; cursor: pointer;
}
.side-bottom a:hover, .side-bottom button:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.side-foot { border-top: 1px solid rgba(255,255,255,.1); padding: 12px 18px 16px; font-size: 11px; color: rgba(255,255,255,.55); }
.side-foot b { color: #fff; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 32px 0; }
.search-box {
  display: flex; align-items: center; gap: 8px; width: 320px; height: 44px; padding: 0 14px;
  background: var(--wash); border-radius: var(--r); color: var(--ink-3);
}
.search-box input { border: 0; background: transparent; height: 100%; padding: 0; font-size: 14px; color: var(--ink); width: 100%; }
.search-box input:focus { outline: none; }
.search-box:focus-within { box-shadow: 0 0 0 2px rgba(51,112,235,.35); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #4a5bbd; color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; text-transform: uppercase;
}
.content { padding: 28px 32px 64px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.crumb a { color: var(--ink-3); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 1px solid var(--btn-border); border-radius: var(--r); background: #fff; color: var(--ink);
  font: 500 14px/14px inherit; font-family: inherit; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-btn);
}
.btn:hover { background: #f7f8fa; text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--btn-border); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--wash-2); }
.btn.sm { height: 28px; font-size: 13px; padding: 0 8px; }
.btn.lg { height: 36px; padding: 0 14px; }
.btns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--ink-3); width: 28px; height: 28px; border-radius: var(--r);
  display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--wash); color: var(--ink); }

/* ---------- forms ---------- */
label.f { display: block; font-size: 12px; line-height: 18px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: 400 14px/20px inherit; font-family: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--r); padding: 0 12px; height: 36px;
}
textarea { padding: 8px 12px; height: auto; min-height: 60px; resize: vertical; }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2342547a' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m7 10 5-5 5 5M7 14l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center; }
input:hover, select:hover, textarea:hover { border-color: #c9ced8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,235,.15); }
input:disabled { background: var(--wash-2); color: var(--ink-3); }
input::placeholder, textarea::placeholder { color: #9aa4b8; }
.hint { font-size: 12px; line-height: 16px; color: var(--ink-3); margin-top: 4px; }
.grid { display: grid; gap: 16px 16px; grid-template-columns: repeat(12, 1fr); }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; }
.c6 { grid-column: span 6; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; } .c12 { grid-column: span 12; }

/* sectioned form, as in the master file: numbered heading with a rule under it */
.section { margin-bottom: 36px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; line-height: 24px;
  padding-bottom: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.section-title .ico { color: var(--ink-2); }
.section-note { color: var(--ink-3); font-size: 13px; margin: -10px 0 16px; }

/* label-left rows (contact / product forms) */
.rows { display: grid; grid-template-columns: 170px 1fr; gap: 14px 20px; align-items: center; }
.rows > label { font-size: 14px; color: var(--ink-2); text-align: right; font-weight: 500; }
.rows > label.top { align-self: start; padding-top: 8px; }
.rows .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rows .trio { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-narrow { max-width: 760px; }

.form-actions {
  position: sticky; bottom: 0; z-index: 5; background: rgba(255,255,255,.96); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); padding: 12px 0; margin-top: 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}

/* ---------- radio pills (contact type) ---------- */
.radios { display: flex; gap: 18px; flex-wrap: wrap; }
.radios label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.radios input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- lists ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink); padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 14px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-size: 14px; line-height: 20px; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: var(--wash-2); }
.doc-name { display: flex; align-items: center; gap: 10px; }
.doc-name .ico { color: var(--primary); }
.doc-name b { font-weight: 500; }
.sub-line { font-size: 12px; line-height: 16px; color: var(--ink-3); }

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.tabs a { padding: 8px 10px; font-size: 13px; font-weight: 500; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a b { font-weight: 500; color: var(--ink-3); margin-left: 4px; font-size: 12px; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--wash); color: var(--ink-2); }
.badge.s-Ordered { background: var(--primary-soft); color: #1d4fb8; }
.badge.s-In-production { background: #fff5e6; color: #9a5b00; }
.badge.s-Shipped { background: #eef0ff; color: #4338ca; }
.badge.s-Arrived { background: var(--ok-soft); color: var(--ok); }
.badge.s-Closed { background: #f0f1f4; color: #4b5565; }
.badge.s-Cancelled { background: var(--danger-soft); color: var(--danger); }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 64px 16px; }
.empty .bubble { width: 112px; height: 112px; border-radius: 50%; margin: 0 auto 24px; display: grid; place-items: center;
  background: #fff; box-shadow: 0 6px 24px rgba(3,27,78,.1); color: var(--primary); }
.empty h2 { font-size: 20px; margin-bottom: 8px; }
.empty p { color: var(--ink-2); margin: 0 auto 20px; max-width: 420px; }

.flash { display: flex; align-items: center; gap: 8px; background: var(--ok-soft); color: #0b5d40; border: 1px solid #b5e3cf;
  padding: 9px 12px; border-radius: var(--r); margin-bottom: 18px; font-size: 14px; }

/* side panels on detail pages */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 14px; margin-bottom: 10px; }
.panel .item { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.panel .item:last-child { border-bottom: 0; }

/* ---------- full-screen shipment editor ---------- */
body.editor-body { overflow: hidden; }
.editor { display: grid; grid-template-rows: 56px 1fr; height: 100vh; }
.ed-top { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: #fff; }
.ed-top .crumbs { display: flex; align-items: center; gap: 10px; font-size: 15px; min-width: 0; }
.ed-top .crumbs .dim { color: var(--ink-3); }
.ed-top .crumbs .sep { color: var(--ink-3); }
.ed-top .grow { flex: 1; }
.ed-body { display: grid; grid-template-columns: 236px 1fr; min-height: 0; }
.ed-docs { border-right: 1px solid var(--line); background: #fafbfc; display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.ed-docs h3 { font-size: 14px; font-weight: 600; margin: 0; padding: 16px 16px 10px; }
.ed-docs a.doc { display: flex; align-items: center; gap: 10px; padding: 8px 16px; color: var(--ink); font-size: 14px; }
.ed-docs a.doc .ico { color: var(--primary); }
.ed-docs a.doc:hover { background: var(--wash-2); text-decoration: none; }
.ed-docs a.doc.on { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.ed-docs .doc-meta { font-size: 11px; color: var(--ink-3); line-height: 14px; }
.ed-docs .sep-line { border-top: 1px solid var(--line); margin: 10px 0; }
.ed-docs .act { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 14px; color: var(--primary); font-weight: 500;
  background: none; border: 0; cursor: pointer; font-family: inherit; width: 100%; text-align: left; }
.ed-docs .act:hover { background: var(--wash-2); text-decoration: none; }
.ed-docs .act.danger { color: var(--danger); }
.ed-main { overflow: auto; min-height: 0; }
.ed-form { max-width: 880px; margin: 0 auto; padding: 36px 32px 80px; }
.ed-form > h1 { font-size: 24px; line-height: 31px; font-weight: 700; margin-bottom: 28px; }
.ed-preview { height: 100%; display: flex; flex-direction: column; background: #eef0f4; }
.ed-preview .bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.ed-preview iframe { flex: 1; width: 100%; border: 0; }

/* items editor */
.items-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.items { width: 100%; border-collapse: collapse; min-width: 1100px; }
table.items th { font-size: 12px; font-weight: 600; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.items td { padding: 6px 4px; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
table.items input, table.items select, table.items textarea { height: 32px; padding: 0 8px; font-size: 13px; }
table.items textarea { min-height: 32px; height: 32px; min-width: 220px; padding: 5px 8px; }
table.items td.amt { text-align: right; font-weight: 600; padding-top: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.items tfoot td { font-weight: 600; padding: 10px 6px; border-bottom: 0; font-variant-numeric: tabular-nums; }
.row-tools { display: flex; gap: 0; }
.items-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.items-actions select { width: 360px; }
.totals { margin-left: auto; width: 340px; margin-top: 18px; font-variant-numeric: tabular-nums; }
.totals .r { display: flex; justify-content: space-between; padding: 4px 0; color: var(--ink-2); }
.totals .r.big { font-size: 16px; font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(140deg, var(--side-a), var(--side-b)); padding: 16px; }
.login { background: #fff; padding: 36px 32px; border-radius: 10px; width: 380px; max-width: 100%; box-shadow: var(--shadow-pop); }
.login h1 { font-size: 24px; line-height: 30px; font-weight: 700; margin: 18px 0 22px; }
.login .mark { width: 36px; height: 36px; border-radius: 8px; background: var(--side-a); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.error { background: var(--danger-soft); border: 1px solid #fecdca; color: var(--danger); padding: 8px 12px; border-radius: var(--r); margin-bottom: 14px; font-size: 13px; }

@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 1000px) {
  .app { grid-template-columns: 200px 1fr; }
  .topbar, .content { padding-left: 20px; padding-right: 20px; }
  .ed-body { grid-template-columns: 200px 1fr; }
  .ed-form { padding: 28px 20px 80px; }
  .rows { grid-template-columns: 140px 1fr; }
}
@media (max-width: 700px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav-group { display: contents; }
  .side-bottom { display: flex; flex-wrap: wrap; margin-top: 0; }
  .side-bottom a, .side-bottom button { width: auto; }
  .side-foot { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .search-box { width: 100%; }
  .grid > * { grid-column: span 12 !important; }
  .rows { grid-template-columns: 1fr; gap: 6px; }
  .rows > label { text-align: left; }
  .ed-body { grid-template-columns: minmax(0, 1fr); }
  .ed-docs { display: none; }
  .ed-form { padding: 20px 16px 80px; }
  body.editor-body { overflow: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.table-wrap { overflow-x: auto; }
.ed-top .crumbs > * { white-space: nowrap; }
.ed-top .crumbs .dim { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- v2: contacts, uploads, snippets, landed cost ---------- */
[hidden] { display: none !important; }
.logo-thumb { width: 36px; height: 24px; object-fit: contain; flex: none; }
.badge.type-supplier { background: #eef0ff; color: #4338ca; }
.badge.type-buyer { background: var(--ok-soft); color: var(--ok); }
.badge.type-forwarder { background: #fff5e6; color: #9a5b00; }
.upload { display: flex; gap: 16px; align-items: flex-start; }
.upload input[type=file] { height: auto; padding: 7px 10px; font-size: 13px; }
.upload-preview { width: 140px; height: 70px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--r); background: #fff; padding: 6px; flex: none; }
.upload-preview.stamp { width: 90px; height: 90px; background: repeating-conic-gradient(#f3f4f7 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); margin-top: 6px; }
label.check input { width: 15px; height: 15px; accent-color: var(--primary); }
.snippet-pick { width: auto; max-width: 220px; height: 26px; font-size: 12px; padding: 0 26px 0 8px; color: var(--primary); border-color: transparent; background-color: var(--primary-soft); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.label-row label.f { margin: 0; }
.snip-content { white-space: pre-wrap; color: var(--ink-2); font-size: 13px; max-width: 520px; }
.lc-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.lc-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 8px 0 24px; }
.kpi { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.kpi .v { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--ink-3); }
.kpi.main { background: var(--primary-soft); border-color: #cddcfb; }
table.lc { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.lc th { font-size: 11.5px; font-weight: 600; text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); background: #fafbfc; vertical-align: bottom; }
table.lc th:first-child, table.lc td:first-child { text-align: left; }
table.lc td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.lc td.desc { white-space: normal; min-width: 180px; }
table.lc tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--line); }
table.lc .hl { background: var(--primary-soft); font-weight: 600; }
table.lc input { width: 70px; height: 30px; text-align: right; font-size: 13px; padding: 0 6px; }
.warn { display: flex; gap: 8px; align-items: flex-start; background: #fff8eb; border: 1px solid #f6dfae; color: #7a4b00; padding: 9px 12px; border-radius: var(--r); font-size: 13px; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg label { padding: 7px 12px; font-size: 13px; cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }
@media (max-width: 1000px) { .lc-inputs { grid-template-columns: 1fr 1fr; } .lc-kpis { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) {
  .lc-inputs, .lc-kpis { grid-template-columns: 1fr; }
  .editor { grid-template-rows: auto 1fr; }
  .ed-top { flex-wrap: wrap; padding: 8px 12px; min-height: 56px; }
  .ed-top .crumbs { flex: 1 1 60%; font-size: 14px; }
  .ed-top .grow { display: none; }
  .ed-main { overflow-x: hidden; }
  .upload { flex-direction: column; }
}

/* ---------- v3: settings ---------- */
.side-bottom a.active { background: rgba(255,255,255,.07); color: #fff; }
.sig-pad { width: 100%; max-width: 520px; aspect-ratio: 16 / 5; border: 1px dashed #b9c2d3; border-radius: 8px; background: #fff;
  touch-action: none; cursor: crosshair; display: block; }
