/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 0;
    color: #333;
}

.container {
    width: 70%;
    max-width: 70%;
    margin: 0 auto;
    background: white;
    border-radius: 0;
    box-shadow: none;
    padding: 20px 24px;
    box-sizing: border-box;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

header h1 {
    color: #2c3e50;
    font-size: 2em;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-update {
    color: #7f8c8d;
    font-size: 0.9em;
}

.last-update span {
    font-weight: bold;
    color: #34495e;
}

.current-time-msk {
    color: #7f8c8d;
    font-size: 1.1em;
    white-space: nowrap;
}

.current-time-msk span {
    font-weight: bold;
    color: #34495e;
    font-size: 1.1em;
}

.update-timer {
    color: #7f8c8d;
    margin-left: 5px;
}

#next-update-timer {
    color: #1e3a5f;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.btn-refresh {
    background: #1e3a5f;
    color: white;
    padding: 8px 16px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-refresh:hover {
    background: #2c5282;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.btn-refresh:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Кнопка меню (сэндвич) и выпадающее меню */
.menu-wrapper {
    position: relative;
}

.btn-menu {
    background: transparent;
    border: none;
    padding: 8px 10px;
    font-size: 1.4em;
    cursor: pointer;
    color: #34495e;
    border-radius: 6px;
    transition: background 0.2s, transform 0.1s;
}

.btn-menu:hover {
    background: #f0f2f5;
    transform: translateY(-1px);
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 110%;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 220px;
    display: none;
    z-index: 1000;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    width: 100%;
    padding: 8px 16px;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.95em;
    color: #2c3e50;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.dropdown-item:hover {
    background: #f5f7fa;
    color: #1a252f;
}

/* Сортировка колонок в таблице портфеля */
.portfolio-table th.sortable {
    cursor: default;
    white-space: nowrap;
    vertical-align: top;
}

.th-label-group {
    display: block;
    padding-right: 20px; /* чтобы текст / селект не налезали на кнопку */
}

/* Подсказки в шапке таблицы */
.th-sub-label {
    font-size: 0.8em;
    font-weight: normal;
    color: #e6c200; /* темно-желтый цвет */
    margin-top: 2px;
}

.portfolio-table th.sortable {
    position: relative;
}

.portfolio-table th.sortable .sort-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%); /* по центру по вертикали */
}

.portfolio-table th.sortable .sort-btn {
    margin-left: 6px;
    padding: 2px 6px;
    font-size: 0.8em;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: #e6c200; /* темно-желтый цвет */
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.portfolio-table th.sortable:hover .sort-btn {
    border-color: #e6c200;
    background: rgba(230, 194, 0, 0.1);
    color: #e6c200;
}

.portfolio-table th.sortable.sorted-asc .sort-btn {
    color: #e6c200;
    font-weight: bold;
}

.portfolio-table th.sortable.sorted-desc .sort-btn {
    color: #e6c200;
    font-weight: bold;
}

/* Сводка портфеля */
.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    display: flex;
    flex-direction: column;
    background: #1e3a5f;
    color: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.summary-card-split {
    flex-direction: row;
    gap: 0;
    padding: 0;
}

.summary-card-half {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 25px;
}

.summary-card-divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 10px 0;
}

.summary-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 10px;
}

.summary-value {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.summary-percent {
    font-size: 1.2em;
    font-weight: bold;
}

/* Курсы валют в хедере */
.header-currency-rates {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: 1em;
    color: #2c3e50;
    margin: 0 15px;
}

.header-currency-rates span {
    white-space: nowrap;
}

/* Форма добавления */
.add-form-container {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.add-form-container h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: start;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-height: 80px;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 500;
    color: #34495e;
    font-size: 0.9em;
}

.form-group input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
    width: 100%;
}

.form-group select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
    background-color: white;
    cursor: pointer;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

/* Контейнер для ввода тикера с индикатором */
.ticker-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.ticker-input-container input {
    flex: 1;
    padding-right: 40px;
    width: 100%;
}

.ticker-status {
    position: absolute;
    right: 10px;
    font-size: 1.2em;
    transition: all 0.3s;
    pointer-events: none;
}

.ticker-hint {
    display: block;
    font-size: 0.85em;
    margin-top: 5px;
    color: #7f8c8d;
    min-height: 20px;
}

.ticker-status.valid {
    color: #22543d;
    animation: checkmark 0.3s ease;
}

.ticker-status.invalid {
    color: #7f1d1d;
    animation: shake 0.3s ease;
}

.ticker-status.validating {
    color: #1e3a5f;
    animation: spin 1s linear infinite;
}

.ticker-status.warning {
    color: #92400e;
}

