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

:root {
  --bg: #f0f2f7;
  --bg2: #ffffff;
  --bg3: #e8eaef;
  --border: #d8dce6;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-light: #6366f112;
  --text: #1a1d26;
  --text-muted: #6b7280;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-card: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  --transition: .18s ease;
}

html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; min-height: 100vh; }

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

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

/* ─── Login Page ────────────────────────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
  background: #f5f6fa;
}
.login-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem 2rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center; margin-bottom: 2rem;
}
.login-logo .icon {
  width: 52px; height: 52px; background: var(--accent-light);
  border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.login-logo .icon svg { width: 28px; height: 28px; fill: var(--accent); }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; }
.login-logo p { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }

.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: .4rem; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; }
.form-group input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .65rem .9rem;
  color: var(--text); font-size: .95rem; transition: border-color var(--transition);
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.form-group input[readonly] { opacity: .6; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.2rem; border-radius: var(--radius); font-size: .9rem;
  font-weight: 600; cursor: pointer; border: none; transition: all var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; padding: .75rem; font-size: .95rem; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #1d4ed8; }
.btn-warning { background: var(--warning); color: #fff; }

.error-msg { background: #fef2f2; border: 1px solid #fca5a5; color: #dc2626; border-radius: var(--radius); padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem; display: none; }
.error-msg.show { display: block; }

/* ─── Dashboard Layout ──────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.main { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: .65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-brand {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.topbar-sub {
  font-size: .72rem;
  color: var(--text-muted);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-left: auto;
}
.topbar-clock {
  font-size: .8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.content {
  padding: 1.25rem 1.25rem 2rem;
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Sections */
.content-section {
  margin-bottom: 2.5rem;
}
.content-section:last-child {
  margin-bottom: 0;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.section-title--l2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}
.section-meta {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

/* ─── Cards / Stats ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.stats-grid--tight {
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 700px) {
  .stats-grid--tight { grid-template-columns: repeat(2, 1fr); }
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: .72rem; color: var(--text-muted); font-weight: 600; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; line-height: 1.15; }
.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); }

/* Generic panel (legacy) */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}
.panel-header h3 { font-size: .9rem; font-weight: 700; }
.panel-body { padding: 1rem 1.2rem; }

/* Dash cards — tek tip kart */
.dash-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 1.15rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
}
.dash-card:last-child { margin-bottom: 0; }
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.dash-heading {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .75rem;
  letter-spacing: -0.02em;
}
.dash-card .dash-heading:first-child { margin-top: 0; }
.dash-note {
  font-size: .78rem;
  color: var(--text-muted);
  margin: -.25rem 0 .75rem;
  line-height: 1.4;
}
.dash-badge {
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .2rem .55rem;
  border-radius: 6px;
  max-width: 100%;
  text-align: right;
}

/* ─── Filters ───────────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.filters input, .filters select {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .8rem;
  color: var(--text); font-size: .85rem;
  transition: border-color var(--transition);
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }

/* ─── Table ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  text-align: left; padding: .6rem .9rem;
  background: var(--bg3); color: var(--text-muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: .65rem .9rem; vertical-align: middle; }

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 20px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-paid      { background: #dbeafe; color: #1e40af; }
.badge-shipped   { background: #ede9fe; color: #5b21b6; }
.badge-delivered { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-returned  { background: #fdf4ff; color: #7c3aed; }
.badge-active    { background: #dcfce7; color: #166534; }
.badge-inactive  { background: #fee2e2; color: #991b1b; }
.badge-increase  { background: #dcfce7; color: #166534; }
.badge-decrease  { background: #fee2e2; color: #991b1b; }
.badge-adjustment{ background: #dbeafe; color: #1e40af; }
.badge-sale      { background: #fef3c7; color: #92400e; }
.badge-return    { background: #fdf4ff; color: #7c3aed; }

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; padding: .75rem 0 0; flex-wrap: wrap; }
.page-info { font-size: .8rem; color: var(--text-muted); margin-right: .5rem; }
.page-btn {
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: .8rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem; opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 500px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12); transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.3rem; line-height: 1; padding: 0; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.2rem 1.4rem; }
.modal-footer { padding: .9rem 1.4rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }

/* ─── Form elements in modal ────────────────────────────────────────────── */
.field-group { margin-bottom: 1rem; }
.field-group label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .35rem; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.field-group input, .field-group select, .field-group textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: .55rem .8rem;
  color: var(--text); font-size: .88rem;
  transition: border-color var(--transition);
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus {
  outline: none; border-color: var(--accent);
}
.field-group textarea { min-height: 80px; resize: vertical; }

