:root {
  --blue: #3b8dd0;
  --blue-dark: #2f78b4;
  --blue-bg: #eef5fc;
  --border: #e6e8eb;
  --text: #333;
  --muted: #8a8f98;
  --bg: #f6f7f9;
  --ok: #2e9e5b;
  --edge: #e6a23c;
  --rest: #b4b8bf;
  --warn-bg: #fff8d6;
  --warn-border: #f0e3a0;
  --teal: #19b3a7;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  width: 760px;
  height: 580px;
  font: 13px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
body.full { width: auto; height: 100vh; }
body.full .app { max-width: 1180px; margin: 0 auto; box-shadow: 0 0 0 1px var(--border); }
[hidden] { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; height: 100%; background: #fff; }
.sidebar { width: 156px; flex: none; display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--border); }
.side-title { padding: 13px 16px; font-weight: 600; background: #f5f5f5; border-bottom: 1px solid var(--border); }
.nav { flex: 1; overflow: auto; }
.nav button {
  display: block; width: 100%; padding: 11px 16px; text-align: left; font: inherit;
  color: #666; background: #fff; border: 0; border-left: 3px solid transparent; cursor: pointer;
}
.nav button:hover { background: #fafbfc; }
.nav button.active { color: var(--blue); background: var(--blue-bg); border-left-color: var(--blue); font-weight: 600; }
.side-foot { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.side-foot select { flex: 1; min-width: 0; }
.icon-btn { width: 30px; border: 1px solid #d5d9de; background: #fff; border-radius: 4px; cursor: pointer; font-size: 14px; }
.icon-btn:hover { border-color: var(--blue); color: var(--blue); }

.content { flex: 1; min-width: 0; overflow-y: auto; background: #fff; }
.panel { min-height: 100%; }
.panel-title { margin: 0; padding: 14px 20px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--border); color: #555; }
.pad { padding: 14px 20px 20px; }
.section-title { margin: 22px 0 10px; padding-bottom: 8px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--border); }
.section-title.small { margin: 16px 0 8px; font-size: 13px; border: 0; padding: 0; color: #444; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.foot { margin-top: 14px; }

.notice, .warn {
  padding: 8px 14px; margin: 0 0 14px; border-radius: 3px; font-size: 12.5px;
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: #5c5230;
}
.warn { margin: 12px 0; }
.warn-text { color: #b4690e; }

/* forms */
.form { margin-top: 4px; }
.form-row { display: flex; align-items: center; gap: 8px; min-height: 40px; flex-wrap: wrap; }
.form-row > label:first-child { width: 96px; flex: none; text-align: right; color: #555; padding-right: 4px; }
.inline-label { margin-left: 12px; color: #555; }
input[type=text], input[type=number], input[type=search], input[type=datetime-local], select {
  height: 32px; padding: 0 10px; font: inherit; color: var(--text); background: #fff;
  border: 1px solid #d5d9de; border-radius: 3px; outline: none; min-width: 0;
}
input[type=number] { width: 150px; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59, 141, 208, .15); }
select { max-width: 330px; }
.suffix { color: #666; }
.check { display: inline-flex; align-items: center; gap: 6px; color: #555; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 16px;
  font: inherit; font-weight: 600; color: #444; background: #fff; border: 1px solid #d5d9de; border-radius: 3px; cursor: pointer;
}
.btn:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; font-weight: 400; color: var(--muted); }
.btn.small { height: 26px; padding: 0 10px; font-size: 12px; font-weight: 500; }
.tag { padding: 1px 6px; font-size: 12px; color: #fff; background: var(--teal); border-radius: 3px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { width: 200px; }
.help { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; font-size: 11px; color: #888; border: 1px solid #aaa; border-radius: 50%; cursor: help; margin-left: 4px; }

/* volumetric weight */
.vol-layout { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.form.compact .form-row { min-height: 36px; }
.form.compact .form-row > label:first-child { width: 76px; }
.form.compact .hint-row { min-height: 0; margin: -2px 0 4px; }
input.s { width: 58px; padding: 0 6px; text-align: center; }
input.m { width: 110px; }
.card { border: 1px solid var(--border); border-radius: 6px; background: #f9fbfd; padding: 14px 16px; }
.vol-result { position: sticky; top: 0; }
.result-big { margin: 2px 0 8px; font-size: 32px; line-height: 1.2; font-weight: 700; color: #4a4d52; word-break: break-all; }
.result-sub { color: #666; }
.result-sub div { line-height: 1.75; }
.formula { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.methods { padding: 0 20px 24px; }
.method { margin: 0 0 14px; padding-left: 10px; border-left: 2px solid var(--blue); }
.method-t { font-weight: 600; margin-bottom: 2px; }
.method p { margin: 2px 0; }

/* units */
.radios { display: flex; gap: 18px; margin: 4px 0 12px; flex-wrap: wrap; }
.radio { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.unit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; }
.unit-cell { display: flex; flex-direction: column; padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; min-height: 52px; }
.unit-cell.copyable { cursor: pointer; }
.unit-cell.copyable:hover { border-color: var(--blue); background: var(--blue-bg); }
.unit-val { font-size: 15px; font-weight: 600; word-break: break-all; }
.unit-name { font-size: 12px; color: var(--muted); }

/* time zones */
.tz-main { text-align: center; padding: 0 0 8px; }
.tz-main-name { font-size: 16px; font-weight: 600; color: #555; }
.tz-main-date { font-size: 12px; color: #777; }
.tz-main-time { font-size: 54px; line-height: 1.1; font-weight: 700; color: #54565a; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.tz-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 12px; color: #555; }
.tz-toolbar select { max-width: 138px; }
.tz-toolbar .btn { padding: 0 12px; }
.tz-toolbar { gap: 8px; }
.tz-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tz-card { position: relative; padding: 6px 6px 6px; line-height: 1.35; text-align: center; border: 1px solid var(--border); border-radius: 4px; }
.tz-card .x { position: absolute; top: 1px; right: 4px; padding: 0 3px; font-size: 14px; color: #bbb; background: none; border: 0; cursor: pointer; }
.tz-card .x:hover { color: #e55; }
.tz-card-name { font-size: 12.5px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 10px; }
.tz-card-date { font-size: 11px; color: #888; }
.tz-card-time { font-size: 19px; line-height: 1.3; font-weight: 700; color: #54565a; font-variant-numeric: tabular-nums; }
.tz-card-meta { font-size: 10.5px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc { display: inline-block; margin-right: 5px; padding: 0 4px; font-size: 10px; line-height: 15px; color: #fff; background: #8fa3b8; border-radius: 3px; }
.tag-s { color: var(--edge); }
.dot { display: inline-block; width: 8px; height: 8px; margin: 0 3px 0 6px; border-radius: 50%; background: var(--rest); vertical-align: middle; }
.dot.work { background: var(--ok); }
.dot.edge { background: var(--edge); }
.dot.rest { background: var(--rest); }
.legend { margin-top: 10px; }
.legend .dot:first-of-type { margin-left: 2px; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl thead th { background: #f5f5f5; font-weight: 600; white-space: nowrap; }
.tbl-wrap { padding: 0 20px 20px; }
.tbl.sticky thead th { position: sticky; top: 0; z-index: 1; }
.copyable { cursor: pointer; }
td.copyable:hover { color: var(--blue); background: var(--blue-bg); }
.cc-top { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.cc-top input { width: 280px; }

/* tariff results */
.results { margin: 14px 0 6px; border: 1px solid var(--border); border-radius: 4px; }
.res-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.res-row:last-child { border-bottom: 0; }
.res-label { width: 230px; flex: none; color: #555; }
.res-val { flex: 1; min-width: 0; }
.res-extra { flex: none; font-size: 12px; }
.total { font-size: 20px; font-weight: 700; color: var(--blue-dark); }
.chip { display: inline-block; margin: 1px 4px 1px 0; padding: 0 7px; font-size: 12px; background: #f0f3f7; border-radius: 10px; }
.desc-line { margin: 10px 0; color: #666; }
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 4px; max-height: 300px; overflow: auto; }
.pick { display: flex; gap: 10px; align-items: baseline; text-align: left; padding: 7px 12px; font: inherit; background: #fff; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.pick:hover { background: var(--blue-bg); }
.pick span { flex: 1; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick i { font-style: normal; color: var(--blue-dark); }

/* postal */
.zip-card { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 4px; }
.zip-addr { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.zip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 14px; margin-bottom: 8px; }
.zip-actions { display: flex; gap: 8px; align-items: center; }

#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 10px); padding: 6px 14px; color: #fff;
  background: rgba(40, 44, 52, .9); border-radius: 4px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* compact fields grid (EU estimator) */
.fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.field label { display: block; margin-bottom: 3px; font-size: 12px; color: #666; }
.field input { width: 100%; }
.check-line { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 6px; }

/* image compressor */
.dropzone { margin: 4px 0 12px; padding: 22px 16px; text-align: center; border: 2px dashed #c9d3de; border-radius: 6px; background: #fafcfe; cursor: pointer; outline: none; }
.dropzone:hover, .dropzone:focus, .dropzone.over { border-color: var(--blue); background: var(--blue-bg); }
.drop-main { font-size: 14px; font-weight: 600; color: #555; margin-bottom: 2px; }
.img-opts { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; color: #555; }
.img-opts label { display: inline-flex; align-items: center; gap: 6px; }
.img-opts select { max-width: 280px; }
.img-bar { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; padding: 8px 0; border-top: 1px solid var(--border); }
.img-bar .spacer { flex: 1; }
.img-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.img-thumb { width: 64px; height: 64px; flex: none; border-radius: 4px; background: #f1f3f6 repeating-conic-gradient(#e7eaee 0% 25%, #f6f7f9 0% 50%) 50% / 12px 12px; overflow: hidden; }
.img-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.img-info { flex: 1; min-width: 0; }
.img-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-detail { font-size: 12.5px; color: #666; }
.img-status { font-size: 12px; font-weight: 600; }
.img-status.ok { color: var(--ok); }
.img-status.warnc { color: #b4690e; }
.img-status.bad { color: #d64545; }
.img-act { flex: none; }

/* exchange rates */
.fx-meta { margin: 8px 0 6px; min-height: 18px; }
.fx-tbl td { vertical-align: middle; }
.fx-tbl .fx-amt { font-size: 15px; text-align: right; white-space: nowrap; }
.fx-tbl thead th:nth-child(3) { text-align: right; }
.fx-tbl .fx-x { width: 28px; padding: 0; text-align: center; }
.fx-tbl .x { font-size: 16px; color: #bbb; background: none; border: 0; cursor: pointer; }
.fx-tbl .x:hover { color: #e55; }
.fx-add { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.fx-add select { flex: 1; max-width: 280px; }

/* HS lookup */
.hs-form { margin: 2px 0 8px; }
.hs-form input { flex: 1; width: auto; min-width: 0; }
.hs-try { margin-bottom: 4px; }
.hs-try .chip { margin-left: 6px; color: var(--blue-dark); text-decoration: none; }
.hs-try .chip:hover { background: var(--blue-bg); }
.hs-hint { margin: -4px 0 6px; }
.hs-card { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px; }
.hs-card-top { display: flex; gap: 12px; align-items: center; }
.hs-name { min-width: 0; }
.hs-code { padding: 1px 7px; font: 600 13px ui-monospace, Menlo, Consolas, monospace; color: var(--blue-dark); background: var(--blue-bg); border: 1px solid transparent; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.hs-code:hover { border-color: var(--blue); }
.hs-code.big { font-size: 16px; padding: 3px 10px; }
.hs-note { margin: 6px 0 0; padding: 4px 8px; font-size: 12px; color: #6b5a22; background: var(--warn-bg); border-radius: 3px; }
.hs-card-act { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hs-detail { margin-top: 8px; }
.hs-list { border: 1px solid var(--border); border-radius: 4px; }
.hs-row { display: grid; grid-template-columns: 118px minmax(0, 1fr) 74px auto; gap: 8px; align-items: center; padding: 5px 8px 5px calc(8px + var(--ind, 0) * 12px); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.hs-row:last-child { border-bottom: 0; }
.hs-row .hs-code { font-size: 12px; }
.hs-desc { color: #555; overflow-wrap: anywhere; }
.hs-rate { color: var(--blue-dark); font-weight: 600; text-align: right; }
.hs-chapter-card { margin: 0 0 10px; padding: 8px 12px; background: #f9fbfd; border: 1px solid var(--border); border-radius: 5px; }
.hs-heads { margin-top: 4px; }
.hs-heads .chip { margin-left: 6px; text-decoration: none; }
.hs-chapters { margin-top: 18px; }
.hs-chapters summary { cursor: pointer; font-weight: 600; color: #555; padding: 6px 0; }
.hs-chap { cursor: pointer; }
.hs-chap:hover td { background: var(--blue-bg); color: var(--blue-dark); }
.hs-chapters .tbl td { padding: 5px 10px; }

/* image presets / batch */
.img-modes { margin: 2px 0 10px; }
.plat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0 10px; }
body.full .plat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plat { padding: 6px 10px 8px; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.plat-t { margin-bottom: 2px; font-weight: 600; color: #555; }
.plat label { display: flex; gap: 6px; align-items: flex-start; padding: 2px 0; line-height: 1.4; cursor: pointer; }
.plat label input { margin-top: 3px; flex: none; }
.plat label > span { flex: 1; min-width: 0; }
.plat .sz { display: block; font-size: 11.5px; color: var(--muted); }
.plat .x, .img-act .x { flex: none; padding: 0 4px; font-size: 16px; line-height: 1; color: #bbb; background: none; border: 0; cursor: pointer; }
.plat .x:hover, .img-act .x:hover { color: #e55; }
.img-custom { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 4px 0 10px; }
.img-opts-p { margin-bottom: 6px; }
.img-opts-p select { max-width: 220px; }
#img-sel-notes { margin-top: 6px; }
#img-sel-notes div { margin: 2px 0; }
.img-tag { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 11px; font-weight: 500; color: var(--blue-dark); background: var(--blue-bg); border-radius: 3px; vertical-align: 1px; }
.img-act { display: flex; gap: 4px; align-items: center; }
.img-bar { flex-wrap: wrap; }
