.nav { display: flex; gap: 2px; margin-inline-start: 6px; }
.nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
@media (max-width: 520px) {
  .brand-name { display: none; }
  .nav a { padding: 7px 9px; font-size: 14.5px; }
}

.page { max-width: 1000px; margin: 0 auto; padding: 18px 16px 110px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; min-width: 160px; }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 28px 22px; text-align: center; }
.login .brand-mark { width: 54px; height: 54px; font-size: 28px; border-radius: 14px; margin: 0 auto 12px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login form { display: grid; gap: 12px; margin-top: 18px; text-align: start; }

/* ---------- list ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { padding: 12px 14px; }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { font-size: 13px; color: var(--ink-3); }
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.toolbar .input { flex: 1; }
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; padding: 14px; cursor: pointer; transition: border-color .15s; }
.item:hover { border-color: var(--line-2); }
.item .avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 17px;
}
.item .meta { flex: 1; min-width: 0; }
.item .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 13.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .acts { display: flex; gap: 4px; flex: none; }
@media (max-width: 560px) {
  .item { flex-wrap: wrap; }
  .item .acts { width: 100%; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
}
.empty { text-align: center; padding: 48px 20px; }
.empty .ico { font-size: 44px; }

/* ---------- editor ---------- */
.ed-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.ed-head .title-input { flex: 1; min-width: 200px; font-weight: 700; font-size: 18px; }
.ed-tabs { display: none; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.ed-tabs button { flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.ed-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.ed-preview { position: sticky; top: 72px; max-height: calc(100vh - 160px); overflow: auto; border-radius: 8px; }
.ed-preview .paper { padding: 32px 30px; font-size: 14px; }
@media (max-width: 980px) {
  .ed-tabs { display: flex; }
  .ed-grid { grid-template-columns: minmax(0, 1fr); }
  .ed-grid[data-tab="edit"] .ed-preview, .ed-grid[data-tab="preview"] .ed-form { display: none; }
  .ed-preview { position: static; max-height: none; overflow: visible; }
  .ed-preview .paper { padding: 26px 18px; }
}
.page.wide { max-width: 1320px; }

.sec { padding: 16px 14px; margin-bottom: 14px; }
.sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sec-head h2 { font-size: 17px; margin: 0; flex: 1; }
.hint { font-size: 13px; color: var(--ink-3); margin: -6px 0 12px; }
.hint code, .chip { font-family: ui-monospace, Consolas, monospace; }

.fld { padding: 10px 0; border-top: 1px solid var(--line); }
.fld:first-of-type { border-top: 0; padding-top: 0; }
.fld-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.fld-label {
  flex: 1; min-width: 0; border: 0; background: transparent; font-weight: 600; font-size: 14px; color: var(--ink-2);
  padding: 4px 2px; border-radius: 6px; outline: none;
}
.fld-label:focus { background: var(--surface-2); color: var(--ink); }
.chip {
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2); border-radius: 6px;
  font-size: 12px; padding: 3px 7px; cursor: pointer; direction: ltr; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
/* Show/hide switch: a hidden field or clause stays in the document, it just isn't printed. */
.switch {
  flex: none; width: 38px; height: 22px; padding: 0; border: 0; border-radius: 99px; cursor: pointer;
  background: var(--line-2); position: relative; transition: background .18s;
}
.switch[aria-checked="true"] { background: var(--brand); }
.switch span {
  position: absolute; top: 3px; inset-inline-end: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: inset-inline-end .18s;
}
.switch[aria-checked="false"] span { inset-inline-end: 19px; }
.off-tag {
  font-size: 11.5px; font-weight: 700; color: var(--ink-3); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; flex: none;
}
.fld.off > :not(.fld-head), .blk-card.off textarea, .blk-card.off .blk-sig-note { opacity: .4; }
.fld.off .fld-label, .fld.off .chip { color: var(--ink-3); }
.blk-card.off { background: var(--surface-2); }

.fld-cfg { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin: 8px 0 4px; padding: 10px; background: var(--surface-2); border-radius: 10px; align-items: end; }
.fld-cfg .input, .fld-cfg .select { min-height: 38px; padding: 6px 10px; font-size: 14px; }
.fld.missing .input, .fld.missing .textarea { border-color: #e0a800; background: var(--accent-soft); }

.blk-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.blk-card:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.blk-bar { display: flex; align-items: center; gap: 2px; padding: 5px 6px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.blk-bar .select { width: auto; min-height: 32px; padding: 2px 8px; font-size: 13.5px; border-radius: 7px; margin-inline-end: auto; }
.blk-bar .btn-icon { min-height: 30px; width: 30px; font-size: 14px; border: 0; background: transparent; }
.blk-bar .btn-icon:hover { background: var(--line); }
.blk-card textarea {
  display: block; width: 100%; border: 0; outline: none; resize: none; padding: 10px 12px; min-height: 48px;
  background: var(--surface); color: var(--ink); line-height: 1.65; font-size: 15px; overflow: hidden;
}
.blk-card[data-type="title"] textarea { font-weight: 800; font-size: 17px; text-align: center; }
.blk-card[data-type="heading"] textarea { font-weight: 700; }
.blk-sig-note { padding: 12px; font-size: 14px; color: var(--ink-3); }
.add-between {
  display: flex; align-items: center; justify-content: center; height: 22px; margin: 2px 0; opacity: .35; cursor: pointer;
  border: 0; background: transparent; width: 100%; color: var(--brand); font-weight: 700; font-size: 13px; transition: opacity .15s;
}
.add-between:hover, .add-between:focus-visible { opacity: 1; }
@media (hover: none) { .add-between { opacity: .7; } }

.actionbar {
  position: fixed; inset: auto 0 0 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  box-shadow: 0 -6px 24px rgba(20, 24, 50, .07);
}
.actionbar .btn { min-height: 46px; }
.actionbar .grow { flex: 1; max-width: 340px; }

.notice { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14.5px; display: flex; gap: 10px; align-items: flex-start; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--brand-soft); color: var(--brand); }

/* ---------- share modal ---------- */
.share-link { display: flex; gap: 8px; margin-bottom: 14px; }
.share-link .input { direction: ltr; font-size: 13.5px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn-wa:hover { background: #25d366; filter: brightness(1.05); }

/* ---------- settings ---------- */
/* ---------- delivery calculator ---------- */
.calc-addr { display: grid; gap: 10px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc-f { display: block; min-width: 0; }
.calc-f .label { margin-bottom: 4px; }
.calc-full { grid-column: 1 / -1; margin-top: 2px; }
.calc-out { margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; font-size: 14.5px; }
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--ink-2); }
.calc-row b { color: var(--ink); font-weight: 600; }
.calc-total {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 9px;
  border-top: 1px solid var(--line-2); font-size: 17px; font-weight: 700;
}
.calc-total b { color: var(--brand); }
.calc-note { margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }

.lessor-sig { background: #fff; border: 1px solid var(--line-2); border-radius: 12px; height: 140px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.lessor-sig img { max-height: 120px; max-width: 90%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.money-in { position: relative; }
.money-in .input { padding-inline-end: 46px; }
.money-in span {
  position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); font-size: 14px; pointer-events: none;
}
