* {
    box-sizing: border-box;
}
body {
    font-family: system-ui, sans-serif;
    margin: 0;
    padding: 14px 16px 18px;
    font-size: 14px;
    color: #1f2937;
    background: #f6f7fb;
}
h3 {
    margin: 0 0 10px;
}
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.header-row h3 {
    margin: 0;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.refresh-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #1b5299;
    background: #fff;
    color: #1b5299;
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.refresh-button.live-button {
    border-color: #4da8da;
    color: #1b5299;
    background: #eef8ff;
}
.refresh-button.live-button:hover:not(:disabled) {
    background: #e0f2ff;
    border-color: #1b5299;
}
.refresh-button:disabled {
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}
.muted {
    color: #6b7280;
}
.card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.customer-card {
    display: grid;
    gap: 3px;
    border-left: 4px solid #1b5299;
}
.customer-name {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
}
.customer-line {
    color: #6b7280;
    font-size: 13px;
}
.customer-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}
.secondary-button {
    border: 1px solid #1b5299;
    background: #fff;
    color: #1b5299;
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.secondary-button:disabled {
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}
.inline-status {
    color: #6b7280;
    font-size: 12px;
}
.dashboard-section {
    border: 1px solid #d4dbe7;
    border-radius: 16px;
    padding: 0;
    margin: 16px 0;
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}
.section-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #111827;
}
.section-subtitle {
    margin-top: 2px;
    color: #6b7280;
    font-size: 12px;
    line-height: 1.35;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 10px;
    margin-bottom: 0;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.section-header-main {
    min-width: 0;
}
.section-toggle {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #1b5299;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
    flex: 0 0 auto;
}
.section-toggle:hover {
    background: #eff6ff;
    border-color: #1b5299;
}
.section-body {
    padding: 12px 14px 14px;
}
.section-body.is-collapsed {
    display: none;
}
.table-controls {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 8px;
    align-items: center;
    margin: 0 0 10px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
}
.table-controls input,
.table-controls select {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 7px 9px;
    font: inherit;
    font-size: 12px;
    min-width: 0;
    background: #fff;
    color: #1f2937;
}
.table-count {
    color: #6b7280;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}
.sortable-header {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    gap: 5px;
    align-items: center;
    text-align: left;
}
.sort-indicator {
    color: #1b5299;
    font-size: 11px;
    min-width: 10px;
}
.column-filter-row th {
    background: #f8fafc;
    padding-top: 4px;
    padding-bottom: 7px;
}
.column-filter-row input,
.column-filter-row select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    padding: 5px 7px;
    font: inherit;
    font-size: 11px;
    color: #1f2937;
    background: #fff;
}
.column-filter-row input::placeholder {
    color: #9ca3af;
}
.empty-state {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    margin: 6px 0 0;
    color: #6b7280;
    background: #fff;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1b5299;
    color: white;
    padding: 7px 10px;
    border-radius: 8px;
    text-decoration: none;
    min-height: 18px;
}
.source-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.source-photoday {
    background: #dbeafe;
    color: #1d4ed8;
}
.source-woocommerce {
    background: #f3e8ff;
    color: #7e22ce;
}
.source-default {
    background: #f3f4f6;
    color: #374151;
}
.source-cell-stack {
    display: inline-grid;
    gap: 4px;
    justify-items: center;
    align-items: center;
}
.source-type-label {
    display: block;
    width: fit-content;
    font-size: 11px;
    font-weight: 650;
    font-style: italic;
    line-height: 1.2;
    color: #6b7280;
    white-space: nowrap;
}
.source-type-label.type-advancepay {
    color: #c2410c;
}
.source-type-label.type-order {
    color: #6b7280;
}
.order-number {
    display: block;
    font-weight: 800;
    color: #1f2937;
    line-height: 1.2;
}
.order-job {
    display: block;
    margin-top: 3px;
    color: #4b5563;
    font-weight: 650;
    line-height: 1.25;
}

.subject-cell-with-thumb {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.subject-thumb-link,
.subject-thumb-placeholder {
    display: inline-flex;
    flex: 0 0 auto;
    width: 58px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #dbe3ef;
    background: #f8fafc;
}
.subject-thumb-placeholder {
    border-style: dashed;
}
.subject-thumb {
    width: 58px;
    height: 72px;
    object-fit: cover;
    display: block;
}
.subject-cell-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.job-title-with-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.job-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    background: #fff;
    flex: 0 0 auto;
}
.job-title-text {
    min-width: 0;
}
.tracking-link {
    display: inline-block;
    margin-top: 4px;
    color: #6b7280;
    font-size: 12px;
    word-break: break-word;
}
.small-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    font-size: 12px;
}
.small-link-row a {
    color: #1b5299;
    text-decoration: none;
    font-weight: 650;
}
.small-link-row a:hover {
    text-decoration: underline;
}
.date-stack {
    display: grid;
    gap: 2px;
    line-height: 1.2;
}
.date-stack-date {
    font-weight: 650;
    color: #1f2937;
}
.date-stack-time {
    color: #6b7280;
    font-size: 12px;
}
.gallery-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.gallery-type-public {
    background: #dcfce7;
    color: #166534;
}
.gallery-type-group {
    background: #f3f4f6;
    color: #374151;
}
.gallery-type-private {
    background: #dbeafe;
    color: #1d4ed8;
}
.gallery-type-unknown {
    background: #fef3c7;
    color: #92400e;
}
.access-code-cell {
    display: grid;
    gap: 4px;
}
.access-code-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    color: #1f2937;
    word-break: break-word;
}
.mini-button {
    border: 1px solid #1b5299;
    background: #fff;
    color: #1b5299;
    border-radius: 7px;
    padding: 4px 7px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    width: fit-content;
}
.mini-button:disabled {
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}
.copy-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
}
.icon-button {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #1b5299;
    border-radius: 7px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.icon-button:hover {
    border-color: #1b5299;
    background: #eff6ff;
}
.icon-button:disabled {
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    background: #fff;
}
.ordered-cell {
    text-align: center;
}
.order-detail-row td {
    padding: 0 0 12px;
    background: #fff;
}
.order-detail-panel {
    margin: 8px 0 0;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #f8fafc;
    overflow: hidden;
}
.order-detail-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
}
.order-detail-title {
    font-size: 15px;
    font-weight: 850;
    color: #111827;
    line-height: 1.25;
}
.order-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}
.order-detail-subtitle {
    margin: 0 0 7px;
    font-size: 12px;
    font-weight: 850;
    color: #1b5299;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.order-detail-items {
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
}
.order-detail-panel > .order-detail-subtitle {
    padding: 12px 14px 0;
    margin-bottom: 0;
    background: #fff;
}
.order-detail-package {
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #f8fafc;
    overflow: hidden;
}
.order-detail-package-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
}
.order-detail-package-name {
    font-size: 14px;
    font-weight: 850;
    color: #111827;
    line-height: 1.25;
}
.order-detail-package-items {
    display: grid;
    gap: 8px;
    padding: 10px;
}
.order-detail-package-items .order-detail-item {
    border-color: #e2e8f0;
    box-shadow: none;
}
.order-detail-item {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}
.order-detail-thumb {
    width: 92px;
    max-height: 120px;
    border-radius: 8px;
    object-fit: contain;
    border: 1px solid #dbe3ef;
    background-color: #eee;
    display: block;
}
.order-detail-thumb-empty {
    width: 92px;
    height: 92px;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
}
.order-detail-item-main {
    min-width: 0;
    display: grid;
    gap: 4px;
}
.order-detail-price {
    font-weight: 800;
    color: #111827;
    white-space: nowrap;
}
.order-detail-download-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
}

