:root {
  --ink: #1a2a26;
  --muted: #5c726b;
  --sage: #2f6f5e;
  --sage-dark: #1c463c;
  --cream: #f4f1ea;
  --line: rgba(26, 42, 38, .08);
  --radius: 12px;
  --sidebar: 240px;
  --shadow: 0 1px 2px rgba(26, 42, 38, .06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--cream);
  max-width: 100%;
  overflow-x: hidden;
}
img, video, canvas { max-width: 100%; height: auto; }
.num { font-variant-numeric: tabular-nums; }
.is-debt { color: #b91c1c; }
.is-paid { color: #15803d; }
.is-credit { color: #1d4ed8; }

.page-kicker { font-size: 12.5px; font-weight: 500; color: var(--muted); margin: 0 0 4px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.section-title { font-size: 17px; font-weight: 600; margin: 0; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--sage-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(-100%);
  transition: transform .2s ease;
}
.sidebar.is-open { transform: translateX(0); }
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 42, 38, .45);
  z-index: 35;
}
.sidebar-brand {
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-brand strong { display: block; font-size: 17px; font-weight: 700; }
.sidebar-brand span { display: block; font-size: 12px; color: rgba(255,255,255,.62); margin-top: 4px; font-weight: 500; }
.sidebar-close {
  display: none;
  background: none;
  border: 0;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.is-active {
  background: rgba(255,255,255,.14);
  color: #fff;
}
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: #cde7dc;
}
.nav-logout {
  margin: 8px 10px 16px;
  color: rgba(255,255,255,.7);
}
.app-main { min-height: 100vh; max-width: 100%; }
.app-content { padding: 16px; max-width: min(1180px, 100%); margin: 0 auto; width: 100%; }
.mobile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
}
.icon-btn {
  border: 0;
  background: none;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { background: var(--sage-50, #f1f6f3); }

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .sidebar-close, .mobile-bar, .nav-backdrop { display: none !important; }
  .app-main { margin-left: var(--sidebar); }
}
@media (max-width: 1023px) {
  .sidebar-close { display: block; }
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--muted); margin: 0; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 0; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}
.badge-plan { background: #dbeafe; color: #1d4ed8; }
.badge-done { background: #dcfce7; color: #15803d; }
.badge-cancel { background: #e5e7eb; color: #4b5563; text-decoration: line-through; }
.badge-noshow { background: #fee2e2; color: #b91c1c; }
.badge-complete { background: #ede9fe; color: #6d28d9; }
.badge-group { background: #ecfeff; color: #0f766e; }
.badge-wait { background: #fef3c7; color: #b45309; }
.badge-called { background: #dbeafe; color: #1d4ed8; }

.progress-track { height: 8px; background: #ece7dc; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: #f7f6f2;
  padding: 12px 16px;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: 12px 16px; height: 48px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: #f7fbf9; }
.data-table tfoot td { font-weight: 600; background: #f7f6f2; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; overflow-y: auto; max-height: min(70vh, 720px); -webkit-overflow-scrolling: touch; max-width: 100%; }
.data-table { min-width: 640px; }

.btn-primary, .btn-secondary, .btn-danger, .btn-danger-solid, .btn-ghost, .btn-tiny {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary {
  background: var(--sage);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  font-size: 14px;
  min-height: 40px;
}
.btn-primary:hover { background: var(--sage-dark); }
.btn-primary:focus { outline: 2px solid #9fd0c0; outline-offset: 2px; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-size: 14px;
  min-height: 40px;
}
.btn-secondary:hover { background: #f1f6f3; }
.btn-danger { background: none; border: 0; color: #b91c1c; font-size: 13px; padding: 8px 0; }
.btn-danger:hover { text-decoration: underline; }
.btn-danger-solid {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 8px 12px;
  font-size: 13px;
  min-height: 40px;
}
.btn-danger-solid:hover { background: #fee2e2; }
.btn-danger-solid:disabled { opacity: .45; cursor: not-allowed; }
.delete-warn {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 12px 0;
}
.btn-ghost {
  font-size: 13px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.btn-ghost:hover { background: #f1f6f3; }
.btn-tiny {
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.btn-tiny:hover { background: #f1f6f3; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 80;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  max-width: 22rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.err { background: #991b1b; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(26,42,38,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal-panel {
  background: #fff;
  width: 100%;
  max-width: min(32rem, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 16px;
  padding: 20px 22px 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: var(--ink); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--ink); }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  min-height: 40px;
}
.field textarea { min-height: 72px; }
.field-hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.pkg-block { border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 4px; margin-bottom: 12px; background: #fbfaf7; }
.pkg-block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.wd { display: inline-flex; align-items: center; gap: 4px; margin: 0 10px 8px 0; font-size: 13px; }

.auto-plan-box { margin: 4px 0 14px; text-align: left; }
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin: 0;
  text-align: left;
}
.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.switch-ui {
  flex: 0 0 44px;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d4d0c8;
  position: relative;
  margin-top: 3px;
  transition: background .15s ease;
}
.switch-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: transform .15s ease;
}
.switch-input:checked + .switch-ui { background: var(--sage); }
.switch-input:checked + .switch-ui::after { transform: translateX(18px); }
.switch-input:focus-visible + .switch-ui { outline: 2px solid #9fd0c0; outline-offset: 2px; }
.switch-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.switch-copy strong { font-size: 14px; font-weight: 650; }
.switch-hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; font-weight: 400; }
.auto-plan { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.wd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.wd-chip { position: relative; margin: 0; cursor: pointer; }
.wd-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.wd-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
}
.wd-chip input:checked + span { background: var(--sage); color: #fff; border-color: var(--sage); }
.wd-chip input:focus-visible + span { outline: 2px solid #9fd0c0; outline-offset: 2px; }
.auto-plan-preview { margin: 8px 0 0; }

/* FullCalendar */
.fc { --fc-border-color: #ece7dc; --fc-today-bg-color: #eef5f1; --fc-page-bg-color: #fff; }
.fc .fc-toolbar-title { font-size: 16px !important; font-weight: 600; }
.fc .fc-button { font-family: Inter, sans-serif !important; text-transform: none !important; }
.fc .fc-button-primary { background: var(--sage) !important; border-color: var(--sage) !important; }
.fc-event-cancelled { opacity: .7; text-decoration: line-through; }
.fc-event { border: 0 !important; font-size: 12px; overflow: hidden; }
.fc-event-group { box-shadow: inset 3px 0 0 rgba(255,255,255,.75); }
.fc-group-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  background: rgba(255,255,255,.28);
  border-radius: 4px;
  padding: 0 4px;
  margin: 0 0 2px;
  text-transform: uppercase;
}
.cal-shell { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); min-height: 0; max-width: 100%; overflow: hidden; }
#calendar { min-height: 0; max-width: 100%; height: 100%; }
.fc .fc-toolbar { flex-wrap: wrap; gap: 6px; }
.fc .fc-event-title, .fc .fc-event-time { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc .fc-col-header-cell .fc-col-header-cell-cushion { padding-right: 28px; }

html.page-takvim, body.page-takvim {
  height: 100%;
  overflow: hidden;
}
body.page-takvim .app-main {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.page-takvim .app-content.cal-page {
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 16px 12px;
}
body.page-takvim .cal-page-top { flex: 0 0 auto; }
body.page-takvim .page-title { font-size: 22px; }
body.page-takvim .cal-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
}
body.page-takvim .cal-summary .stat-card { padding: 6px 10px; }
body.page-takvim .cal-summary .stat-value { font-size: 16px; margin: 0; }
body.page-takvim .cal-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
}
body.page-takvim #calendar { flex: 1 1 auto; min-height: 0; height: 100%; }
body.page-takvim .fc, body.page-takvim .fc .fc-view-harness { height: 100% !important; }
body.page-takvim .fc .fc-scroller { overflow: hidden !important; }

.grp-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 10px 2px; margin-bottom: 10px; background: #fbfaf7; }
.grp-row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 12.5px; font-weight: 600; }

.day-more-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  z-index: 2;
}
.day-more-btn:hover { background: #eef5f1; color: var(--ink); }

.ctx-menu {
  position: fixed;
  z-index: 90;
  min-width: 220px;
  max-width: min(300px, calc(100vw - 16px));
  max-height: min(80vh, 560px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(26, 42, 38, .18);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.ctx-menu[hidden] { display: none !important; }
.ctx-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 9px 10px;
  min-height: 40px;
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}
.ctx-menu button:hover, .ctx-menu button:focus { background: #eef5f1; outline: none; }
.ctx-menu .ctx-danger { color: #b91c1c; }
.ctx-menu .ctx-danger:hover { background: #fef2f2; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.ctx-pick {
  display: flex;
  gap: 6px;
  padding: 4px 6px 8px;
  align-items: center;
}
.ctx-pick[hidden] { display: none !important; }
.ctx-pick input[type="date"] {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  padding: 4px 8px;
  font: inherit;
  font-size: 14px;
}
.ctx-pick button {
  width: auto;
  min-height: 36px;
  padding: 4px 10px;
  background: var(--sage);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.ctx-pick button:hover { background: var(--sage-dark); }

@media (max-width: 767px) {
  .app-content { padding: 12px; }
  .page-title { font-size: 22px; }
  .cal-shell { padding: 6px; border-radius: 10px; }
  .fc .fc-toolbar-title { font-size: 14px !important; }
  .fc .fc-button { padding: 4px 8px !important; }
  .fc-event { font-size: 11px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-backdrop { padding: 8px; align-items: flex-end; }
  .modal-panel { max-height: 92vh; border-radius: 16px 16px 0 0; padding: 16px; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  body.page-takvim .app-content.cal-page { padding: 8px 10px 10px; }
  body.page-takvim .cal-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  body.page-takvim .cal-summary .stat-label { font-size: 10px; }
  body.page-takvim .cal-summary .stat-value { font-size: 14px; }
  body.page-takvim .page-kicker { display: none; }
}
