:root {
  --theme: #1F3A5F;          /* Wealthforce navy - match your SharePoint site theme */
  --theme-dark: #162B47;
  --theme-light: #E8EEF6;
  --text: #242424;
  --text-2: #616161;
  --line: #E0E0E0;
  --bg: #FAF9F8;
  --red: #C50F1F;
  --red-bg: #FDE7E9;
  --green: #107C10;
  --green-bg: #DFF6DD;
  --amber-bg: #FFF4CE;
  --radius: 4px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
       font-size: 14px; color: var(--text); background: var(--bg); }
[hidden] { display: none !important; }
h1 { font-size: 24px; font-weight: 600; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* App bar */
.appbar { height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center;
          gap: 16px; padding: 0 32px; }
.logo { height: 24px; width: auto; display: block; }
.appbar-divider { width: 1px; height: 26px; background: #C8C6C4; }
.appbar-product { font-size: 18px; font-weight: 600; color: var(--theme); }
.appbar-spacer { flex: 1; }
.appbar-user { display: flex; align-items: center; gap: 12px; }
.appbar-user .who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.appbar-user .who span { font-size: 12px; color: var(--text-2); }
.persona { width: 32px; height: 32px; border-radius: 50%; background: var(--theme-light); color: var(--theme);
           display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.btn.subtle { font-weight: 400; min-height: 28px; padding: 3px 12px; }
@media (max-width: 700px) { .appbar { padding: 0 14px; } .appbar-user .who { display: none; } }
body.embedded .appbar { display: none; }
body.embedded .page { padding-top: 12px; }

.page { padding-top: 12px; }

.page { max-width: 1280px; margin: 0 auto; padding: 24px 32px 48px; }
.title-row { display: flex; align-items: center; gap: 12px; }
.badge { background: var(--amber-bg); color: #8A5A00; font-size: 12px; padding: 3px 8px; border-radius: 10px; }
#from-line { margin: 6px 0 14px; }

/* Pivot */
.pivot { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.pivot-item { background: none; border: none; font: inherit; padding: 10px 12px; cursor: pointer; color: var(--text-2); position: relative; }
.pivot-item.active { color: var(--text); font-weight: 600; }
.pivot-item.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; background: var(--theme); border-radius: 2px; }

/* Command bar */
.commandbar { display: flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line);
              border-radius: var(--radius); padding: 4px 8px; margin-bottom: 16px; }
.cmd { background: none; border: none; font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px;
       border-radius: var(--radius); cursor: pointer; color: var(--text); }
.cmd:hover { background: #F3F2F1; }
.cmd svg, .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cmd svg { stroke: var(--theme); }
.cmd-spacer { flex: 1; }
.cmd, .btn { white-space: nowrap; }
@media (max-width: 560px) {
  .commandbar { flex-wrap: wrap; }
  .commandbar .cmd { padding: 8px 6px; }
  .commandbar .btn.primary { width: 100%; justify-content: center; margin-top: 4px; }
  .page { padding: 16px 14px 40px; }
}
.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px; min-height: 32px; border-radius: var(--radius);
       border: 1px solid #D1D1D1; background: #fff; cursor: pointer; font-weight: 600; }
.btn:hover { background: #F5F5F5; }
.btn.primary { background: var(--theme); border-color: var(--theme); color: #fff; }
.btn.primary:hover { background: var(--theme-dark); }
.btn:disabled, .cmd:disabled { opacity: .5; cursor: default; }
.link { background: none; border: none; padding: 0; font: inherit; color: var(--theme); text-decoration: underline; cursor: pointer; }

/* Cards + layout */
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; }
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.req { color: var(--red); }
input:not([type]), input[type=password], textarea { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid #D1D1D1;
       border-bottom-color: #616161; border-radius: var(--radius); background: #fff; }
input:focus, textarea:focus { outline: none; border-bottom: 2px solid var(--theme); }
textarea { resize: vertical; }
.toggle-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.toggle { width: 40px; height: 20px; border-radius: 10px; border: 1px solid #616161; background: #fff; padding: 0; position: relative; cursor: pointer; }
.toggle span { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #616161; transition: left .15s; }
.toggle.on { background: var(--theme); border-color: var(--theme); }
.toggle.on span { left: 23px; background: #fff; }
.segmented { display: inline-flex; border: 1px solid #D1D1D1; border-radius: var(--radius); overflow: hidden; }
.seg { font: inherit; border: none; background: #fff; padding: 6px 16px; cursor: pointer; }
.seg + .seg { border-left: 1px solid #D1D1D1; }
.seg.active { background: var(--theme); color: #fff; font-weight: 600; }
input[type=datetime-local] { width: 100%; font: inherit; padding: 5px 8px; border: 1px solid #D1D1D1;
       border-bottom-color: #616161; border-radius: var(--radius); background: #fff; }
#sched-hint { display: block; margin-top: 4px; }
.details-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.details-head .link { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; font-size: 13px; }
.details-head .link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.ac { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none; background: #fff;
           border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,.14); z-index: 5;
           max-height: 260px; overflow-y: auto; }
.suggest li, .book-list li { padding: 7px 12px; cursor: pointer; }
.suggest li.on, .suggest li:hover, .book-list li:hover { background: var(--theme-light); }
.suggest b, .book-list b { display: block; font-weight: 600; }
.suggest span, .book-list span { font-size: 12px; color: var(--text-2); }
.check { display: flex; align-items: center; gap: 8px; margin: -2px 0 14px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--theme); }
.search { font: inherit; padding: 5px 10px; border: 1px solid #D1D1D1; border-radius: var(--radius); width: 240px; }
.search.wide { width: 100%; margin-bottom: 8px; }
.book-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; border-top: 1px solid var(--line); }
.book-list li { border-bottom: 1px solid #F0F0F0; }
.tel { color: var(--theme); text-decoration: none; white-space: nowrap; }
.tel:hover { text-decoration: underline; }
#contact-dlg small { display: block; margin-top: 4px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.summary .size { display: block; font-weight: 400; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.summary .size.over { color: var(--red); font-weight: 600; }
.summary { border-top: 1px solid var(--line); padding-top: 12px; font-weight: 600; }

/* Page editor */
.pages-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pages-head h2 { margin-bottom: 8px; }
.dropzone { border: 1.5px dashed #C8C6C4; border-radius: 6px; padding: 16px; text-align: center; color: var(--text); margin-bottom: 14px; }
.dropzone svg { width: 26px; height: 26px; fill: none; stroke: var(--theme); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dropzone.over { border-color: var(--theme); background: var(--theme-light); }
.size-help { margin: -6px 0 14px; font-size: 13px; }
.size-help summary { cursor: pointer; color: var(--theme); font-weight: 600; width: max-content; }
.size-help[open] { background: #F7F9FC; border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; }
.size-help p { margin: 8px 0 4px; }
.size-help ul { margin: 4px 0 0; padding-left: 20px; }
.size-help li { margin: 4px 0; }
.doc { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.doc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.doc-num { width: 24px; height: 24px; border-radius: 50%; background: var(--theme-light); color: var(--theme); font-size: 12px; font-weight: 700;
           display: inline-flex; align-items: center; justify-content: center; flex: none; }
.doc-title { flex: 1; min-width: 0; }
.doc-title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 32px; height: 32px; border: none; background: none; border-radius: var(--radius); cursor: pointer; color: var(--text); font-size: 15px; }
.icon-btn:hover:not(:disabled) { background: #F3F2F1; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.thumbs { display: flex; flex-wrap: wrap; gap: 14px; }
.thumb { width: 124px; background: none; border: none; padding: 0; cursor: pointer; font: inherit; text-align: center; }
.thumb .sheet { position: relative; border: 1px solid #D1D1D1; background: #fff; padding: 1px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.thumb img { display: block; width: 120px; }
.thumb:hover .sheet { border-color: var(--theme); }
.thumb .cap { font-size: 12px; margin-top: 4px; color: var(--text-2); }
.thumb.removed .sheet { border: 2px solid var(--red); padding: 0; }
.thumb.removed img { opacity: .3; }
.thumb.removed .sheet::after { content: "\2715"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
                               font-size: 56px; color: var(--red); }
.thumb.removed .cap { color: var(--red); font-weight: 600; }
.cover-sheet { width: 120px; height: 155px; padding: 10px 8px; text-align: left; font-size: 8px; }
.cover-sheet .ch { display: flex; justify-content: space-between; font-weight: 700; border-bottom: 2px solid #222; padding-bottom: 3px; margin-bottom: 7px; }
.cover-sheet .ch b { font-size: 11px; }
.cover-sheet .ch .cover-logo { height: 9px; width: auto; align-self: center; }
.cover-sheet i { display: block; height: 1px; background: #BDBDBD; margin: 7px 0 0 32px; }
.cover-sheet .box { border: 1px solid #BDBDBD; height: 34px; margin-top: 9px; }
.loading-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; color: var(--text-2); border-top: 1px solid var(--line); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--theme-light); border-top-color: var(--theme); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--text-2); padding: 18px 0 6px; }

/* Text boxes + page editor */
.tile { position: relative; }
.add-text { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 4px; border: 1px solid #C8C6C4;
            background: #fff; color: var(--theme); font-weight: 700; font-size: 13px; cursor: pointer; opacity: 0; }
.tile:hover .add-text, .add-text:focus { opacity: 1; }
.text-badge { position: absolute; left: 4px; bottom: 4px; background: var(--theme); color: #fff; font-size: 11px;
              font-weight: 600; border-radius: 3px; padding: 1px 5px; z-index: 1; }
.dialog.editor { width: 980px; }
.dialog-head label { display: flex; align-items: center; gap: 6px; }
.dialog-head select { font: inherit; padding: 4px 6px; border: 1px solid #D1D1D1; border-radius: var(--radius); }
.ed-hint { margin: -4px 0 10px; }
.ed-pages { flex: 1; overflow-y: auto; background: #E9EBEE; border-radius: 4px; padding: 16px; }
.ed-label { font-size: 12px; color: var(--text-2); margin: 0 auto 4px; max-width: 820px; }
.pe-page { position: relative; margin: 0 auto 22px; max-width: 820px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2);
           cursor: text; user-select: none; }
.pe-page img { display: block; width: 100%; pointer-events: none; }
.pe-page .loading { padding: 120px 0; text-align: center; color: var(--text-2); }
.tb { position: absolute; display: flex; align-items: stretch; outline: 1px dashed rgba(31,58,95,.55); cursor: default; z-index: 2; }
.tb.active { outline: 1.5px solid var(--theme); background: rgba(232,238,246,.45); z-index: 3; }
.tb.dragging { opacity: .85; }
.tb input { border: none; background: transparent; padding: 0 2px; margin: 0; font-family: Helvetica, Arial, sans-serif;
            color: #000; outline: none; min-width: 1ch; line-height: 1.2; cursor: text; }
.tb .grip { cursor: move; width: 14px; padding: 0; display: flex; align-items: center; justify-content: center; color: var(--theme);
            background: #fff; font-size: 12px; position: absolute; left: -16px; top: 0; bottom: 0; border: 1px solid var(--theme);
            border-radius: 3px 0 0 3px; opacity: 0; }
.tb.active .grip, .tb:hover .grip { opacity: 1; }
.tb-bar { position: absolute; left: -16px; bottom: 100%; margin-bottom: 3px; display: none; align-items: center; gap: 2px;
          background: #fff; border: 1px solid var(--theme); border-radius: 4px; padding: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.15);
          white-space: nowrap; font-family: "Segoe UI", sans-serif; }
.tb.active .tb-bar { display: flex; }
.tb-bar button { font: 600 12px/1 "Segoe UI", sans-serif; border: none; background: var(--theme-light); color: var(--theme);
                 border-radius: 3px; padding: 4px 6px; cursor: pointer; }
.tb-bar button:disabled { opacity: .35; cursor: default; }
.tb-bar .del { background: var(--red); color: #fff; }
.tb-bar .sz { font-size: 11px; color: var(--text-2); padding: 0 4px; min-width: 34px; text-align: center; }
.fld { position: absolute; background: rgba(0,120,212,.08); outline: 1px solid rgba(0,120,212,.35); cursor: pointer; z-index: 1; }
.fld:hover { background: rgba(0,120,212,.2); outline-color: rgba(0,120,212,.8); }
.fld.check { border-radius: 2px; }
.hide-fields .fld { display: none; }
.ed-form { color: var(--theme); }
.count { background: var(--theme); color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 7px; margin-left: 4px; font-weight: 600; }
.draft-flag { display: inline-block; margin-left: 10px; font-size: 12px; font-weight: 400; color: var(--theme); background: var(--theme-light);
              border-radius: 10px; padding: 2px 9px; }

/* Usage disclaimer (send pop-up) */
.usage-notice { background: #FFF8E6; border: 1px solid #F1D79A; border-radius: 6px; padding: 8px 12px; margin: 12px 0 0;
                color: #5C4300; font-size: 13px; line-height: 1.45; }

/* Message bar */
.msgbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; background: #F3F2F1; }
.msgbar.error { background: var(--red-bg); color: #8A0E19; }
.msgbar.success { background: var(--green-bg); color: #0E5C0E; }
.msgbar span { flex: 1; }
.msgbar-x { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; }

/* Sent list */
.list { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 13px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
td { padding: 10px 16px; border-bottom: 1px solid #F0F0F0; vertical-align: top; }
tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.wait { background: var(--theme-light); color: var(--theme); }
.pill.sched { background: #EFE6F7; color: #5C2E91; }
.pill.muted { background: #F0F0F0; color: var(--text-2); }
.row-btn { font: inherit; font-size: 13px; background: none; border: 1px solid #D1D1D1; border-radius: var(--radius);
           padding: 3px 10px; cursor: pointer; }
.row-btn:hover { background: #F5F5F5; }
.detail { display: block; font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* Dialogs */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 10; }
.dialog { background: #fff; border-radius: 8px; padding: 24px; width: 420px; max-width: calc(100% - 32px); box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.dialog.wide { width: 900px; height: 85vh; display: flex; flex-direction: column; padding: 16px 20px; }
.dialog-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.dialog-head h2 { margin: 0; flex: 1; }
.dialog-head a { color: var(--theme); }
.dialog iframe { flex: 1; border: 1px solid var(--line); width: 100%; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.signin { max-width: 440px; margin: 40px auto; }
.signin h1 { margin-bottom: 8px; }
.signin .btn { margin-top: 8px; }
.signin .msgbar { margin-top: 12px; }

/* Extra recipients ("Add another fax number") */
.add-recipient { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; font-size: 13px; margin: -2px 0 14px; }
.add-recipient svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.recipient-extra { border: 1px solid var(--stroke, #E1DFDD); border-left: 3px solid var(--theme); border-radius: 4px;
  padding: 10px 12px 2px; margin: 0 0 12px; background: #FAF9F8; }
.rx-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; font-size: 13px; }
.rx-head b { flex: 1; white-space: nowrap; }
.rx-head .link { font-size: 13px; text-decoration: none; }
#preview-who { margin-left: 8px; padding: 4px 6px; font: inherit; font-size: 13px; }

/* HD tick box and "Send again" */
.hd-check { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 12px; }
.hd-check input { margin-top: 3px; }
.hd-check small { display: block; font-weight: 400; }
.row-actions-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.dialog p.small { font-size: 13px; }

/* Incoming / Received */
#in-frame { flex: 1; width: 100%; border: 1px solid #E1DFDD; border-radius: 4px; }
#in-info { margin: 0 0 8px; }
#in-assign { padding: 5px 6px; font: inherit; max-width: 240px; }
.dialog-head a.btn { text-decoration: none; }
.pill.auto { background: #E8F3FC; color: var(--theme); margin-left: 6px; }
.pill.new { background: var(--theme); color: #fff; }
tr.unread td { font-weight: 600; }
.dialog.adv { height: auto; max-height: 85vh; }
.adv-form { display: grid; grid-template-columns: 1.2fr 1.4fr 1fr 1.4fr auto auto; gap: 8px; align-items: center; margin: 8px 0; }
.adv-form input:not([type=checkbox]) { padding: 6px 8px; font: inherit; border: 1px solid #D1D1D1; border-radius: 4px; min-width: 0; }
.adv-form .check { margin: 0; }
.adv-list { overflow: auto; max-height: 50vh; }
.adv-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.adv-list th, .adv-list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #EDEBE9; }
