/* ============================================================
   זבת חלב ודבש — מחולל הצעות מחיר
   Design system: warm cream surfaces, deep-gold serif headings,
   rose accent. Mobile-first, RTL.
   ============================================================ */

:root {
    --bg: #f9f6f4;
    --surface: #ffffff;
    --border: #e0e0e0;
    --ink: #333333;
    --muted: #616161;
    --placeholder: #6b7280;
    --brand: #735c00;
    --accent: #f06292;
    --accent-dark: #e84a7f;
    --green: #4caf50;
    --green-dark: #43a047;
    --red: #ff5252;
    --red-dark: #e53935;
    --amber: #f5a623;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --font-body: 'Heebo', -apple-system, sans-serif;
    --font-display: 'Frank Ruhl Libre', 'Liberation Serif', serif;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============ Top bar ============ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 8px 16px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-logo {
    height: 40px;
    width: auto;
    flex-shrink: 0;
}

.topbar-titles h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--brand);
    line-height: 1.2;
    white-space: nowrap;
}

.topbar-titles span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.topbar-nav {
    display: none;
    gap: 28px;
}

.nav-link {
    padding: 6px 0;
    color: var(--muted);
    text-decoration: none;
    font-size: 16px;
    font-family: var(--font-body);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.nav-link:hover {
    color: var(--brand);
}

.nav-link.active {
    color: var(--brand);
    font-weight: 700;
    border-bottom-color: var(--brand);
}

/* ============ Layout ============ */

.layout {
    max-width: 1440px;
    margin: 0 auto;
}

.content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 16px;
}

/* Side navigation — desktop only */
.sidenav {
    display: none;
}

.sidenav-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: var(--brand);
    padding: 24px 16px 16px;
}

.sidenav-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidenav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 16px;
    text-align: right;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.sidenav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidenav-link:hover {
    background: var(--bg);
}

.sidenav-link.active {
    background: var(--bg);
    color: var(--brand);
}

/* ============ Cards & sections ============ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 18px;
    color: var(--brand);
    margin-bottom: 20px;
}

.card-title svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

.subheading {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--brand);
    margin: 20px 0 12px;
}

.section-anchor {
    scroll-margin-top: 80px;
}

/* ============ Forms ============ */

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.field label,
label {
    color: var(--muted);
    font-size: 15px;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 16px; /* prevents iOS zoom-on-focus */
    color: var(--ink);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--placeholder);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(115, 92, 0, 0.12);
    background: var(--surface);
}

input.error,
textarea.error {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(255, 82, 82, 0.12);
}

textarea {
    resize: vertical;
    min-height: 110px;
}

.input-elevated {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 13px 17px;
}

.error-message {
    color: var(--red-dark);
    font-size: 13px;
}

.hidden {
    display: none !important;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Quote details */
.details-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.details-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.details-notes textarea {
    min-height: 130px;
}

/* Checkbox */
.checkbox-line,
.import-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* ============ Buttons ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    min-height: 44px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s, filter 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    filter: brightness(0.97);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-accent,
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 700;
}

.btn-accent:hover,
.btn-primary:hover {
    background: var(--accent-dark);
    filter: none;
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn-success:hover {
    background: var(--green-dark);
    filter: none;
}

.btn-danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.btn-danger:hover {
    background: var(--red-dark);
    filter: none;
}

.btn-info {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-warning {
    background: var(--amber);
    border-color: var(--amber);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--muted);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--ink);
}

.btn-icon {
    padding: 10px;
    min-width: 44px;
}

.btn-round {
    border-radius: 999px;
}

