/* vdd-asakai — Vakıf Mağaza KPI Dashboard
   Mock-up'tan korunmuş görsel dil, canlı dashboard'a uyarlanmış. */

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

:root {
  --blue: #1A56DB;
  --blue2: #3B82F6;
  --blue-pale: #EEF2FF;
  --green: #059669;
  --green-pale: #DCFCE7;
  --amber: #D97706;
  --amber-pale: #FEF3C7;
  --red: #DC2626;
  --red-pale: #FEE2E2;
  --navy: #0F2044;
  --bg: #F4F6FB;
  --card: #fff;
  --text: #1A2855;
  --muted: #5A6A94;
  --border: #E0E7FF;

  --brand-primary: var(--blue);
  --brand-accent: #c33434;
}

html, body { height: auto; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

.wrap {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

/* PROGRESS BAR (top) */
#progressTrack {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 20;
  pointer-events: none;
}
#progressBar {
  height: 100%;
  width: 0%;
  background: var(--brand-primary);
  transition: width 220ms ease;
}
#progressBar.indeterminate {
  width: 100% !important;
  background: linear-gradient(90deg, transparent, var(--brand-primary), transparent);
  background-size: 200% 100%;
  animation: prog-indet 1.1s linear infinite;
}
@keyframes prog-indet {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* TOPBAR */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 18px;
  border-bottom: 1.5px solid var(--border);
  flex-wrap: wrap; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 48px; height: 48px;
  background: var(--brand-primary);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 24px; color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.logo-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 22px; color: var(--navy); }
.logo-name span { color: var(--muted); font-weight: 500; }
.logo-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

.tb-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.live-badge {
  display: flex; align-items: center; gap: 7px;
  background: var(--green-pale); color: #15803D;
  font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 22px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #15803D; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.ts-wrap { text-align: right; }
.ts { font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

.period-sel {
  padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 14px; color: var(--text); background: #fff;
  font-family: 'DM Sans', sans-serif; cursor: pointer; outline: none;
  font-weight: 500;
}

.btn-refresh {
  padding: 9px 18px;
  background: var(--brand-primary); color: #fff;
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 600;
  border: none; border-radius: 9px; cursor: pointer;
  transition: filter 120ms ease;
}
.btn-refresh:hover { filter: brightness(1.1); }
.btn-refresh:disabled { opacity: 0.6; cursor: progress; }

/* SECTION HEADERS */
.sec {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
  margin: 28px 0 14px; display: flex; align-items: center; gap: 10px;
}
.sec::before { content: ''; width: 4px; height: 17px; background: var(--brand-primary); border-radius: 2px; flex-shrink: 0; }
.sec-note {
  font-size: 13px; font-weight: 400; color: var(--muted);
  text-transform: none; letter-spacing: 0; margin-left: 6px;
}

/* GRIDS */
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 1100px) { .g4, .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .g4, .g3, .g2 { grid-template-columns: 1fr; } }
@media (min-width: 1920px) {
  body { font-size: 18px; }
  .wrap { max-width: 1820px; }
  .kpi-val { font-size: 36px; }
  .health-num { font-size: 38px; }
}

/* KPI CARDS */
.kpi {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 16px 18px;
  position: relative; overflow: hidden;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.kpi:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(26, 86, 219, 0.08); }
.kpi::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 4px; background: var(--brand-primary); border-radius: 13px 13px 0 0;
}
.kpi.g::after { background: var(--green); }
.kpi.a::after { background: var(--amber); }
.kpi.r::after { background: var(--red); }
.kpi.bd { animation: kpiPulse 1.6s ease-in-out infinite; }
@keyframes kpiPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.kpi-lbl { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 8px; line-height: 1.35; }
.kpi-val { font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; margin-top: 6px; color: var(--muted); line-height: 1.4; }
.kpi-detail-link { font-size: 12px; color: var(--brand-primary); margin-top: 6px; cursor: pointer; }

/* HEALTH CARD */
.health-card {
  background: var(--card); border: 1.5px solid var(--border); border-radius: 15px;
  padding: 24px 28px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 32px;
}
.health-circle { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.health-circle svg { width: 100%; height: 100%; }
.health-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif; font-size: 42px; font-weight: 700;
}
.health-meta { flex: 1; }
.health-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 8px; font-family: 'Space Grotesk', sans-serif; }
.health-desc { font-size: 14px; color: var(--muted); }

/* CARDS */
.card { background: var(--card); border: 1.5px solid var(--border); border-radius: 13px; padding: 18px 22px; margin-bottom: 0; }
.lgnd { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.li { display: flex; align-items: center; gap: 6px; }
.ls { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }

/* TABLES */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-align: left; padding: 10px 12px;
  border-bottom: 1.5px solid var(--border); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
  user-select: none;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--brand-primary); }
.tbl th.sortable::after { content: ' ⇅'; opacity: .35; font-size: 11px; }
.tbl th.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--brand-primary); }
.tbl th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--brand-primary); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #F8FAFF; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .mono { font-family: 'DM Mono', 'Courier New', monospace; font-size: 13px; color: var(--brand-primary); cursor: pointer; }
.tbl .mono:hover { text-decoration: underline; }

/* PILLS */
.pill { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--green-pale); color: #15803D; }
.pill.wn { background: var(--amber-pale); color: #B45309; }
.pill.bd { background: var(--red-pale); color: var(--red); }
.pill.nu { background: var(--blue-pale); color: #4338CA; }

/* ALARM RIBBON */
.alert-ribbon {
  background: var(--red-pale);
  border: 1.5px solid #FECACA;
  border-radius: 13px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 14px;
  font-size: 16px; font-weight: 600; color: #991B1B;
}
.alert-ribbon.warn { background: var(--amber-pale); border-color: #FCD34D; color: #78350F; }
.alert-ribbon.ok { background: var(--green-pale); border-color: #86EFAC; color: #14532D; }
.alert-ribbon.hidden { display: none; }
.alert-ribbon .ico {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.alert-ribbon.warn .ico { background: var(--amber); }
.alert-ribbon.ok .ico { background: var(--green); }

/* ALARM FLASH (body) */
@keyframes alarmFlash {
  0%, 100% { background: var(--bg); }
  50% { background: #FEE2E2; }
}
body.alarm-active { animation: alarmFlash 1.5s ease-in-out 3; }

/* MODAL */
.modal-root { position: fixed; inset: 0; z-index: 100; }
.modal-root.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 32, 68, 0.55); backdrop-filter: blur(2px); }
.modal {
  position: relative; max-width: 1280px; width: 95vw; max-height: 90vh;
  margin: 4vh auto 0; background: #fff;
  border-radius: 16px; box-shadow: 0 18px 48px rgba(15, 32, 68, 0.3);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  padding: 18px 24px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1.5px solid var(--border);
}
.modal-head h3 { font-family: 'Space Grotesk', sans-serif; font-size: 19px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; font-size: 28px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-tabs {
  display: flex; gap: 0; padding: 0 20px; background: #F8FAFF;
  border-bottom: 1.5px solid var(--border);
}
.modal-tabs .tab {
  padding: 12px 18px; background: none; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 600;
  color: var(--muted); border-bottom: 2.5px solid transparent;
}
.modal-tabs .tab.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }
.modal-body { padding: 18px 24px; overflow: auto; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* UTILS */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.center { text-align: center; }

/* FOOTER */
.footer {
  margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
}
