/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-sans:  'Plus Jakarta Sans', sans-serif;
  --font-serif: 'Instrument Serif', serif;

  --bg:         #F7F6F2;
  --bg-card:    #FFFFFF;
  --bg-muted:   #EFEDE8;

  --text:       #1A1916;
  --text-muted: #7A7870;
  --text-hint:  #B0AEA8;

  --border:     #E2E0DA;
  --border-md:  #C8C6BF;

  --accent:     #2D2A5E;
  --accent-mid: #4A469E;
  --accent-lt:  #EEEDFE;
  --accent-text:#3C3489;

  --pos:        #0F6E56;
  --pos-lt:     #E1F5EE;
  --pos-text:   #085041;

  --neg:        #993C1D;
  --neg-lt:     #FAECE7;
  --neg-text:   #712B13;

  --neu:        #534AB7;
  --neu-lt:     #EEEDFE;
  --neu-text:   #3C3489;

  --success-bg: #EAF3DE;
  --success-text:#27500A;
  --danger-bg:  #FCEBEB;
  --danger-text:#791F1F;
  --warn-bg:    #FAEEDA;
  --warn-text:  #633806;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ─── Typography ────────────────────────────────────────────────────────────── */
h1 { font-size: 2rem;   font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.4rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: .95rem; font-weight: 600; }
p  { font-size: .95rem; color: var(--text-muted); line-height: 1.7; }

.serif { font-family: var(--font-serif); font-style: italic; }
.label {
  font-size: .7rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-hint);
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 16px 20px; border-radius: var(--radius); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer; transition: all .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-mid); border-color: var(--accent-mid); }

.btn-outline {
  background: transparent; color: var(--text);
  border-color: var(--border-md);
}
.btn-outline:hover { background: var(--bg-muted); }

.btn-danger {
  background: var(--danger-bg); color: var(--danger-text);
  border-color: #F7C1C1;
}
.btn-danger:hover { background: #F7C1C1; }

.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: .72rem; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  letter-spacing: .03em;
}
.badge-pos { background: var(--pos-lt); color: var(--pos-text); }
.badge-neg { background: var(--neg-lt); color: var(--neg-text); }
.badge-neu { background: var(--neu-lt); color: var(--neu-text); }
.badge-accent { background: var(--accent-lt); color: var(--accent-text); }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warn    { background: var(--warn-bg);    color: var(--warn-text);    }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text);  }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--text); }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px rgba(74,70,158,.12);
}
.form-hint { font-size: .78rem; color: var(--text-hint); }

/* ─── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: .875rem; margin-bottom: 16px;
  border-left: 3px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--pos); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: #E24B4A; }
.alert-warn    { background: var(--warn-bg);    color: var(--warn-text);    border-color: #EF9F27; }
.alert-info    { background: var(--accent-lt);  color: var(--accent-text);  border-color: var(--neu); }

/* ─── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--bg-muted);
  padding: 12px 16px; text-align: left;
  font-size: .72rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-hint);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-muted); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* ─── Pagination ────────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 24px; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm); font-size: .85rem;
  border: 1px solid var(--border);
}
.pagination a { color: var(--text-muted); transition: all .15s; }
.pagination a:hover { background: var(--bg-muted); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ─── Stat cards ────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--bg-muted);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .stat-label { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-hint); margin-bottom: 6px; }
.stat-card .stat-val   { font-size: 1.6rem; font-weight: 600; line-height: 1; }
.stat-card .stat-sub   { font-size: .78rem; color: var(--text-hint); margin-top: 3px; }
.stat-val.pos { color: var(--pos); }
.stat-val.neg { color: var(--neg); }
.stat-val.neu { color: var(--neu); }

/* ─── Sentiment bar ─────────────────────────────────────────────────────────── */
.sent-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 12px 0 8px; }
.sent-bar .bar-pos { background: #1D9E75; }
.sent-bar .bar-neg { background: #D85A30; }
.sent-bar .bar-neu { background: #7F77DD; }
.sent-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.sent-legend span { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-pos { background: #1D9E75; }
.dot-neg { background: #D85A30; }
.dot-neu { background: #7F77DD; }

/* ─── Divider ───────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ─── Flash messages ────────────────────────────────────────────────────────── */
.flash-wrap { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.flash-item {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ─── Empty state ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-hint); }
.empty-state h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 6px; }
.empty-state p  { font-size: .875rem; }

/* ─── Upload zone ───────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-md);
  border-radius: var(--radius-lg);
  padding: 40px 24px; text-align: center;
  transition: all .2s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent-mid);
  background: var(--accent-lt);
}
.upload-zone .uz-icon {
  width: 48px; height: 48px; margin: 0 auto 12px;
  background: var(--accent-lt); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.upload-zone .uz-icon svg { width: 22px; height: 22px; stroke: var(--accent-mid); }

/* ─── Steps ─────────────────────────────────────────────────────────────────── */
.steps { display: flex; flex-direction: column; gap: 10px; }
.step-item { display: flex; align-items: center; gap: 10px; font-size: .875rem; }
.step-dot  { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.step-done { color: var(--text-muted); }
.step-done .step-dot { background: var(--pos); }
.step-active { color: var(--text); font-weight: 500; }
.step-active .step-dot { background: var(--neu); }
.step-wait { color: var(--text-hint); }
.step-wait .step-dot { background: var(--border-md); }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .container, .container-sm { padding: 0 16px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