/* Подсказка для тикера */
.ticker-hint {
    display: block;
    font-size: 0.85em;
    margin-top: 5px;
    color: #7f8c8d;
    min-height: 18px;
    line-height: 1.2;
}

.ticker-hint.success {
    color: #22543d;
}

.ticker-hint.error {
    color: #7f1d1d;
}

.ticker-hint.warning {
    color: #92400e;
}

/* Анимации */
@keyframes checkmark {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

/* История цен */
.price-history-container {
    padding: 20px;
}

.price-history-container h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.history-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.history-filter {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.history-filter:hover {
    border-color: #667eea;
}

.history-filter:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.btn-secondary {
    background: #1e3a5f;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 58, 95, 0.3);
}

.btn-secondary:active {
    transform: translateY(0);
}

.price-history-content {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.history-date-group {
    margin-bottom: 30px;
}

.history-date-header {
    font-size: 1.1em;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #1e3a5f;
}

.history-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.history-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #1e3a5f;
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-ticker {
    font-size: 1.2em;
    font-weight: 700;
    color: #2c3e50;
}

.history-time {
    font-size: 0.85em;
    color: #7f8c8d;
}

.history-company {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.history-price {
    font-size: 1.3em;
    font-weight: 600;
    color: #22543d;
    margin-bottom: 5px;
}

.history-change {
    font-size: 0.9em;
    display: flex;
    gap: 10px;
}

.history-change.positive {
    color: #22543d;
}

.history-change.negative {
    color: #7f1d1d;
}

.history-volume {
    font-size: 0.85em;
    color: #95a5a6;
    margin-top: 5px;
}

.no-history-message {
    text-align: center;
    padding: 40px;
    color: #95a5a6;
    font-size: 1.1em;
}

.no-history-message p {
    margin-bottom: 15px;
}

/* Таблица истории цен (альтернативное представление) */
.history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.history-table th {
    background: #1e3a5f;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.history-table td {
    padding: 12px;
    border-bottom: 1px solid #ecf0f1;
}

.history-table tr {
    transition: background-color 0.2s, box-shadow 0.2s;
}

.history-table tr:hover {
    background-color: #e8f0f5;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.15);
    transform: translateY(-1px);
}

.history-table .price-cell {
    font-weight: 600;
    color: #22543d;
}

/* История транзакций (покупки/продажи) */
.transactions-container {
    padding: 20px;
}

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

.transactions-header h3 {
    margin: 0;
    color: #2c3e50;
}

.transactions-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.trans-filter {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.trans-filter:hover,
.trans-filter:focus {
    outline: none;
    border-color: #667eea;
}

.trans-filter[type="date"] {
    font-family: inherit;
}

.transactions-content {
    background: white;
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.transactions-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.transactions-table th {
    background: #1e3a5f;
    color: white;
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.transactions-table td {
    padding: 15px 10px;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
}

.transactions-table tbody tr {
    transition: background-color 0.2s, box-shadow 0.2s;
}

.transactions-table tbody tr:hover {
    background-color: #e8f0f5;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.15);
    transform: translateY(-1px);
}

.transaction-type-buy {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    background: #22543d;
    color: white;
    font-weight: 600;
    font-size: 0.9em;
}

.transaction-type-sell {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    background: #7f1d1d;
    color: white;
    font-weight: 600;
    font-size: 0.9em;
}

.transaction-notes {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #7f8c8d;
    font-size: 0.9em;
}

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

.no-data-message {
    text-align: center;
    padding: 60px 20px;
    color: #95a5a6;
}

.no-data-message p {
    margin: 10px 0;
    font-size: 1.1em;
}

/* Стили для модальных окон транзакций */
.modal textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
    transition: border-color 0.3s;
}

.modal textarea:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.modal input[type="datetime-local"] {
    font-family: inherit;
}

/* Адаптация кнопки добавления транзакции */
#add-transaction-btn {
    white-space: nowrap;
}

/* Управление категориями */
.categories-container {
    padding: 20px;
}

.categories-header {
    margin-bottom: 20px;
}

.categories-header h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.categories-description {
    margin: 0;
    color: #7f8c8d;
    font-size: 0.95em;
}

.categories-content {
    background: white;
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.categories-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

/* Таблица в модальном окне управления категориями */
.manage-categories-content .categories-table {
    width: auto;
    min-width: auto;
    font-size: 0.95em;
    margin: 0 auto;
}

.categories-table th {
    background: #1e3a5f;
    color: white;
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.manage-categories-content .categories-table th {
    padding: 10px 8px;
}

.categories-table td {
    padding: 15px 10px;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
}

.manage-categories-content .categories-table td {
    padding: 10px 8px;
}

.categories-table td:last-child {
    white-space: nowrap;
    text-align: right;
}

/* Выравнивание столбца с видами активов по левому краю */
.categories-table th:nth-child(4),
.categories-table td:nth-child(4) {
    text-align: left;
}

.categories-table td:last-child .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
}

.categories-table tbody tr {
    transition: background-color 0.2s, box-shadow 0.2s;
}

.categories-table tbody tr:hover {
    background-color: #e8f0f5;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.15);
    transform: translateY(-1px);
}

.category-select,
.asset-type-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    max-width: 300px;
}

.category-select:hover,
.category-select:focus,
.asset-type-select:hover,
.asset-type-select:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.category-select:disabled,
.asset-type-select:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

.save-indicator {
    display: inline-block;
    margin-left: 10px;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.3s;
    min-width: 20px;
}

.ticker-company-cell {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ticker-company-ticker {
    font-weight: 400;
    font-size: 0.9em;
    color: #7f8c8d;
}

.ticker-company-name {
    font-size: 1.1em;
    font-weight: 700;
    color: #2c3e50;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

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

/* Бейдж категории */
.category-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: #e8f4f8;
    color: #2c5f7f;
    font-size: 0.85em;
    white-space: nowrap;
}

/* Переключатель представлений */
.view-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    gap: 15px;
}

.view-switcher {
    display: flex;
    gap: 10px;
    align-items: center;
}

.view-controls .menu-wrapper {
    margin-left: 0;
    margin-right: auto;
}

/* Отображение свободных средств */
.cash-balance-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 15px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.cash-balance-label {
    color: #7f8c8d;
    font-size: 0.9em;
    font-weight: 500;
}

.cash-balance-value {
    color: #2c3e50;
    font-size: 1em;
    font-weight: 600;
}

.view-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: #7f8c8d;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s;
    position: relative;
}

.view-btn:hover {
    background: #f8f9fa;
    color: #2c3e50;
}

.view-btn.active {
    background: #1e3a5f;
    color: white;
}

/* Представления портфеля */
.portfolio-view {
    animation: fadeIn 0.3s ease-in;
}

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

/* Контейнер диаграммы категорий */
.category-chart-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.category-chart-container h3 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 1.5em;
    text-align: center;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.category-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    max-width: 250px;
    flex-shrink: 0;
}

.category-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
}

.category-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.category-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95em;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-value {
    color: #7f8c8d;
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-bar-container {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.category-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-percentage {
    min-width: 60px;
    text-align: right;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95em;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: #1e3a5f;
    color: white;
}

.btn-primary:hover {
    background: #2c5282;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.btn-secondary {
    background: #4a5568;
    color: white;
}

.btn-secondary:hover {
    background: #2d3748;
}

.btn-danger {
    background: #7f1d1d;
    color: white;
    padding: 8px 12px;
    font-size: 1.2em;
    min-width: auto;
    width: 40px;
    height: 40px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
}

.btn-danger:hover {
    background: #991b1b;
    transform: scale(1.1);
}

.btn-edit {
    background: #1e3a5f;
    color: white;
    padding: 8px 12px;
    font-size: 1.2em;
    min-width: auto;
    width: 40px;
    height: 40px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
}

.btn-edit:hover {
    background: #2c5282;
    transform: scale(1.1);
}

.btn-buy {
    background: #22543d;
    color: transparent;
    padding: 0;
    font-size: 0;
    min-width: auto;
    width: 45px;
    height: 45px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(34, 84, 61, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-buy::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
}

.btn-buy:hover {
    background: #1a3d2e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 84, 61, 0.4);
}

.btn-buy:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(34, 84, 61, 0.3);
}

.btn-sell {
    background: #7f1d1d;
    color: transparent;
    padding: 0;
    font-size: 0;
    min-width: auto;
    width: 40px;
    height: 40px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(127, 29, 29, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-sell::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round"><line x1="5" y1="12" x2="19" y2="12"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
}

.btn-sell:hover {
    background: #991b1b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(127, 29, 29, 0.4);
}

.btn-sell:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(127, 29, 29, 0.3);
}

/* Таблица портфеля */
.portfolio-table-container {
    margin-top: 30px;
    overflow-x: auto; /* Горизонтальная прокрутка для таблицы */
    -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS */
}

.portfolio-table-container h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-size: 1.1em;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    border-left: 4px solid #7f1d1d;
}

.portfolio-table {
    width: 100%;
    min-width: 1200px; /* Минимальная ширина таблицы */
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden;
}

.portfolio-table thead {
    background: #1e3a5f;
    color: white;
}

.portfolio-table th {
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    vertical-align: top; /* выравниваем все заголовки по верхнему краю */
}

/* Выбор периода для колонки "Изменение" */
.change-period-select {
    margin-left: 6px;
    padding: 4px 8px;
    font-size: 0.85em;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background-color: #16324a;
    color: #ecf0f1;
}

.change-period-select:focus {
    outline: none;
    border-color: #ffffff;
}

.portfolio-table td {
    padding: 15px 10px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
    white-space: nowrap;
}

/* Бейдж процента доли в портфеле в колонке "Текущая стоимость" */
.portfolio-share-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background-color: #1e3a5f; /* основной цвет интерфейса */
    color: #ffffff;
    font-size: 0.75em;
    font-weight: 600;
}

/* Ячейка с мини-графиком */
.sparkline-cell {
    text-align: center;
    padding: 10px 5px !important;
    vertical-align: middle;
}

.sparkline-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 30px;
}

/* Ячейка с действиями - одна кнопка по центру в колонке */
.portfolio-table td:last-child {
    white-space: nowrap;
    text-align: center;
}

.portfolio-table td:last-child .btn-sell {
    margin: 0 auto;
    display: inline-flex;
}

.portfolio-table tbody tr {
    transition: background-color 0.2s, box-shadow 0.2s;
}

.portfolio-table tbody tr:hover {
    background-color: #e8f0f5;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.15);
    transform: translateY(-1px);
}

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

/* Цветовая индикация прибыли/убытка */
.profit {
    color: #27ae60;
    font-weight: bold;
}

.loss {
    color: #e74c3c;
    font-weight: bold;
}

.neutral {
    color: #7f8c8d;
}

/* Модальное окно */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Модальное окно управления категориями - без прокрутки */
.manage-categories-content {
    max-width: 800px;
    max-height: none;
    overflow-y: visible;
    height: auto;
    padding: 20px;
}

.manage-categories-content h2 {
    margin-bottom: 15px;
    font-size: 1.3em;
}

.manage-categories-content #categories-list-container {
    margin-top: 10px;
}

