* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --white: #ffffff;
    --bg-main: #f5f5f5;
    --bg-card: rgba(255, 255, 255, 0.95);
    --border: #e0e0e0;
    --border-light: #ececec;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #888888;
    --accent: #5a6c7d;
    --accent-hover: #4a5c6d;
    --accent-light: #f0f2f4;
    --blue-accent: #3d96e8;
    --blue-accent-hover: #5ba5ec;
    --blue-light: rgba(61, 150, 232, 0.08);
    --blue-bg: rgba(61, 150, 232, 0.12);
    --warning: #d4a03c;
    --warning-bg: rgba(212, 160, 60, 0.1);
    --error: #dc3545;
    --error-bg: rgba(255, 229, 232, 0.9);
    --error-border: #ff6b7a;
    --radius: 8px;
    --radius-sm: 6px;
    --transition: all 0.15s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-main);
    min-height: 100vh;
    padding: 20px;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

/* Карточки - минималистичный дизайн */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 0;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.card.error-state {
    border: 2px solid var(--error-border);
    background: var(--error-bg);
}

.main-card {
    padding: 24px;
}

.rates-card {
    padding: 20px;
}

.compact-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title-with-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

.error-message {
    padding: 12px 16px;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 13px;
    font-weight: 600;
    margin-top: 12px;
    line-height: 1.5;
}

.error-message strong {
    display: block;
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.compact label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Инпуты - контрастные */
.select-input,
.text-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--white);
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
    font-weight: 500;
}

.select-input:focus,
.text-input:focus {
    outline: none;
    border-color: var(--blue-accent);
    background: var(--white);
}

.select-input:disabled {
    background: #f8f8f8;
    color: var(--text-muted);
    cursor: not-allowed;
}

.text-input::placeholder {
    color: var(--text-muted);
}

/* Кнопки - минималистичные */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.btn-icon:hover:not(:disabled) {
    color: var(--blue-accent);
    border-color: var(--blue-accent);
    background: var(--blue-light);
}

.btn-icon:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-steps {
    padding: 8px 16px;
    background: var(--white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-steps:hover {
    background: var(--blue-accent-hover);
    color: var(--white);
    border-color: var(--blue-accent-hover);
}

.btn-steps:active {
    transform: translateY(1px);
}

/* Информационные блоки */
.customer-info {
    padding: 14px;
    background: #fafafa;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid var(--border-light);
}

.customer-info .placeholder-text {
    color: var(--text-muted);
    font-style: italic;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.info-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-row:first-child {
    padding-top: 0;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
}

.info-value {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 13px;
}

.additional-conditions {
    color: #28a745 !important;
    font-weight: 700 !important;
}

.recommended-mup {
    color: #28a745 !important;
    font-weight: 700;
}

.exception-badge {
    display: inline-block;
    padding: 5px 10px;
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    color: var(--warning);
    font-size: 11px;
    font-weight: 700;
    margin-top: 8px;
}

/* Результаты - контрастные */
.result-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fafafa;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

/* Приглушенный синий фон для итоговой строки */
.result-row.total {
    background: var(--blue-bg);
    border: 2px solid var(--blue-accent);
    font-weight: 700;
}

.result-row .label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.result-row.total .label {
    color: #0057b3;
    font-weight: 700;
}

.result-row .value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.result-row.total .value {
    font-size: 17px;
    color: #009e2f;
    font-weight: 700;
}

.details-info {
    margin-top: 8px;
    padding: 12px 16px;
    background: #fafafa;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    border: 1px solid var(--border-light);
}

.calc-steps {
    margin-top: 12px;
    padding: 16px;
    background: var(--blue-light);
    border: 1px solid var(--blue-accent);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.7;
}

.calc-steps .steps-title {
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--blue-accent);
}

.calc-steps .step {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.calc-steps .step:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--blue-accent);
    font-weight: bold;
}

.calc-steps .step:last-child {
    margin-bottom: 0;
}

/* Курсы валют */
.rates-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.rates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.rate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #fafafa;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.rate-item.modified {
    background: var(--warning-bg);
    border-left: 3px solid var(--warning);
}

.rate-currency {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    min-width: 50px;
}

.rate-value {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.rate-edit-btn {
    padding: 6px 12px;
    background: var(--white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.rate-edit-btn:hover {
    background: var(--blue-accent-hover);
    color: var(--white);
    border-color: var(--blue-accent-hover);
}

/* Контейнер кнопок под курсами */
.rates-card>div[style*="margin-top: 12px"] {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#cbrIframeContainer {
    margin-top: 16px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

#cbrIframe {
    display: block;
    width: 100%;
    border: none;
}

/* Поиск и выпадающие меню */
.search-container {
    position: relative;
    width: 100%;
}

.search-container.search-full-width {
    width: 100%;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: -1px;
}

.dropdown-menu.active {
    display: block;
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-light);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--blue-light);
    color: var(--blue-accent);
}

/* Увеличенный ползунок скроллбара */
.dropdown-menu::-webkit-scrollbar {
    width: 12px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 6px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--blue-accent);
    border-radius: 6px;
    border: 2px solid var(--white);
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: var(--blue-accent-hover);
}

/* Адаптивность */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .main-card {
        padding: 18px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .rates-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
        font-size: 13px;
    }

    .rate-item {
        padding: 12px 14px;
    }

    .result-row.total .value {
        font-size: 16px;
    }

    .btn-steps {
        font-size: 11px;
        padding: 7px 12px;
    }
}

/* Стили для избранного */
.dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.dropdown-item:hover {
    background-color: #f0f0f0;
}

.dropdown-item.favorite {
    background-color: #fffacd;
}

.dropdown-item.favorite:hover {
    background-color: #fff9b3;
}

.dropdown-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.star-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #ffd700;
    padding: 0 5px;
    margin-left: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.star-btn:hover {
    transform: scale(1.2);
}

.dropdown-separator {
    height: 1px;
    background-color: #ddd;
    margin: 5px 0;
}

/* Улучшение стилей dropdown */
#customerDropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

#customerDropdown.active {
    display: block;
}

/* Улучшение контейнера для поля ввода */
.input-group {
    position: relative;
}

/* Стили для избранного */
.dropdown-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 12px 16px !important;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-light);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--blue-light) !important;
    color: var(--blue-accent);
}

.dropdown-item.favorite {
    background-color: #fffacd !important;
}

.dropdown-item.favorite:hover {
    background-color: #fff9b3 !important;
}

.dropdown-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.star-btn {
    background: none !important;
    border: none !important;
    font-size: 18px !important;
    cursor: pointer !important;
    color: #ffd700 !important;
    padding: 0 5px !important;
    margin-left: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
    line-height: 1;
}

.star-btn:hover {
    transform: scale(1.3);
}

.dropdown-separator {
    height: 1px;
    background-color: #ddd;
    margin: 5px 0;
}