/* Med AI paneli (/dashboard) ve giris sayfasi. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --border: #e3e7f0;
  --text: #121826;
  --text-2: #4a5568;
  --muted: #7a8599;
  --brand: #4f46e5;
  --brand-2: #0891b2;
  --brand-soft: #eef0ff;
  --bar: #4f46e5;
  --bar-hover: #3730a3;
  --ok: #157f54;
  --ok-soft: #e5f6ee;
  --danger: #c53048;
  --danger-soft: #fdecef;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 24, 38, .05), 0 6px 20px rgba(18, 24, 38, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d111b;
    --surface: #151b28;
    --surface-2: #1b2232;
    --border: #273047;
    --text: #e8ecf5;
    --text-2: #b4bdd0;
    --muted: #8590a8;
    --brand: #8b85ff;
    --brand-2: #22c3e6;
    --brand-soft: #23264a;
    --bar: #8b85ff;
    --bar-hover: #b7b3ff;
    --ok: #4fd39a;
    --ok-soft: #12352a;
    --danger: #ff7d92;
    --danger-soft: #3a1820;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
p { margin: 0; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- marka ---------- */

.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 18px; }
.logo-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 14px; font-weight: 800;
}
.logo small { font-weight: 600; color: var(--muted); font-size: 12px; display: block; line-height: 1; }