.btn-grow {
    flex: 1;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 16px;
    font-family: var(--font-display);
    font-size: 17px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

/* ============ Items section ============ */

.items-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.items-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.add-item-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.span-name,
.span-desc,
.span-actions {
    grid-column: 1 / -1;
}

.add-item-actions {
    display: flex;
    gap: 8px;
}

/* Library */
.library-card .card-title {
    margin-bottom: 16px;
}

.library-search {
    position: relative;
    margin-bottom: 18px;
}

.library-search-icon {
    position: absolute;
    top: 50%;
    right: 18px;
    transform: translateY(-50%);
    width: 21px;
    height: 21px;
    color: var(--brand);
    opacity: 0.65;
    pointer-events: none;
    transition: color 0.2s, opacity 0.2s;
}

.library-search:focus-within .library-search-icon {
    color: var(--accent);
    opacity: 1;
}

.library-search input {
    width: 100%;
    padding: 15px 50px;
    font-size: 16px;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.library-search input::placeholder {
    color: var(--placeholder);
}

.library-search input:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(240, 98, 146, 0.14), var(--shadow-sm);
}

.library-search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.library-search-clear {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--bg);
    border: none;
    border-radius: 50%;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.library-search-clear[hidden] {
    display: none;
}

.library-search-clear:hover {
    background: var(--accent);
    color: #fff;
}

.library-search-clear svg {
    width: 13px;
    height: 13px;
}

.search-empty {
    text-align: center;
    color: var(--placeholder);
    font-size: 14px;
    padding: 16px 0 4px;
}

.library-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
}

.library-list > p {
    color: var(--placeholder);
    text-align: center;
    padding: 16px 0;
}

.saved-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.saved-item:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-sm);
}

.saved-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.saved-item-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--ink);
    line-height: 1.35;
}

.saved-item-desc {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.saved-item-desc:empty {
    display: none;
}

.saved-item-meta {
    align-self: flex-start;
    margin-top: 4px;
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
    font-weight: 700;
    font-size: 13px;
    color: var(--brand);
    white-space: nowrap;
}

.saved-item-actions {
    display: flex;
    gap: 6px;
}

.saved-item-actions .btn {
    flex: 1;
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 6px;
}

.saved-item-actions .btn-success {
    flex: 1.4;
}

/* ============ Tables ============ */

.items-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.items-table thead {
    background: var(--bg);
}

.items-table th {
    padding: 12px 16px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--muted);
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.items-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    color: var(--ink);
    vertical-align: middle;
}

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

.items-table tbody tr:hover {
    background: rgba(249, 246, 244, 0.6);
}

.items-table td[colspan] {
    text-align: center;
    color: var(--muted);
    padding: 48px 16px;
}

.items-table .btn {
    min-height: 30px;
}

.actions-column {
    white-space: nowrap;
}

/* Mobile: stack table rows as label/value cards (script.js emits
   plain <td>s in fixed column order, so labels come from CSS) */
@media (max-width: 767px) {
    .items-table thead {
        display: none;
    }

    .items-table tr {
        display: block;
        padding: 10px 0;
        border-bottom: 1px solid var(--border);
    }

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

    .items-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 5px 16px;
        border-bottom: none;
        text-align: left;
    }

    .items-table td::before {
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 14px;
        color: var(--muted);
        flex-shrink: 0;
    }

    #items-tbody td:nth-child(1)::before { content: "מנה/מוצר"; }
    #items-tbody td:nth-child(2)::before { content: "תיאור"; }
    #items-tbody td:nth-child(3)::before { content: "כמות"; }
    #items-tbody td:nth-child(4)::before { content: "מחיר יח'"; }
    #items-tbody td:nth-child(5)::before { content: "סה\"כ"; }
    #items-tbody td:nth-child(6)::before { content: "פעולות"; }

    #extra-services-list td:nth-child(1)::before { content: "שם השירות"; }
    #extra-services-list td:nth-child(2)::before { content: "תיאור"; }
    #extra-services-list td:nth-child(3)::before { content: "מחיר"; }
    #extra-services-list td:nth-child(4)::before { content: "פעולות"; }

    /* Empty-state row (single td with colspan) stays a plain message */
    .items-table td:only-child {
        display: block;
        text-align: center;
    }

    .items-table td:only-child::before {
        content: none !important;
    }
}