.order-detail-customer-download {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fbff;
}
.order-detail-customer-download .order-detail-subtitle {
    margin-bottom: 4px;
}
.order-detail-customer-download a:not(.button) {
    color: #1b5299;
    font-weight: 700;
    word-break: break-word;
}
.order-detail-customer-download .order-detail-download-actions {
    margin-top: 0;
    justify-content: flex-end;
    flex: 0 0 auto;
}
.order-detail-customer-download .button,
.order-detail-customer-download .mini-button {
    min-height: 30px;
}
.order-detail-totals {
    display: grid;
    gap: 4px;
    justify-content: end;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
}
.order-detail-totals div {
    display: grid;
    grid-template-columns: 90px 90px;
    gap: 12px;
    align-items: center;
    color: #4b5563;
}
.order-detail-totals strong {
    text-align: right;
    color: #111827;
}
.order-detail-total {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid #dbe3ef;
    font-size: 14px;
    font-weight: 850;
}
.total-row td {
    border-bottom: 0;
    font-weight: 800;
    background: #f9fafb;
}
.total-label {
    text-align: right;
    color: #374151;
}
.ordered-yes {
    color: #16a34a;
    font-size: 16px;
    font-weight: 700;
}
.ordered-no {
    color: #dc2626;
    font-size: 16px;
    font-weight: 700;
}
.spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid #d1d5db;
    border-top-color: #1b5299;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}
