/* ============================================================
   Сверка ИБ с Эскроу — Design System
   Aesthetic: Clean Precision (from AI Task Manager v2)
   Fonts: Sora (headings) + Plus Jakarta Sans (body)
   ============================================================ */

:root {
    --font-heading: 'Sora', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    --white: #FFFFFF;
    --gray-25: #FCFCFD;
    --gray-50: #F9FAFB;
    --gray-100: #F2F4F7;
    --gray-200: #EAECF0;
    --gray-300: #D0D5DD;
    --gray-400: #98A2B3;
    --gray-500: #667085;
    --gray-600: #475467;
    --gray-700: #344054;
    --gray-800: #1D2939;
    --gray-900: #101828;

    --accent: #4F46E5;
    --accent-light: #818CF8;
    --accent-lighter: #EEF2FF;
    --accent-dark: #3730A3;

    --success: #12B76A;
    --success-light: #ECFDF3;
    --warning: #F79009;
    --warning-light: #FFFAEB;
    --error: #F04438;
    --error-light: #FEF3F2;
    --info: #2E90FA;
    --info-light: #EFF8FF;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
    --shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.15);

    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    --sidebar-width: 240px;
    --header-height: 56px;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.5;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.25;
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.375rem;
}

h3 {
    font-size: 1.125rem;
}

button {
    cursor: pointer;
    font-family: var(--font-body);
    border: none;
    background: none;
    font-size: inherit;
}

input,
select,
textarea {
    font-family: var(--font-body);
    font-size: 0.875rem;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* ---- App Shell ---- */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: var(--space-4) 0;
}

.sidebar-logo {
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: 0 var(--space-3);
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.sidebar-link:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.sidebar-link.active {
    background: var(--accent-lighter);
    color: var(--accent);
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ---- Header ---- */
.header {
    height: var(--header-height);
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    flex-shrink: 0;
}

.header-title {
    font-size: 1rem;
    font-weight: 600;
}

/* ---- Page Content ---- */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

/* ---- Login ---- */
.login-wrapper {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-10);
    box-shadow: var(--shadow-lg);
    width: 380px;
    text-align: center;
}

.login-card .logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
    color: var(--white);
    font-size: 1.5rem;
}

.login-card h2 {
    margin-bottom: var(--space-2);
}

.login-card .subtitle {
    color: var(--gray-500);
    font-size: 0.8125rem;
    margin-bottom: var(--space-6);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

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

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

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

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

.btn-success:hover {
    background: #0ea85e;
}

.btn-ghost {
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-outline {
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    background: var(--white);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* ---- Inputs ---- */
.input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    outline: none;
    transition: border-color var(--transition-fast);
    font-size: 0.875rem;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

.select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23667085' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ---- Card ---- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: var(--space-5);
    transition: box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--gray-25);
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-lighter);
}

.upload-zone.active {
    border-color: var(--accent);
    background: var(--accent-lighter);
}

.upload-zone.has-file {
    border-color: var(--success);
    background: var(--success-light);
}

.upload-zone .icon {
    font-size: 2rem;
    margin-bottom: var(--space-3);
    color: var(--gray-400);
}

.upload-zone.has-file .icon {
    color: var(--success);
}

.upload-zone .label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
}

.upload-zone .hint {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: var(--space-1);
}

.upload-zone .filename {
    font-size: 0.8125rem;
    color: var(--success);
    font-weight: 600;
    margin-top: var(--space-2);
}

/* ---- Badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
}

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

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

.badge-error {
    background: var(--error-light);
    color: var(--error);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.badge-default {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: var(--space-5);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
    margin-top: var(--space-1);
}

.stat-card .stat-value.success {
    color: var(--success);
}

.stat-card .stat-value.warning {
    color: var(--warning);
}

.stat-card .stat-value.error {
    color: var(--error);
}

.stat-card .stat-value.accent {
    color: var(--accent);
}

/* ---- Table ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.data-table th {
    background: var(--gray-50);
    padding: var(--space-3) var(--space-4);
    font-weight: 600;
    text-align: left;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-800);
}

.data-table tr:hover td {
    background: var(--gray-25);
}

.data-table .num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-weight: 500;
}

.data-table .diff-positive {
    color: var(--success);
    font-weight: 600;
}

.data-table .diff-negative {
    color: var(--error);
    font-weight: 600;
}

/* ---- History Cards ---- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.history-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--accent-light);
}

.history-card .hc-left {
    flex: 1;
}

.history-card .hc-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: var(--space-1);
}

.history-card .hc-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    display: flex;
    gap: var(--space-4);
}

.history-card .hc-stats {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

/* ---- Animations ---- */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        transform: rotate(360deg);
    }
}

.fade-in {
    animation: fadeSlideUp 200ms ease;
}

/* ---- Loading ---- */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: var(--space-8) auto;
}

.loading-text {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: var(--space-3);
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    box-shadow: var(--shadow-lg);
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    animation: fadeSlideUp 200ms ease;
    border-left: 3px solid var(--accent);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

.toast.warning {
    border-left-color: var(--warning);
}

/* ---- Upload Page Grid ---- */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

/* ---- Step Indicator ---- */
.steps {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-8);
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-400);
}

.step.active {
    color: var(--accent);
}

.step.done {
    color: var(--success);
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    background: var(--gray-100);
    color: var(--gray-500);
}

.step.active .step-num {
    background: var(--accent);
    color: var(--white);
}

.step.done .step-num {
    background: var(--success);
    color: var(--white);
}

.step-divider {
    width: 40px;
    height: 2px;
    background: var(--gray-200);
    margin: 0 var(--space-1);
}

.step-divider.done {
    background: var(--success);
}

/* ---- Detail Section ---- */
.detail-section {
    margin-top: var(--space-6);
}

.detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.detail-section-header h3 {
    font-size: 1rem;
}

/* ---- Scrollable Table ---- */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--white);
}

/* ---- Actions Bar ---- */
.actions-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--gray-400);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: var(--space-3);
}

.empty-state .title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: var(--space-2);
}

.empty-state .description {
    font-size: 0.8125rem;
}

/* ---- Sheet Selector ---- */
.sheet-selector {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.sheet-chip {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--white);
}

.sheet-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.sheet-chip.selected {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

/* ---- Month Diff Row ---- */
.month-diff-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-2) 0;
    font-size: 0.8125rem;
}

.month-diff-row .month-name {
    width: 80px;
    color: var(--gray-600);
    font-weight: 500;
}

.month-diff-row .val {
    width: 120px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Project Name Input ---- */
.project-input-wrapper {
    margin-bottom: var(--space-6);
}

.project-input-wrapper label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}