/* ============ Services ============ */

.service-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: end;
    margin-bottom: 20px;
}

.service-name {
    grid-column: 1 / -1;
}

.service-form .btn-round {
    justify-self: start;
}

.services-chips {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
}

.services-chips .saved-item {
    flex: 1 1 100%;
}

/* ============ Summary & export ============ */

.summary-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.totals-card {
    position: relative;
    overflow: hidden;
    padding: 32px;
    border-radius: 16px;
    background: linear-gradient(135deg, #e1bee7 0%, #f06292 100%);
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.totals-watermark {
    position: absolute;
    bottom: -28px;
    left: -28px;
    width: 150px;
    height: 150px;
    opacity: 0.2;
    pointer-events: none;
}

.totals-rows {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.totals-label {
    font-family: var(--font-display);
    font-size: 16px;
    opacity: 0.9;
}

.totals-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 15px;
}

.totals-line > span:last-child {
    font-weight: 700;
}

.totals-discount-line label {
    color: #fff;
    font-size: 15px;
}

.discount-controls {
    display: flex;
    gap: 6px;
    margin-right: auto;
}

.discount-controls input,
.discount-controls select {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.45);
    color: #fff;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 15px;
    font-family: var(--font-body);
}

.discount-controls input {
    width: 84px;
    text-align: center;
}

.discount-controls input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.discount-controls select {
    width: 56px;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    cursor: pointer;
}

.discount-controls select option {
    color: var(--ink);
}

.discount-controls input:focus,
.discount-controls select:focus {
    outline: none;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.3);
}

.totals-amount {
    font-family: var(--font-display);
    font-size: 40px;
    line-height: 1.15;
    font-weight: 500;
}

.totals-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
    margin: 8px 0;
}

.totals-note {
    font-size: 13px;
    opacity: 0.85;
}

.export-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.export-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.export-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.export-tile svg {
    width: 24px;
    height: 24px;
    color: var(--brand);
}

.export-tile:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.export-tile:active {
    transform: scale(0.98);
}

.server-status {
    padding: 10px;
    background: #fff3cd;
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 12px;
    color: #856404;
}

/* ============ Advanced panels ============ */

.advanced-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.advanced-panel summary {
    padding: 16px 20px;
    cursor: pointer;
    color: var(--muted);
    font-size: 15px;
    user-select: none;
}

.advanced-panel summary:hover {
    color: var(--brand);
}

.advanced-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 20px 20px;
}

.import-panel {
    margin: 0 16px 24px;
}

.import-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.import-options label {
    margin-top: 0;
}

/* ============ Footer ============ */

.footer {
    margin-top: 32px;
    padding: 24px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 6px 0;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s;
}

.footer-link svg {
    width: 16px;
    height: 16px;
}

.footer-link:hover {
    color: var(--brand);
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 14px;
    color: var(--muted);
}

.footer-brand strong {
    font-family: var(--font-display);
    color: var(--brand);
    font-size: 16px;
}

/* ============ Tabs ============ */

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeUp 0.3s ease-out both;
}

.tab-next {
    display: flex;
    justify-content: flex-start;
    margin-top: 20px;
}

.tab-next .btn {
    min-width: 200px;
}

.library-tab-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.library-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.quote-table-header {
    padding: 20px 20px 0;
}

.quote-table-header .card-title {
    margin-bottom: 16px;
}

/* ============ Mobile bottom tab bar ============ */

.tabbar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: 90;
    display: flex;
    align-items: stretch;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

.tabbar-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s, background 0.2s;
}

.tabbar-btn svg {
    width: 22px;
    height: 22px;
}

.tabbar-btn.active {
    color: var(--brand);
    background: var(--bg);
    font-weight: 700;
}

