:root {
  --bg: #080b10;
  --bg-elevated: #0e1219;
  --surface: #131922;
  --surface-hover: #1a2230;
  --surface-2: #1e2736;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --text: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #4f8cff;
  --accent-soft: rgba(79,140,255,.12);
  --accent-glow: rgba(79,140,255,.35);
  --success: #34d399;
  --success-soft: rgba(52,211,153,.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251,191,36,.12);
  --danger: #f87171;
  --danger-soft: rgba(248,113,113,.12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
  --sidebar-w: 280px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0c1018 0%, #0a0d14 100%);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.content-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1.75rem 2rem 0;
  flex-wrap: wrap;
}

.page-content { padding: 1.5rem 2rem 2.5rem; flex: 1; }

.page-title { font-size: 1.625rem; font-weight: 700; letter-spacing: -.02em; }
.page-subtitle { color: var(--text-secondary); font-size: .925rem; margin-top: .2rem; }

/* Brand */
.brand { display: flex; gap: .85rem; align-items: center; margin-bottom: 1.5rem; }

.brand-mark {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: .85rem;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.brand-name { font-size: 1.15rem; font-weight: 700; }
.brand-name span { color: var(--accent); }
.brand-tag { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }

/* Pipeline mini */
.pipeline-mini { margin-bottom: 1.5rem; padding: .85rem; background: var(--surface); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.pipeline-mini-header { display: flex; justify-content: space-between; font-size: .78rem; color: var(--text-secondary); margin-bottom: .5rem; }
.pipeline-mini-header strong { color: var(--accent); }

.progress-track { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #7c5cff); border-radius: 99px; transition: width .6s ease; }

/* Nav */
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: .75rem .75rem .35rem; font-weight: 600; }

.nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .75rem; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: .875rem; font-weight: 500;
  transition: all .15s; margin-bottom: .15rem;
}

.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px rgba(79,140,255,.25); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-count, .nav-badge {
  margin-left: auto; font-style: normal; font-size: .7rem; font-weight: 600;
  padding: .15rem .45rem; border-radius: 99px; background: var(--surface-2); color: var(--text-secondary);
}
.nav-badge.danger { background: var(--danger-soft); color: var(--danger); }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.ai-badge {
  display: flex; align-items: center; gap: .4rem;
  font-size: .75rem; color: var(--accent); margin-bottom: .35rem;
}
.sidebar-footer small { color: var(--text-muted); font-size: .7rem; }

/* Stats */
.stats-grid { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.stats-grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stats-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  transition: border-color .2s, transform .2s;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.stat-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card .label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-card .value { font-size: 1.65rem; font-weight: 700; margin-top: .35rem; letter-spacing: -.02em; }
.stat-card .value small { font-size: .85rem; font-weight: 500; color: var(--text-secondary); margin-left: .15rem; }
.stat-card.accent .value { color: var(--accent); }
.stat-card.success .value { color: var(--success); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.danger .value { color: var(--danger); }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
}
.panel-accent { background: linear-gradient(135deg, rgba(79,140,255,.08), rgba(124,92,255,.05)); border-color: rgba(79,140,255,.2); }
.panel-highlight { border-color: rgba(79,140,255,.3); background: linear-gradient(180deg, var(--surface) 0%, rgba(79,140,255,.04) 100%); }
.panel-compact { max-width: 340px; }
.panel-wide { flex: 1; }

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.15rem; gap: 1rem; flex-wrap: wrap;
}
.panel-header h2 { font-size: 1rem; font-weight: 600; }
.panel-header p { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1.25rem; }
.grid-2-1 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.grid-upload-table { display: grid; grid-template-columns: 320px 1fr; gap: 1.25rem; }

/* Steps horizontal */
.steps-horizontal { display: flex; align-items: center; gap: 0; flex-wrap: wrap; padding: .5rem 0; }
.step-item { display: flex; flex-direction: column; align-items: center; gap: .4rem; min-width: 80px; }
.step-item span { font-size: .72rem; color: var(--text-muted); text-align: center; }
.step-item.done span { color: var(--success); }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--border-strong);
  display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: var(--text-muted);
}
.step-item.done .step-dot { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.step-item.done .step-dot .nav-icon { width: 14px; height: 14px; }
.step-line { flex: 1; height: 2px; background: var(--border); min-width: 24px; margin-bottom: 1.2rem; }
.step-line.done { background: var(--success); opacity: .5; }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.quick-action {
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: .82rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: all .15s;
  width: 100%; text-align: left;
}
.quick-action:hover { background: var(--surface-hover); border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.quick-action .nav-icon { width: 16px; height: 16px; color: var(--accent); }

/* Process page */
.process-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 2rem;
  padding: 1.75rem 2rem; margin-bottom: 1.5rem;
  background: linear-gradient(135deg, rgba(79,140,255,.1) 0%, rgba(124,92,255,.06) 50%, transparent 100%);
  border: 1px solid rgba(79,140,255,.2); border-radius: var(--radius);
}
.process-hero .eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 600; }
.process-hero h2 { font-size: 1.35rem; margin: .35rem 0; }
.process-hero p { color: var(--text-secondary); font-size: .9rem; max-width: 520px; }

