:root {
  --navy: #013a58;
  --navy-2: #0b4d72;
  --sky: #0095d9;
  --sky-tint: #e8f4fb;
  --bg: #f3f6f8;
  --card: #ffffff;
  --ink: #1b2a35;
  --muted: #5b6b77;
  --line: #d9e1e7;
  --ok: #17784f;
  --ok-tint: #e7f5ee;
  --err: #b42318;
  --err-tint: #fdecea;
  --test: #9a5b00;
  --test-tint: #fff4dc;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--sky); }
h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.25; }
h2 { font-size: 1rem; color: var(--navy); }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted, .hint { color: var(--muted); }
small.hint { display: block; font-size: .78rem; margin-top: .25rem; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: #fff; padding: .55rem 1.25rem; border-bottom: 3px solid var(--sky);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .9rem; text-decoration: none; }
.brand img { height: 44px; width: auto; display: block; }
.brand .product {
  color: var(--navy); font-weight: 700; font-size: .95rem; padding-left: .9rem;
  border-left: 1px solid var(--line);
}
.meta { display: flex; align-items: center; gap: 1.1rem; font-size: .85rem; }
.meta a { color: var(--navy); text-decoration: none; font-weight: 600; }
.meta a:hover { color: var(--sky); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-title { font-size: 1.5rem; color: var(--navy); }
.lede { color: var(--muted); margin: 0 0 1.25rem; }
.back { display: inline-block; font-size: .85rem; text-decoration: none; margin-bottom: .6rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}

.pill {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: .15rem .55rem; border-radius: 99px; background: var(--sky-tint); color: var(--navy);
}
.pill-test { background: var(--test-tint); color: var(--test); }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash-ok { background: var(--ok-tint); color: var(--ok); }
.flash-error { background: var(--err-tint); color: var(--err); }
.flash-warn { background: var(--test-tint); color: var(--test); font-weight: 400; }

/* buttons */
.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--navy);
  font: inherit; font-weight: 600; padding: .6rem 1.1rem; border-radius: 8px; cursor: pointer;
  text-decoration: none; text-align: center;
}
.btn:hover { border-color: var(--sky); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn-block { display: block; width: 100%; }
.linkish { background: none; border: 0; padding: 0; color: var(--sky); font: inherit; font-size: .8rem; cursor: pointer; }

/* forms */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.req { color: var(--err); }
input, select, textarea {
  width: 100%; padding: .58rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: -1px; border-color: var(--sky); }
input[type=checkbox] { width: auto; accent-color: var(--navy); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.1rem; }
.field.wide { grid-column: 1 / -1; }
.field.has-error input, .field.has-error select { border-color: var(--err); }
small.error { display: block; color: var(--err); font-size: .78rem; margin-top: .25rem; }
.input-unit { position: relative; }
.input-unit .unit { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .8rem; pointer-events: none; }
.quote-form { max-width: 760px; }
.actions { display: flex; justify-content: flex-end; }

/* step 1: import / export */
.dir-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; max-width: 820px; }
.dir-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; padding: 2rem 1.75rem;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink);
  border-bottom: 5px solid var(--navy); transition: transform .12s, box-shadow .15s, border-color .15s;
}
.dir-card.dir-export { border-bottom-color: var(--sky); }
.dir-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(1, 58, 88, .12); border-color: var(--sky); }
.dir-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  background: var(--sky-tint); color: var(--navy); font-size: 1.6rem; font-weight: 700; margin-bottom: .5rem;
}
.dir-name { font-size: 1.6rem; font-weight: 800; color: var(--navy); }
.dir-blurb { color: var(--muted); }
.sample-link { margin-top: 1.75rem; font-size: .9rem; }

/* step 2: mode -> incoterm */
.mode-row { padding: 1.1rem 1.25rem 1.25rem; }
.mode-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .8rem; }
.mode-head h2 { margin: 0; font-size: 1.1rem; }
.term-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.term-card {
  display: flex; flex-direction: column; gap: .3rem; padding: .9rem 1rem; border: 1px solid var(--line);
  border-left: 4px solid var(--navy); border-radius: 10px; text-decoration: none; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.term-card:hover { border-color: var(--sky); box-shadow: 0 4px 14px rgba(1, 58, 88, .08); }
.term-card.is-pending { border-left-color: var(--line); }
.term-code { font-size: 1.25rem; font-weight: 800; color: var(--navy); letter-spacing: .02em; }
.term-card.is-pending .term-code { color: var(--muted); }
.term-help { font-size: .8rem; color: var(--muted); flex: 1; }
.term-card .pill { align-self: flex-start; }
.term-card.has-variants { border-left-color: var(--navy); }
.variant-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .35rem; }
.variant {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: var(--navy); font-weight: 600; font-size: .85rem; text-decoration: none;
}
.variant:hover { border-color: var(--sky); background: var(--sky-tint); }
.variant.is-pending { color: var(--muted); }
.variant-text { display: flex; flex-direction: column; line-height: 1.3; }
.variant-text b { color: var(--navy); }
.variant-text small { color: var(--muted); font-weight: 400; font-size: .75rem; }

