:root {
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e2e6ec;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #111827;
    color: #e5e7eb;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar__logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar__title { font-weight: 700; font-size: 15px; }
.sidebar__subtitle { font-size: 12px; color: #94a3b8; }

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar nav a {
    color: #cbd5e1;
    padding: 10px 12px;
    border-radius: 8px;
}

.sidebar nav a:hover { background: #1f2937; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: white; }

.sidebar__footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar__logout {
    color: #f87171;
    font-size: 14px;
}
.sidebar__credit {
    font-size: 11px;
    color: #64748b;
}

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}
.toast {
    min-width: 240px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    animation: toast-in .2s ease;
}
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
.toast--info { background: var(--primary); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 14px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 6px 11px;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid var(--border);
    color: var(--text);
}
.pagination a:hover { background: #f1f5f9; text-decoration: none; }
.pagination .current { background: var(--primary); color: white; border-color: var(--primary); }
.pagination .disabled { color: #cbd5e1; pointer-events: none; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.stat-card__value { font-size: 26px; font-weight: 700; }
.stat-card__label { font-size: 13px; color: var(--muted); margin-top: 4px; }

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

.content {
    flex: 1;
    padding: 32px 40px;
    max-width: 1100px;
}

h1 { margin-top: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card h2 { margin-top: 0; font-size: 16px; }

form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; min-width: 200px; }

input[type="text"], input[type="password"], input[type="file"], select, textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

textarea {
    resize: vertical;
    width: 100%;
}

#supplier-search-form { flex-wrap: nowrap; }
#supplier-search-input { flex: 1; }

.btn {
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: inline-block;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2ff; color: var(--primary-dark); }

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}
.table th, .table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }

.badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge--ok, .badge--done { background: #dcfce7; color: var(--success); }
.badge--not_found { background: #fef3c7; color: var(--warn); }
.badge--error { background: #fee2e2; color: var(--danger); }
.badge--pending, .badge--processing { background: #e0e7ff; color: var(--primary-dark); }

.progress {
    background: #e5e7eb;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
    margin: 8px 0;
}
.progress__bar {
    background: var(--primary);
    height: 100%;
    width: 0%;
    transition: width .2s ease;
}

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
}
.alert-error { background: #fee2e2; color: var(--danger); }
.alert-success { background: #dcfce7; color: var(--success); }

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(760px circle at 15% 10%, #dbe6ff 0%, transparent 55%),
        radial-gradient(760px circle at 85% 90%, #e0f2fe 0%, transparent 55%),
        linear-gradient(180deg, #f4f7fc 0%, #eef1f8 100%);
}
.auth-card {
    background: var(--card-bg);
    padding: 40px 36px 32px;
    border-radius: 18px;
    border: 1px solid rgba(226, 230, 236, .7);
    box-shadow: 0 20px 45px -20px rgba(30, 41, 59, .25), 0 2px 8px rgba(30, 41, 59, .04);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 18px;
    width: 100%;
    max-width: 360px;
}
/* переопределяем общие правила "form label { flex:1; min-width:200px }" -
   иначе label растягивается и съедает лишнюю высоту внутри карточки входа */
.auth-card label { display: flex; flex-direction: column; flex: none; min-width: 0; gap: 7px; font-size: 13px; font-weight: 600; color: #475569; }
.auth-card input[type="text"],
.auth-card input[type="password"] {
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-card input[type="text"]:focus,
.auth-card input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.auth-card .btn-primary {
    width: 100%;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    box-shadow: 0 8px 16px -6px rgba(37, 99, 235, .45);
}

.auth-card__brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 6px;
}
.auth-card__logo {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    font-weight: 700;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 6px 14px -4px rgba(29, 78, 216, .5);
}
.auth-card__title { font-weight: 700; font-size: 19px; color: var(--text); letter-spacing: -.01em; }
.auth-card__subtitle { font-size: 13px; color: var(--muted); }
.auth-card__footer {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.password-field {
    position: relative;
    display: flex;
}
.password-field input { flex: 1; padding-right: 44px; }
.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 17px;
    padding: 7px 10px;
    line-height: 1;
    border-radius: 8px;
    color: #94a3b8;
}
.password-toggle:hover { background: #f1f5f9; color: var(--text); }
.password-toggle:disabled { cursor: not-allowed; opacity: .5; }

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