.process-progress-ring { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.process-progress-ring svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.ring-fill { fill: none; stroke: url(#grad); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 327; transition: stroke-dashoffset .8s ease; stroke: var(--accent); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label strong { font-size: 1.5rem; }
.ring-label span { font-size: .68rem; color: var(--text-muted); }

.process-steps { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }

.process-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
}
.process-card.completed { border-color: rgba(52,211,153,.25); }
.process-card-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.015);
}
.step-badge {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.process-card.completed .step-badge { background: var(--success-soft); color: var(--success); }
.process-card-header h3 { font-size: .975rem; font-weight: 600; }
.process-card-header p { font-size: .8rem; color: var(--text-muted); margin-top: .1rem; }
.status-pill {
  margin-left: auto; display: flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; padding: .3rem .65rem; border-radius: 99px;
}
.status-pill.success { background: var(--success-soft); color: var(--success); }
.status-pill .nav-icon { width: 14px; height: 14px; }

.process-card-body { padding: 1.35rem; }
.action-step { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.action-info { display: flex; gap: 2rem; flex-wrap: wrap; }
.metric-row { display: flex; flex-direction: column; gap: .15rem; }
.metric-row span { font-size: .75rem; color: var(--text-muted); }
.metric-row strong { font-size: 1.25rem; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.muted-text { color: var(--text-secondary); font-size: .9rem; }
.action-buttons { display: flex; gap: .65rem; flex-wrap: wrap; }
.result-chip { margin-top: .85rem; font-size: .8rem; padding: .45rem .75rem; border-radius: 8px; display: inline-block; }
.result-chip.success { background: var(--success-soft); color: var(--success); }
.result-chip.warning { background: var(--warning-soft, rgba(245,158,11,.12)); color: var(--warning, #f59e0b); }

/* Fatura analiz servis durumu */
.service-status-panel {
  margin: 0 1.5rem 0;
  padding: .85rem 1rem;
  background: linear-gradient(135deg, rgba(59,130,246,.08), rgba(124,92,255,.06));
  border: 1px solid rgba(59,130,246,.22);
  border-radius: var(--radius-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.service-status-panel.hidden { display: none; }
.service-status-panel.is-complete {
  border-color: rgba(34,197,94,.35);
  background: linear-gradient(135deg, rgba(34,197,94,.08), rgba(59,130,246,.04));
}
.service-status-panel.is-error {
  border-color: rgba(239,68,68,.35);
  background: linear-gradient(135deg, rgba(239,68,68,.08), rgba(245,158,11,.04));
}
.service-status-inner { display: flex; flex-direction: column; gap: .55rem; }
.service-status-header {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.service-status-title-wrap { display: flex; align-items: center; gap: .5rem; }
.service-status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(59,130,246,.5);
  animation: pulse-dot 1.8s ease infinite;
}
.service-status-panel.is-complete .service-status-dot {
  background: var(--success); animation: none; box-shadow: none;
}
.service-status-panel.is-error .service-status-dot {
  background: var(--danger, #ef4444); animation: none;
}
.service-status-panel.is-offline .service-status-dot {
  background: var(--warning, #f59e0b); animation: none;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(59,130,246,.45); }
  70% { box-shadow: 0 0 0 8px rgba(59,130,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}
.service-status-badge {
  font-size: .95rem; font-weight: 700; color: var(--accent);
  min-width: 3rem; text-align: right;
}
.service-progress-track { height: 8px; }
.service-status-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; font-size: .78rem; color: var(--text-secondary);
}
.service-connection { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; }
.service-connection.ok { background: var(--success-soft); color: var(--success); }
.service-connection.warn { background: rgba(245,158,11,.15); color: #f59e0b; }
.service-connection.err { background: rgba(239,68,68,.12); color: #ef4444; }

.pipeline-form-row { display: flex; gap: 1rem; align-items: stretch; flex-wrap: wrap; }
.pipeline-form-row .dropzone-inline { flex: 1; min-width: 280px; }

/* Dropzone */
.dropzone-form { display: flex; flex-direction: column; gap: .85rem; }

.dropzone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1.75rem 1.25rem;
  text-align: center;
  transition: all .2s;
  background: rgba(255,255,255,.02);
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.dropzone-inline { padding: 1rem; text-align: left; }
.dropzone-icon { color: var(--accent); margin-bottom: .5rem; }
.dropzone-icon .nav-icon { width: 32px; height: 32px; margin: 0 auto; }
.dropzone-label { font-weight: 600; font-size: .9rem; }
.dropzone-hint { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.dropzone-file { font-size: .8rem; color: var(--accent); margin-top: .5rem; min-height: 1.2em; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

.data-table { width: 100%; border-collapse: collapse; font-size: .855rem; }
.data-table th, .data-table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th {
  background: rgba(255,255,255,.03);
  color: var(--text-muted); font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,.025); }
.data-table .nowrap { white-space: nowrap; }
.data-table .truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.data-table .amount.danger { color: var(--danger); }
.data-table .muted { color: var(--text-muted); font-size: .8rem; }
.data-table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.data-table .col-actions form { margin: 0; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.filter-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .82rem; color: var(--text-secondary); margin-right: .75rem;
}
.filter-toggle input { accent-color: var(--accent); }
.panel-note { margin-top: .75rem; font-size: .82rem; }
.badge-accent { background: rgba(59,130,246,.15); color: #60a5fa; }
.row-danger td { background: rgba(248,113,113,.04); }

.progress-inline { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: .2rem; }
.progress-inline-fill { height: 100%; background: var(--accent); border-radius: 99px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: .22rem .6rem; border-radius: 99px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--text-secondary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  border: none; font-family: var(--font);
  font-size: .855rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #6366f1); color: #fff; box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.btn-danger { color: #f87171; border-color: rgba(248,113,113,.35); }
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,.12); color: #fca5a5; }
.btn-sm { padding: .45rem .85rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.35rem; font-size: .925rem; }
.btn-block { width: 100%; }

.file-pick { position: relative; overflow: hidden; cursor: pointer; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Search */
.search-box input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem 1rem;
  color: var(--text);
  font-family: var(--font);
  font-size: .855rem;
  min-width: 220px;
  outline: none;
  transition: border-color .15s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }

.link-muted { font-size: .82rem; color: var(--text-muted); text-decoration: none; }
.link-muted:hover { color: var(--accent); }

.legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: .35rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.success { background: var(--success); }
.dot.danger { background: var(--danger); }

/* Alert banners */
.alert-banner {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: 1.15rem 1.35rem; border-radius: var(--radius);
  margin-bottom: 1.25rem; border: 1px solid;
}
.alert-banner.danger { background: var(--danger-soft); border-color: rgba(248,113,113,.3); }
.alert-banner.success { background: var(--success-soft); border-color: rgba(52,211,153,.3); }
.alert-banner-icon .nav-icon { width: 22px; height: 22px; }
.alert-banner strong { display: block; margin-bottom: .15rem; }
.alert-banner p { font-size: .875rem; color: var(--text-secondary); }

/* Empty state */
.empty-state {
  text-align: center; padding: 2.5rem 1.5rem; color: var(--text-muted);
}
.empty-state.compact { padding: 1.5rem; }
.empty-icon { color: var(--text-muted); opacity: .5; margin-bottom: .75rem; }
.empty-icon .nav-icon { width: 40px; height: 40px; margin: 0 auto; }
.empty-state p { margin-bottom: 1rem; }

/* Loading overlay */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(8,11,16,.85); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
}
.loading-overlay.hidden { display: none; }
.loading-overlay p { color: var(--text-secondary); font-size: .9rem; }

.loading-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast-container { position: fixed; top: 1.25rem; right: 1.25rem; z-index: 10000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .85rem 1.15rem; border-radius: var(--radius-sm);
  font-size: .855rem; font-weight: 500;
  box-shadow: var(--shadow); animation: slideIn .3s ease;
  max-width: 360px; border: 1px solid;
}
.toast-success { background: #0f1f18; border-color: rgba(52,211,153,.4); color: var(--success); }
.toast-error { background: #1f0f0f; border-color: rgba(248,113,113,.4); color: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Responsive */
@media (max-width: 1100px) {
  .grid-2-1 { grid-template-columns: 1fr; }
  .grid-upload-table { grid-template-columns: 1fr; }
  .panel-compact { max-width: none; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .topbar, .page-content { padding-left: 1.25rem; padding-right: 1.25rem; }
  .process-hero { flex-direction: column; text-align: center; }
  .action-step { flex-direction: column; align-items: stretch; }
}