/* Вкладки в модальном окне управления */
.tab-button {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 1em;
    color: #7f8c8d;
    transition: all 0.3s;
}

.tab-button:hover {
    color: #2c3e50;
}

.tab-button.active {
    color: #1e3a5f;
    border-bottom-color: #1e3a5f;
    font-weight: 600;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.modal-content h3 {
    margin-top: 0;
    color: #1e3a5f;
    font-size: 1.2em;
    border-bottom: 2px solid #1e3a5f;
    padding-bottom: 10px;
}

.modal-content .form-group {
    margin-bottom: 20px;
}

/* Стили для модального окна информации о тикере */
#ticker-info-content p {
    margin: 10px 0;
    line-height: 1.6;
}

#ticker-info-content strong {
    color: #2c3e50;
    min-width: 150px;
    display: inline-block;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .header-controls {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .btn-refresh {
        width: 100%;
    }
    
    .category-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .category-info {
        width: 100%;
        min-width: auto;
    }
    
    .category-bar-container {
        width: 100%;
    }
    
    .category-percentage {
        width: 100%;
        text-align: left;
    }
    
    .view-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .view-switcher {
        flex-direction: column;
        width: 100%;
    }
    
    .view-btn {
        width: 100%;
        text-align: center;
    }
    
    .btn-buy {
        align-self: stretch;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .portfolio-table {
        font-size: 0.85em;
    }
    
    .portfolio-table th,
    .portfolio-table td {
        padding: 10px 5px;
    }
    
    .portfolio-summary {
        grid-template-columns: 1fr;
    }
}

/* Анимация обновления */
.updating {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Переключатель типа диаграммы */
.chart-type-toggle {
    display: flex;
    gap: 10px;
    background: #f8f9fa;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chart-toggle-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #7f8c8d;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.chart-toggle-btn:hover {
    background: #e9ecef;
    color: #2c3e50;
}

.chart-toggle-btn.active {
    background: #1e3a5f;
    color: white;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
}

/* Анимация изменения цены */
@keyframes price-flash {
    0% {
        background-color: rgba(30, 58, 95, 0.3);
    }
    50% {
        background-color: rgba(30, 58, 95, 0.6);
    }
    100% {
        background-color: transparent;
    }
}

/* Круговая диаграмма категорий */
.categories-pie-chart-container {
    background: #f7fafc;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.categories-pie-chart-container h4 {
    color: #2c3e50;
    font-size: 1.3em;
    margin: 0 0 20px 0;
}

.categories-pie-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.pie-chart-svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.pie-chart-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 300px;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.pie-legend-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.pie-legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.pie-legend-details {
    flex: 1;
    min-width: 0;
}

.pie-legend-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95em;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pie-legend-value {
    color: #7f8c8d;
    font-size: 0.85em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pie-legend-percentage {
    font-weight: 600;
    color: #1e3a5f;
    font-size: 0.95em;
    white-space: nowrap;
}
