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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.5;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 20px 0 30px;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
    color: #1d1d1f;
}

/* Panels */
.panel {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.panel h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1d1d1f;
}

/* Form elements */
.form-row {
    display: flex;
    gap: 16px;
}

.form-group {
    flex: 1;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #86868b;
    margin-bottom: 6px;
}

input[type="text"],
input[type="date"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

input[readonly] {
    background: #f5f5f7;
    color: #86868b;
}

/* Customer select */
.customer-select {
    display: flex;
    gap: 10px;
}

.customer-select select {
    flex: 1;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #0071e3;
    color: white;
}

.btn-primary:hover {
    background: #0077ed;
}

.btn-primary:disabled {
    background: #d2d2d7;
    cursor: not-allowed;
}

.btn-secondary {
    background: #e8e8ed;
    color: #1d1d1f;
}

.btn-secondary:hover {
    background: #d2d2d7;
}

/* Items list */
.items-list {
    margin-bottom: 20px;
    min-height: 100px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #86868b;
    font-size: 14px;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f5f5f7;
    border-radius: 8px;
    margin-bottom: 8px;
}

.item-info {
    flex: 1;
}

.item-description {
    font-weight: 500;
    font-size: 14px;
}

.item-details {
    font-size: 12px;
    color: #86868b;
    margin-top: 2px;
}

.item-quantity {
    width: 70px;
}

.item-quantity input {
    text-align: center;
    padding: 6px;
}

.item-price,
.item-total {
    width: 110px;
    text-align: right;
    font-size: 14px;
    font-family: "SF Mono", Monaco, monospace;
}

.item-price .currency,
.item-total .currency {
    color: #86868b;
    font-size: 12px;
    margin-right: 4px;
}

.btn-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: #ff3b30;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.btn-remove:hover {
    background: #ff453a;
}

.add-item-section {
    display: flex;
    gap: 10px;
}

/* Totals */
.totals-panel {
    /* Removed sticky positioning - was causing overlap */
}

.totals {
    margin-bottom: 20px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.total-row .amount {
    font-family: "SF Mono", Monaco, monospace;
}

.total-row .currency {
    color: #86868b;
    font-size: 12px;
    margin-right: 4px;
}

.total-final {
    font-size: 18px;
    font-weight: 600;
    border-top: 2px solid #1d1d1f;
    margin-top: 8px;
    padding-top: 12px;
}

/* SRD Conversion Section */
.srd-conversion {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.srd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ced4da;
}

.srd-header span:first-child {
    font-weight: 600;
    font-size: 14px;
    color: #495057;
}

.exchange-rate {
    font-size: 12px;
    color: #6c757d;
    background: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-family: "SF Mono", Monaco, monospace;
}

.exchange-rate.loading {
    color: #adb5bd;
}

.exchange-rate.error {
    color: #dc3545;
    background: #fff5f5;
}

.exchange-rate.fallback {
    color: #fd7e14;
    background: #fff8e1;
}

.srd-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    color: #495057;
}

.srd-row .amount {
    font-family: "SF Mono", Monaco, monospace;
}

.srd-row .currency {
    color: #6c757d;
    font-size: 11px;
    margin-right: 4px;
}

.srd-rate-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.srd-rate-input label {
    font-size: 12px;
    color: #6c757d;
}

.srd-rate-input input {
    width: 80px;
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, monospace;
}

.srd-rate-input input:focus {
    outline: none;
    border-color: #0071e3;
}

