:root {
    --bg-color: #f7f7f8;
    --card-bg: #ffffff;
    --text-main: #1a1a1a;
    --text-secondary: #666666;
    --primary: #800020; /* Винный/Бордовый цвет "Своё Вино" */
    --primary-light: #a31c3b;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-color);
    position: relative;
    overflow-x: hidden;
}

.header {
    background: var(--card-bg);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.server-status {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f1f3f5;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffc107; /* warning / checking by default */
}

.status-dot.online {
    background: #28a745;
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.6);
}

.status-dot.offline {
    background: #dc3545;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--primary);
    background: rgba(128, 0, 32, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
}

.view {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* Scanner View */
.scanner-frame {
    background: #000;
    border-radius: var(--radius);
    height: 400px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.corners {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary);
}
.top-left { top: 20px; left: 20px; border-right: none; border-bottom: none; border-radius: 12px 0 0 0; }
.top-right { top: 20px; right: 20px; border-left: none; border-bottom: none; border-radius: 0 12px 0 0; }
.bottom-left { bottom: 20px; left: 20px; border-right: none; border-top: none; border-radius: 0 0 0 12px; }
.bottom-right { bottom: 20px; right: 20px; border-left: none; border-top: none; border-radius: 0 0 12px 0; }

.scan-instruction {
    color: rgba(255,255,255,0.7);
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
}

.scanning-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    animation: scan 2s infinite ease-in-out;
}
.scanning-line.hidden { display: none; }

@keyframes scan {
    0% { top: 10%; }
    50% { top: 90%; }
    100% { top: 10%; }
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-secondary {
    background: #e9ecef;
    color: var(--text-main);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 20px;
    cursor: pointer;
}

/* Loading */
#loading-view {
    text-align: center;
    padding-top: 100px;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(128, 0, 32, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Wine Card */
.wine-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.wine-image-container {
    background: #f8f9fa;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
}
.wine-image-container img {
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.rating-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #ffc107;
    color: #000;
    font-weight: 600;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.wine-info {
    padding: 20px;
}

.wine-winery {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.wine-title {
    font-size: 22px;
    line-height: 1.3;
    margin-bottom: 16px;
    color: var(--text-main);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}
.tag {
    background: #f1f3f5;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.property {
    margin-bottom: 12px;
    font-size: 15px;
}
.prop-label {
    color: var(--text-secondary);
    width: 60px;
    display: inline-block;
}
.prop-value {
    font-weight: 500;
}

.wine-description {
    margin-top: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* Sommelier */
.sommelier-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: var(--shadow);
}
.sommelier-section h3 {
    font-size: 18px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sommelier-section h3::before {
    content: '🍷';
}
.sommelier-section p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.pairing-options {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.btn-pairing {
    flex: 1;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: 0.2s;
}
.btn-pairing:hover, .btn-pairing.selected {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(128, 0, 32, 0.05);
}
.mt-10 { margin-top: 10px; }

/* Modal Dialog */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    max-width: 420px;
    width: 90%;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 101;
}

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

.modal-header h3 {
    font-size: 18px;
    color: var(--text-main);
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

.settings-hint {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.field-hint {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.feedback-box {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.feedback-box.hidden {
    display: none;
}

.feedback-box.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback-box.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

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

.modal-actions .btn {
    padding: 12px;
    font-size: 14px;
}
