/* ==========================================================================
   Sai Kripa Enterprises Billing Application - Apple HIG Design System
   Crafted in accordance with Apple's Human Interface Guidelines (Foundations & Craft)
   San Francisco Typography, Dynamic Type Scales, Tabular Figures, Inset Grouping,
   and Adaptive Light/Dark Mode.
   ========================================================================== */

:root {
    /* Apple Dynamic System Colors (Light Appearance) */
    --system-background: #ffffff;
    --system-grouped-background: #f2f2f7;
    --secondary-system-grouped-background: #ffffff;
    --tertiary-system-grouped-background: #ffffff;

    --surface-elevated: #ffffff;
    --separator: #e5e5ea;
    --separator-opaque: #c6c6c8;
    --hairline: rgba(60, 60, 67, 0.12);

    /* Apple System Labels */
    --label: #1c1c1e;
    --secondary-label: #636366;
    --tertiary-label: #8e8e93;
    --quaternary-label: #aeaeb2;

    /* Apple System Accent & Tints */
    --system-blue: #007aff;
    --system-blue-hover: #0062cc;
    --system-blue-tint: #eff6ff;

    --system-green: #34c759;
    --system-green-tint: #eafaf1;
    --system-green-text: #1d7e3a;

    --system-orange: #ff9500;
    --system-orange-tint: #fff8eb;
    --system-orange-text: #9e5b00;

    --system-red: #ff3b30;
    --system-red-tint: #feeeee;
    --system-red-text: #b3261e;

    --system-indigo: #5856d6;
    --system-indigo-tint: #f0f0fd;
    --system-indigo-text: #413ea0;

    --system-teal: #30b0c7;

    /* Apple Continuous Squircles & Radii */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 9999px;

    /* Apple Subtle Shadows */
    --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Dimensions */
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --tabbar-height: 60px;
}

/* Dark Appearance Support (Apple HIG `dark-mode.md`) */
@media (prefers-color-scheme: dark) {
    :root {
        --system-background: #000000;
        --system-grouped-background: #1c1c1e;
        --secondary-system-grouped-background: #2c2c2e;
        --tertiary-system-grouped-background: #3a3a3c;

        --surface-elevated: #2c2c2e;
        --separator: #38383a;
        --separator-opaque: #48484a;
        --hairline: rgba(235, 235, 245, 0.15);

        --label: #ffffff;
        --secondary-label: #aeaeb2;
        --tertiary-label: #8e8e93;
        --quaternary-label: #636366;

        --system-blue: #0a84ff;
        --system-blue-hover: #409cff;
        --system-blue-tint: rgba(10, 132, 255, 0.15);

        --system-green: #30d158;
        --system-green-tint: rgba(48, 209, 88, 0.15);
        --system-green-text: #30d158;

        --system-orange: #ff9f0a;
        --system-orange-tint: rgba(255, 159, 10, 0.15);
        --system-orange-text: #ff9f0a;

        --system-red: #ff453a;
        --system-red-tint: rgba(255, 69, 58, 0.15);
        --system-red-text: #ff453a;

        --system-indigo: #5e5ce6;
        --system-indigo-tint: rgba(94, 92, 230, 0.15);
        --system-indigo-text: #7d7aff;

        --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "SF Pro", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.47059;
    letter-spacing: -0.011em;
    color: var(--label);
    background-color: var(--system-grouped-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Tabular figures for all currency numbers and data grids */
.tabular-nums,
.table td,
.metric-value,
.tax-number,
.badge {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* Focus visibility for accessibility (HIG `focus-and-selection.md`) */
:focus-visible {
    outline: 2px solid var(--system-blue);
    outline-offset: 2px;
}

/* Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* macOS-Style Sidebar (HIG `sidebars.md`) */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--secondary-system-grouped-background);
    border-right: 1px solid var(--separator);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid var(--hairline);
}

.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--system-blue), #2b5cf6);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 122, 255, 0.25);
}

.brand-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--label);
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--secondary-label);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 0.85rem 0.65rem;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tertiary-label);
    padding: 0.65rem 0.75rem 0.35rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    color: var(--secondary-label);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
    color: var(--label);
    background-color: var(--hairline);
}

.nav-link.active {
    color: var(--system-blue);
    background-color: var(--system-blue-tint);
    font-weight: 600;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-icon-svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.85;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s ease, stroke 0.15s ease;
}

.nav-link:hover .nav-icon-svg {
    transform: scale(1.06);
}

