
:root {
    --wine:      #7B1D2A;
    --wine-deep: #4E0F18;
    --wine-lt:   #A8324A;
    --gold:      #C9A84C;
    --gold-lt:   #E8C97A;
    --cream:     #F9F4EE;
    --cream-d:   #EDE6DA;
    --ink:       #1A1209;
    --ink-mid:   #3D2B1A;
    --ink-soft:  #6B5040;
    --white:     #FFFFFF;
    --border:    rgba(123,29,42,0.15);
    --shadow:    0 4px 32px rgba(26,18,9,0.12);
    --radius:    12px;
    --ff-display:'Playfair Display', Georgia, serif;
    --ff-body:   'DM Sans', system-ui, sans-serif;
    --nav-h:     70px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--ff-body);
    background: var(--cream);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.6;
}


::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--cream-d); }
::-webkit-scrollbar-thumb { background: var(--wine-lt); border-radius: 3px; }


.auth-page { min-height: 100vh; }

.auth-split {
    display: grid;
    grid-template-columns: 1fr 520px;
    min-height: 100vh;
}


.auth-hero {
    background: linear-gradient(145deg, var(--wine-deep) 0%, var(--wine) 50%, var(--wine-lt) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    position: relative;
    overflow: hidden;
}

.hero-content { position: relative; z-index: 2; color: var(--cream); }

.logo-block {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
}
.logo-grape { font-size: 2rem; }
.logo-text {
    font-family: var(--ff-display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--gold-lt);
}
.logo-text em { font-style: normal; color: var(--white); }

.auth-hero h1 {
    font-family: var(--ff-display);
    font-size: clamp(2rem, 3.5vw, 3.2rem);
    line-height: 1.15;
    margin-bottom: 24px;
    color: var(--cream);
}
.auth-hero h1 em { font-style: italic; color: var(--gold-lt); }

.hero-sub {
    font-size: 1.05rem;
    opacity: 0.8;
    max-width: 480px;
    margin-bottom: 48px;
    color: var(--cream-d);
}

.hero-stats {
    display: flex;
    gap: 40px;
}
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num {
    font-family: var(--ff-display);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--gold-lt);
    line-height: 1;
}
.stat-label { font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }


.hero-deco { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.deco-circle {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(201,168,76,0.2);
}
.c1 { width: 400px; height: 400px; top: -100px; right: -100px; }
.c2 { width: 600px; height: 600px; bottom: -200px; left: -150px; opacity: 0.5; }
.deco-line {
    position: absolute;
    background: linear-gradient(to right, transparent, rgba(201,168,76,0.3), transparent);
    height: 1px;
    width: 100%;
}
.l1 { top: 35%; }
.l2 { top: 65%; opacity: 0.5; }


.auth-panel {
    background: var(--white);
    display: flex;
    flex-direction: column;
    padding: 60px 48px;
    overflow-y: auto;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 40px;
    border-bottom: 2px solid var(--cream-d);
}
.tab-btn {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    font-family: var(--ff-body);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab-btn.active { color: var(--wine); border-bottom-color: var(--wine); }

.auth-form { display: none; }
.auth-form.active { display: flex; flex-direction: column; gap: 20px; }
.auth-form h2 {
    font-family: var(--ff-display);
    font-size: 1.8rem;
    color: var(--ink);
}
.form-sub { color: var(--ink-soft); font-size: 0.9rem; margin-top: -12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mid); font-weight: 500; }
.field input {
    padding: 13px 16px;
    border: 1.5px solid var(--cream-d);
    border-radius: 8px;
    font-family: var(--ff-body);
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--cream);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.field input:focus {
    border-color: var(--wine);
    box-shadow: 0 0 0 3px rgba(123,29,42,0.08);
    background: var(--white);
}
.hint { font-size: 0.78rem; color: var(--ink-soft); }

.btn-primary {
    padding: 15px 28px;
    background: var(--wine);
    color: var(--cream);
    border: none;
    border-radius: 8px;
    font-family: var(--ff-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    margin-top: 4px;
}
.btn-primary:hover { background: var(--wine-deep); box-shadow: 0 6px 20px rgba(123,29,42,0.3); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
}
.alert-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }


.app-body { display: flex; min-height: 100vh; background: var(--cream); }


.sidebar {
    width: 260px;
    background: var(--wine-deep);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 28px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo span { font-size: 1.5rem; }
.sidebar-logo strong {
    font-family: var(--ff-display);
    font-size: 1.1rem;
    color: var(--gold-lt);
    font-weight: 700;
}
.sidebar-logo em { display: block; font-style: normal; font-size: 0.7rem; color: rgba(249,244,238,0.5); letter-spacing: 0.08em; text-transform: uppercase; }

.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-section { margin-bottom: 8px; }
.nav-label {
    padding: 8px 24px 4px;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(249,244,238,0.35);
    font-weight: 500;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: rgba(249,244,238,0.7);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 400;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: var(--cream); }
.nav-link.active { background: rgba(201,168,76,0.12); color: var(--gold-lt); border-left-color: var(--gold); }
.nav-link .icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-user {
    padding: 20px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 36px; height: 36px;
    background: var(--wine-lt);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--ff-display);
    font-size: 0.9rem;
    color: var(--cream);
    font-weight: 700;
    flex-shrink: 0;
}
.user-info strong { display: block; font-size: 0.82rem; color: var(--cream); font-weight: 500; }
.user-info small { font-size: 0.72rem; color: rgba(249,244,238,0.45); }
.user-info a { font-size: 0.72rem; color: rgba(249,244,238,0.45); text-decoration: none; }
.user-info a:hover { color: var(--gold-lt); }


.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 40px;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-family: var(--ff-display); font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.topbar-actions { display: flex; gap: 12px; align-items: center; }

.page-body { padding: 36px 40px; flex: 1; }


.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px 28px;
    border: 1px solid var(--border);
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.icon-wine { background: rgba(123,29,42,0.1); }
.icon-grape { background: rgba(201,168,76,0.12); }
.icon-map { background: rgba(78,15,24,0.08); }
.icon-bottle { background: rgba(168,50,74,0.1); }

.stat-card-val { font-family: var(--ff-display); font-size: 2rem; font-weight: 700; color: var(--wine); line-height: 1; }
.stat-card-label { font-size: 0.78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }


.table-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.table-header h3 { font-family: var(--ff-display); font-size: 1.1rem; font-weight: 700; }

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--cream);
    border: 1px solid var(--cream-d);
    border-radius: 8px;
    padding: 8px 14px;
    min-width: 240px;
}
.search-bar input {
    border: none;
    background: none;
    font-family: var(--ff-body);
    font-size: 0.88rem;
    color: var(--ink);
    outline: none;
    flex: 1;
}
.search-bar span { color: var(--ink-soft); }

.filter-row {
    padding: 12px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--cream);
}
.filter-row select, .filter-row input[type="number"] {
    padding: 7px 12px;
    border: 1px solid var(--cream-d);
    border-radius: 6px;
    font-family: var(--ff-body);
    font-size: 0.82rem;
    color: var(--ink);
    background: var(--white);
    cursor: pointer;
    outline: none;
}

