:root {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --border-subtle: rgba(148, 163, 184, 0.2);
    --accent: #38bdf8;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --danger: #f97373;
    --success: #22c55e;
    --warning: #fbbf24;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.3);
}

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

body {
    margin: 0;
    padding: 24px;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
}

.page {
    max-width: 1600px;
    margin: 0 auto;
}

/* HEADER */
.header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.header-title {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon {
    font-size: 32px;
}

.header-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
}

.header-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-filter label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ALERT */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

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

.alert--success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
    color: #bbf7d0;
}

.alert--error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid var(--danger);
    color: #fecaca;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn--primary {
    background: linear-gradient(135deg, #0ea5e9, #22c55e);
    color: #0b1120;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

.btn--success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4);
}

.btn--success:hover {
    transform: translateY(-2px);
}

.btn--ghost {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

.btn--ghost:hover {
    background: rgba(15, 23, 42, 0.9);
}

.btn--danger {
    background: linear-gradient(135deg, #f97373, #ef4444);
    color: #fff;
    box-shadow: 0 4px 14px rgba(248, 113, 113, 0.4);
}

.btn--danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(248, 113, 113, 0.5);
}

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

.btn-icon {
    font-size: 16px;
    margin-right: 6px;
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card--blue::before {
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
}

.stat-card--green::before {
    background: linear-gradient(90deg, transparent, #22c55e, transparent);
}

.stat-card--orange::before {
    background: linear-gradient(90deg, transparent, #f59e0b, transparent);
}

.stat-card--cyan::before {
    background: linear-gradient(90deg, transparent, #06b6d4, transparent);
}

.stat-card--red::before {
    background: linear-gradient(90deg, transparent, #ef4444, transparent);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.stat-card__icon {
    font-size: 40px;
}

.stat-card__label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card__value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card--blue .stat-card__value {
    color: #60a5fa;
}

.stat-card--green .stat-card__value {
    color: #4ade80;
}

.stat-card--orange .stat-card__value {
    color: #fbbf24;
}

.stat-card--cyan .stat-card__value {
    color: #22d3ee;
}

.stat-card--red .stat-card__value {
    color: #f87171;
}

.stat-card__meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* CARD */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
    padding: 24px;
}

.card-inner {
    /* Пустой контейнер для будущих стилей */
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
}

.chart-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.chart-container {
    height: 400px;
    position: relative;
}

/* FORMS */
.settings-form,
.transfer-form,
.auto-transfer-form {
    margin-top: 16px;
}

.form-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

.form-grid--4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-grid--5 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid--6 {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

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

.field--action {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.field label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.field-hint {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.field input[type="text"],
.field input[type="number"],
.select-field {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.field input:focus,
.select-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.select-field {
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* AUTO TRANSFER RULES */
.rules-list {
    margin: 16px 0;
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.rules-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.rule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px;
    margin-bottom: 10px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    transition: all 0.2s;
}

.rule-item:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(56, 189, 248, 0.3);
}

.rule-item:last-child {
    margin-bottom: 0;
}

.rule-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.rule-info strong {
    white-space: nowrap;
    color: var(--accent);
}

.rule-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.5);
    color: #bae6fd;
    text-transform: uppercase;
    white-space: nowrap;
}

.rule-threshold {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fde047;
    white-space: nowrap;
}

/* DAILY STATS */
.daily-stats {
    max-width: 600px;
}

.stats-header {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.daily-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.daily-stat-row:last-child {
    border-bottom: none;
}

.daily-date {
    font-size: 14px;
    color: var(--text-muted);
}

.daily-count {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

/* TABLE */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: rgba(15, 23, 42, 0.3);
    margin-top: 16px;
}

.profiles-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
    font-size: 13px;
}

.profiles-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.profiles-table thead tr {
    background: linear-gradient(135deg, #1e3a4c, #2d4a5c);
}

.profiles-table th {
    text-align: left;
    padding: 14px 16px;
    font-weight: 600;
    color: #e5e7eb;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.profiles-table tbody tr {
    transition: background 0.2s;
}

.profiles-table tbody tr:hover {
    background: rgba(56, 189, 248, 0.05);
}

.profiles-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

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

/* RESPONSIVE DESIGN */

/* Tablet (до 1024px) */
@media (max-width: 1024px) {
    body {
        padding: 16px;
    }
    
    .header-title {
        font-size: 24px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .form-grid--6 {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* Mobile (до 768px) */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-title {
        font-size: 20px;
    }
    
    .header-filter,
    .header-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card {
        padding: 16px;
    }
    
    .form-grid--4,
    .form-grid--5,
    .form-grid--6 {
        grid-template-columns: 1fr;
    }
    
    /* Правила автопереноса на мобильных */
    .rule-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .rule-info {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .rule-info strong {
        display: block;
        width: 100%;
    }
    
    .rule-badge,
    .rule-threshold {
        display: inline-block;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .table-wrapper {
        margin-left: -12px;
        margin-right: -12px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* Small Mobile (до 480px) */
@media (max-width: 480px) {
    .header-title {
        font-size: 18px;
    }
    
    .icon {
        font-size: 24px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-card__icon {
        font-size: 32px;
    }
    
    .stat-card__value {
        font-size: 24px;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Desktop (от 1440px) - улучшенный вид правил */
@media (min-width: 1440px) {
    .rule-info {
        flex-wrap: nowrap;
    }
}
