/* Shared tablet workspace: full-width content, touch targets and scrollable data. */
.shell, #app, .card, .settings-grid > *, .dashboard-grid > *, .lower-grid > *,
.account-grid > *, .master-grid > *, .form-grid > * { min-width: 0; }
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.button-group, .slot-actions, .form-actions { flex-wrap: wrap; }
.detail-row > *, .account-card h3, .settings-card p { overflow-wrap: anywhere; }
.slot-actions { display: flex; gap: 8px; }
.sidebar { height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
.login-page { min-height: 100dvh; }

@media (max-width: 1366px), (pointer: coarse) {
    body { font-size: 15px; }
    .btn, .btn.small { min-height: 44px; padding: 11px 14px; font-size: 13px; justify-content: center; }
    .icon-button, .notification { min-width: 44px; min-height: 44px; }
    .nav-item { min-height: 48px; font-size: 14px; }
    .field { font-size: 13px; }
    .field input, .field select, .field textarea, .filter-control input,
    .filter-control select, .reminder-copy { font-size: 16px; min-height: 46px; }
    .filter-control { min-height: 46px; font-size: 13px; }
    .subtitle, .card-head p, .detail-row, .account-dates, .account-dates strong,
    .report-tabs a, .settings-card p { font-size: 13px; }
    h2 { font-size: 17px; }
    h3 { font-size: 15px; }
    table, .full-table { font-size: 13px; }
    table th { font-size: 12px; }
    table th, table td { padding: 14px 16px; }
    table .btn { white-space: nowrap; }
    .slot-actions { min-width: 220px; max-width: 330px; }
    .slot-actions .btn { flex: 1 1 auto; }
    .slot-actions form { display: flex; flex: 1 1 auto; }
    .slot-actions form .btn { width: 100%; }
    summary { min-height: 44px; }
    .account-grid, .master-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .account-actions { grid-template-columns: 1fr; }
    .account-actions .btn { width: 100%; min-height: 48px; }
    .report-tabs { gap: 24px; overflow-x: auto; white-space: nowrap; }
    .report-tabs a { display: inline-flex; align-items: center; min-height: 48px; }
    .access-matrix input[type="checkbox"] { width: 24px; height: 24px; }
    .filters .field { flex: 1 1 170px; }
    .filter-group { flex-wrap: wrap; }
    .filter-control { max-width: 100%; }
    .filters .button-group { flex-wrap: wrap; }
    .customer-results { max-height: min(40dvh, 320px); }
    .switch-option { min-height: 52px; font-size: 14px; }
}

@media (max-width: 1200px) {
    .sidebar { width: 280px; max-width: calc(100vw - 56px); padding: 56px 18px env(safe-area-inset-bottom); transform: translateX(-100%); z-index: 40; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; position: absolute; top: 8px; right: 12px; }
    .sidebar .help-card { display: none; }
    .shell { margin-left: 0; }
    .scrim.show { display: block; position: fixed; inset: 0; background: #15221466; z-index: 39; }
    body:has(.sidebar.open) { overflow: hidden; }
    .topbar { height: 72px; padding: 0 24px; }
    .header-date { display: none; }
    main#app { padding: 26px 24px; }
    .page-heading { gap: 16px; flex-wrap: wrap; }
    .page-heading > .button-group { flex-direction: row; flex-wrap: wrap; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid, .lower-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
    .reminder-board { grid-template-columns: minmax(0, 1fr); }
    .filters { gap: 12px; }
    .filters .filter-group { width: 100%; }
    dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
    footer { flex-wrap: wrap; gap: 10px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
}

@media (max-width: 767px) {
    main#app { padding: 22px 16px; }
    .topbar { padding: 0 16px; }
    .header-right .demo-label { display: none; }
    .account-grid, .master-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2 { grid-column: 1; }
    .form-actions > .btn, .form-actions > form { flex: 1 1 auto; }
    .settings-card { padding: 20px; }
    .performance-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .demo-data-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-card { padding: 26px; }
}

/* Compact toolbars and shared form/pagination affordances. */
.filters { justify-content: flex-start; align-items: flex-end; gap: 12px; }
.filters .field { flex: 0 1 190px; min-width: 140px; }
.filters .field:has(input[name="q"]) { flex: 0 1 420px; min-width: 260px; }
.filters .filter-group { width: auto; flex: 0 1 auto; }
.filters .button-group { margin-left: 0; }
input[type="search"], input[name="q"] { width: 100%; }
.field:has(> input[type="search"]) { max-width: 680px; }
.password-control { position: relative; display: flex; width: 100%; align-items: stretch; min-width: 0; }
.password-control input { padding-right: 116px; min-width: 0; }
.password-toggle { position: absolute; right: 3px; top: 3px; bottom: 3px; padding: 0 12px; min-width: 72px; border: 0; border-radius: 6px; background: #edf4e8; color: #195d46; font: inherit; font-size: 12px; cursor: pointer; }
.password-toggle:focus-visible, .page-link:focus-visible { outline: 2px solid #195d46; outline-offset: 2px; }
.field-requirement { font-size: 10px; color: #6e766c; font-weight: 500; align-self: flex-start; }
.field-requirement.is-required { color: #a43a32; }
.crm-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin: 22px 0; padding: 16px 0; border-top: 1px solid var(--line); }
.pagination-summary { margin: 0; font-size: 13px; color: var(--muted); }
.pagination-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; color: #345041; font-size: 13px; text-decoration: none; }
.page-link:hover { background: #edf4e8; }
.page-link.current { background: var(--green); border-color: var(--green); color: white; font-weight: 700; }
.page-link.disabled { color: #8a9187; background: #f3f5f1; }
.page-position { display: none; font-size: 13px; color: var(--muted); padding: 0 8px; }
@media(max-width: 1200px) {
 .filters .field { flex: 0 1 180px; }
 .filters .field:has(input[name="q"]) { flex: 1 1 340px; max-width: 520px; }
 .filters .filter-group { width: auto; }
}
@media(max-width: 767px) {
 .filters .field { flex: 1 1 150px; }
 .filters .field:has(input[name="q"]) { flex-basis: 100%; min-width: 0; max-width: none; }
 .page-number { display: none; }
 .page-position { display: inline; }
 .pagination-controls { width: 100%; justify-content: space-between; }
}
.field-label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px; }
.field-requirement { display: inline-block; align-self: auto; font-size: 10px; padding: 2px 6px; border-radius: 4px; background: #f1f4ee; line-height: 1.3; }
.field-requirement.is-required { background: #fcf0ee; }
.slot-picker { min-width: 0; }
.slot-picker .switch-option { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; min-height: 48px; }
.slot-picker .customer-results { margin-top: 10px; }
.slot-picker .subtitle { margin-top: 8px; font-size: 12px; }
.dashboard-filters { align-items: center; justify-content: space-between; }
.dashboard-filters .dashboard-period { display: inline-flex; align-items: center; min-height: 46px; margin: 0; white-space: nowrap; font-size: 12px; }
.customer-overview { margin-bottom: 22px; }
.customer-section { margin-top: 24px; }
.customer-metric-help { margin: 14px 0 0; line-height: 1.7; font-size: 12px; color: var(--muted); }
.page-heading h1 { overflow-wrap: anywhere; }
@media(max-width:767px) { .dashboard-filters .dashboard-period { min-height: 0; } }
.customer-section table a { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
@media(min-width:1000px) { .customer-details-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }

/* Account directory: compact rows with touch-sized actions. */
.payment-proof-dialog { width: min(760px,calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 16px; box-sizing: border-box; }
.payment-proof-dialog::backdrop { background: #15221499; }
.payment-proof-dialog .modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.payment-proof-dialog h2 { margin: 0; font-size: 18px; }
.payment-proof-dialog [data-proof-view-status] { font-size: 13px; color: var(--muted); }
.payment-proof-image-wrap { display: flex; justify-content: center; }
.payment-proof-image-wrap img { max-width: 100%; height: auto; max-height: 65dvh; object-fit: contain; border-radius: 6px; }
.payment-proof-dialog .btn, .payment-proof-dialog .icon-button { min-height: 44px; }
.payment-proof-upload { margin-top: 22px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; }
.payment-proof-upload input[type=file] { width: 100%; min-height: 44px; padding: 10px; }
.payment-proof-upload .subtitle { font-size: 12px; line-height: 1.7; margin: 8px 0; }
.payment-proof-preview { display: block; max-width: min(100%,320px); max-height: 280px; object-fit: contain; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; }
.payment-proof-preview[hidden] { display: none; }
.approval-detail strong { overflow-wrap: anywhere; min-width: 0; max-width: 75%; }
.account-history { margin-top: 24px; }
.account-history-entry { padding: 0; border-top: 1px solid var(--line); }
.account-history > .subtitle { margin-bottom: 14px; font-size: 12px; }
.account-history-header { display: grid; grid-template-columns: minmax(0,1fr) auto 16px; align-items: center; gap: 16px; padding: 10px 0; min-height: 44px; cursor: pointer; list-style: none; }
.account-history-header::-webkit-details-marker { display: none; }
.account-history-header:hover { background: #f8faf5; }
.account-history-header:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }
.account-history-summary, .account-history-when { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.account-history-slot, .account-history-customer, .account-history-when, .account-history-note { color: var(--muted); }
.account-history-when { text-align: right; font-size: 11px; }
.account-history-chevron { color: var(--muted); text-align: center; }
.account-history-entry details[open] .account-history-chevron { transform: rotate(180deg); }
.account-history-expanded { padding: 2px 12px 14px; background: #f8faf5; border-radius: 6px; font-size: 12px; }
.account-history-note { font-size: 12px; line-height: 1.7; }
.account-history-entry p { margin: 12px 0 8px; line-height: 1.7; overflow-wrap: anywhere; }
.account-history-facts { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 12px; line-height: 1.8; }
.account-history-note { display: block; margin-top: 10px; }
.account-history-changes { margin: 12px 0; font-size: 12px; }
.account-history-changes > div { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 12px; padding: 8px 0; }
.account-history-changes dt { color: var(--muted); }
.account-history-changes dd { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; overflow-wrap: anywhere; }
@media(max-width:540px) {
    .account-history-changes > div { grid-template-columns: minmax(0,1fr); gap: 4px; }
    .account-history-header { grid-template-columns: minmax(0,1fr) 16px; gap: 4px 12px; }
    .account-history-summary { grid-column: 1; }
    .account-history-when { grid-column: 1; grid-row: 2; flex-direction: row; flex-wrap: wrap; gap: 4px 10px; text-align: left; }
    .account-history-chevron { grid-column: 2; grid-row: 1 / 3; }
}
.subscription-transaction-table { min-width: 960px; }
.subscription-transaction-table td { vertical-align: top; }
.subscription-transaction-table .log-secondary { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.subscription-transaction-table .log-date { white-space: nowrap; }
.template-editor > .field, .template-reminders > .field { margin-top: 22px; }
.template-editor textarea, .transaction-message-dialog textarea { width: 100%; min-width: 0; line-height: 1.7; font: inherit; resize: vertical; }
.template-help { font-size: 12px; color: var(--muted); line-height: 2.2; overflow-wrap: anywhere; }
.template-help code { display: inline-block; background: #eef2eb; padding: 0 6px; border-radius: 4px; }
.template-reminders { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 16px; }
.transaction-message-dialog { width: min(720px,calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid var(--line); border-radius: 18px; box-sizing: border-box; }
.transaction-message-dialog::backdrop { background: #15221488; }
.transaction-message-dialog .modal-header { align-items: flex-start; gap: 16px; }
.transaction-message-dialog .field { margin-top: 16px; }
.transaction-message-dialog .btn { min-height: 44px; }
.transaction-message-notice { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.account-view-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 0 14px; flex-wrap: wrap; }
.account-view-toolbar p { margin: 0; font-size: 14px; font-weight: 600; }
.account-view-toolbar p span { color: var(--muted); font-weight: 400; }
.account-view-switch { display: inline-flex; padding: 4px; gap: 4px; background: #eef2eb; border: 1px solid var(--line); border-radius: 12px; }
.account-view-switch a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 80px; padding: 8px 16px; border-radius: 8px; color: #52604f; text-decoration: none; font-size: 13px; font-weight: 600; }
.account-view-switch a.is-active { background: #fff; color: var(--green); box-shadow: 0 1px 4px #15221414; }
.account-list { padding: 0; overflow: hidden; }
.account-list-heading, .account-list-row { display: grid; grid-template-columns: minmax(180px,1.4fr) minmax(130px,.8fr) minmax(200px,1fr) minmax(210px,auto); align-items: center; gap: 20px; padding: 18px 22px; }
.account-list-heading { background: #f6f8f3; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.account-list-row + .account-list-row { border-top: 1px solid var(--line); }
.account-list-row:hover { background: #fafcf8; }
.account-list-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-list-identity > div { min-width: 0; }
.account-list-identity .platform-logo { flex-shrink: 0; width: 38px; height: 38px; }
.account-list-name { display: inline-block; font-size: 14px; font-weight: 700; color: #243b2c; text-decoration: none; overflow-wrap: anywhere; padding: 6px 0; }
.account-list-name:hover { text-decoration: underline; }
.account-list-identity p, .account-list-dates p { margin: 3px 0 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; line-height: 1.6; }
.account-list-stock { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.account-list-stock strong { font-size: 14px; }
.account-list-stock strong span { font-size: 12px; font-weight: 400; color: var(--muted); }
.account-list-dates > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.account-list-dates strong { font-size: 12px; white-space: nowrap; }
.account-list-actions { display: flex; align-items: center; gap: 8px; }
.account-list-actions .btn { min-height: 44px; padding: 10px 12px; font-size: 12px; white-space: nowrap; justify-content: center; }
.account-list-actions svg { width: 16px; height: 16px; }
.account-view-switch a:focus-visible, .account-list a:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
@media(max-width:1000px) {
    .account-list-heading { display: none; }
    .account-list-row { grid-template-columns: minmax(0,1fr) auto; gap: 14px 20px; }
    .account-list-identity { grid-column: 1; grid-row: 1; }
    .account-list-stock { grid-column: 2; grid-row: 1; align-items: flex-end; }
    .account-list-dates { grid-column: 1; grid-row: 2; }
    .account-list-actions { grid-column: 2; grid-row: 2; justify-content: flex-end; }
}
@media(max-width:540px) {
    .account-list-row { padding: 16px; gap: 16px 12px; }
    .account-list-identity .platform-logo { display: none; }
    .account-list-dates { grid-column: 1 / -1; }
    .account-list-actions { grid-column: 1 / -1; grid-row: 3; }
    .account-list-actions .btn { flex: 1; min-height: 48px; }
    .account-view-toolbar p span { display: block; margin-top: 4px; }
}