.nav-link.active .nav-icon-svg {
    stroke: var(--system-blue);
    stroke-width: 2.1;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar / Navigation Bar (HIG `toolbars.md`) */
.topbar {
    height: var(--topbar-height);
    background-color: var(--surface-elevated);
    border-bottom: 1px solid var(--separator);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.content-body {
    padding: 1.75rem 2rem;
    flex: 1;
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
}

/* Apple Typography Headers (HIG `typography.md`) */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--label);
    line-height: 1.2;
}

.page-description {
    font-size: 0.85rem;
    color: var(--secondary-label);
    margin-top: 0.2rem;
}

/* Inset Grouped Cards (HIG `lists-and-tables.md`) */
.card {
    background-color: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    box-shadow: var(--shadow-subtle);
    margin-bottom: 1.5rem;
    position: relative;
}

.card-allow-overflow,
.card.card-allow-overflow {
    overflow: visible !important;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.card-title {
    font-size: 0.975rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--label);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--hairline);
    background-color: var(--system-grouped-background);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

/* Apple Metrics Summary Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background-color: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-subtle);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric-card:hover {
    box-shadow: var(--shadow-card);
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--secondary-label);
    margin-bottom: 0.4rem;
}

.metric-value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--label);
    line-height: 1.15;
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--tertiary-label);
    margin-top: 0.4rem;
    font-weight: 500;
}

/* Metric Tints */
.metric-card.metric-success .metric-value { color: var(--system-green-text); }
.metric-card.metric-warning .metric-value { color: var(--system-orange-text); }
.metric-card.metric-danger .metric-value  { color: var(--system-red-text); }
.metric-card.metric-info .metric-value    { color: var(--system-blue); }

/* Apple Segmented Controls (HIG `segmented-controls.md`) */
.segmented-control {
    display: inline-flex;
    background-color: var(--separator);
    padding: 3px;
    border-radius: var(--radius-sm);
    gap: 2px;
}

.segmented-control a,
.segmented-control button {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--secondary-label);
    text-decoration: none;
    border-radius: var(--radius-xs);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.12s ease;
    white-space: nowrap;
}

.segmented-control a.active,
.segmented-control button.active {
    background-color: var(--surface-elevated);
    color: var(--label);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Tables (HIG `lists-and-tables.md`) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.table th {
    background-color: var(--secondary-system-grouped-background);
    color: var(--secondary-label);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--separator);
    white-space: nowrap;
}

.table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--hairline);
    color: var(--label);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: var(--hairline);
}

.table-condensed th, .table-condensed td {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }

/* Apple Status Badges & Pills (HIG `labels.md`) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.badge-paid {
    background-color: var(--system-green-tint);
    color: var(--system-green-text);
}

.badge-partially_paid {
    background-color: var(--system-indigo-tint);
    color: var(--system-indigo-text);
}

.badge-pending {
    background-color: var(--system-orange-tint);
    color: var(--system-orange-text);
}

.badge-inactive {
    background-color: var(--separator);
    color: var(--secondary-label);
}

/* Apple Buttons (HIG `buttons.md`) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    min-height: 36px;
}

.btn-primary {
    background-color: var(--system-blue);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--system-blue-hover);
}

.btn-secondary {
    background-color: var(--surface-elevated);
    color: var(--label);
    border-color: var(--separator-opaque);
}

.btn-secondary:hover {
    background-color: var(--hairline);
}

.btn-danger {
    background-color: var(--system-red);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #d73329;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.775rem;
    min-height: 28px;
    border-radius: var(--radius-xs);
}

/* Preset Pill Buttons for Quantity & Weight Variants */
.preset-pill-btn {
    appearance: none;
    background: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius-pill);
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--label);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.2;
}

.preset-pill-btn:hover {
    border-color: var(--system-blue);
    color: var(--system-blue);
    background: var(--system-blue-tint);
}

.preset-pill-btn.active {
    background: var(--system-blue);
    border-color: var(--system-blue);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 122, 255, 0.35);
}

/* ==========================================================================
   Apple HIG Pagination & Lazyload Components
   ========================================================================== */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.85rem;
    padding: 0.85rem 1.25rem;
    background-color: var(--surface-elevated);
    border-top: 1px solid var(--separator);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.82rem;
    color: var(--secondary-label);
}

.pagination-info strong {
    color: var(--label);
    font-weight: 600;
}

.pagination-per-page {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--secondary-label);
}

