/* AI Şirket paneli. Dış kaynak yok: sistem yazı tipleri, tek vurgu rengi, açık ve koyu tema. */

:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b1f27;
  --muted: #5a6372;
  --border: #d5d9e0;
  --accent: #2456c9;
  --accent-text: #ffffff;
  --accent-soft: #e4ecfc;
  --ok: #1a7f43;
  --ok-soft: #e1f4e8;
  --warn: #8a5a00;
  --warn-soft: #fdf1d3;
  --danger: #b3261e;
  --danger-soft: #fbe4e1;
  --dot-idle: #8b93a1;
  --dot-wait: #e0a400;
  --dot-run: #1f9d55;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.08);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #252a33;
    --text: #e8eaee;
    --muted: #a2aab8;
    --border: #353b46;
    --accent: #7ba0ff;
    --accent-text: #0d1424;
    --accent-soft: #232f4d;
    --ok: #5fd08a;
    --ok-soft: #173325;
    --warn: #f0c35c;
    --warn-soft: #3a2f12;
    --danger: #ff8a80;
    --danger-soft: #3d1b19;
    --dot-idle: #7b8392;
    --dot-wait: #f0c040;
    --dot-run: #4cc27e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

[hidden] { display: none !important; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.5rem 0.75rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Düğmeler ve form alanları */

.btn {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ok { color: var(--ok); border-color: var(--ok); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 0.25rem 0.6rem; font-size: 0.875rem; }
.btn.emergency {
  background: #c62828;
  border-color: #c62828;
  color: #ffffff;
  letter-spacing: 0.04em;
  font-weight: 800;
}
.btn.emergency:hover:not(:disabled) { background: #a81f1f; }
.btn.emergency:focus-visible { outline-color: #ffffff; box-shadow: 0 0 0 5px #c62828; }

label { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; }
label.inline { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-weight: 500; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
}
textarea { resize: vertical; min-height: 5rem; }
input[type="checkbox"] { width: auto; min-height: 0; }

.form-error { color: var(--danger); min-height: 1.4em; margin: 0.5rem 0; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.875rem; margin-top: 0.35rem; }
.form-row { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; align-items: center; }

/* Giriş */

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card .btn { width: 100%; margin-top: 0.5rem; }

/* Üst çubuk */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 1.1rem; }
.topbar-status { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.topbar-actions { display: flex; gap: 0.5rem; margin-left: auto; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.live { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.live-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--dot-idle); }
.live.on .live-dot { background: var(--dot-run); }
.live.on { color: var(--ok); }
.live.off { color: var(--danger); }

/* Bantlar */

.banners:empty { display: none; }
.banner { padding: 0.65rem 1rem; font-weight: 600; border-bottom: 1px solid var(--border); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }

/* Sekmeler */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tabs button {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  min-height: 40px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
  margin-bottom: -1px;
  padding-bottom: calc(0.5rem + 1px);
}
.count {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 0.8rem;
  text-align: center;
}

.content { padding: 1rem; max-width: 1200px; margin: 0 auto; }
.content:focus { outline: none; }
.section-head { margin-bottom: 1rem; }
.section-head .actions { margin-top: 0.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.two-col { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; align-items: start; }

.error-box, .empty-box {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 1rem;
}
.error-box { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

/* Metin blokları: veri her zaman textContent ile gelir, satır sonları korunur */

.textblock {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  margin: 0.35rem 0 0.75rem;
}
.textblock.plain { background: transparent; border: 0; padding: 0; margin: 0 0 0.5rem; }
.textblock.mono { font-family: var(--mono); font-size: 0.9rem; }

/* Özet */

.kpis { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; }
.kpi .label { color: var(--muted); font-size: 0.85rem; }
.kpi .value { font-size: 1.4rem; font-weight: 800; }
.kpi .sub { color: var(--muted); font-size: 0.85rem; }
.kpi.link { cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.kpi.link:hover { background: var(--surface-2); }

progress {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  display: block;
  margin-top: 0.35rem;
}
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
progress.warn::-webkit-progress-value { background: var(--dot-wait); }
progress.warn::-moz-progress-bar { background: var(--dot-wait); }
progress.danger::-webkit-progress-value { background: var(--danger); }
progress.danger::-moz-progress-bar { background: var(--danger); }

.gm-card { border-color: var(--accent); border-width: 2px; }

/* Olay akışı */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.15rem 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 0.4rem;
}
.feed li.warn { border-left: 4px solid var(--dot-wait); }
.feed li.danger { border-left: 4px solid var(--danger); }
.feed .time { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.feed .meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.feed .summary { grid-column: 2; }

/* Durum noktaları */

.dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--dot-idle);
  flex: none;
}
.dot.calisiyor { background: var(--dot-run); }
.dot.bekliyor { background: var(--dot-wait); }
.dot.bosta { background: var(--dot-idle); }

/* Kadro: organizasyon şeması */

.org { display: flex; flex-direction: column; align-items: center; gap: 0; }
.org-gm { width: min(100%, 360px); }
.org-line { width: 2px; height: 1.25rem; background: var(--border); }
.org-bus { width: 100%; border-top: 2px solid var(--border); height: 0; }
.org-depts { display: grid; gap: 1rem; width: 100%; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-top: 0; }
.dept { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.dept h3 { margin-bottom: 0.5rem; }

.person {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.person:last-child { margin-bottom: 0; }
button.person:hover { border-color: var(--accent); }
.person .role { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.person .name { font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.person .status-text { font-weight: 500; color: var(--muted); font-size: 0.85rem; margin-left: auto; white-space: nowrap; flex: none; }
.person .task { color: var(--muted); font-size: 0.85rem; }
.person.empty { border-style: dashed; background: transparent; cursor: default; color: var(--muted); }
.person.empty .name { font-weight: 600; }

/* Tablolar: dar ekranda kart olur */

.table-wrap { width: 100%; }
table.responsive { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.responsive th, table.responsive td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.responsive th { background: var(--surface-2); font-size: 0.85rem; color: var(--muted); }
table.responsive tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.link-btn { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; text-align: left; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.chip { font: inherit; padding: 0.25rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; min-height: 32px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* Onay kartları */

.approval h3 { margin-bottom: 0.25rem; }
.approval-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.legal {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin: 0.5rem 0 0.75rem;
}
.legal .legal-title { font-weight: 800; }
.legal.uygun { border-color: var(--ok); background: var(--ok-soft); }
.legal.duzeltme { border-color: var(--dot-wait); background: var(--warn-soft); }
.legal.engel { border-color: var(--danger); background: var(--danger-soft); }
.legal.bekliyor { background: var(--surface-2); }
.legal .textblock { background: transparent; border: 0; padding: 0; margin: 0.25rem 0 0; }

details.fold { margin-bottom: 1rem; }
details.fold > summary { cursor: pointer; font-weight: 700; padding: 0.4rem 0; }

/* Kurul */

.verdict { border-left: 4px solid var(--accent); padding-left: 0.8rem; }
.seat { border-top: 1px solid var(--border); padding: 0.5rem 0; }
.seat:first-child { border-top: 0; }
.seat-name { font-weight: 700; }

/* Ofis: canlı ofis haritası (çizim ofis.js'te, tuval üzerinde) */

.ofis-wrap { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
.ofis-map {
  background: #5c9e47;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.ofis-canvas { display: block; width: 100%; height: auto; touch-action: manipulation; }
.ofis-canvas.ofis-hit { cursor: pointer; }
.ofis-side { min-width: 0; }
.ofis-status { margin-bottom: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.ofis-status.warn { color: var(--danger); font-weight: 600; }
.ofis-evren { width: 100%; justify-content: flex-start; text-align: left; margin-bottom: 0.75rem; }
.ofis-list { list-style: none; margin: 0; padding: 0; }
.ofis-person {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.5rem;
  align-items: center;
  width: 100%;
  min-height: 40px;
  margin-bottom: 0.35rem;
  padding: 0.35rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.ofis-person:hover { background: var(--surface-2); }
.ofis-person.empty { border-style: dashed; background: transparent; color: var(--muted); cursor: default; }
.ofis-person .dot { grid-row: span 3; }
.ofis-person .ofis-role { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.ofis-person .ofis-name { font-weight: 700; }
.ofis-person .ofis-state { color: var(--muted); font-size: 0.85rem; }
.dot.bos_masa { background: transparent; border: 1px dashed var(--dot-idle); }

@media (min-width: 1100px) {
  .ofis-wrap { grid-template-columns: minmax(0, 1fr) 290px; }
  .ofis-side { max-height: 80vh; overflow-y: auto; }
}

/* Şirket bilgisi */

textarea.knowledge { min-height: 55vh; font-family: var(--mono); font-size: 0.9rem; line-height: 1.5; }

/* Ayrıntı penceresi */

.dialog {
  width: min(900px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
.dialog::backdrop { background: rgba(10, 12, 16, 0.55); }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
}
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 1rem; overflow-y: auto; max-height: calc(100vh - 7rem); }
.kv { display: grid; grid-template-columns: 9rem 1fr; gap: 0.25rem 0.75rem; margin-bottom: 0.75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.qa { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.5rem; }
.qa .answer { margin-left: 0.5rem; }

/* Bildirim */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  max-width: min(92vw, 560px);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.toast.error { background: var(--danger); color: #ffffff; }
.toast.ok { background: var(--ok); color: #ffffff; }

@media (prefers-color-scheme: dark) {
  .toast.ok { color: #08210f; }
  .toast.error { color: #2a0b09; }
}

/* Dar ekran: tek sütun, tablolar kart */

@media (max-width: 767px) {
  .content { padding: 0.75rem; }
  .topbar { padding: 0.5rem 0.75rem; }
  .topbar-status { order: 3; width: 100%; }
  .tabs { padding: 0.5rem 0.75rem 0; gap: 0.2rem; }
  .tabs button { padding: 0.4rem 0.6rem; font-size: 0.9rem; min-height: 38px; }
  .two-col { grid-template-columns: 1fr; }
  .feed li { grid-template-columns: 1fr; }
  .feed .summary { grid-column: 1; }
  .kv { grid-template-columns: 1fr; }
  .org-depts { grid-template-columns: 1fr; }
  .org-bus { display: none; }

  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive { border: 0; background: transparent; }
  table.responsive thead { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
  table.responsive tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.75rem;
  }
  table.responsive td { border: 0; padding: 0.3rem 0; display: block; text-align: left; }
  table.responsive td.num { text-align: left; }
  table.responsive td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
  table.responsive td.no-label:empty { display: none; }
  table.responsive td.no-label::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
