:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --border: #2e3248;
  --text: #e8eaf0;
  --text-muted: #8b91a8;
  --primary: #4f7cff;
  --primary-dark: #3a62e0;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.35);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .75rem 2rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: .5rem; margin-right: auto; }
.brand-icon { font-size: 1.4rem; }
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand-sub { color: var(--text-muted); font-size: .8rem; }
.nav-links { display: flex; gap: .25rem; }
.nav-link {
  padding: .4rem .9rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--bg3);
  color: var(--text);
  text-decoration: none;
}
.nav-user { display: flex; align-items: center; gap: .75rem; }
.nav-user-name { color: var(--text-muted); font-size: .875rem; }
.btn-logout {
  padding: .35rem .8rem;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-logout:hover { background: var(--bg3); color: var(--text); text-decoration: none; }

/* ── Main ── */
.main-content { padding: 2rem; max-width: 1300px; margin: 0 auto; }

/* ── Alerts ── */
.alerts { margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: .5rem; }
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  border-left: 4px solid;
}
.alert-success { background: rgba(46,204,113,.1); border-color: var(--success); color: #a8e6c3; }
.alert-danger  { background: rgba(231,76,60,.1);  border-color: var(--danger);  color: #f0a8a0; }
.alert-warning { background: rgba(243,156,18,.1); border-color: var(--warning); color: #f7d59a; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  border: none; cursor: pointer;
  font-size: .875rem; font-weight: 500;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary{ background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-full     { width: 100%; justify-content: center; }
.btn-xs       { padding: .25rem .6rem; font-size: .75rem; border-radius: 4px; }
.btn-sm       { padding: .35rem .75rem; font-size: .8rem; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card h3 {
  font-size: 1rem; font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
}
.card-danger { border-color: rgba(231,76,60,.3); }
.card-danger h3 { color: var(--danger); }

/* ── Page header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column; gap: .4rem;
}
.stat-label { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }

/* ── Filters ── */
.filters-form {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: .35rem; flex: 1; min-width: 160px; }
.form-group label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.form-input, .form-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .5rem .75rem;
  font-size: .875rem;
  font-family: inherit;
  transition: border-color .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input-sm { max-width: 110px; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.form-meta { color: var(--text-muted); font-size: .8rem; margin-bottom: .75rem; }
textarea.form-input { resize: vertical; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.table th {
  background: var(--bg3);
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(79,124,255,.04); }
.table tfoot td { font-weight: 600; background: var(--bg3); }
.table-sm th, .table-sm td { padding: .45rem .75rem; font-size: .8rem; }
.row-disabled td { opacity: .5; }
.amount { font-variant-numeric: tabular-nums; text-align: right; }
.actions-cell { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-pending   { background: rgba(243,156,18,.15); color: #f39c12; }
.badge-validated { background: rgba(46,204,113,.15); color: #2ecc71; }
.badge-rejected  { background: rgba(231,76,60,.15);  color: #e74c3c; }
.badge-admin     { background: rgba(79,124,255,.15); color: var(--primary); }
.badge-user      { background: rgba(139,145,168,.15); color: var(--text-muted); }
.badge-cat       { background: var(--bg3); color: var(--text-muted); }

/* ── Pagination ── */
.pagination { display: flex; gap: .4rem; margin-top: 1rem; }
.page-link {
  padding: .35rem .75rem;
  border-radius: var(--radius);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .8rem;
}
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
}

/* ── Login ── */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 2rem;
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.brand-icon-lg { font-size: 3rem; display: block; margin-bottom: .5rem; }
.login-logo h1 { font-size: 1.6rem; font-weight: 800; }
.login-logo p { color: var(--text-muted); font-size: .875rem; }
.login-card .form-group { margin-bottom: 1rem; }
.login-card .btn-full { margin-top: .5rem; padding: .75rem; font-size: 1rem; }

/* ── Upload ── */
.upload-card { max-width: 600px; }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  margin-bottom: 1rem;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(79,124,255,.05);
}
.drop-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-icon { font-size: 3rem; margin-bottom: .75rem; }
.drop-text { font-size: 1rem; font-weight: 500; margin-bottom: .25rem; }
.drop-sub { color: var(--text-muted); font-size: .875rem; }
.file-preview { margin-top: 1rem; }
.file-preview img { max-height: 200px; border-radius: var(--radius); }
.upload-info { color: var(--text-muted); font-size: .8rem; margin-bottom: 1.25rem; line-height: 1.8; }

.progress-wrap { margin-bottom: 1rem; }
.progress-bar {
  height: 6px; background: var(--bg3);
  border-radius: 999px; overflow: hidden; margin-bottom: .4rem;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width .3s;
  animation: progress-anim 2s linear infinite;
}
@keyframes progress-anim { 0%{width:10%} 50%{width:80%} 100%{width:95%} }
.progress-label { color: var(--text-muted); font-size: .8rem; }

/* ── Ticket layout ── */
.ticket-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) { .ticket-layout { grid-template-columns: 1fr; } }
.ticket-img {
  width: 100%; border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform .2s;
}
.ticket-img.img-zoom {
  transform: scale(2);
  transform-origin: top left;
  cursor: zoom-out;
  position: relative; z-index: 10;
}
.ocr-raw {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-muted);
}
.add-item-form { margin-top: 1rem; }
.add-item-form summary {
  cursor: pointer; color: var(--primary);
  font-size: .875rem; font-weight: 500;
  padding: .5rem 0;
  list-style: none;
}
.item-form { margin-top: .75rem; }
.inline-form {
  display: inline-flex; align-items: center; gap: .4rem;
  margin-top: .25rem;
}
.text-muted { color: var(--text-muted); }

/* ── Utility ── */
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
