:root {
    --bg: #FFFFFF;
    --surface: #F5F5F5;
    --border: #E0E0E0;
    --text: #1F1D1E;
    --muted: #6B6B6B;
    --accent: #FD243C;
    --accent-hover: #D41E33;
    --error: #FD243C;
    --success: #2E9E5B;
    --success-hover: #26834A;
}

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

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.login-container {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(31, 29, 30, 0.08);
    overflow: hidden;
}

/* Красная полоска сверху */
.login-container::before {
    content: "";
    display: block;
    height: 4px;
    background: var(--accent);
}

.login-inner {
    padding: 36px 40px 40px;
}

.logo {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}

.logo-img {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.subtitle {
    color: var(--muted);
    text-align: center;
    font-size: 14px;
    margin-bottom: 28px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

label.remember {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    color: var(--muted);
    cursor: pointer;
}

input[type="text"],
input[type="password"] {
    padding: 11px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(253, 36, 60, 0.10);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

button[type="submit"] {
    margin-top: 4px;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

button[type="submit"]:hover {
    background: var(--accent-hover);
}

button[type="submit"]:active {
    transform: scale(0.98);
}

#status {
    margin-top: 18px;
    font-size: 13px;
    text-align: center;
    color: var(--muted);
    min-height: 18px;
}

#status.error { color: var(--error); }

.btn {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }


body.dashboard {
    display: block;
}

.topbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent);
}


.topbar-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    font-size: 13px;
    color: var(--muted);
}

/* Кнопка в шапке: цвета от .btn, ширина своя */
.btn--sm {
    display: inline-block;
    width: auto;
    margin-top: 0;
    padding: 8px 16px;
    font-size: 13px;
}

.dashboard-main {
    max-width: 880px;
    margin: 0 auto;
    padding: 40px 32px 64px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 6px;
}

.page-hint {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 28px;
}

.uploads {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.shop-picker {
    margin-bottom: 28px;
}

.tills-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 28px;
}

.tills-label {
    font-size: 12px;
    color: var(--muted);
    padding-left: 2px;
}

.tills-input {
    width: 100%;
    padding: 14px 18px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.15s;
}

.tills-input:focus { border-color: var(--accent); }
.tills-input::placeholder { color: var(--muted); }
.tills-input.is-invalid { border-color: var(--error); }

.shop-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    padding: 14px 18px;
    font-family: inherit;
    text-align: left;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.shop-select:hover {
    border-color: var(--accent);
    background: var(--surface);
}

.shop-select:disabled {
    opacity: 0.6;
    cursor: default;
}

.shop-select-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.shop-select-label {
    font-size: 12px;
    color: var(--muted);
}

.shop-select-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Шеврон рисуем рамками, чтобы не тащить иконку */
.shop-select-arrow {
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    margin-top: -4px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: border-color 0.15s;
}

.shop-select:hover .shop-select-arrow {
    border-color: var(--accent);
}

.shop-select.is-set {
    border-color: var(--accent);
}

.shop-select.is-set .shop-select-value {
    color: var(--text);
}

.shop-select.is-set .shop-select-arrow {
    border-color: var(--accent);
}

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 180px;
    padding: 28px 20px;
    text-align: center;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

/* Иначе dragleave срабатывает при наведении на вложенные span */
.dropzone > * {
    pointer-events: none;
}

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

.dropzone.dragover {
    border-color: var(--accent);
    background: rgba(253, 36, 60, 0.04);
}

.dropzone.filled {
    border-style: solid;
    border-color: var(--accent);
}

.dropzone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.dropzone-hint {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.dropzone-file {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    word-break: break-all;
}

.dropzone-check {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--success);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.18s, transform 0.18s;
}

.dropzone.uploaded .dropzone-check {
    opacity: 1;
    transform: scale(1);
}

.dropzone.uploaded {
    border-style: solid;
    border-color: var(--success);
}

.dropzone.uploaded:hover {
    border-color: var(--success);
}

.dropzone-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    background: var(--accent);
    border-radius: 0 0 10px 10px;
    transition: width 0.15s linear;
}

.dropzone.uploaded .dropzone-progress {
    background: var(--success);
}

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

.actions .btn {
    width: auto;
    margin-top: 0;
    padding: 12px 28px;
}

.btn[hidden] {
    display: none;
}

.btn--link {
    text-decoration: none;
    text-align: center;
    line-height: 1.2;
    background: var(--success);
}

.btn--link:hover {
    background: var(--success-hover);
}

#result-link {
    margin-left: auto;
}

#compare-btn {
    margin-left: auto;
    background: var(--success);
}

#compare-btn:hover {
    background: var(--success-hover);
}

/* ---------- Модалка выбора магазина ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(31, 29, 30, 0.45);
}

/* hidden на flex-элементе иначе не срабатывает */
.modal[hidden] { display: none; }

.modal-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

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

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

.modal-close {
    width: 28px;
    height: 28px;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
    background: var(--surface);
}

.modal-search {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
}

.modal-search:focus { border-color: var(--accent); }

.shop-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
}

.shop-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.shop-item:hover { background: var(--surface); }

.shop-item.is-active {
    background: rgba(253, 36, 60, 0.08);
}

.shop-item.is-active .shop-item-name { color: var(--accent); }

.shop-item-name {
    font-size: 14px;
    font-weight: 600;
}

.shop-item-meta {
    font-size: 12px;
    color: var(--muted);
}

.shop-empty {
    padding: 20px 12px;
    font-size: 13px;
    text-align: center;
    color: var(--muted);
    list-style: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn:not(.is-loading) .spinner {
    display: none;
}

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

.is-busy .uploads,
.is-busy .shop-picker,
.is-busy .tills-field {
    opacity: 0.5;
    pointer-events: none;
}

.is-busy #status {
    color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
}


@media (max-width: 720px) {
    .topbar { padding: 0 20px; }
    .dashboard-main { padding: 28px 20px 48px; }
    .uploads { grid-template-columns: 1fr; }
    .modal-panel { max-width: none; max-height: 88vh; }
}