.per-page-select {
    appearance: none;
    background: var(--surface-elevated) url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 0.5rem center / 11px;
    border: 1px solid var(--separator);
    border-radius: var(--radius-xs);
    padding: 3px 1.5rem 3px 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--label);
    cursor: pointer;
    outline: none;
}

.per-page-select:focus {
    border-color: var(--system-blue);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pagination-nav {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.45rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--label);
    text-decoration: none;
    border-radius: var(--radius-xs);
    border: 1px solid var(--separator);
    background-color: var(--surface-elevated);
    transition: all 0.12s ease;
}

.pagination-link:hover:not(.disabled):not(.active) {
    border-color: var(--system-blue);
    color: var(--system-blue);
    background-color: var(--system-blue-tint);
}

.pagination-link.active {
    background-color: var(--system-blue);
    border-color: var(--system-blue);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 122, 255, 0.25);
}

.pagination-link.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
    background-color: transparent;
}

.pagination-ellipsis {
    padding: 0 0.3rem;
    color: var(--tertiary-label);
    font-size: 0.8rem;
}

.lazyload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.lazyload-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Forms & Text Entry (HIG `entering-data.md` & `text-fields.md`) */
.form-group {
    margin-bottom: 1.15rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.form-label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--secondary-label);
    margin-bottom: 0.35rem;
}

.form-label .required {
    color: var(--system-red);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    color: var(--label);
    background-color: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--system-blue);
    box-shadow: 0 0 0 3px var(--system-blue-tint);
}

.form-text {
    font-size: 0.75rem;
    color: var(--tertiary-label);
    margin-top: 0.3rem;
}

/* Alerts & Inline Banners (HIG `feedback.md`) */
.alert {
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background-color: var(--system-green-tint);
    color: var(--system-green-text);
    border: 1px solid rgba(52, 199, 89, 0.25);
}

.alert-danger {
    background-color: var(--system-red-tint);
    color: var(--system-red-text);
    border: 1px solid rgba(255, 59, 48, 0.25);
}

.alert-warning {
    background-color: var(--system-orange-tint);
    color: var(--system-orange-text);
    border: 1px solid rgba(255, 149, 0, 0.25);
}

.alert-info {
    background-color: var(--system-blue-tint);
    color: var(--system-blue);
    border: 1px solid rgba(0, 122, 255, 0.25);
}

/* Modals & Dialog Sheets (HIG `sheets.md` & `modality.md`) */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.25rem 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-backdrop.show {
    display: flex;
}

.modal-dialog {
    background-color: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 2.5rem);
    display: flex;
    flex-direction: column;
    margin: auto;
    overflow: hidden;
    position: relative;
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog > form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2.5rem);
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background-color: var(--surface-elevated);
    z-index: 2;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--label);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--tertiary-label);
    padding: 0.25rem;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.modal-close:hover {
    color: var(--label);
}

.modal-body {
    padding: 1.25rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 999px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.32);
}

.modal-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--hairline);
    background-color: var(--system-grouped-background);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    z-index: 2;
}

/* ==========================================================================
   Apple HIG Product Variant Combobox & Popover Dropdown
   ========================================================================== */
.product-picker-wrapper,
.autocomplete-wrapper {
    position: relative;
    overflow: visible;
}

.product-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.product-search-box:focus-within {
    border-color: var(--system-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18);
}

.product-search-icon {
    position: absolute;
    left: 10px;
    font-size: 0.8rem;
    color: var(--tertiary-label);
    pointer-events: none;
    user-select: none;
}

.item-search-input {
    width: 100%;
    padding: 0.55rem 2.2rem 0.55rem 2.1rem !important;
    border: none !important;
    background: transparent !important;
    font-size: 0.88rem;
    color: var(--label);
    outline: none !important;
    box-shadow: none !important;
}

.product-clear-btn {
    position: absolute;
    right: 24px;
    background: var(--tertiary-label);
    color: var(--system-background);
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.product-clear-btn:hover {
    background: var(--secondary-label);
}

.product-chevron {
    position: absolute;
    right: 10px;
    font-size: 0.7rem;
    color: var(--tertiary-label);
    pointer-events: none;
    transition: transform 0.2s ease;
}

.product-search-box.open .product-chevron {
    transform: rotate(180deg);
}

/* Floating Apple HIG Popover for Product Selection */
.autocomplete-dropdown,
.product-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 380px;
    width: 100%;
    max-width: 520px;
    background: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14), 0 4px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: dropdownPop 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 4px;
}