table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--cream); }
th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th a { color: var(--ink-soft); text-decoration: none; }
th a:hover { color: var(--wine); }
td {
    padding: 13px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(123,29,42,0.06);
    color: var(--ink-mid);
}
tbody tr:hover { background: rgba(249,244,238,0.6); }
tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.04em;
}
.badge-wine { background: rgba(123,29,42,0.1); color: var(--wine); }
.badge-gold { background: rgba(201,168,76,0.15); color: #8B6914; }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-blue  { background: #DBEAFE; color: #1E40AF; }
.badge-red   { background: #FEE2E2; color: #991B1B; }

.action-btns { display: flex; gap: 6px; }
.btn-sm {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px;
    transition: all 0.15s;
}
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--ink-mid); }
.btn-outline:hover { border-color: var(--wine); color: var(--wine); }
.btn-danger { background: #FEE2E2; color: #991B1B; }
.btn-danger:hover { background: #991B1B; color: white; }
.btn-success { background: #D1FAE5; color: #065F46; }
.btn-success:hover { background: #065F46; color: white; }


.btn { padding: 10px 20px; border-radius: 8px; font-family: var(--ff-body); font-size: 0.88rem; font-weight: 500; border: none; cursor: pointer; transition: all 0.15s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-wine { background: var(--wine); color: var(--cream); }
.btn-wine:hover { background: var(--wine-deep); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); color: var(--ink-mid); }
.btn-ghost:hover { border-color: var(--wine); color: var(--wine); }


.pagination {
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.pagination-info { font-size: 0.82rem; color: var(--ink-soft); }
.pagination-links { display: flex; gap: 4px; }
.page-link {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--ink-mid);
    text-decoration: none;
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.page-link:hover, .page-link.active { background: var(--wine); color: var(--cream); border-color: var(--wine); }


.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(26,18,9,0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(26,18,9,0.25);
    animation: modalIn 0.25s ease-out;
}
@keyframes modalIn { from { opacity:0; transform:scale(0.96) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }

.modal-head {
    padding: 24px 28px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-head h3 { font-family: var(--ff-display); font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--ink-soft); line-height: 1; padding: 4px; border-radius: 4px; }
.modal-close:hover { background: var(--cream); }

.modal-body { padding: 24px 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-mid); font-weight: 500; }
.form-field input, .form-field select, .form-field textarea {
    padding: 10px 14px;
    border: 1.5px solid var(--cream-d);
    border-radius: 8px;
    font-family: var(--ff-body);
    font-size: 0.88rem;
    color: var(--ink);
    background: var(--cream);
    outline: none;
    transition: border-color 0.2s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    border-color: var(--wine);
    background: var(--white);
}
.form-field textarea { resize: vertical; min-height: 80px; }

.modal-foot {
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}


.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.section-header h2 { font-family: var(--ff-display); font-size: 1.5rem; }
.section-header p { color: var(--ink-soft); font-size: 0.88rem; margin-top: 2px; }


.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}
.report-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.report-card-head {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.report-card-head h4 { font-family: var(--ff-display); font-size: 1rem; }
.report-card-body { padding: 0; }

.rank-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid rgba(123,29,42,0.05);
    transition: background 0.15s;
}
.rank-row:last-child { border-bottom: none; }
.rank-row:hover { background: var(--cream); }
.rank-num { width: 24px; height: 24px; border-radius: 50%; background: var(--cream-d); display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); flex-shrink: 0; }
.rank-num.gold { background: var(--gold); color: var(--white); }
.rank-info { flex: 1; }
.rank-name { font-weight: 500; font-size: 0.88rem; color: var(--ink); }
.rank-sub { font-size: 0.75rem; color: var(--ink-soft); }
.rank-val { font-family: var(--ff-display); font-weight: 700; color: var(--wine); font-size: 1rem; }


@media (max-width: 900px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-panel { padding: 40px 28px; }
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: none; }
    .main-content { margin-left: 0; }
    .page-body { padding: 24px 20px; }
    .topbar { padding: 0 20px; }
    .form-grid { grid-template-columns: 1fr; }
}


.text-wine { color: var(--wine); }
.text-gold { color: var(--gold); }
.text-soft { color: var(--ink-soft); }
.font-display { font-family: var(--ff-display); }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-6 { margin-top: 24px; }
.gap-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.w100 { width: 100%; }


.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }


.empty-state {
    padding: 60px 24px;
    text-align: center;
    color: var(--ink-soft);
}
.empty-state span { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }
