@media screen {
  :root {
    --workspace: #f4f5f7;
    --panel: #f8f9fa;
    --paper: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #dfe3e8;
    --line-strong: #b8c0cc;
    --accent: #143d67;
    --accent-dark: #0d2f52;
    --danger: #a13a3a;
    --radius-control: 7px;
    --radius-panel: 9px;
  }

  html,
  body {
    background: var(--workspace);
  }

  body {
    padding-left: 204px;
  }

  .app-loading-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    padding: 24px;
    place-items: center;
    background: #f4f5f7;
    opacity: 1;
    transition: opacity 220ms ease;
  }

  .app-loading-screen.is-ready {
    pointer-events: none;
    opacity: 0;
  }

  .app-loading-mark {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #172033;
    animation: app-loading-arrive 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  .app-loading-mark img {
    width: 64px;
    height: 64px;
    object-fit: contain;
  }

  .app-loading-mark div {
    display: grid;
    gap: 3px;
  }

  .app-loading-mark strong {
    font-size: 18px;
    letter-spacing: -0.025em;
  }

  .app-loading-mark span {
    color: var(--muted);
    font-size: 12px;
  }

  @keyframes app-loading-arrive {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
  }

  .app-header {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 204px;
    min-height: 100dvh;
    padding: 24px 16px 18px;
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
    border-right: 1px solid #d7dce3;
    border-bottom: 0;
    background: #fbfbfc;
    backdrop-filter: none;
  }

  .brand-lockup {
    min-height: 54px;
    padding: 0 6px 22px;
    border-bottom: 1px solid var(--line);
  }

  .brand-lockup img {
    width: 42px;
    height: 42px;
  }

  .brand-name {
    color: #172033;
    font-size: 15px;
  }

  .header-actions {
    display: flex;
    width: 100%;
    min-height: 0;
    padding-top: 20px;
    align-items: stretch;
    flex: 1;
    flex-direction: column;
    gap: 6px;
  }

  .header-actions > .button {
    position: relative;
    display: inline-flex;
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    color: #3f4a5a;
    border: 1px solid transparent;
    background: transparent;
    font-size: 13px;
    font-weight: 680;
    text-align: left;
  }

  #invoiceListButton {
    order: 1;
  }

  #newInvoiceButton {
    order: 2;
  }

  #installButton {
    order: 3;
    margin-top: 8px;
  }

  #updateButton {
    order: 0;
    margin-bottom: 8px;
    color: #fff;
    border-color: var(--accent-dark);
    background: var(--accent);
  }

  #invoiceListButton::before,
  #newInvoiceButton::before,
  #installButton::before {
    display: inline-grid;
    width: 20px;
    height: 20px;
    place-items: center;
    color: currentColor;
    font-size: 17px;
    font-weight: 500;
    line-height: 1;
  }

  #invoiceListButton::before {
    content: "▤";
    font-size: 16px;
  }

  #newInvoiceButton::before {
    content: "+";
    font-size: 21px;
  }

  #installButton::before {
    content: "↓";
  }

  .header-actions > .button:hover {
    border-color: #e2e6eb;
    background: #f1f3f6;
  }

  .header-actions > .button[aria-current="page"] {
    color: #ffffff;
    border-color: var(--accent);
    background: var(--accent);
  }

  .header-actions > #printButton {
    position: fixed;
    top: 16px;
    right: 28px;
    z-index: 18;
    width: auto;
    min-width: 126px;
    justify-content: center;
    color: #fff;
    border-color: var(--accent-dark);
    background: var(--accent);
    box-shadow: 0 1px 2px rgb(15 31 49 / 0.12);
  }

  .header-actions > #printButton:hover {
    border-color: var(--accent-dark);
    background: var(--accent-dark);
  }

  .account-controls {
    order: 10;
    width: 100%;
    margin-top: auto;
    padding: 15px 9px 2px;
    align-items: flex-start;
    flex-direction: column;
    border-top: 1px solid var(--line);
  }

  .account-identity {
    position: relative;
    padding-left: 16px;
    max-width: 100%;
  }

  .account-identity::before {
    position: absolute;
    top: 6px;
    left: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2f7d57;
    content: "";
  }

  .account-email {
    max-width: 145px;
    color: #344054;
    font-size: 12px;
  }

  .sync-status {
    max-width: 145px;
    color: var(--muted);
    font-size: 10px;
  }

  #signOutButton[hidden] {
    display: none !important;
  }

  #signOutButton {
    min-height: 44px;
    flex-shrink: 0;
  }

  .button-primary {
    border-color: var(--accent-dark);
    background: var(--accent);
  }

  .button-primary:hover {
    background: var(--accent-dark);
  }

  .button-secondary {
    color: #253247;
    border-color: #c9d0da;
  }

  .history-page {
    width: min(1180px, calc(100% - 64px));
    margin: 0 auto;
    padding: 44px 0 38px;
  }

  .history-hero {
    min-height: 92px;
    padding: 0 0 26px;
  }

  .history-hero h1 {
    color: #172033;
    font-size: clamp(32px, 3vw, 42px);
    font-weight: 700;
    letter-spacing: -0.045em;
  }

  .history-hero h1:focus-visible,
  .panel-heading h1:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 5px;
  }

  .history-intro {
    margin-top: 7px;
    font-size: 14px;
  }

  .history-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }

  .history-hero-actions > .button {
    min-height: 42px;
    padding-inline: 17px;
  }

  .draft-notice {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-color: #b9c9d9;
    border-radius: 8px;
    background: #f7fafc;
  }

  .draft-notice-label {
    color: var(--accent);
    font-size: 10px;
  }

  .draft-notice h2 {
    font-size: 15px;
  }

  .history-section {
    border-color: #d7dce3;
    border-radius: 9px;
    box-shadow: 0 1px 2px rgb(15 31 49 / 0.035);
  }

  .history-section-heading {
    min-height: 88px;
    padding: 17px 20px;
  }

  .history-section-heading h2 {
    font-size: 18px;
  }

  .history-search {
    position: relative;
    width: min(330px, 38vw);
  }

  .history-search::after {
    position: absolute;
    bottom: 12px;
    left: 13px;
    color: #738094;
    content: "⌕";
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
  }

  .history-search input {
    padding-left: 36px;
  }

  .invoice-table-head,
  .invoice-record {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.25fr) 105px 50px 90px 220px;
    gap: 18px;
    align-items: center;
  }

  .invoice-table-head {
    min-height: 40px;
    padding: 9px 20px;
    color: #536174;
    border-bottom: 1px solid var(--line);
    background: #f8f9fb;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .invoice-record {
    min-height: 72px;
    padding: 14px 20px;
    border-bottom-color: #e5e8ec;
  }

  .invoice-record:hover {
    background: #fafbfc;
  }

  .invoice-record > div:first-child,
  .invoice-record-meta,
  .invoice-record-meta > div {
    display: contents;
  }

  .invoice-record-meta dt {
    display: none;
  }

  .invoice-number,
  .invoice-customer,
  .invoice-record-meta dd {
    min-width: 0;
    margin: 0;
  }

  .invoice-number {
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 750;
  }

  .invoice-customer {
    display: block;
    overflow: hidden;
    color: #344054;
    font-size: 13px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .invoice-record-meta dd {
    color: #4f5c6e;
    font-size: 12px;
    font-weight: 600;
  }

  .invoice-record-actions {
    gap: 6px;
  }

  .invoice-record-actions .button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 11px;
  }

  .history-empty-state {
    padding-block: 64px 70px;
  }

  .history-storage-note {
    max-width: 78ch;
    color: #566274;
    font-size: 11px;
    line-height: 1.5;
  }

  .workspace {
    width: 100%;
    min-height: 100dvh;
    grid-template-columns: minmax(420px, 0.82fr) minmax(620px, 1.18fr);
  }

  .editor-panel {
    padding: 34px 30px 44px;
    border-right-color: #d7dce3;
    background: #f8f9fa;
  }

  .panel-heading {
    min-height: 48px;
    margin-bottom: 20px;
  }

  .panel-heading h1 {
    color: #172033;
    font-size: 25px;
    letter-spacing: -0.035em;
  }

  .save-status {
    color: #667085;
    font-size: 11px;
  }

  .form-section {
    margin-bottom: 14px;
    padding: 18px;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px #dfe3e8;
  }

  .form-section legend {
    color: #253247;
    font-size: 13px;
    font-weight: 750;
  }

  input,
  textarea {
    color: #172033;
    border-color: #bfc7d2;
    border-radius: 6px;
    background: #fff;
  }

  input:focus,
  textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(20 61 103 / 0.09);
  }

  input[readonly] {
    background: #f3f5f7;
  }

  .item-row [data-item-field="description"] {
    text-transform: none;
  }

  .preview-panel {
    background: #e8ebef;
  }

  .preview-toolbar {
    min-height: 72px;
    padding: 14px 170px 14px 22px;
    border-bottom-color: #d4d9e0;
    background: #f8f9fa;
  }

  .preview-tool-button[aria-pressed="true"] {
    background: var(--accent);
  }

  .preview-stage {
    min-height: calc(100dvh - 72px);
    padding: 28px;
  }

  .toast {
    right: 24px;
    bottom: 24px;
    border-radius: 7px;
    background: #172033;
  }
}

