:root { font: 16px/1.5 "DM Sans", system-ui, sans-serif; color: #12283a; background: #f4f7f6; }
* { box-sizing: border-box; }
body { margin: 0; }
.storage-notice { display: none; }
[data-hosted] .storage-notice { display: block; padding: 8px 16px; text-align: center; background: #e4f1ed; }
.top { background: white; border-bottom: 1px solid #dce6e3; }
.bar, main { max-width: 960px; margin: auto; padding-inline: clamp(16px, 5vw, 48px); }
.bar, .heading, li, .actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.bar { min-height: 68px; }
.bar img { width: 155px; margin-left: -18px; }
#connection { font-size: .88rem; font-weight: 650; color: #285c51; }
main { padding-block: 52px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.045em; line-height: 1.1; }
.heading p, dialog p { margin-top: 9px; color: #49606a; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid #b8cdc8; border-radius: 8px; padding: 9px 14px; background: white; color: #12283a; font-weight: 650; }
.primary { color: white; background: #086860; border-color: #086860; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 3px solid #138578; outline-offset: 2px; }
.panel { margin-top: 28px; background: white; border: 1px solid #dce6e3; border-radius: 14px; }
#empty { padding: 38px 18px; text-align: center; color: #49606a; }
ul { margin: 0; padding: 0; list-style: none; }
li { padding: 15px 18px; }
li + li { border-top: 1px solid #dce6e3; }
li strong, li small { display: block; overflow-wrap: anywhere; }
li small { color: #49606a; }
li button { flex-shrink: 0; }
#notice { margin-top: 16px; color: #824619; }
dialog { width: min(100% - 24px, 620px); border: 1px solid #dce6e3; border-radius: 15px; padding: 24px; color: inherit; }
dialog::backdrop { background: #102b3c77; }
label { display: grid; gap: 5px; margin-top: 15px; font-weight: 600; }
input, select, textarea { border: 1px solid #a8bdb8; border-radius: 7px; padding: 8px; width: 100%; color: inherit; background: white; }
.row, .compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compare { margin-top: 18px; }
.compare section { min-width: 0; padding: 10px; background: #f4f7f6; border-radius: 8px; }
dt { font-weight: 600; }
dd { margin: 0 0 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.actions { justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
[hidden] { display: none !important; }
.account-bar { display: flex; align-items: center; gap: 12px; }
#install-iphone-help ol { padding-inline-start: 1.5rem; }
#install-iphone-help li { display: list-item; padding: 4px 0; border: 0; }
.access-card { max-width: 440px; margin: auto; background: white; border: 1px solid #dce6e3; border-radius: 14px; padding: 26px; }
.access-card p, #directory-count { margin-top: 10px; color: #49606a; }
#access-tagline { margin: 0 0 8px; color: #086860; font-size: .9rem; font-weight: 650; }
#access-error { color: #8b371f; }
#access-error:empty { display: none; }
.text-button { background: transparent; border: 0; padding: 0; text-align: left; text-decoration: underline; }
.access-card a { color: #086860; }
.directory-panel { padding: 18px; }
.directory-panel label { margin: 0; }
#business-name { margin: 0 0 6px; color: #49606a; font-weight: 650; }
.workflow summary { cursor: pointer; font-weight: 650; padding: 16px 18px; }
.workflow ol { padding: 0; margin: 0; }
.workflow li { display: block; border-top: 1px solid #dce6e3; }
.workflow li p { margin-top: 4px; }
.workspace-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 24px; }
.workspace-nav [aria-current="page"] { background: #dcefea; border-color: #78a79d; }
.setup-card { padding: 18px; }
.setup-card fieldset, #setup-editor fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.setup-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.record-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
#setup-status, #setup-empty, #template-preview { margin-block: 12px; color: #49606a; }
#setup-editor-message { color: #8b371f; }
#setup-editor-message:empty { display: none; }

#registration-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
#team-view fieldset { border: 0; padding: 0; margin: 12px 0 0; min-width: 0; }
#team-view legend { font-weight: 650; }
.team-member { margin-top: 14px; padding-top: 12px; border-top: 1px solid #dce6e3; }

.registration-mode .access-card { max-width: 660px; }
#registration-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.registration-wide { grid-column: 1 / -1; }
#registration-documents { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
#registration-documents legend, .profile-document-choices legend { padding: 0; font-weight: 650; }
#registration-documents p { margin-top: 3px; color: #49606a; font-size: .9rem; }
#registration-document-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
#registration-document-options label { margin-top: 8px; }
#profile-form .profile-document-choices { margin-top: 16px; }
@media (max-width: 520px) {
  main { padding-block: 24px; }
  .access-card { padding: 18px; }
  #registration-fields, #registration-document-options { grid-template-columns: minmax(0, 1fr); }
  .record-actions { justify-content: start; }
  .setup-card li { flex-wrap: wrap; }
}

/* Signed-in workspace */
body:has(#workspace:not([hidden])) .bar { max-width: 1440px; padding-inline: clamp(16px, 3vw, 42px); }
#workspace {
  --workspace-accent: #0a6c62;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  max-width: 1440px;
  min-height: calc(100vh - 69px);
  padding: 0;
  background: #f5f7f9;
}
.workspace-sidebar { background: #fff; border-right: 1px solid #e2e9ec; padding: 32px 16px; }
#business-name { color: #12283a; font-size: .95rem; padding: 0 12px 18px; margin: 0 0 13px; border-bottom: 1px solid #e2e9ec; overflow-wrap: anywhere; }
.workspace-nav { display: grid; gap: 5px; margin: 0; }
.workspace-nav button {
  position: relative;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  color: #405562;
  font-size: .91rem;
}
.workspace-nav button:hover { background: #f0f5f5; filter: none; }
.workspace-nav [aria-current="page"] { background: #e6f3ef; color: #075d54; }
.workspace-nav [aria-current="page"]::before { content: ''; position: absolute; inset: 8px auto 8px 0; width: 3px; border-radius: 3px; background: var(--workspace-accent); }
.workspace-content { min-width: 0; padding: clamp(24px, 4vw, 52px); }
.workspace-content .heading { align-items: flex-start; }
.workspace-content .heading > button { flex-shrink: 0; }
.workspace-content .panel { border-color: #e0e8eb; border-radius: 12px; }
.draft-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 28px 0 0; }
.draft-summary > div { min-width: 0; padding: 16px 18px; border: 1px solid #e0e8eb; border-radius: 12px; background: #fff; }
.draft-summary dt { color: #48606a; font-size: .84rem; }
.draft-summary dd { margin: 5px 0 0; font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.draft-panel h2 { padding: 15px 18px; border-bottom: 1px solid #e0e8eb; font-size: 1rem; }
.draft-panel li { padding: 16px 18px; }
.draft-panel #empty { padding: 42px 16px; }
#empty-title { color: #12283a; font-weight: 700; }
#empty-detail { margin-top: 5px; font-size: .91rem; }
#empty-create { margin-top: 15px; color: #075d54; }
.workspace-content .workflow { margin-top: 18px; }
@media (max-width: 760px) {
  #workspace { display: block; }
  .workspace-sidebar { border-right: 0; border-bottom: 1px solid #e2e9ec; padding: 14px 16px; }
  #business-name { margin-bottom: 7px; padding: 0 0 8px; }
  .workspace-nav { display: flex; gap: 4px; margin: 0; }
  .workspace-nav button { padding: 9px 11px; }
}
@media (max-width: 480px) {
  .workspace-content { padding: 20px 16px 32px; }
  .draft-summary { gap: 7px; margin-top: 20px; }
  .draft-summary > div { padding: 10px 8px; }
  .draft-summary dt { font-size: .75rem; }
  .workspace-content .heading { gap: 8px; }
  .workspace-content .heading > button { padding: 8px 10px; font-size: .85rem; }
  .draft-panel #empty { padding-block: 27px; }
}

#document-status { margin-top: 12px; color: #48606a; }
#document-status:empty, #document-error:empty { display: none; }
#document-lines { display: grid; gap: 12px; margin-block: 16px 10px; }
.document-item { min-width: 0; border: 1px solid #e0e8eb; border-radius: 8px; padding: 0 12px 12px; }
.document-item button { margin-top: 10px; }
#document-total { font-weight: 700; }
#document-error { color: #8b371f; }
.document-item { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 0 10px; }
.document-item button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 600px) {
  .document-item { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
  .document-item > label:first-of-type { grid-column: 1 / -1; }
}

.draft-chart { margin: 18px 0 0; padding: 16px 18px; }
.draft-chart figcaption { font-size: 1rem; font-weight: 700; }
.draft-chart dl { display: grid; gap: 10px; margin: 14px 0 0; }
.draft-chart dl > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 10px; }
.draft-chart dt { font-size: .85rem; color: #405562; }
.draft-chart dd { display: grid; grid-template-columns: minmax(0, 1fr) minmax(20px, auto); align-items: center; gap: 10px; margin: 0; }
.draft-chart dd strong { text-align: right; font-variant-numeric: tabular-nums; }
.draft-chart-track { display: block; height: 10px; border-radius: 4px; background: #e9eff1; }
.draft-chart-track > span { display: block; height: 100%; border-radius: inherit; background: #08776c; }
#chart-pending-bar { background: #966118; }
#chart-conflicts-bar { background: #a64450; }

.item-pricing { grid-column: 1 / -1; min-width: 0; }
.item-pricing-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.item-pricing-actions button[aria-expanded="true"] { background: #e6f3ef; color: #075d54; }
.tier-panel, .history-panel { margin-top: 10px; padding: 10px; border: 1px solid #e0e8eb; border-radius: 8px; background: #f8fafb; }
.tier-panel > label { margin-top: 0; }
.tier-rates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.history-panel { overflow-x: auto; }
.history-panel table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.history-panel caption { text-align: left; font-weight: 700; margin-bottom: 8px; }
.history-panel th, .history-panel td { text-align: left; padding: 6px; border-bottom: 1px solid #e0e8eb; }
.item-pricing-message:empty { display: none; }
@media (max-width: 480px) { .tier-rates { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) {
  .history-panel table { table-layout: fixed; font-size: .75rem; }
  .history-panel th, .history-panel td { padding: 5px 3px; overflow-wrap: anywhere; }
}

.document-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
#document-list li > div:first-child { min-width: 0; }
#item-import { margin-top: 18px; }
#item-import summary { cursor: pointer; font-weight: 700; }
#item-import p, #item-import button { margin-top: 8px; }
@media (max-width: 760px) {
  #document-list li { align-items: flex-start; flex-direction: column; }
  .document-actions { justify-content: flex-start; }
}

#profile-form #document-branding { margin-top: 24px; padding: 14px; border: 1px solid #e0e8eb; border-radius: 8px; }
#document-branding legend { font-weight: 700; padding: 0 5px; }
#company-logo-preview { display: block; max-width: min(100%, 180px); max-height: 100px; object-fit: contain; margin-top: 12px; }
#document-branding .logo-hint { font-size: .85rem; color: #48606a; margin: 5px 0; }
#company-logo-remove { margin-top: 8px; }
#company-logo-box { display: flex; padding: 12px; margin-top: 12px; border: 1px dashed #c6d5d9; border-radius: 8px; }
#company-logo-box[data-position="right"] { justify-content: flex-end; }
#company-logo-box[data-position="center"] { justify-content: center; }
#company-logo-box #company-logo-preview { margin: 0; }
#purchase-order-editor { margin-block: 16px; }
#purchase-order-scan { margin-block: 12px 18px; padding: 12px 16px; background: #f4f7f6; border-radius: 8px; }
#purchase-order-scan label { margin-top: 0; }
#purchase-order-scan p { margin: 8px 0 0; color: #49606a; }
#po-scan-status:empty { display: none; }
#invoice-remarks:has(#payment-qr-controls:not([hidden])) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
#payment-qr-preview { display: block; width: 88px; height: 88px; object-fit: contain; margin-top: 8px; }
#payment-qr-remove { margin-top: 8px; }
@media (max-width: 480px) {
  #invoice-remarks:has(#payment-qr-controls:not([hidden])) { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .bar img { width: 120px; }
  .account-bar { gap: 5px; }
  .account-bar button { padding: 7px; font-size: .8rem; }
}