/* ─── Empty / Loading states ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

.loading-row td { text-align: center; padding: 2rem; color: var(--text-muted); }
.spinner {
  width: 22px; height: 22px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: .5rem; z-index: 2000; }
.toast {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: .75rem 1.1rem;
  font-size: .85rem; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: .6rem;
  animation: slideIn .25s ease; max-width: 320px;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.info    { border-color: var(--info); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

.form-select {
  padding: .4rem .65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg2);
  font-size: .85rem;
  color: var(--text);
}

/* Buttons — ek */
.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
}
.btn-ghost:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--bg3);
}
.btn-primary-soft {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  font-weight: 600;
}
.btn-primary-soft:hover {
  background: #e0e7ff;
}

/* KPI strip */
.dash-card--kpi {
  padding: 1.1rem 1.15rem 1.15rem;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.15rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 520px) {
  .kpi-row { grid-template-columns: 1fr; gap: .65rem; padding-bottom: .85rem; margin-bottom: .85rem; }
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.kpi-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.kpi-value--accent { color: var(--accent); }
.kpi-value--success { color: var(--success); }

.chart-block {
  margin-top: 0;
}
.chart-canvas-wrap {
  overflow-x: auto;
  margin: 0 -0.15rem;
  padding: 0 .15rem;
}
.chart-canvas-wrap canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}
.chart-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1.25rem;
  font-size: .85rem;
}

/* Targets */
.target-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.target-line {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.target-name {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.progress-wrap {
  height: 10px;
  background: var(--bg3);
  border-radius: 5px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width .4s ease;
}
.progress-bar-month {
  background: var(--success);
}
.target-meta {
  font-size: .75rem;
  color: var(--text-muted);
}
.target-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.target-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
@media (max-width: 500px) {
  .target-inputs { grid-template-columns: 1fr; }
}
.target-form label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.target-form input {
  padding: .45rem .55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: .9rem;
}

/* Ticker */
.dash-card--ticker .dash-heading {
  margin-bottom: .5rem;
}
.ticker-wrap {
  overflow: hidden;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.ticker-track {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: .65rem .75rem;
  white-space: nowrap;
  animation: tickerScroll 45s linear infinite;
}
.ticker-item {
  font-size: .82rem;
  font-weight: 600;
  flex-shrink: 0;
}
.ticker-item.muted {
  color: var(--text-muted);
  font-weight: 500;
}
@keyframes tickerScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Report toolbar */
.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.report-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.report-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 768px) {
  .report-panels { grid-template-columns: 1fr; }
}

.table-wrap--compact table { font-size: .8rem; }
.cell-center { text-align: center; }

/* Live blocks layout — masaüstü: üst tam genişlik, orta iki sütun, alt tam genişlik */
.live-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  body:not(.tv-mode) .live-blocks {
    grid-template-columns: 1fr;
  }
}
body:not(.tv-mode) .live-blocks > .live-block:nth-child(1) {
  grid-column: 1 / -1;
}
body:not(.tv-mode) .live-blocks > .live-block:nth-child(4) {
  grid-column: 1 / -1;
}
@media (max-width: 900px) {
  body:not(.tv-mode) .live-blocks > .live-block:nth-child(1),
  body:not(.tv-mode) .live-blocks > .live-block:nth-child(4) {
    grid-column: 1;
  }
}
.live-block {
  margin: 0;
  min-width: 0;
}

.tv-slide-dots {
  display: flex;
  justify-content: center;
  gap: .45rem;
  padding: .75rem 0 0;
}
.tv-slide-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: transform .15s ease;
}
.tv-slide-dots span.on {
  background: var(--accent);
  transform: scale(1.15);
}
.tv-slide-dots span[role='button']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* TV mode */
body.tv-mode {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent-soft: #1f2937;
  --shadow-card: 0 4px 24px rgba(0,0,0,.35);
}
body.tv-mode .topbar {
  background: var(--bg2);
  border-color: var(--border);
}
body.tv-mode .section-optional {
  display: none !important;
}
body.tv-mode .content {
  max-width: none;
  padding: 1rem 1.25rem 2rem;
}
body.tv-mode .live-blocks {
  display: block;
}
body.tv-mode .live-blocks .live-block {
  display: none;
  margin-bottom: 0;
  min-height: calc(100vh - 120px);
  animation: fadeSlide .4s ease;
}
body.tv-mode .live-blocks .live-block.is-active {
  display: block;
}
@keyframes fadeSlide {
  from { opacity: 0.4; }
  to { opacity: 1; }
}
body.tv-mode .ticker-track {
  animation-duration: 55s;
}
body.tv-mode #tvSlideDots {
  display: flex !important;
}
body:not(.tv-mode) #tvSlideDots {
  display: none !important;
}
body:not(.tv-mode) .live-blocks .live-block {
  display: block !important;
}

.text-muted-sm {
  font-size: .78rem;
  color: var(--text-muted);
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar { padding: .55rem .85rem; }
  .content { padding: 1rem; }
}