@media screen and (max-width: 1359px) {
  .invoice-table-head,
  .invoice-record {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.15fr) 105px 48px 84px 108px;
    gap: 12px;
  }

  .invoice-record-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .stacked-preview-button,
  .preview-back-button {
    display: block;
  }

  .stacked-preview-button {
    width: 100%;
    margin: -2px 0 16px;
  }

  .preview-stage {
    min-height: 600px;
  }
}

@media screen and (max-width: 960px) {
  body {
    padding-left: 0;
    padding-top: calc(66px + env(safe-area-inset-top));
  }

  .app-header {
    position: fixed;
    inset: 0 0 auto;
    width: 100%;
    min-height: 66px;
    padding: calc(9px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 9px calc(14px + env(safe-area-inset-left));
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgb(251 251 252 / 0.96);
  }

  .brand-lockup {
    min-height: 0;
    padding: 0;
    border: 0;
  }

  .brand-lockup img {
    width: 40px;
    height: 40px;
  }

  .header-actions {
    width: auto;
    min-height: 44px;
    padding: 0;
    align-items: center;
    flex: 0 1 auto;
    flex-direction: row;
    gap: 7px;
    min-width: 0;
  }

  .header-actions > .button {
    width: auto;
    min-height: 44px;
    padding: 8px 11px;
    justify-content: center;
  }

  .header-actions > #printButton {
    position: static;
    min-width: 0;
  }

  #invoiceListButton::before,
  #newInvoiceButton::before,
  #installButton::before,
  #updateButton::before {
    display: none;
  }

  body[data-page="history"] #invoiceListButton,
  body[data-page="editor"] #newInvoiceButton {
    display: none !important;
  }

  .account-controls {
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 0 0 0 12px;
    align-items: center;
    flex-direction: row;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .account-email {
    display: block;
    max-width: 190px;
  }

  #installButton {
    order: 0;
    margin: 0;
  }

  #invoiceListButton,
  #newInvoiceButton {
    order: 1;
  }

  .history-page {
    width: min(100% - 40px, 920px);
    padding-top: 34px;
  }

  .workspace {
    min-height: calc(100dvh - 66px);
  }

  .header-actions > #printButton {
    display: inline-flex;
  }

  .preview-toolbar {
    padding-right: 22px;
  }
}