.tabbar-total {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

/* Reserve space so the bar never covers content */
body {
    padding-bottom: 96px;
}

/* ============ Loading overlay & PDF sheet ============ */

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(51, 51, 51, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.loading-overlay[hidden] {
    display: none;
}

.loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 48px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.loading-box p {
    font-size: 16px;
    font-weight: 500;
    color: var(--ink);
}

.big-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--bg);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.pdf-sheet {
    position: fixed;
    inset: 0;
    z-index: 210;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.pdf-sheet[hidden] {
    display: none;
}

.pdf-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(51, 51, 51, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.pdf-sheet-panel {
    position: relative;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    animation: sheetUp 0.3s ease-out both;
}

@keyframes sheetUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.pdf-sheet-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8f5e9;
    border-radius: 50%;
    color: var(--green);
}

.pdf-sheet-icon svg {
    width: 30px;
    height: 30px;
}

.pdf-sheet-panel h3 {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--ink);
}

.pdf-sheet-panel p {
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
    margin-bottom: 8px;
}

/* On larger screens show the sheet as a centered dialog */
@media (min-width: 768px) {
    .pdf-sheet {
        align-items: center;
        padding: 24px;
    }

    .pdf-sheet-panel {
        border-radius: 20px;
        padding-bottom: 28px;
    }
}

/* ============ Loading / alerts ============ */

.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Entry animation */
.fade-in,
.card,
.summary-grid,
.items-grid {
    animation: fadeUp 0.45s ease-out both;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
    html { scroll-behavior: auto; }
}

/* ============================================================
   Tablet ≥ 768px
   ============================================================ */
@media (min-width: 768px) {
    .content {
        padding: 32px;
        gap: 32px;
    }

    .card {
        padding: 25px;
    }

    .topbar {
        padding: 8px 32px;
    }

    .topbar-nav {
        display: flex;
    }

    .items-table {
        min-width: 560px;
    }

    .field-row {
        flex-direction: row;
    }

    .details-grid {
        display: grid;
        grid-template-columns: 2fr 1fr; /* RTL: fields right, notes left */
        gap: 24px;
        align-items: start;
    }

    .add-item-grid {
        grid-template-columns: 2fr 3fr 1fr 1fr;
        align-items: end;
    }

    .span-name { grid-column: auto; }
    .span-desc { grid-column: auto; }
    .span-actions { grid-column: 1 / -1; }

    .add-item-actions {
        justify-content: flex-start;
    }

    .add-item-actions .btn-grow {
        flex: 0 0 auto;
        min-width: 160px;
    }

    .service-form {
        grid-template-columns: 2fr 2fr 1fr auto;
    }

    .service-name { grid-column: auto; }

    .services-chips .saved-item {
        flex: 0 1 calc(50% - 6px);
    }

    .summary-grid {
        display: grid;
        grid-template-columns: 5fr 7fr; /* RTL: totals right, export left */
        gap: 32px;
        align-items: start;
    }

    .footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 24px 32px;
    }

    .tabbar {
        display: none;
    }

    body {
        padding-bottom: 0;
    }

    .library-tab-grid {
        display: grid;
        grid-template-columns: 1fr 1fr; /* RTL: dishes right, services left */
        align-items: start;
        gap: 24px;
    }

    .quote-table-header {
        padding: 25px 25px 0;
    }

    .import-panel {
        margin: 0 32px 24px;
    }
}

/* ============================================================
   Desktop ≥ 1100px — side navigation appears
   ============================================================ */
@media (min-width: 1100px) {
    .layout {
        display: grid;
        grid-template-columns: 256px 1fr; /* RTL: sidenav right, content left */
        align-items: start;
    }

    .sidenav {
        display: block;
        position: sticky;
        top: 64px;
        height: calc(100vh - 64px);
        overflow-y: auto;
        padding: 16px;
        background: var(--surface);
        border-left: 1px solid var(--border);
    }

    .library-list {
        max-height: 560px;
    }

    .services-chips .saved-item {
        flex: 0 1 calc(33.333% - 8px);
    }
}
