:root {
  --brand-50: #ebf5ff; --brand-100: #e1effe; --brand-200: #c3ddfd; --brand-500: #3f83f8; --brand-600: #1c64f2; --brand-700: #1a56db; --brand-800: #1e429f;
  --gray-50: #f5f6f7; --gray-100: #f3f4f6; --gray-200: #eff1f5; --gray-300: #d1d5db; --gray-400: #9ca3af; --gray-500: #6b7280; --gray-600: #4b5563; --gray-700: #374151; --gray-800: #1f2a37; --gray-900: #111928;
  --green-50: #f3faf7; --green-100: #def7ec; --green-500: #0e9f6e; --green-700: #046c4e;
  --red-50: #fdf2f2; --red-500: #f05252; --red-600: #e02424; --red-700: #c81e1e; --orange-500: #ff5a1f;
  --yellow-100: #fdf6b2; --yellow-500: #c27803; --mui-text: #263238;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 500; color: var(--gray-900); background: #fff; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }
.rail { width: 64px; flex: none; background: #fff; border-right: 1px solid var(--gray-100); display: flex; flex-direction: column; align-items: center; padding: 10px 0; position: sticky; top: 0; height: 100vh; z-index: 30; }
.rail-logo { width: 38px; height: 38px; border-radius: 8px; background: var(--brand-700); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -.5px; }
.rail-item { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 60px; padding: 6px 0; margin-top: 8px; border-radius: 8px; font-size: 11px; color: var(--gray-800); font-weight: 500; }
.rail-item .ico { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--gray-600); }
.rail-item.active .ico { background: var(--brand-50); color: var(--brand-700); }
.rail-item:hover .ico { background: var(--gray-100); }
.rail-spacer { flex: 1; }
.rail-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-size: 12px; font-weight: 600; border: 0; }
.subnav { width: 180px; flex: none; border-right: 1px solid var(--gray-100); padding: 10px 8px; position: sticky; top: 0; height: 100vh; background: #fff; }
.subnav-head { display: flex; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 600; padding: 4px 2px 10px; }
.subnav-head button { border: 0; background: none; color: var(--gray-500); padding: 2px; border-radius: 6px; display: grid; }
.subnav a { display: block; font-size: 15px; padding: 6px 6px; border-radius: 6px; color: var(--gray-900); margin-bottom: 2px; }
.subnav a.active, .subnav a:hover { background: var(--gray-100); }
.main { flex: 1; min-width: 0; background: #fff; }
.page { padding: 22px 24px 80px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 500; border: 0; background: transparent; color: var(--gray-800); white-space: nowrap; outline: 1px solid var(--gray-200); outline-offset: -1px; }
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--brand-700); color: #fff; outline: 0; }
.btn-primary:hover { background: var(--brand-800); }
.btn-primary:disabled, .btn-primary.disabled { background: var(--gray-100); color: var(--gray-300); cursor: default; }
.btn-soft { background: var(--gray-100); outline: 0; color: var(--gray-900); }
.btn-soft:hover { background: var(--gray-200); }
.btn-plain { outline: 0; }
.btn-danger { background: var(--red-600); color: #fff; outline: 0; }
.btn-danger:hover { background: var(--red-700); }
.btn-icon { width: 40px; padding: 0; }
.link { color: var(--brand-600); background: none; border: 0; padding: 0; font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.link:hover { text-decoration: underline; }
.link-mui { color: var(--brand-600); background: none; border: 0; padding: 0; font-size: 14px; font-weight: 400; cursor: pointer; }
.link-mui:hover { text-decoration: underline; }

/* ---------- list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.list-head h1 { font-size: 24px; font-weight: 700; margin: 0; display: flex; align-items: baseline; gap: 16px; line-height: 36px; }
.list-head h1 .link { font-size: 14px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.search { position: relative; width: 214px; margin-right: 18px; }
.search input { width: 100%; height: 40px; border: 0; outline: 1px solid transparent; outline-offset: -1px; border-radius: 10px; padding: 8.5px 12px 8.5px 36px; font-size: 14px; background: #fff; }
.search input:focus { outline-color: var(--brand-600); }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--gray-500); }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--gray-800); border: 0; outline: 1px solid var(--gray-200); outline-offset: -1px; background: transparent; }
.chip.on { background: var(--gray-100); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.toolbar .grow { flex: 1; }
.tbl-wrap { border-radius: 12px 12px 0 0; overflow: visible; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.tbl th { background: var(--gray-50); color: var(--gray-500); font-size: 14px; font-weight: 400; text-align: left; padding: 8px 16px; height: 48px; white-space: nowrap; }
.tbl th:first-child { border-top-left-radius: 12px; }
.tbl th:last-child { border-top-right-radius: 12px; }
.tbl td { font-size: 14px; font-weight: 500; padding: 0 16px; height: 48px; border-bottom: 1px solid var(--gray-100); background: #fff; vertical-align: middle; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--gray-50); }
.tbl td.muted { color: var(--gray-400); }
.tbl .chk { width: 48px; padding: 0 0 0 16px; }
.tbl .menu-cell { width: 56px; text-align: center; padding: 0; }
.due-ago { display: block; color: var(--red-700); font-size: 14px; line-height: 20px; }
.cb { width: 16px; height: 16px; border: 1px solid var(--gray-300); border-radius: 4px; appearance: none; -webkit-appearance: none; background: #fff; cursor: pointer; display: inline-grid; place-items: center; margin: 0; vertical-align: middle; }
.cb:checked { background: var(--brand-600); border-color: var(--brand-600); }
.cb:checked::after { content: ''; width: 8px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: 12px; line-height: 18px; font-weight: 500; background: var(--gray-100); color: var(--gray-700); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--gray-500); }
.pill.paid { background: var(--green-100); color: var(--green-700); } .pill.paid::before { background: var(--green-500); }
.pill.partial { background: var(--yellow-100); color: var(--yellow-500); } .pill.partial::before { background: var(--yellow-500); }
.pill.sent { background: var(--brand-100); color: var(--brand-700); } .pill.sent::before { background: var(--brand-600); }
.pill.read { background: #edebfe; color: #5521b5; } .pill.read::before { background: #7e3af2; }
.pill.overdue { background: var(--red-50); color: var(--red-700); } .pill.overdue::before { background: var(--red-600); }
.pill.undelivered { background: var(--red-50); color: var(--red-700); } .pill.undelivered::before { background: var(--red-600); }
.pager { display: flex; justify-content: center; margin-top: 12px; }
.pager-box { display: inline-flex; align-items: center; border: 1px solid var(--gray-200); border-radius: 10px; height: 34px; overflow: hidden; }
.pager-box button { border: 0; background: #fff; width: 38px; height: 34px; color: var(--gray-500); display: grid; place-items: center; }
.pager-box button:disabled { color: var(--gray-300); cursor: default; }
.pager-box span { padding: 0 16px; font-size: 13px; border-left: 1px solid var(--gray-200); border-right: 1px solid var(--gray-200); height: 34px; display: grid; place-items: center; }
.bulkbar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--gray-900); color: #fff; border-radius: 12px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.bulkbar .btn { color: #fff; outline-color: #374151; }
.bulkbar .btn:hover { background: #1f2937; }
.empty { text-align: center; color: var(--gray-500); padding: 60px 0; font-size: 14px; }

/* ---------- menus / popovers ---------- */
.pop { position: fixed; z-index: 1000; background: #fff; border-radius: 10px; box-shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.05); padding: 4px 0; min-width: 160px; }
.pop .mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 14px; border: 0; background: none; text-align: left; font-size: 14px; font-weight: 500; color: var(--gray-900); }
.pop .mi:hover, .pop .mi.hl { background: var(--gray-100); }
.pop .mi.danger { color: var(--red-600); }
.pop .sep { height: 1px; background: var(--gray-100); margin: 4px 0; }
.pop .mi .chev { margin-left: auto; color: var(--gray-500); }
.pop.mui { border-radius: 4px; box-shadow: 0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12); padding: 8px 0; }
.pop.mui .mi { font-weight: 400; font-size: 16px; padding: 6px 13px; }

/* ---------- editor ---------- */
.ed-wrap { max-width: 1288px; margin: 0 auto; padding: 20px 24px 80px; }
.ed-top { display: flex; justify-content: space-between; align-items: center; }
.ed-wrap .ed-top + .ed-cols { margin-top: 40px; }
.ed-top .right { display: flex; gap: 8px; }
.ed-cols { display: flex; gap: 20px; margin-top: 30px; align-items: flex-start; justify-content: center; }
.ed-main { flex: 1; max-width: 820px; min-width: 0; }
.ed-side { width: 400px; flex: none; display: flex; flex-direction: column; gap: 16px; }
.card { background: #fff; border: 1px solid var(--gray-200); border-radius: 8px; box-shadow: 0 2px 1px -1px rgba(0,0,0,.02), 0 1px 1px 0 rgba(0,0,0,.02), 0 1px 3px 0 rgba(0,0,0,.06); }
.ed-card { padding: 25px 25px 25px; }
.ed-meta { display: flex; justify-content: space-between; gap: 16px; padding: 0 0 26px; }
.ed-cust { flex: 0 1 420px; padding: 4px 12px 0; }
.ed-fields { width: 320px; display: flex; flex-direction: column; gap: 14px; }
.lbl { font-size: 14px; font-weight: 500; color: var(--gray-900); margin-bottom: 8px; display: block; }
.inp { width: 100%; min-height: 48px; border-radius: 12px; border: 0; outline: 1px solid transparent; outline-offset: -1px; background: var(--gray-100); padding: 12px 16px; font-size: 16px; color: var(--gray-900); }
.inp:focus { outline-color: var(--brand-600); }
.inp.sm { min-height: 40px; border-radius: 10px; padding: 8.5px 12px; font-size: 14px; }
textarea.inp { resize: vertical; font-weight: 500; }
.inp.err { outline-color: var(--red-600); background: var(--red-50); color: var(--red-700); }
.err-text { color: var(--red-600); font-size: 14px; margin-top: 6px; }
.datefield { position: relative; display: flex; align-items: center; gap: 8px; cursor: text; }
.datefield input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; padding: 0; font-size: 16px; font-weight: 500; }
.inp.sm.datefield input { font-size: 13px; }
.datefield.plain { background: transparent; outline: 0; min-height: 44px; padding: 0 12px; }
.datefield.plain input { font-size: 15px; font-weight: 400; color: var(--mui-text); }
.datefield .clear { border: 0; background: var(--gray-300); color: #fff; width: 16px; height: 16px; border-radius: 50%; display: none; place-items: center; padding: 0; }
.datefield:hover .clear { display: grid; }
.datefield .cal { border: 0; background: none; color: var(--gray-500); padding: 0; display: grid; }
.combo { width: 248px; min-height: 40px; border-radius: 8px; outline: 1px solid transparent; outline-offset: -1px; padding: 8.5px 12px; display: flex; align-items: center; background: #fff; cursor: pointer; }
.combo:focus-within { outline-color: var(--brand-600); }
.combo input { border: 0; outline: 0; background: transparent; padding: 0; width: 100%; font-size: 16px; font-weight: 500; color: var(--gray-900); }
.combo input::placeholder { color: var(--gray-500); }
.combo-list { position: fixed; z-index: 1000; background: #fff; border-radius: 10px; box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.05); overflow: hidden; }
.combo-list .opts { max-height: 260px; overflow-y: auto; }
.combo-list .opt { padding: 8px 12px; min-height: 36px; font-size: 14px; font-weight: 500; color: var(--gray-900); cursor: pointer; display: flex; align-items: center; }
.combo-list .opt:hover, .combo-list .opt.hl { background: var(--gray-50); }
.combo-list .opt mark { background: none; color: var(--brand-600); }
.combo-list .foot { border-top: 1px solid var(--gray-100); padding: 8px 12px; font-size: 14px; color: var(--brand-600); display: flex; gap: 8px; align-items: center; cursor: pointer; }
.combo-list .foot:hover { background: var(--gray-50); }
.combo-list .none { padding: 10px 12px; font-size: 14px; color: var(--gray-500); }
.cust-sel { display: flex; align-items: center; gap: 70px; padding: 0; font-size: 16px; font-weight: 400; color: var(--gray-900); }
.cust-sel .link-mui { font-size: 13px; font-weight: 500; }
.cust-lines { font-size: 14px; color: var(--gray-600); font-weight: 400; margin-top: 8px; line-height: 1.5; white-space: pre-line; }

/* items table (MUI-style) */
.items { border: 1px solid var(--gray-200); border-radius: 4px; color: var(--mui-text); font-weight: 400; }
.items table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.items th { font-size: 14px; font-weight: 600; text-transform: uppercase; padding: 16px; text-align: right; border-bottom: 1px solid rgba(224,224,224,1); height: 53px; vertical-align: middle; color: var(--mui-text); }
.items th:first-child { text-align: left; }
.items td { padding: 8px 16px; overflow-wrap: anywhere; font-size: 16px; text-align: right; vertical-align: middle; }
.items td:first-child { text-align: left; }
.items .it-name { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: #000; font-size: 16px; padding: 10px 0; }
.items .it-name svg { color: var(--gray-700); }
.items .num-inp { width: 100%; max-width: 109px; height: 35px; border: 1px solid rgba(0,0,0,.12); border-radius: 4px; text-align: right; padding: 8px 14px; font-size: 16px; background: #fff; color: var(--mui-text); }
.items .num-inp.narrow { max-width: 80px; }
.items .num-inp:focus { outline: 2px solid var(--brand-600); outline-offset: -1px; }
.items .desc { width: 100%; min-height: 66px; border: 1px solid rgba(0,0,0,.12); border-radius: 4px; padding: 8px 14px; font-size: 16px; color: var(--gray-900); resize: vertical; line-height: 1.1; font-weight: 400; }
.items .row-sep td { border-bottom: 1px solid rgba(224,224,224,1); }
.items .del { border: 0; background: none; color: var(--red-600); padding: 4px; border-radius: 50%; display: grid; place-items: center; margin-left: auto; }
.items .del:hover { background: rgba(0,0,0,.04); }
.items .tot td { padding: 7px 8px 7px 16px; text-align: right; }
.items .tot td.add-cell { text-align: left; }
.items .tot.first td { padding-top: 25px; }
.items .tot-label { font-size: 16px; }
.items .add-cell { vertical-align: top; padding-top: 14px; }
.items .amount-due td { padding: 16px 8px 16px 16px; border-top: 1px solid rgba(224,224,224,1); }
.taxdisc { position: relative; }
.items .c-num { width: 141px; } .items .c-num-d { width: 104px; } .items .c-disc { width: 100px; } .items .c-amt { width: 124px; }
.items .add-cell .combo { max-width: 100%; }
@media (max-width: 1600px) { .items .c-num { width: 116px; } .items .c-num-d { width: 92px; } .items .c-disc { width: 92px; } .items .c-amt { width: 112px; } .items td, .items th { padding-left: 10px; padding-right: 10px; } }

/* rich note */
.note-box { border-radius: 12px; background: var(--gray-100); outline: 1px solid transparent; outline-offset: -1px; overflow: hidden; }
.note-box:focus-within { outline-color: var(--brand-600); }
.note-tools { display: flex; justify-content: space-between; padding: 12px 16px; }
.note-tools div { display: flex; gap: 16px; }
.note-tools button { border: 0; background: none; color: var(--gray-600); padding: 0; display: grid; border-radius: 4px; }
.note-tools button:hover, .note-tools button.on { color: var(--gray-900); }
.note-body { padding: 16px 16px 12px; font-size: 16px; min-height: 120px; outline: 0; white-space: pre-wrap; font-weight: 500; }
.note-body p { margin: 0; }
.note-body ul, .note-body ol { padding-left: 24px; margin: 4px 0; }
.note-body:empty::before { content: attr(data-placeholder); color: var(--gray-500); }
.note-count { text-align: right; font-size: 12px; color: var(--gray-500); margin-top: 6px; }
.photo-btn { width: 100%; height: 40px; border: 0; border-radius: 10px; background: var(--brand-100); color: var(--brand-600); font-weight: 500; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; }
.photo-btn:hover { background: var(--brand-100); }
.photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.photo { position: relative; width: 120px; }
.photo img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--gray-200); display: block; }
.photo input { width: 100%; margin-top: 4px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 12px; padding: 3px 6px; }
.photo .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(17,25,40,.7); color: #fff; display: grid; place-items: center; padding: 0; }

/* side card */
.side-card { padding: 24px; }
.side-card .sep { height: 1px; background: var(--gray-200); margin: 18px 0 16px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 500; min-height: 23px; position: relative; color: var(--gray-900); }
.sw { width: 36px; height: 18px; border-radius: 99px; background: var(--gray-200); border: 0; position: relative; padding: 0; flex: none; box-shadow: inset 0 0 0 1px var(--gray-300); }
.sw::after { content: ''; position: absolute; top: 1px; left: 1px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s; }
.sw.on { background: var(--brand-600); box-shadow: none; }
.sw.on::after { left: 19px; }
.recur-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-top: 16px; color: var(--mui-text); }
.mui-select { width: 160px; height: 35px; border: 1px solid rgba(0,0,0,.15); border-radius: 4px; padding: 0 32px 0 14px; font-size: 13px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5'%3E%3Cpath d='M0 0l5 5 5-5z' fill='%23666'/%3E%3C/svg%3E") no-repeat right 10px center; appearance: none; -webkit-appearance: none; color: var(--gray-900); }
.mui-select:focus { outline: 2px solid var(--brand-600); outline-offset: -1px; }
.mui-select:disabled { color: var(--gray-400); }
.next-issue { width: 160px; height: 35px; border: 1px solid rgba(0,0,0,.08); border-radius: 4px; padding: 0 10px; font-size: 12px; display: flex; align-items: center; }
.project-head { font-size: 14px; font-weight: 600; padding-bottom: 16px; border-bottom: 1px solid var(--gray-200); margin-bottom: 12px; }
.project-btn { width: 100%; height: 40px; border: 0; border-radius: 10px; background: var(--brand-100); color: var(--brand-600); font-size: 14px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 6px; }
.project-btn:hover { background: var(--brand-100); }
.project-chip { display: flex; justify-content: space-between; align-items: center; font-size: 14px; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 8px; }

/* ---------- modals ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 4px; box-shadow: 0 11px 15px -7px rgba(0,0,0,.2), 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12); width: 100%; max-height: calc(100vh - 64px); display: flex; flex-direction: column; color: var(--mui-text); font-weight: 400; }
.modal.round { border-radius: 16px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid rgba(0,0,0,.12); font-size: 20px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; color: var(--mui-text); }
.modal-head.center { justify-content: center; position: relative; font-size: 22px; font-weight: 700; color: var(--gray-900); padding: 20px; border-bottom: 1px solid var(--gray-100); }
.modal-head .x { border: 0; background: none; color: var(--gray-700); padding: 4px; display: grid; border-radius: 50%; }
.modal-head.center .x { position: absolute; right: 20px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid rgba(0,0,0,.12); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.modal-foot.split { justify-content: space-between; padding: 20px; border-top: 1px solid var(--gray-100); }
.mbtn { border: 0; background: none; font-size: 15px; font-weight: 500; padding: 6px 8px; border-radius: 4px; color: var(--mui-text); }
.mbtn:hover { background: rgba(0,0,0,.04); }
.mbtn.primary { color: var(--brand-600); }
.mbtn:disabled { color: rgba(0,0,0,.26); cursor: default; background: none; }
.seg { display: inline-flex; border: 1px solid var(--gray-200); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; background: #fff; font-size: 11px; padding: 4px 6px; color: var(--gray-700); font-weight: 400; }
.seg button.on { background: var(--brand-50); color: var(--brand-600); }
.seg-big { display: flex; background: var(--gray-100); border-radius: 10px; padding: 4px; }
.seg-big button { flex: 1; border: 0; background: transparent; height: 32px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--gray-700); }
.seg-big button.on { background: #fff; color: var(--gray-900); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.mui-field { position: relative; border: 1px solid rgba(0,0,0,.15); border-radius: 4px; padding: 0 12px; display: flex; align-items: center; min-height: 46px; }
.mui-field:focus-within { border-color: var(--brand-600); box-shadow: inset 0 0 0 1px var(--brand-600); }
.mui-field > label { position: absolute; top: -8px; left: 8px; background: #fff; padding: 0 4px; font-size: 11px; color: rgba(0,0,0,.6); }
.mui-field:focus-within > label { color: var(--brand-600); }
.mui-field input, .mui-field select, .mui-field textarea { border: 0; outline: 0; background: transparent; width: 100%; font-size: 15px; padding: 12px 0; color: var(--mui-text); font-weight: 400; }
.mui-field textarea { resize: vertical; min-height: 100px; line-height: 1.35; }
.mui-field .suffix { color: var(--gray-500); font-size: 14px; }
.helper { font-size: 11px; color: rgba(0,0,0,.6); margin: 4px 12px 0; }
.chk-row { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 14px 0; cursor: pointer; }
.cbm { width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.54); border-radius: 2px; appearance: none; -webkit-appearance: none; margin: 0; display: inline-grid; place-items: center; cursor: pointer; }
.cbm:checked { background: var(--brand-600); border-color: var(--brand-600); }
.cbm:checked::after { content: ''; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.cust-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cust-grid .lbl { margin-bottom: 8px; }
.inp-icon { position: relative; }
.inp-icon svg { position: absolute; left: 14px; top: 17px; color: var(--gray-500); }
.inp-icon .inp { padding-left: 32px; }
.ccbcc { position: absolute; right: 14px; top: 13px; display: flex; gap: 8px; font-size: 15px; }
.ccbcc button { border: 0; background: none; color: var(--brand-600); padding: 0; font-weight: 500; }
.ccbcc button:disabled { color: var(--gray-400); }
.phone { display: flex; align-items: center; background: var(--gray-100); border-radius: 12px; min-height: 48px; padding: 0 12px; gap: 10px; border: 1px solid var(--gray-300); }
.phone input { border: 0; background: transparent; outline: 0; flex: 1; font-size: 16px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.chip-add { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--gray-200); background: #fff; font-size: 14px; color: var(--gray-900); }
.chip-add:hover { background: var(--gray-50); }
.sec-title { display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 700; margin: 16px 0 10px; color: var(--gray-900); }
.sec-title button { border: 0; background: none; color: var(--gray-500); padding: 2px; display: grid; }
.addr { width: 100%; border: 1px solid var(--gray-200); border-radius: 4px; padding: 12px; font-size: 15px; min-height: 46px; resize: vertical; font-family: inherit; }
.addr:focus { outline: 2px solid var(--brand-600); outline-offset: -1px; }
.field-head { display: flex; justify-content: space-between; align-items: center; }
.field-head button { border: 0; background: none; color: var(--gray-500); padding: 0; display: grid; }
.edit-fields { display: flex; justify-content: flex-end; margin: 18px 0 10px; }
.edit-fields button { border: 0; background: var(--brand-50); color: var(--brand-700); border-radius: 8px; height: 32px; padding: 0 10px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.cust-sep { height: 1px; background: var(--gray-200); margin: 30px 0 0; }
.tabs { display: flex; gap: 40px; border-bottom: 1px solid var(--gray-200); margin: 0 0 24px; }
.tabs button { border: 0; background: none; padding: 10px 0; font-size: 15px; font-weight: 500; color: var(--gray-700); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand-600); border-color: var(--brand-600); }
.stats { display: grid; grid-template-columns: 1fr 1fr; text-align: center; padding: 20px 0; border-bottom: 1px solid var(--gray-200); }
.stats b { display: block; font-size: 32px; font-weight: 600; color: var(--gray-900); }
.stats span { font-size: 14px; font-weight: 600; color: var(--gray-900); }

/* calendar */
.calpop { position: fixed; z-index: 1000; background: #fff; border-radius: 10px; box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.05); padding: 14px 12px 16px; width: 238px; }
.cal-h { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 16px; font-size: 13px; font-weight: 600; }
.cal-h u { margin-right: 6px; cursor: pointer; }
.cal-h button { border: 0; background: none; padding: 2px 4px; color: var(--gray-700); }
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 8px; text-align: center; font-size: 12px; }
.cal-g .dow { color: var(--gray-500); font-weight: 500; }
.cal-g button { border: 0; background: none; width: 28px; height: 28px; border-radius: 50%; margin: 0 auto; font-size: 12px; font-weight: 500; color: var(--gray-900); padding: 0; }
.cal-g button:hover { background: var(--gray-100); }
.cal-g button.sel { background: var(--brand-700); color: #fff; }
.cal-g button.today { box-shadow: inset 0 0 0 1px var(--brand-600); }
.cal-g button.dis { color: var(--gray-300); }

/* ---------- preview ---------- */
.pv-wrap { max-width: 1288px; margin: 0 auto; padding: 24px 24px 80px; }
.pv-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }
.pv-top .right { display: flex; gap: 8px; }
.pv-cols { display: flex; gap: 20px; align-items: flex-start; }
.pv-doc { flex: 1; min-width: 0; max-width: 800px; }
.pv-doc iframe { width: 100%; border: 0; display: block; }
.pv-side { width: 400px; flex: none; display: flex; flex-direction: column; gap: 14px; }
.pv-card { padding: 20px; }
.pv-card h3 { margin: 0 0 12px; font-size: 18px; font-weight: 600; font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; color: #212529; }
.pv-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; padding: 4px 0; color: var(--mui-text); font-weight: 600; }
.pv-row.light { font-weight: 400; color: #212529; font-size: 14px; }
.pv-links { display: flex; flex-direction: column; gap: 14px; margin: 12px 0 16px; align-items: flex-start; }
.pv-links .link { font-size: 14px; font-weight: 400; }
.pv-sep { height: 1px; background: var(--gray-200); margin: 4px 0 16px; }
.act { display: flex; gap: 12px; align-items: center; padding: 10px 0; }
.act .ic { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--gray-200); display: grid; place-items: center; flex: none; color: var(--gray-700); }
.act .tx { font-size: 14px; color: var(--gray-900); font-weight: 500; }
.act .tm { font-size: 11px; color: var(--gray-600); margin-top: 3px; }
.mail-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--gray-100); border-radius: 10px; min-height: 42px; padding: 6px 10px; }
.mail-chips span { display: inline-flex; align-items: center; gap: 6px; background: var(--gray-200); border-radius: 6px; padding: 3px 8px; font-size: 13px; color: var(--gray-900); }
.mail-chips span button { border: 0; background: none; padding: 0; color: var(--gray-500); display: grid; }
.mail-chips input { border: 0; background: transparent; outline: 0; flex: 1; min-width: 120px; font-size: 14px; }
.tx-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tx-tbl th { text-align: left; font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--gray-200); }
.tx-tbl td { padding: 18px 14px; border-bottom: 1px solid var(--gray-200); }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--gray-900); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); display: flex; gap: 12px; align-items: center; }
.toast.err { background: var(--red-700); }
.toast .link { color: #93c5fd; }

/* ---------- login / settings ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--gray-50); padding: 16px; }
.login .card { width: 360px; max-width: 100%; padding: 28px; }
.login h1 { font-size: 22px; margin: 14px 0 6px; }
.login p { color: var(--gray-500); font-size: 14px; margin: 0 0 18px; font-weight: 400; }
.set-wrap { max-width: 860px; }
.set-sec { padding: 20px; margin-bottom: 16px; }
.set-sec h2 { font-size: 16px; margin: 0 0 14px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.set-grid .full { grid-column: 1 / -1; }
.logo-box { display: flex; gap: 16px; align-items: center; }
.logo-box img { max-width: 200px; max-height: 100px; border: 1px solid var(--gray-200); border-radius: 8px; padding: 6px; background: #fff; }
.tax-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.sig-pad { border: 1px dashed var(--gray-300); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 160px; display: block; }
.qr-drop { border: 1px dashed var(--gray-400); border-radius: 8px; height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--gray-700); font-size: 15px; cursor: pointer; background: #fff; }
.qr-drop img { max-height: 120px; }

@media (max-width: 1100px) {
  .ed-cols, .pv-cols { flex-direction: column; align-items: stretch; }
  .ed-side, .pv-side { width: 100%; }
  .ed-main { max-width: none; }
}
@media (max-width: 760px) {
  .subnav { display: none; }
  .rail { width: 64px; }
  .page, .ed-wrap { padding: 16px; }
  .ed-meta { flex-direction: column; }
  .ed-fields { width: 100%; }
  .tbl .hide-sm { display: none; }
  .cust-grid, .set-grid { grid-template-columns: 1fr; }
  .search { width: 140px; margin-right: 0; }
  .toolbar { flex-wrap: wrap; }
  .items .num-inp { width: 64px; }
}