.loading-card {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
td:last-child {
    white-space: nowrap;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}
.table-wrap {
    width: 100%;
    overflow-x: auto;
}
th,
td {
    border-bottom: 1px solid #e5e7eb;
    padding: 6px 4px;
    text-align: left;
    vertical-align: middle;
}
th {
    color: #6b7280;
    font-weight: 800;
    background: #fff;
}
@media (max-width: 520px) {
  body {
    padding: 14px 18px 22px 14px;
    font-size: 16px;
    overflow-x: hidden;
  }

  h3 {
    font-size: 18px;
  }

  .refresh-button {
    font-size: 14px;
    padding: 7px 10px;
  }

  .header-actions {
    gap: 6px;
  }

  .card,
  .empty-state {
    padding: 12px;
  }

  .customer-name {
    font-size: 17px;
  }

  .customer-line {
    font-size: 15px;
  }

  .secondary-button,
  .inline-status {
    font-size: 14px;
  }

  .dashboard-section {
    margin: 14px 0;
  }

  .section-header {
    display: flex;
    padding: 12px;
  }

  .section-title {
    font-size: 16px;
  }

  .section-subtitle {
    font-size: 14px;
  }

  .section-body {
    padding: 12px;
  }

  .section-toggle {
    width: 34px;
    height: 34px;
  }

  .table-controls {
    grid-template-columns: 1fr;
  }

  .table-controls input,
  .table-controls select,
  .table-count {
    font-size: 14px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    margin: 8px 0;
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: start;
    column-gap: 12px;
    border-bottom: 0;
    padding: 7px 0;
    text-align: right;
    white-space: normal;
    min-width: 0;
  }

  td::before {
    color: #6b7280;
    content: attr(data-label);
    font-weight: 700;
    text-align: left;
  }

  td:last-child {
    white-space: normal;
  }

  td[data-label="Order"],
  td[data-label="Gallery"] {
    display: block;
    text-align: left;
  }

  td[data-label="Order"]::before,
  td[data-label="Gallery"]::before {
    display: block;
    margin-bottom: 4px;
  }

  .order-number {
    font-size: 16px;
  }

  .order-job {
    font-size: 16px;
    color: #374151;
  }

  .subject-cell-with-thumb {
    align-items: flex-start;
  }

  .subject-thumb-link,
  .subject-thumb-placeholder,
  .subject-thumb {
    width: 52px;
    height: 64px;
  }

  .job-logo {
    width: 34px;
    height: 34px;
  }

  .tracking-link {
    font-size: 14px;
  }

  .small-link-row {
    font-size: 14px;
  }

  .date-stack-time,
  .gallery-type-badge,
  .access-code-value,
  .mini-button,
  .icon-button {
    font-size: 14px;
  }

  .copy-actions {
    justify-content: flex-end;
  }

  .ordered-cell {
    text-align: right;
  }

  .total-row td {
    display: grid;
  }

  .total-label {
    text-align: left;
  }

  .button {
    padding: 8px 12px;
  }

  .order-detail-row {
    border: 0;
    padding: 0;
  }

  .order-detail-row td {
    display: block;
    padding: 0;
  }

  .order-detail-row td::before {
    content: "";
    display: none;
  }

  .order-detail-panel {
    margin-top: 8px;
    border-radius: 12px;
  }

  .order-detail-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .order-detail-package-header {
    padding: 10px;
  }

  .order-detail-package-items {
    padding: 8px;
  }

  .order-detail-item {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .order-detail-thumb,
  .order-detail-thumb-empty {
    width: 86px;
  }

  .order-detail-price {
    grid-column: 2;
  }

  .order-detail-totals {
    justify-content: stretch;
  }

  .order-detail-totals div {
    grid-template-columns: 1fr auto;
  }

  .order-detail-customer-download {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .order-detail-customer-download .order-detail-download-actions {
    justify-content: flex-start;
  }

  .source-badge {
    justify-content: center;
  }

  .source-cell-stack {
    justify-items: center;
  }

  .source-type-label {
    font-size: 12px;
  }
}