.autocomplete-item,
.product-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border-bottom: 1px solid var(--hairline);
    transition: background-color 0.12s ease;
}

.autocomplete-item:last-child,
.product-dropdown-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted,
.product-dropdown-item:hover,
.product-dropdown-item.highlighted {
    background-color: var(--system-blue-tint);
}

.product-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--system-teal), #2b5cf6);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.product-info,
.autocomplete-info {
    flex: 1;
    min-width: 0;
}

.product-title,
.autocomplete-title {
    font-weight: 600;
    color: var(--label);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-meta,
.autocomplete-meta {
    font-size: 0.74rem;
    color: var(--secondary-label);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-extra {
    text-align: right;
    flex-shrink: 0;
}

.product-price {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--system-blue);
    font-variant-numeric: tabular-nums;
}

/* Public Customer Invoice View (Apple Digital Receipt) */
.public-invoice-container {
    max-width: 840px;
    margin: 2.5rem auto;
    padding: 0 1rem;
}

.public-invoice-card {
    background-color: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.public-invoice-header {
    background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
    color: #ffffff;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.public-invoice-body {
    padding: 2rem;
}

/* Mobile Responsiveness (HIG `layout.md`) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .content-body {
        padding: 1.25rem 1rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .public-invoice-header, .public-invoice-body {
        padding: 1.25rem;
    }
}

/* ==========================================================================
   Apple HIG Searchable Customer Combobox & Dropdown
   ========================================================================== */
.customer-combobox-group {
    position: relative;
    z-index: 100;
}

.customer-picker-wrapper {
    position: relative;
    overflow: visible;
}

.customer-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.customer-search-box:focus-within {
    border-color: var(--system-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18);
}

.customer-search-icon {
    position: absolute;
    left: 12px;
    font-size: 0.85rem;
    color: var(--tertiary-label);
    pointer-events: none;
    user-select: none;
}

.customer-search-field {
    width: 100%;
    padding: 0.65rem 2.25rem 0.65rem 2.25rem !important;
    border: none !important;
    background: transparent !important;
    font-size: 0.925rem;
    color: var(--label);
    outline: none !important;
    box-shadow: none !important;
}

.customer-clear-btn {
    position: absolute;
    right: 28px;
    background: var(--tertiary-label);
    color: var(--system-background);
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.customer-clear-btn:hover {
    background: var(--secondary-label);
}

.customer-chevron {
    position: absolute;
    right: 12px;
    font-size: 0.75rem;
    color: var(--tertiary-label);
    pointer-events: none;
    transition: transform 0.2s ease;
}

.customer-search-box.open .customer-chevron {
    transform: rotate(180deg);
}

/* Floating Apple HIG Dropdown Menu */
.customer-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface-elevated);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 99999;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    animation: dropdownPop 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownPop {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.customer-results-list {
    overflow-y: auto;
    padding: 6px;
    max-height: 280px;
}

.customer-dropdown-divider {
    height: 1px;
    background: var(--hairline);
    margin: 2px 0;
}

.customer-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.customer-dropdown-item:hover,
.customer-dropdown-item.highlighted {
    background: var(--system-blue-tint);
}

.customer-dropdown-item.walkin-item {
    background: var(--system-grouped-background);
    margin: 4px;
}

.customer-dropdown-item.walkin-item:hover,
.customer-dropdown-item.walkin-item.highlighted {
    background: var(--system-blue-tint);
}

.customer-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--system-blue), #2b5cf6);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.walkin-avatar {
    background: linear-gradient(135deg, #8e8e93, #636366);
    font-size: 0.95rem;
}

.customer-info {
    flex: 1;
    min-width: 0;
}

.customer-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-meta {
    font-size: 0.76rem;
    color: var(--secondary-label);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-extra {
    text-align: right;
    flex-shrink: 0;
}

.customer-dropdown-footer {
    padding: 8px 10px;
    background: var(--system-grouped-background);
    border-top: 1px solid var(--hairline);
}

.btn-quick-add-footer {
    width: 100%;
    padding: 7px 12px;
    background: transparent;
    border: 1px dashed var(--system-blue);
    border-radius: var(--radius-sm);
    color: var(--system-blue);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.15s ease;
}

.btn-quick-add-footer:hover {
    background: var(--system-blue-tint);
}

/* Selected Customer Card (Apple HIG Inset Grouped Pill) */
.selected-customer-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.15rem;
    background: var(--system-grouped-background);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    gap: 1rem;
    animation: fadeIn 0.2s ease;
}

.selected-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
}

