:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #333b45;
  --muted: #80868e;
  --accent: #2067b0;
  --accent-soft: #e5f0fb;
  --primary: #9dcf00;          /* Bitrix "Kaydet" yeşili */
  --primary-hover: #a8d80a;
  --primary-text: #2c3a00;
  --danger: #d03b3b;
  --series: #2a78d6;
  --free: #e5f0fb;
  --part: #fff3d6;
  --full: #fde4e1;
  --radius: 10px;
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.page { max-width: 1320px; margin: 0 auto; padding: 16px; }
.page.narrow { max-width: 640px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.warn { color: #b25a00; }
.req { color: var(--danger); }
.empty { padding: 24px 0; }
.mt { margin-top: 12px; }
.clip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* form */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.inline select, label.inline input { width: auto; }
input, select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 9px; min-height: 34px; width: 100%;
}
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.grid2 > .card { margin-bottom: 0; }
.tab-pane > .grid2 { margin-bottom: 16px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form > label { flex: 1 1 160px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.actions.center { justify-content: center; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 6px; padding: 8px 16px; cursor: pointer; min-height: 36px;
}
.btn:hover { background: #f5f7f8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); text-transform: uppercase; letter-spacing: .02em; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.link { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }
.link:hover { text-decoration: underline; }
.icon-btn { font: inherit; font-size: 20px; line-height: 1; width: 32px; height: 32px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: #f5f7f8; }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.alert ul { margin: 6px 0; padding-left: 20px; }
.alert-error { background: #fdecec; color: #8a1f1f; border: 1px solid #f5c2c2; }
.alert-ok { background: #ecf8e6; color: #2e5d12; border: 1px solid #c8e6b5; }
.alert-warn { background: #fff4e5; color: #6b3d00; border: 1px solid #f3cf9b; margin: 12px 0 0; }
.alert-info { background: var(--accent-soft); color: #18406b; border: 1px solid #c3dbf3; margin: 12px 0 0; }

/* rozetler */
.stage { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.stage i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.type { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.type-new { background: #e5f0fb; color: #1c5cab; }
.type-control { background: #efeafc; color: #4a3aa7; }
.type-sel { width: auto; min-height: 28px; padding: 3px 6px; font-size: 12px; font-weight: 600; border-radius: 12px; }
.type-sel.type-none { color: var(--muted); font-weight: 400; }
.type-sel.type-new { background: #e5f0fb; color: #1c5cab; border-color: #c3dbf3; }
.type-sel.type-control { background: #efeafc; color: #4a3aa7; border-color: #d9d0f5; }

/* --- Randevu ekranı (popup) --- */
.cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cards2 .card { margin-bottom: 16px; }
.entity-card { display: flex; flex-direction: column; gap: 4px; }
.ec-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.ec-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.ec-line { font-size: 13px; }
.current-appt { margin-top: 4px; background: #f3f8e6; border-radius: 6px; padding: 4px 8px; align-self: flex-start; }
.new-deal { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }

.user-row { display: flex; align-items: center; gap: 12px; }
.user-pill { display: inline-flex; align-items: center; gap: 8px; background: #f2f4f6; border-radius: 16px; padding: 5px 12px; font-weight: 600; }
.user-pill::before { content: "👤"; font-size: 12px; }

.cal-wrap { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 24px; align-items: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day {
  font: inherit; position: relative; aspect-ratio: 1; border: 1px solid transparent; background: #f7f9fa; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text);
}
.cal-day:hover:not(:disabled) { border-color: var(--accent); }
.cal-day.other { color: #b4b8bd; background: transparent; }
.cal-day.off { background: #f0f1f2; color: #9a9ea4; }
.cal-day.past { color: #cfd2d6; background: transparent; cursor: not-allowed; }
.cal-day.today { border-color: var(--accent); font-weight: 700; }
.cal-day.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cal-day em { position: absolute; top: 2px; right: 3px; font-style: normal; font-size: 10px; font-weight: 700; line-height: 14px; min-width: 14px; padding: 0 3px; border-radius: 7px; background: #f3cf9b; color: #6b3d00; }
.cal-day.active em { background: #fff; color: var(--accent); }
.cal-loading { margin-top: 6px; }
.times-head { margin-bottom: 10px; min-height: 22px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot {
  font: inherit; position: relative; min-width: 66px; padding: 7px 0; border: 1px solid #b9d3ee; background: var(--free);
  color: var(--accent); border-radius: 6px; cursor: pointer; font-weight: 600;
}
.slot small { position: absolute; top: -6px; right: -6px; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; background: #6b3d00; color: #fff; }
.slot-part { background: var(--part); border-color: #f3cf9b; color: #6b3d00; }
.slot-full { background: var(--full); border-color: #f2b8b0; color: #9b2c1f; }
.slot:hover:not(:disabled) { filter: brightness(.96); }
.slot:disabled { background: #f3f4f5; border-color: #eceef0; color: #c4c7cb; cursor: not-allowed; }
.slot.active, .slot.active:hover { background: var(--accent); color: #fff; border-color: var(--accent); filter: none; }
.custom-time { margin-top: 12px; }
.legend { display: flex; gap: 14px; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid; }
.lg-free { background: var(--free); border-color: #b9d3ee; }
.lg-part { background: var(--part); border-color: #f3cf9b; }
.lg-full { background: var(--full); border-color: #f2b8b0; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.seg label { flex-direction: row; cursor: pointer; color: var(--text); font-size: 14px; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 8px 18px; }
.seg label + label span { border-left: 1px solid var(--border); }
.seg input:checked + span { background: var(--accent); color: #fff; font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.bk-foot {
  position: sticky; bottom: 0; background: var(--surface); border-radius: var(--radius); padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.done { text-align: center; padding: 40px 16px; }
.done h2 { justify-content: center; font-size: 20px; }
.done-icon { width: 56px; height: 56px; border-radius: 50%; background: #0ca30c; color: #fff; font-size: 30px; display: grid; place-items: center; margin: 0 auto 12px; }

/* --- Ana sayfa --- */
.app-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font: inherit; font-size: 13px; border: 1px solid var(--border); background: #fff; border-radius: 16px; padding: 5px 14px; cursor: pointer; }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabs { display: flex; gap: 4px; background: #dde3e7; padding: 3px; border-radius: 8px; }
.tab { font: inherit; border: 0; background: transparent; padding: 7px 16px; border-radius: 6px; cursor: pointer; color: var(--text); }
.tab.active { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.seg-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.seg-card { font: inherit; text-align: left; background: var(--surface); border: 2px solid transparent; border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.seg-card:hover { border-color: #c3dbf3; }
.seg-card.active { border-color: var(--accent); }
.seg-label { font-size: 12px; color: var(--muted); }
.seg-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--surface); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px; }
.filters label { flex: 0 1 170px; }
.filters label.grow { flex: 1 1 220px; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; flex-basis: 100%; }
.presets button { font: inherit; font-size: 12px; border: 1px solid var(--border); background: #fff; border-radius: 14px; padding: 4px 12px; cursor: pointer; }
.presets button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.table-wrap { background: var(--surface); border-radius: var(--radius); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fafbfc; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
.tbl tr.day-head td { background: #f4f7f9; font-weight: 600; font-size: 12px; color: #4d5560; padding: 6px 12px; }
.tbl tr.past td { color: var(--muted); }
.tbl-compact td, .tbl-compact th { padding: 7px 8px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: 12px; color: var(--muted); min-height: 22px; display: flex; align-items: center; }
.kpi-value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi-hero { background: var(--accent); color: #fff; }
.kpi-hero .kpi-label { color: #d6e6f7; }

.chart-daily { display: flex; gap: 8px; height: 220px; }
.bars-y { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); padding-bottom: 18px; text-align: right; min-width: 20px; }
.bars { flex: 1; display: flex; align-items: stretch; gap: 2px; border-bottom: 1px solid var(--border); position: relative;
  background: linear-gradient(to top, transparent 49.5%, #eef0f2 49.5%, #eef0f2 50.5%, transparent 50.5%) 0 0 / 100% calc(100% - 18px) no-repeat; }
.bar-col { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 3px; cursor: default; }
.bar-plot { flex: 1; position: relative; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; background: var(--series); border-radius: 4px 4px 0 0; }
.bar-x { height: 18px; font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; line-height: 18px; }
.bar-col:hover .bar { filter: brightness(1.15); }
.bar-col:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% - 10px); left: 50%; transform: translateX(-50%);
  background: #333b45; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 4px; white-space: nowrap; z-index: 2; pointer-events: none;
}
.bar-cell { width: 45%; }
.hbar { height: 10px; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }

/* yeni randevu penceresi */
.modal { position: fixed; inset: 0; background: rgba(30, 38, 48, .45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px 16px; z-index: 50; }
.modal-box { background: var(--surface); border-radius: 12px; width: 100%; max-width: 640px; padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.25); max-height: calc(100vh - 80px); overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 18px; }
.search-results { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; max-height: 360px; overflow: auto; }
.result { font: inherit; display: grid; grid-template-columns: 74px 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; color: var(--text); }
.result:hover { border-color: var(--accent); background: #f7fbff; }
.r-kind { grid-row: span 2; align-self: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.r-main { font-weight: 600; }
.r-sub { font-size: 12px; color: var(--muted); }
.new-contact { border-top: 1px solid var(--border); padding-top: 10px; }
.new-contact summary { cursor: pointer; color: var(--accent); margin-bottom: 10px; }

/* ayarlar */
.user-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: #18406b; border-radius: 14px; padding: 4px 6px 4px 12px; font-size: 13px; }
.user-chip button { border: 0; background: rgba(0,0,0,.08); border-radius: 50%; width: 18px; height: 18px; cursor: pointer; line-height: 1; }
.weekdays { display: flex; gap: 12px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #333b45; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast-error { background: #8a1f1f; }

@media (max-width: 820px) {
  .cal-wrap, .cards2, .grid2 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .filters label { flex: 1 1 140px; }
  .bk-foot { flex-direction: column; align-items: stretch; }
}

/* --- İstatistik: canlı görünüm --- */
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi-hero .kpi-sub { color: #d6e6f7; }
.kpi-money { background: linear-gradient(135deg, #f3fbe2, #ffffff); border: 1px solid #dcefb4; }
.kpi-money .kpi-value { color: #3d6b00; }
.highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.hl { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 14px 16px; border-left: 4px solid transparent; }
.hl-gold { border-left-color: #e8b007; background: linear-gradient(90deg, #fff8e1, #ffffff 60%); }
.hl-blue { border-left-color: var(--series); background: linear-gradient(90deg, #eaf3fd, #ffffff 60%); }
.hl-icon { font-size: 28px; line-height: 1; }
.hl-label { font-size: 12px; color: var(--muted); }
.hl-name { font-size: 16px; font-weight: 700; margin-top: 2px; }
.hl-value { font-size: 13px; font-weight: 600; color: #4d5560; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.seg-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-toggle button { font: inherit; font-size: 12px; border: 0; background: #fff; padding: 5px 12px; cursor: pointer; color: var(--text); }
.seg-toggle button + button { border-left: 1px solid var(--border); }
.seg-toggle button.active { background: var(--accent); color: #fff; font-weight: 600; }

.chart-daily { height: 240px; }
.chart-daily .bars { gap: 3px; background-size: 100% calc(100% - 36px); background-position: 0 18px; }
.chart-daily.dense .bars { gap: 1px; }
.bar-plot { margin-top: 18px; }
.bar { transition: height .35s ease; background: linear-gradient(180deg, #4a90e2, var(--series)); }
.bar-money { background: linear-gradient(180deg, #b5dc3c, #7cb305); }
.bar-max { box-shadow: 0 0 0 2px #e8b007 inset; }
.bar-val { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 2px; font-size: 10px; font-weight: 700; color: #4d5560; white-space: nowrap; pointer-events: none; }
.chart-daily.dense .bar-val { font-size: 9px; }
.bar-col.weekend .bar-x { color: #c0392b; }
.bar-col.today .bar-x { color: var(--accent); font-weight: 700; }

.board .rank { width: 32px; text-align: center; font-size: 16px; }
.board tr.podium td { background: #fffdf3; }
.board tr.p1 td { background: #fff7d6; }
.hbar-money { background: linear-gradient(90deg, #b5dc3c, #7cb305); }

/* --- Roller --- */
.role { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fbfcfd; }
.role-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.role-order { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }
.role-name { font-weight: 600; }
.role-grid { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: start; margin-bottom: 10px; }
.role-flags, .role-cats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
.roles-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 820px) { .role-grid { grid-template-columns: 1fr; } }

/* Büyük tutarlar kutudan taşmasın */
.kpi { min-width: 0; }
.kpi-value { font-size: clamp(20px, 2.4vw, 28px); overflow-wrap: anywhere; line-height: 1.2; }