/* quote page */
.quote-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quote-head .lede { margin: 0; }
.total-box { background: var(--navy); color: #fff; border-radius: var(--radius); padding: .7rem 1.1rem; border-bottom: 3px solid var(--sky); text-align: right; }
.total-box span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.total-box strong { font-size: 1.35rem; }
.total-box small { display: block; font-size: .72rem; opacity: .8; }
.quote-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.preview { display: flex; flex-direction: column; gap: .75rem; }
.preview iframe { width: 100%; height: 76vh; min-height: 520px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.send { position: sticky; top: 80px; }
.send-group { margin: 1rem 0; }
.send-group-head { display: flex; justify-content: space-between; align-items: baseline; }
.team-list { display: flex; flex-direction: column; gap: .35rem; max-height: 300px; overflow-y: auto; }
.tick { display: flex; align-items: center; gap: .65rem; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 400; margin: 0; }
.tick:hover { border-color: var(--sky); }
.tick:has(input:checked) { background: var(--sky-tint); border-color: var(--sky); }
.tick .who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.tick .who small { color: var(--muted); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; }
.history { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.history ul { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
.history li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.history li span { display: block; color: var(--muted); font-size: .72rem; }
.history li.bad { color: var(--err); }

/* confirm dialog */
dialog { border: 0; border-radius: var(--radius); padding: 1.25rem 1.4rem; max-width: 420px; width: calc(100% - 2rem); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(1, 30, 45, .45); }
dialog ul { padding-left: 1.1rem; margin: .5rem 0 1rem; }
dialog .row { display: flex; gap: .6rem; justify-content: flex-end; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0%, #025a87 60%, var(--sky) 130%); }
.login-wrap { width: 100%; max-width: 380px; padding: 1rem; }
.login-card { background: #fff; border-radius: 14px; padding: 2rem 1.75rem 1.6rem; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); border-bottom: 4px solid var(--sky); }
.login-logo { display: block; width: 210px; max-width: 100%; margin: 0 auto 1.25rem; }
.login-card h1 { text-align: center; color: var(--navy); font-size: 1.3rem; margin: 0; }
.login-card .sub { text-align: center; color: var(--muted); margin: .2rem 0 1.25rem; font-size: .9rem; }
.login-card input { margin-bottom: 1rem; }
.login-card .err { background: var(--err-tint); color: var(--err); padding: .55rem .75rem; border-radius: 8px; font-size: .85rem; }
.login-foot { text-align: center; color: rgba(255, 255, 255, .75); font-size: .8rem; margin-top: 1rem; letter-spacing: .02em; }

@media (max-width: 860px) {
  .quote-layout { grid-template-columns: 1fr; }
  .send { position: static; }
  .preview iframe { height: 60vh; }
}
@media (max-width: 560px) {
  .grid, .dir-grid, .term-grid { grid-template-columns: 1fr; }
  .brand .product { display: none; }
  .brand img { height: 36px; }
  .wrap { padding: 1rem 1rem 3rem; }
}

/* checkboxes in forms */
.field-check { display: flex; flex-direction: column; justify-content: center; }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 600; margin: 0; cursor: pointer; }
label.check input { width: 18px; height: 18px; }

/* standard costs */
.std-card { border-left: 4px solid var(--navy); }
.std-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.std-head .hint { margin: 0; }
.std-card details { margin-top: .75rem; }
.std-card summary { cursor: pointer; color: var(--sky); font-weight: 600; font-size: .9rem; }
.std-card h3 { margin-top: 1rem; }
.std-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.std-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.std-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.std-table .small, .small { font-size: .75rem; }
.std-edit td:first-child { width: 55%; }
.std-edit td:first-child label { margin: 0; font-weight: 500; }
.std-edit td:first-child small { display: block; }
.std-edit input { max-width: 140px; text-align: right; }
.std-edit input.changed { border-color: var(--test); background: var(--test-tint); }
.undo-form { margin: 0; }