/* ---------- iskelet ---------- */

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100dvh; }
.side {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100dvh;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav .ico { width: 18px; text-align: center; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; }
.side-foot a { color: var(--muted); }

.main { min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 32px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar h1 { font-size: 20px; }
.who { display: flex; align-items: center; gap: 12px; }
.who-text { text-align: right; font-size: 13px; line-height: 1.3; }
.who-text strong { display: block; font-size: 14px; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-weight: 800;
}
.content { padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 24px; max-width: 1200px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .who-text { display: none; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { display: none; }
  .topbar { padding: 14px 16px; }
  .content { padding: 20px 16px 40px; }
}

/* ---------- bilesenler ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { font-size: 16px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile { min-width: 0; }
@media (max-width: 860px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .tile { padding: 14px; } .tile-value { font-size: 26px; } .card { padding: 16px; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--text-2); }
input, select {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px;
  font: inherit; font-weight: 700; font-size: 14px; border: 1px solid transparent; border-radius: 10px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-small { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input { width: 150px; padding: 6px 10px; font-size: 13px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 10px; }

/* ---------- grafik: son 30 gun ---------- */

.chart { position: relative; }
.bars { display: grid; grid-template-columns: repeat(30, 1fr); align-items: end; gap: 2px; height: 180px; border-bottom: 1px solid var(--border); }
.bar-slot { height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bar { width: 100%; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-slot:hover .bar, .bar-slot:focus .bar { background: var(--bar-hover); }
.bar-slot:focus { outline: none; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%); padding: 6px 10px; border-radius: 8px;
  background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; white-space: nowrap; display: none;
}
.chart-tip strong { font-size: 14px; }
.chart-max { position: absolute; top: -2px; left: 0; font-size: 12px; color: var(--muted); }

.ext-status { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.ext-status.on .dot { background: var(--ok); }

/* ---------- giris ---------- */

.auth { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side {
  background: radial-gradient(900px 500px at 0% 0%, #6d64ff 0%, transparent 60%), radial-gradient(700px 500px at 100% 100%, #0ab3d6 0%, transparent 60%), #1a1a3a;
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side .logo { color: #fff; }
.auth-side h2 { font-size: 34px; line-height: 1.2; max-width: 460px; }
.auth-side p { opacity: .8; max-width: 440px; margin-top: 14px; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; }
.auth-card h1 { font-size: 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 24px 16px; gap: 16px; }
  .auth-side h2 { font-size: 22px; }
  .auth-side .auth-quote { display: none; }
}

/* ---------- kisaltmalar ---------- */

.ab-toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.ab-toolbar input[type="search"] { flex: 1 1 240px; }
.ab-toolbar .inline-form input { width: 240px; }
.ab-list { display: flex; flex-direction: column; gap: 12px; }
.ab-doctor { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.ab-doctor > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; flex-wrap: wrap; }
.ab-doctor[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 0; }
.ab-doctor-name { font-weight: 700; display: flex; align-items: center; gap: 10px; }
.ab-doctor-name::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.ab-doctor[open] .ab-doctor-name::before { transform: rotate(90deg); }
.ab-counts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ab-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 20px; }
.ab-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.ab-rows { display: flex; flex-direction: column; gap: 8px; }
.ab-row { display: grid; grid-template-columns: minmax(110px, 200px) minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.ab-row input, .ab-row textarea { padding: 8px 10px; font-size: 14px; }
.ab-row textarea { width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; resize: vertical; min-height: 38px; }
.ab-row textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ab-row.readonly { grid-template-columns: minmax(110px, 200px) minmax(0, 1fr); padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.ab-row.readonly b { word-break: break-word; }
.ab-row.overridden { opacity: .55; }
.ab-row.overridden span::after { content: " · kişisel tanımınız geçerli"; color: var(--muted); font-size: 12px; }
.ab-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ab-empty { font-size: 14px; color: var(--muted); }
.ab-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ab-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(760px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.ab-dialog::backdrop { background: rgba(10, 14, 30, .5); }
.ab-dialog-box { padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100dvh - 40px); }
.ab-dialog textarea { width: 100%; min-height: 220px; padding: 12px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.ab-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ab-preview { overflow: auto; max-height: 50dvh; display: flex; flex-direction: column; gap: 6px; }
.ab-preview label { display: grid; grid-template-columns: auto minmax(90px, 180px) 1fr; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; align-items: start; }
.ab-preview label.dup { opacity: .55; }
.ab-preview .skipped { font-size: 12px; color: var(--muted); }
#ab-import-status.error { color: var(--danger); }
#ab-status.error { color: var(--danger); font-weight: 700; }
@media (max-width: 640px) {
  .ab-row, .ab-row.readonly { grid-template-columns: 1fr; }
  .ab-toolbar .inline-form { width: 100%; }
  .ab-toolbar .inline-form input { flex: 1; width: auto; }
}
.ab-section h3 .badge { text-transform: none; letter-spacing: 0; }
@media (max-width: 640px) {
  .ab-row:not(.readonly) { grid-template-columns: minmax(0, 1fr) auto; }
  .ab-row:not(.readonly) textarea { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- menu uyarilari ---------- */

.nav-alert {
  margin-left: auto; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800;
  background: var(--danger); color: #fff; white-space: nowrap; animation: pulse 1.6s ease-in-out infinite;
}
.nav-count { margin-left: auto; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(197, 48, 72, .45); } 50% { box-shadow: 0 0 0 5px rgba(197, 48, 72, 0); } }
@media (prefers-reduced-motion: reduce) { .nav-alert { animation: none; } }

/* ---------- aylik kullanim ---------- */

.month-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.month-form select { width: auto; min-width: 180px; }
.spark { display: grid; grid-template-columns: repeat(12, 6px); gap: 2px; align-items: end; height: 26px; }
.spark i { display: block; background: var(--bar); border-radius: 2px 2px 0 0; min-height: 1px; }
.spark i.zero { background: var(--border); }
.spark i.current { background: var(--bar-hover); }
.note-live { font-size: 12px; color: var(--muted); }

/* ---------- demo talepleri ---------- */

.demo-list { display: flex; flex-direction: column; gap: 12px; }
.demo-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; display: grid; gap: 10px; }
.demo-item.today { border: 2px solid var(--danger); }
.demo-item.handled { opacity: .65; }
.demo-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.demo-head h3 { font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.demo-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); }
.demo-meta a { color: var(--brand); text-decoration: none; font-weight: 600; }
.demo-message { font-size: 14px; white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.badge-new { background: var(--danger); color: #fff; border-color: transparent; }
.ab-doctor.ab-common { border: 2px solid var(--brand); }
.ab-doctor.ab-common .ab-doctor-name { color: var(--brand); }
