/* === Reset & Base === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

/* === Layout === */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

nav {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 600;
    font-size: 18px;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 24px;
    list-style: none;
}

.nav-links a {
    color: var(--gray-700);
    text-decoration: none;
    padding: 8px 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-user span {
    color: var(--gray-500);
    font-size: 14px;
}

main {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* === Components === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

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

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

.card-title {
    font-size: 18px;
    font-weight: 600;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

select.form-control {
    cursor: pointer;
}

/* === Tables === */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-500);
    text-transform: uppercase;
}

.table tr:hover {
    background: var(--gray-50);
}

.table td.actions {
    white-space: nowrap;
}

.table .number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* === Toasts === */
#toasts {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Loader === */
.loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--gray-500);
}

.loader.hidden {
    display: none;
}

/* === Login === */
.login-container {
    max-width: 400px;
    margin: 80px auto;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 32px;
}

/* === Page Headers === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

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

/* === Badges === */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: var(--success);
}

.badge-warning {
    background: #fef9c3;
    color: var(--warning);
}

.badge-danger {
    background: #fee2e2;
    color: var(--danger);
}

.badge-info {
    background: #dbeafe;
    color: var(--primary);
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--gray-700);
}

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

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card .label {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 600;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.pagination button:hover {
    background: var(--gray-50);
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Modal === */
.modal-overlay {
    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 {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* === File Upload === */
.file-upload {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.file-upload.dragover {
    border-color: var(--primary);
    background: #dbeafe;
}

.file-upload input {
    display: none;
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
}

.tab:hover {
    color: var(--gray-700);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* === Responsive === */
@media (max-width: 768px) {
    nav {
        padding: 0 16px;
    }
    
    .nav-links {
        gap: 16px;
        font-size: 14px;
    }
    
    main {
        padding: 16px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .page-header .actions {
        width: 100%;
    }
    
    .page-header .actions .btn {
        flex: 1;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .modal {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .nav-links {
        gap: 12px;
        font-size: 13px;
    }
    
    .nav-brand {
        font-size: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* === Back Link === */
.back-link {
    color: var(--gray-500);
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
    margin-bottom: 8px;
}

.back-link:hover {
    color: var(--primary);
}

/* === Offer Detail Modal === */
.modal-large {
    max-width: 800px;
    width: 95%;
}

.modal-body {
    padding: 20px 0;
    max-height: 70vh;
    overflow-y: auto;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.detail-section {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
}

.detail-section h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.section-header h4 {
    margin: 0;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item label {
    font-size: 12px;
    color: var(--gray-500);
}

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

.info-item .price {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

/* === Calculations List === */
.calculations-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.calculation-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
}

.calculation-card.calculation-error {
    border-color: var(--danger);
    background: #fef2f2;
}

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

.calc-header h5 {
    margin: 0;
    font-size: 14px;
}

.calc-prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

.calc-price label {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.price-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--success);
}

.calc-breakdown {
    border-top: 1px solid var(--gray-200);
    padding-top: 12px;
    margin-top: 12px;
}

.calc-breakdown summary {
    cursor: pointer;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
}

.breakdown-content {
    margin-top: 12px;
}

.breakdown-table {
    width: 100%;
    font-size: 13px;
}

.breakdown-table td {
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
}

.breakdown-table tfoot td {
    border-top: 2px solid var(--gray-200);
    border-bottom: none;
    padding-top: 10px;
}

.calc-error-message {
    color: var(--danger);
    font-size: 14px;
    padding: 10px;
    background: #fee2e2;
    border-radius: 4px;
}

.calc-footer {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
}

/* === Clickable Row === */
.clickable-row:hover {
    background-color: var(--gray-50);
}

/* === Settings Page === */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

.card-description {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 20px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-actions {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    transition: all 0.2s;
}

.tab:hover {
    color: var(--gray-700);
    background: var(--gray-50);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* === Channel Tabs === */
.channel-tabs {
    margin-bottom: 24px;
}

.channel-tabs-inner {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.channel-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.channel-tab:hover {
    background: var(--gray-200);
}

.channel-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.channel-tab.active .badge {
    background: rgba(255,255,255,0.2);
    color: white;
}

.channel-settings-form {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 24px;
}

/* === Info Item === */
.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.info-item label {
    font-size: 12px;
    color: var(--gray-500);
}

.info-item span {
    font-size: 16px;
    font-weight: 500;
}

/* === Error text === */
p.error {
    color: var(--danger);
}

/* === Export Layout === */
.export-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .export-layout {
        grid-template-columns: 1fr;
    }
}

/* === Checkbox === */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* === Exports List === */
.exports-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

.export-item:hover {
    border-color: var(--gray-300);
}

.export-info {
    flex: 1;
}

.export-name {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.export-meta {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.export-stats {
    font-size: 13px;
    color: var(--gray-600);
}

.export-actions {
    display: flex;
    gap: 8px;
    margin-left: 16px;
}

/* === Backups Page === */
.backup-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .backup-layout {
        grid-template-columns: 1fr;
    }
}

.backup-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-200);
}

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

.info-label {
    color: var(--gray-500);
}

.info-value {
    font-weight: 500;
}

.hint {
    font-size: 13px;
    color: var(--gray-500);
}

.hint a {
    color: var(--primary);
}

.backups-table code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}
