/* ═══════════════════════════════════════════════════════
   FATURABOT — Temiz, minimal, göz yormayan tasarım
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --radius: 10px;
  --radius-lg: 14px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0; color: var(--text-2); }

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

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
  transition: all .15s; border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* AUTH */
.auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(180deg, #f8fafc 0%, #eff6ff 100%);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: var(--radius-lg); padding: 32px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand h1 { font-size: 1.5rem; margin: 8px 0 4px; }
.auth-brand p { color: var(--text-3); font-size: 13px; }
.brand-logo {
  font-size: 40px; display: inline-flex;
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--primary-soft);
  align-items: center; justify-content: center; margin-bottom: 4px;
}
.brand-logo.small { font-size: 22px; width: 36px; height: 36px; border-radius: 10px; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius); margin-bottom: 20px; }
.auth-tabs .tab { flex: 1; padding: 8px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: all .15s; }
.auth-tabs .tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; color: var(--text); background: var(--surface); transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-footer { margin-top: 24px; color: var(--text-3); font-size: 12px; text-align: center; max-width: 400px; }

/* APP SHELL */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 16px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; font-size: 14px; transition: all .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a span { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 14px; }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 0 4px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.user-meta { overflow: hidden; flex: 1; }
.user-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { padding: 32px 40px; max-width: 1200px; width: 100%; margin: 0 auto; }
.page-header { margin-bottom: 28px; }
.page-header .subtitle { color: var(--text-3); margin-top: 4px; font-size: 13px; }
.flex-between { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.header-actions input[type="search"] { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; min-width: 240px; }
.back-link { font-size: 13px; color: var(--text-3); display: inline-block; margin-bottom: 4px; }

/* DASHBOARD */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-card.accent { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%); color: white; border-color: transparent; }
.stat-card.accent .stat-label { color: rgba(255,255,255,.8); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
.stat-value { font-size: 1.75rem; font-weight: 700; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.panel-head { margin-bottom: 16px; }

.chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 20px; }
.bar {
  flex: 1; background: var(--surface-2); border-radius: 6px 6px 0 0;
  position: relative; min-height: 4px; display: flex; flex-direction: column; justify-content: flex-end;
}
.bar-inner { background: var(--primary); border-radius: 6px 6px 0 0; min-height: 4px; transition: background .2s; }
.bar:hover .bar-inner { background: var(--primary-hover); }
.bar .bar-value { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 4px; font-size: 11px; color: var(--text-2); white-space: nowrap; font-weight: 600; }
.bar .bar-label { padding: 6px 0; text-align: center; font-size: 10px; color: var(--text-3); }

.top-stores { display: flex; flex-direction: column; gap: 8px; }
.top-store-row { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.top-store-row .store-count { font-size: 12px; color: var(--text-3); }
.top-store-row .store-total { font-weight: 600; }

/* UPLOAD */
.upload-zone {
  background: var(--surface); border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg); padding: 48px 24px; text-align: center; transition: all .2s;
}
.upload-zone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.upload-zone .upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone h2 { margin-bottom: 4px; }
.upload-buttons { display: flex; gap: 10px; justify-content: center; margin: 20px 0 12px; flex-wrap: wrap; }
.processing { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; margin-top: 16px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.banner.success { background: var(--success-soft); color: #15803d; border: 1px solid #bbf7d0; }
.banner.warning { background: var(--warning-soft); color: #b45309; border: 1px solid #fde68a; }
.banner.error { background: var(--danger-soft); color: #b91c1c; border: 1px solid #fecaca; }

/* RECEIPTS LIST */
.receipts-list { display: flex; flex-direction: column; gap: 8px; }
.receipt-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; transition: all .15s;
}
.receipt-row:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.receipt-row .store { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.receipt-row .meta { font-size: 12px; color: var(--text-3); }
.receipt-row .total { font-weight: 700; font-size: 15px; text-align: right; }
.receipt-row .badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--text-2); }
.receipt-row .badge.low { background: var(--warning-soft); color: var(--warning); }
.receipt-row .badge.medium { background: var(--warning-soft); color: var(--warning); }
.receipt-row .badge.high { background: var(--success-soft); color: var(--success); }

.empty-state { text-align: center; padding: 64px 24px; background: var(--surface); border: 1px dashed var(--border-2); border-radius: var(--radius-lg); color: var(--text-3); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 8px; }

/* RECEIPT DETAIL */
.items-table-wrap { overflow-x: auto; }
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th { text-align: left; padding: 10px 12px; background: var(--surface-2); font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.items-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.items-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.items-table tr:last-child td { border-bottom: none; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kv { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kv span { display: block; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.kv strong { font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kv.primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%); color: white; border-color: transparent; }
.kv.primary span { color: rgba(255,255,255,.8); }

.vat-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 16px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.vat-row:last-child { border-bottom: none; }

/* TOAST */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13px; max-width: 360px; animation: slideIn .2s ease-out; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* MOBILE */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; padding: 0; flex-direction: row; border-right: none; border-top: 1px solid var(--border); z-index: 50; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .nav { flex-direction: row; gap: 0; padding: 6px; }
  .nav a { flex: 1; flex-direction: column; gap: 4px; padding: 8px 4px; text-align: center; font-size: 11px; }
  .nav a span { font-size: 18px; }
  .main { padding: 20px 16px 100px; }
  .page-header h1 { font-size: 1.375rem; }
  .header-actions { width: 100%; }
  .header-actions input[type="search"] { flex: 1; min-width: 0; }
}