@media screen and (min-width: 701px) {
  /* Flattened identity and metadata participate in the same six-column grid.
     Override the original card layout's explicit action-column placement. */
  .invoice-number {
    grid-column: 1;
    grid-row: 1;
  }

  .invoice-customer {
    grid-column: 2;
    grid-row: 1;
  }

  .invoice-record-meta dd {
    grid-row: 1;
  }

  .invoice-record-meta > div:nth-child(1) dd { grid-column: 3; }
  .invoice-record-meta > div:nth-child(2) dd { grid-column: 4; }
  .invoice-record-meta > div:nth-child(3) dd { grid-column: 5; }

  .invoice-record-actions {
    grid-column: 6;
    grid-row: 1;
  }
}

@media screen and (max-width: 767px) {
  .header-actions > #printButton {
    display: none;
  }
}

@media screen and (max-width: 700px) {
  body {
    padding-top: 0;
  }

  .app-header {
    position: sticky;
    min-height: 62px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-actions {
    display: contents;
  }

  .account-controls {
    width: 100%;
    padding: 8px 0 0;
    justify-content: space-between;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .account-email,
  .sync-status {
    max-width: calc(100vw - 140px);
  }

  .brand-name {
    font-size: 14px;
  }

  .header-actions > .button {
    min-height: 44px;
    padding-inline: 10px;
    font-size: 12px;
  }

  #installButton {
    display: none;
  }

  .history-page {
    width: calc(100% - 28px);
    padding: 26px 0 24px;
  }

  .history-hero {
    min-height: 0;
    gap: 14px;
    padding-bottom: 20px;
  }

  .history-hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .history-hero-actions #historyNewInvoiceButton {
    grid-column: 1 / -1;
  }

  .history-hero h1 {
    font-size: 30px;
  }

  .history-intro {
    font-size: 13px;
  }

  .draft-notice {
    padding: 16px;
  }

  .history-section-heading {
    min-height: 0;
    padding: 16px;
  }

  .invoice-table-head {
    display: none;
  }

  .invoice-record {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 14px;
    min-height: 0;
    padding: 17px 16px;
  }

  .invoice-record > div:first-child {
    display: grid;
    grid-column: 1;
    gap: 4px;
  }

  .invoice-number,
  .invoice-customer {
    grid-column: auto;
  }

  .invoice-number {
    font-size: 13px;
  }

  .invoice-customer {
    font-size: 12px;
  }

  .invoice-record-meta {
    display: grid;
    grid-column: 1;
    grid-template-columns: auto auto auto;
    gap: 13px;
    margin-top: 4px;
  }

  .invoice-record-meta > div {
    display: grid;
    gap: 2px;
  }

  .invoice-record-meta dt {
    display: block;
    margin: 0;
    color: #596678;
    font-size: 10px;
  }

  .invoice-record-meta dd {
    font-size: 11px;
  }

  .invoice-record-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    justify-content: center;
  }

  .invoice-record-actions .button {
    min-width: 74px;
    min-height: 44px;
  }

  .editor-panel {
    padding: 22px 14px calc(104px + env(safe-area-inset-bottom));
  }

  .form-section {
    padding: 16px;
  }

  .mobile-output-action {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 19;
    margin: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgb(248 249 250 / 0.96);
    backdrop-filter: blur(12px);
  }

  .preview-stage {
    min-height: 440px;
    padding: 14px;
  }

  .toast {
    right: 14px;
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

@media screen and (max-width: 420px) {
  .brand-lockup > div {
    display: block;
  }

  .brand-lockup img {
    width: 36px;
    height: 36px;
  }

  .brand-name {
    max-width: 100px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .invoice-record {
    grid-template-columns: minmax(0, 1fr);
  }

  .invoice-record-actions {
    grid-column: 1;
    grid-row: auto;
    flex-direction: row;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invoice-record-meta {
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-loading-mark {
    animation: none;
  }
}

@media print {
  .app-loading-screen {
    display: none !important;
  }
}

@media screen {
  .history-filters { display: flex; align-items: end; gap: 16px; }
  #paymentFilterLabel { display: grid; gap: 6px; margin: 0; width: 150px; color: var(--muted); font-size: 11px; font-weight: 650; }
  #paymentFilterLabel[hidden] { display: none; }
  #paymentFilter { min-height: 44px; font-size: 13px; }
  .invoice-record-actions { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-end; }
  .payment-badge { margin-right: auto; padding: 4px 7px; border-radius: 4px; color: #667085; background: #f2f4f7; font-size: 11px; font-weight: 600; }
  .payment-badge-paid { color: #247052; background: #eaf5ef; }
  .payment-badge-refunded { color: #765529; background: #faf1e4; }
  .invoice-more { position: relative; }
  .invoice-more summary { list-style: none; cursor: pointer; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 7px; font-size: 11px; font-weight: 650; }
  .invoice-more summary::-webkit-details-marker { display: none; }
  .invoice-more summary::after { content: " ▾"; }
  .invoice-more summary:hover { background: var(--workspace); }
  .invoice-more summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .invoice-more-menu { position: absolute; z-index: 5; right: 0; top: calc(100% + 6px); width: 180px; display: grid; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: 0 8px 28px rgb(23 32 51 / 12%); }
  .invoice-more-menu .button { justify-content: flex-start; border: none; background: transparent; text-align: left; font-size: 12px; }
  .invoice-more-menu .button:hover { background: var(--workspace); }
  @media (max-width: 900px) {
    .history-section-heading { flex-wrap: wrap; gap: 18px; }
    .history-filters { width: 100%; }
    .history-filters .history-search { width: auto; flex: 1; }
  }
  @media (max-width: 560px) {
    .history-filters { flex-wrap: wrap; gap: 12px; }
    #paymentFilterLabel { width: 120px; }
    .history-filters .history-search { min-width: 130px; }
  }
}

@media screen {
  .history-section { overflow: visible; }
  .history-section-heading { border-radius: 9px 9px 0 0; }
  .invoice-record-actions { flex-direction: row; }
  .folder-section { margin: 0 0 24px; }
  .folder-section[hidden] { display: none; }
  .folder-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
  .folder-toolbar .button { min-height: 38px; padding: 8px 12px; font-size: 12px; }
  .folder-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
  .folder-breadcrumbs button { border: 0; background: transparent; padding: 8px 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
  .folder-breadcrumbs button + button::before { content: "/"; margin-right: 12px; color: var(--line-strong); }
  .folder-breadcrumbs [aria-current] { color: var(--ink); font-weight: 650; }
  .folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
  .folder-tile { display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: center; gap: 3px 12px; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); }
  .folder-tile:hover { border-color: #96adc4; background: #f8fafc; }
  .folder-tile > span:not(.folder-icon) { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .folder-tile small { grid-column: 2; color: var(--muted); font-size: 11px; }
  .folder-icon { grid-row: span 2; position: relative; width: 25px; height: 19px; border: 1.5px solid #7e96af; background: #edf2f7; border-radius: 3px; }
  .folder-icon::before { content: ""; position: absolute; left: -1.5px; top: -5px; width: 12px; height: 5px; background: #edf2f7; border: 1.5px solid #7e96af; border-bottom: none; border-radius: 3px 3px 0 0; }
  .organize-dialog { width: min(440px, calc(100vw - 32px)); max-height: 90dvh; padding: 28px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); box-shadow: 0 24px 80px rgb(23 32 51 / 18%); }
  .organize-dialog::backdrop { background: rgb(23 32 51 / 38%); }
  .organize-dialog label[hidden] { display: none; }
  #folderError { color: var(--danger); }
  #folderError:empty { display: none; }
  @media (min-width: 768px) {
    .invoice-table-head, .invoice-record { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) 105px 45px 80px 190px; gap: 12px; }
  }
  @media (max-width: 767px) {
    .invoice-record-actions { flex-direction: column; align-items: stretch; }
    .payment-badge { margin: 0; text-align: center; }
    .invoice-more summary { text-align: center; min-height: 44px; padding: 12px; }
    .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .folder-tile { padding: 14px 10px; gap: 4px 8px; }
  }
}

@media screen and (max-width: 420px) {
  .invoice-record-actions { flex-direction: row; align-items: center; }
  .invoice-record-actions .payment-badge { margin-right: auto; }
}

@media screen {
  .invoice-customization summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; padding: 8px 0; }
  .invoice-customization .field-stack { margin-top: 16px; }
  .invoice-customization .button { justify-self: start; min-height: 36px; font-size: 12px; padding: 8px 12px; }
  .folder-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .attachments-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
  .attachments-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 12px; font-size: 13px; }
  .attachments-list li > span { width: 100%; overflow-wrap: anywhere; }
  .attachments-list .button { font-size: 12px; min-height: 36px; padding: 8px 12px; }
  #attachmentsDialog { max-height: 85dvh; overflow: auto; }
  #attachmentsError, #bookingFolderError { font-size: 13px; color: var(--muted); }
  #attachmentsError:empty, #bookingFolderError:empty { display: none; }
}
#previewTerms { white-space: pre-wrap; overflow-wrap: anywhere; }
.invoice-logo { object-fit: contain; }
@media screen {
  #invoiceLogoUpload, #invoiceAttachments { min-width: 0; font-size: 13px; padding: 8px; }
  #invoiceLogoUpload::file-selector-button, #invoiceAttachments::file-selector-button { font: inherit; font-weight: 600; border: 0; border-radius: 4px; padding: 8px 10px; margin-right: 10px; color: var(--accent); background: var(--workspace); cursor: pointer; }
}

/* Quotini workspace: option 1, retaining the existing brand and typeface. */
@media screen {
  .history-page { max-width: 1380px; padding-top: 38px; }
  .history-hero { align-items: center; padding-bottom: 28px; }
  .history-hero-actions { align-items: center; flex-wrap: nowrap; }
  .workspace-tools summary { border: 0; font-size: 16px; min-width: 40px; text-align: center; }
  .invoice-more summary::after { content: none; }
  .invoice-more summary { border-color: transparent; font-size: 14px; letter-spacing: 1px; }
  .workspace-tools .invoice-more-menu { width: 190px; }
  .draft-notice { border: 0; background: #eaf0f6; padding: 14px 18px; margin-bottom: 28px; }
  .draft-notice-label { display: none; }
  .draft-notice h2 { font-size: 13px; }
  #draftNoticeSummary { font-size: 12px; margin-top: 3px; }
  .draft-notice-actions .button { min-height: 34px; border: 0; background: transparent; padding: 6px 10px; font-size: 12px; }
  .folder-section { margin-bottom: 28px; }
  .folder-toolbar { margin-bottom: 18px; }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .folder-tile { min-height: 82px; padding: 20px; background: var(--paper); }
  .history-section { border: 0; background: transparent; }
  .history-section-heading { padding: 0 0 20px; background: transparent; border: 0; }
  .history-section-heading h2 { font-size: 15px; }
  .history-count { font-size: 12px; }
  .history-filters { flex-direction: row-reverse; gap: 12px; }
  .history-search { width: min(350px, 32vw); }
  .history-search input, #paymentFilter { background: var(--paper); border-color: var(--line); }
  .invoice-table-head { border: 1px solid var(--line); border-radius: 8px 8px 0 0; text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; min-height: 44px; }
  .invoice-history-list { background: var(--paper); border-inline: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0 0 8px 8px; }
  .invoice-record { min-height: 74px; padding-top: 16px; padding-bottom: 16px; font-variant-numeric: tabular-nums; }
  .invoice-record-actions .button { border-color: transparent; background: transparent; color: var(--accent); }
  .payment-badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 5px 8px; }
  .payment-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
  .payment-badge-unpaid { color: var(--danger); background: #fbecec; }
  .payment-badge-paid { color: #247052; background: #eaf5ef; }
  .payment-badge-refunded { color: var(--muted); background: #edf0f3; }
  .sidebar-folders { order: 3; min-height: 0; overflow: auto; margin: 24px -4px 12px; padding: 0 4px; }
  .sidebar-folders[hidden], body:has(#invoiceListPage[hidden]):has(#editorPage[hidden]):has(#settingsPage[hidden]) .sidebar-folders { display: none; }
  .sidebar-folder-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 10px; font-size: 12px; color: var(--muted); }
  .sidebar-folder-heading button { border: 0; background: transparent; color: var(--accent); font-size: 21px; cursor: pointer; }
  #sidebarFolderTree button { width: 100%; padding: 10px 8px; border: 0; border-radius: 5px; background: transparent; text-align: left; font: inherit; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
  #sidebarFolderTree button:hover { background: var(--workspace); color: var(--ink); }
  #sidebarFolderTree button[aria-current] { background: #eaf0f6; color: var(--accent); font-weight: 600; }
  .sidebar-folder-branch summary { display: flex; align-items: center; cursor: pointer; }
  .sidebar-folder-branch summary::before { content: '›'; color: var(--muted); }
  .sidebar-folder-branch[open] > summary::before { transform: rotate(90deg); }
  .sidebar-folder-children { padding-left: 12px; border-left: 1px solid var(--line); margin-left: 5px; }
  #installButton { order: 4; }
}
@media screen and (min-width: 1100px) {
  body { padding-left: 236px; }
  .app-header { width: 236px; }
  .history-page { width: calc(100% - 72px); }
}
@media screen and (max-width: 767px) {
  .sidebar-folders { display: none; }
  .history-page { padding-top: 24px; }
  .history-hero-actions { width: auto; }
  .history-hero-actions #historyNewInvoiceButton { width: auto; }
  .history-filters { flex-direction: row; }
  .folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .folder-toolbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .folder-tile { min-height: 74px; padding: 14px 10px; }
  .invoice-record-actions { flex-direction: row; align-items: center; }
  .invoice-record-actions .button { min-width: 0; }
  .invoice-more summary { min-height: 40px; padding: 10px 6px; }
  .draft-notice { gap: 10px; }
}
@media screen and (max-width: 767px) {
  .history-hero-actions { display: flex; width: 100%; justify-content: flex-start; }
  .history-hero-actions #historyNewInvoiceButton { grid-column: auto; }
  .history-filters { display: grid; grid-template-columns: 120px minmax(0, 1fr); }
  .history-filters .history-search { min-width: 0; width: 100%; }
}

@media screen and (max-width: 960px) {
  .sidebar-folders { display: none; }
}

.item-help-list { margin: 12px 0; padding-left: 18px; list-style: disc; }
.item-help-list .field-help { margin: 0 0 6px; padding-left: 2px; }

@media screen {
 .profile-controls { padding: 18px 2px 0; }
 .profile-controls[hidden] { display: none; }
 .profile-controls label { display: block; margin-bottom: 6px; font-size: 11px; color: var(--muted); }
 .profile-controls select { width: 100%; min-height: 38px; font: inherit; font-size: 12px; }
 .profile-controls > div { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
 .profile-controls button { border: 0; background: transparent; padding: 6px 0; color: var(--accent); font: inherit; font-size: 11px; cursor: pointer; }
 #profileLogoPreview { object-fit: contain; }
 #profileError { color: var(--danger); font-size: 12px; }
}
@media screen and (max-width: 960px) {
 .profile-controls { padding: 0; max-width: 160px; }
 .profile-controls label { display: none; }
 .profile-controls select { min-height: 32px; }
}
@media screen and (max-width: 700px) {
 .app-header { flex-wrap: wrap; }
 .profile-controls { margin-left: auto; }
}
@media screen {
 .profile-controls select { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; background: var(--paper); color: var(--ink); font-weight: 600; }
 .profile-controls select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
}

@media screen {
 #editProfileButton { order: 5; }
 #editProfileButton::before { content: "⚙"; width: 20px; text-align: center; font-size: 17px; }
 .settings-page { max-width: 1080px; }
 .settings-intro { color: var(--muted); font-size: 13px; margin-top: 8px; }
 .settings-form { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-panel); }
 .settings-section { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(0, 1.4fr); gap: 40px; padding: 30px; border-bottom: 1px solid var(--line); }
 .settings-section-intro h2 { color: var(--ink); font-size: 16px; margin: 0 0 8px; }
 .settings-section-intro p { color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 30ch; }
 .settings-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
 .settings-fields label { color: var(--ink); font-size: 12px; font-weight: 600; }
 .settings-fields input, .settings-fields textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 12px; font: inherit; font-size: 13px; color: var(--ink); background: var(--paper); }
 .settings-fields textarea { resize: vertical; min-height: 160px; line-height: 1.6; }
 .settings-fields .field-help { margin: 0 0 16px; font-size: 11px; }
 .settings-logo { display: flex; gap: 16px; align-items: center; }
 .settings-logo input { min-width: 0; }
 .settings-logo img { flex: 0 0 100px; border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
 .settings-logo input::file-selector-button { border: 0; border-radius: 4px; padding: 8px; margin-right: 8px; color: var(--accent); background: var(--workspace); font: inherit; cursor: pointer; }
 .settings-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 30px; }
 .settings-form #profileError { margin: 16px 30px 0; color: var(--muted); }
 .settings-form #profileError:empty { display: none; }
}
@media screen and (max-width: 767px) {
 .settings-section { grid-template-columns: 1fr; gap: 18px; padding: 20px; }
 .settings-section-intro p { max-width: none; }
 .settings-footer { padding: 20px; }
 #editProfileButton::before { display: none; }
}
@media screen and (min-width: 961px) {
 #editProfileButton { order: 3; }
 .sidebar-folders { order: 4; }
 #installButton { order: 5; }
}