.btn-apply-rate,
.btn-reset-rate {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-apply-rate {
    background: #0071e3;
    color: white;
}

.btn-apply-rate:hover {
    background: #0077ed;
}

.btn-reset-rate {
    background: #6c757d;
    color: white;
}

.btn-reset-rate:hover {
    background: #5a6268;
}

.exchange-rate.manual {
    color: #0071e3;
    background: #e7f3ff;
}

.btn-generate {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    background: #34c759;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-generate:hover {
    background: #30d158;
}

.btn-generate:disabled {
    background: #d2d2d7;
    cursor: not-allowed;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-large {
    max-width: 800px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Catalog browser */
.catalog-browser {
    display: grid;
    grid-template-columns: 120px 200px 1fr;
    gap: 16px;
    min-height: 400px;
}

.catalog-categories,
.catalog-products,
.catalog-config {
    background: #f5f5f7;
    border-radius: 10px;
    padding: 12px;
    overflow-y: auto;
}

.category-btn,
.product-btn {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.category-btn:hover,
.product-btn:hover {
    border-color: #0071e3;
}

.category-btn.active,
.product-btn.active {
    background: #0071e3;
    color: white;
    border-color: #0071e3;
}

.product-name {
    font-weight: 500;
    font-size: 13px;
}

.product-price {
    font-size: 11px;
    color: #86868b;
    margin-top: 2px;
}

.product-btn.active .product-price {
    color: rgba(255,255,255,0.8);
}

.hint {
    text-align: center;
    padding: 20px;
    color: #86868b;
    font-size: 13px;
}

/* Config section */
.config-section {
    margin-bottom: 16px;
}

.config-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: #86868b;
    margin-bottom: 10px;
}

.config-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-btn {
    padding: 10px 12px;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.config-btn:hover {
    border-color: #0071e3;
}

.config-btn.active {
    background: #0071e3;
    color: white;
    border-color: #0071e3;
}

.config-spec {
    font-size: 12px;
    font-weight: 500;
}

.config-price {
    font-size: 11px;
    color: #86868b;
    margin-top: 2px;
}

.config-btn.active .config-price {
    color: rgba(255,255,255,0.8);
}

.color-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-btn {
    padding: 8px 14px;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-btn:hover {
    border-color: #0071e3;
}

.color-btn.active {
    background: #0071e3;
    color: white;
    border-color: #0071e3;
}

/* Header nav */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

header nav {
    display: flex;
    gap: 16px;
}

.btn-link {
    background: none;
    border: none;
    color: #0071e3;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Additional button styles */
.btn-danger {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #ff3b30;
    color: white;
}

.btn-danger:hover {
    background: #ff453a;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #86868b;
    padding: 0;
    line-height: 1;
}

.btn-close:hover {
    color: #1d1d1f;
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-remove-small {
    width: 24px;
    height: 24px;
    border: none;
    background: #ff3b30;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
}

.spacer {
    flex: 1;
}

/* Modal sizes */
.modal-medium {
    max-width: 500px;
}

.modal-xlarge {
    max-width: 1000px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin-bottom: 0;
}

/* Product Management Layout */
.products-layout {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.products-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.products-category-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
}

.pm-category-btn {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    transition: all 0.2s;
}

.pm-category-btn:hover {
    border-color: #0071e3;
}

.pm-category-btn.active {
    background: #0071e3;
    color: white;
    border-color: #0071e3;
}

.products-main {
    overflow-y: auto;
    background: #f5f5f7;
    border-radius: 10px;
    padding: 12px;
}

.products-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pm-product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.pm-product-item:hover {
    border-color: #0071e3;
}

.pm-product-info {
    flex: 1;
}

.pm-product-name {
    font-weight: 500;
    font-size: 14px;
}

.pm-product-category {
    font-size: 12px;
    color: #86868b;
}

.pm-product-price {
    font-family: "SF Mono", Monaco, monospace;
    font-size: 13px;
    color: #1d1d1f;
}

.products-editor {
    display: none;
}

.editor-placeholder {
    text-align: center;
    padding: 40px;
    color: #86868b;
}

/* Variations editor */
.variations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.variation-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.variation-spec {
    flex: 2;
}

.variation-price {
    flex: 1;
    max-width: 120px;
}

/* Customer Management */
.customers-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    min-height: 300px;
}

.customers-list {
    background: #f5f5f7;
    border-radius: 10px;
    padding: 12px;
    overflow-y: auto;
}

.cm-customer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    margin-bottom: 8px;
}

.cm-customer-item:hover {
    border-color: #0071e3;
}

.cm-customer-name {
    font-weight: 500;
    font-size: 14px;
}

.cm-customer-initials {
    font-family: "SF Mono", Monaco, monospace;
    font-size: 13px;
    color: #86868b;
    background: #e8e8ed;
    padding: 4px 8px;
    border-radius: 4px;
}

.customers-editor {
    background: #f5f5f7;
    border-radius: 10px;
    padding: 20px;
}

.modal-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #d2d2d7;
}

.modal-small {
    max-width: 360px;
}

/* Account rows */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.account-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.account-name {
    flex: 1;
}

.account-number {
    flex: 1;
}

/* Logo preview */
.logo-preview {
    width: 100%;
    height: 100px;
    background: #f5f5f7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    overflow: hidden;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-preview .no-logo {
    color: #86868b;
    font-size: 13px;
}

/* Settings Form */
.settings-form {
    max-height: 60vh;
    overflow-y: auto;
}

.settings-form h4 {
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 20px 0 12px;
    padding-top: 12px;
    border-top: 1px solid #e8e8ed;
}

.settings-form h4:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

input[type="email"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="email"]:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

/* Header with company switcher */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-switcher select {
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    background: white;
    color: #1d1d1f;
    cursor: pointer;
    font-weight: 500;
}

.company-switcher select:focus {
    outline: none;
    border-color: #0071e3;
}

.company-switcher.hidden {
    display: none;
}

/* Accounts selection */
.accounts-selection {
    margin-bottom: 20px;
    padding-top: 16px;
    border-top: 1px solid #e5e5e5;
}

.accounts-selection > label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #86868b;
    margin-bottom: 12px;
}

.accounts-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bank-select-all {
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 8px;
}

.bank-select-all label {
    font-weight: 600;
    color: #1d1d1f;
}

.bank-group {
    padding: 8px 0;
}

.bank-header label {
    font-weight: 500;
    color: #1d1d1f;
}

.bank-accounts {
    margin-left: 20px;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.account-checkbox-label {
    font-size: 13px;
    color: #424245;
    cursor: pointer;
}

.account-checkbox-label:hover {
    color: #1d1d1f;
}

.accounts-checkboxes input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.no-accounts {
    color: #86868b;
    font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
    .catalog-browser {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .item-row {
        flex-wrap: wrap;
    }

    .item-info {
        width: 100%;
        margin-bottom: 8px;
    }

    .products-layout {
        grid-template-columns: 1fr;
    }

    .customers-layout {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
        gap: 8px;
    }
}
