:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #171b2e;
  --muted: #6d7488;
  --line: #e4e7ef;
  --primary: #5b43e6;
  --primary-strong: #4931d1;
  --danger: #d83b55;
  --success: #16875d;
  --warning: #a96800;
  --shadow: 0 18px 50px rgba(31, 35, 60, .08);
  --radius: 18px;
  --fc-border-color: #e7e9f1;
  --fc-button-bg-color: #ffffff;
  --fc-button-border-color: #dfe2ec;
  --fc-button-text-color: #33384e;
  --fc-button-hover-bg-color: #f2f0ff;
  --fc-button-hover-border-color: #cfc8ff;
  --fc-button-active-bg-color: #5b43e6;
  --fc-button-active-border-color: #5b43e6;
  --fc-event-bg-color: #5b43e6;
  --fc-event-border-color: #5b43e6;
  --fc-today-bg-color: rgba(91, 67, 230, .07);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; padding: 12px clamp(16px, 4vw, 52px); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 16px; }
.brand small, .user-chip small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.brand-mark { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #6b52ef, #3a23b4); font-size: 25px; font-weight: 800; box-shadow: 0 12px 30px rgba(91,67,230,.28); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 19px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; flex-direction: column; align-items: flex-end; margin-right: 6px; }
.user-chip strong { font-size: 14px; }

.btn { min-height: 40px; padding: 9px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; font-weight: 700; font-size: 14px; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 9px 20px rgba(91,67,230,.2); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { color: #36394b; background: #fff; border-color: #dfe2ec; }
.btn-secondary:hover, .btn-ghost:hover { background: #f2f0ff; border-color: #d3cdfa; }
.btn-ghost { color: #555b70; background: transparent; border-color: transparent; }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }

.app-main, .admin-main { width: min(1520px, calc(100% - 32px)); margin: 28px auto 56px; }
.calendar-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.calendar-card { padding: clamp(16px, 2.5vw, 30px); }
.calendar-heading, .panel-heading, .page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.calendar-heading { margin-bottom: 24px; }
.calendar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.google-appointment-button { min-height: 40px; display: flex; align-items: center; }
.google-appointment-button > div { display: flex; align-items: center; }

h1, h2, p { margin-top: 0; }
.calendar-heading h1, .page-heading h1 { margin-bottom: 6px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; }
.calendar-heading p, .page-heading p, .panel-heading p { margin-bottom: 0; color: var(--muted); }
.panel-heading h2 { margin-bottom: 4px; font-size: 19px; }

.setup-banner { margin-bottom: 18px; padding: 15px 17px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: #fff8e8; border: 1px solid #f2dba8; border-radius: 14px; }
.setup-banner div { display: flex; flex-direction: column; gap: 4px; }
.setup-banner span { color: #765719; font-size: 14px; }

#calendar { position: relative; min-height: 560px; }
#calendar.is-loading::after { content: "Takvim yükleniyor…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 700; background: rgba(255,255,255,.7); backdrop-filter: blur(2px); z-index: 5; }
.fc .fc-toolbar-title { font-size: clamp(19px, 2vw, 25px); }
.fc .fc-button { border-radius: 9px; box-shadow: none !important; font-weight: 700; text-transform: none; }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion { color: #454a5f; }
.fc-event { border-radius: 7px; padding: 1px 3px; }
.fc-event-title { font-weight: 700; }

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 18px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 20, 35, .55); backdrop-filter: blur(5px); }
.modal-card { position: relative; width: min(620px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 24px; background: #fff; border-radius: 20px; box-shadow: 0 28px 80px rgba(10,12,24,.32); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.modal-header h2 { margin-bottom: 4px; }
.icon-btn { width: 38px; height: 38px; border: 0; border-radius: 11px; background: #f2f3f7; color: #555b70; font-size: 26px; line-height: 1; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

.form-stack { display: flex; flex-direction: column; gap: 15px; }
.form-stack h2 { margin: 8px 0 0; font-size: 18px; }
label { display: flex; flex-direction: column; gap: 7px; color: #4a5065; font-size: 13px; font-weight: 750; }
label small { color: var(--muted); font-weight: 500; line-height: 1.45; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--text); background: #fff; border: 1px solid #dfe2eb; border-radius: 10px; outline: none; transition: .16s ease; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #8c7cf0; box-shadow: 0 0 0 4px rgba(91,67,230,.1); }
input[readonly], textarea[readonly], input:disabled, select:disabled { background: #f5f6f9; color: #60667a; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-label { flex-direction: row; align-items: center; width: fit-content; }
.check-label input, .switch-line input { width: 18px; min-height: 18px; accent-color: var(--primary); }

.alert { margin-bottom: 16px; padding: 13px 15px; border-radius: 12px; border: 1px solid; line-height: 1.45; }
.alert-error { color: #8e2133; background: #fff0f3; border-color: #f2c0ca; }
.alert-success { color: #116849; background: #edfff7; border-color: #bcebd8; }
.alert-info { color: #31558a; background: #eff6ff; border-color: #c8dcf9; }
.muted { color: var(--muted); }

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: radial-gradient(circle at 20% 20%, rgba(91,67,230,.16), transparent 32%), radial-gradient(circle at 80% 85%, rgba(70,151,255,.12), transparent 30%), #f4f6fb; }
.auth-shell { width: min(430px, 100%); }
.install-shell { width: min(720px, 100%); }
.auth-card { padding: clamp(24px, 5vw, 38px); background: rgba(255,255,255,.96); border: 1px solid rgba(255,255,255,.9); border-radius: 24px; box-shadow: 0 28px 80px rgba(29,31,53,.14); }
.auth-card .brand-mark { margin-bottom: 24px; }
.auth-card h1 { margin-bottom: 8px; font-size: 30px; letter-spacing: -.03em; }
.install-card { margin: 20px 0; }

.admin-main { display: flex; flex-direction: column; gap: 20px; }
.page-heading { padding: 8px 2px; }
.admin-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 20px; }
.panel { padding: 22px; }
.panel-heading { margin-bottom: 18px; }
.status-pill { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-pill.good { color: #0f6848; background: #e7faF2; }
.status-pill.warn { color: #8b5a00; background: #fff4d7; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; margin: 20px 0; }
.check-grid.compact { grid-template-columns: 1fr; margin: 0; }
.check-item { padding: 10px 12px; display: flex; align-items: center; gap: 8px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.check-item span { width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%; color: #fff; }
.check-item.ok { color: #186f52; background: #effbf6; }
.check-item.ok span { background: #23a273; }
.check-item.bad { color: #9a3548; background: #fff0f3; }
.check-item.bad span { background: #d94a62; }
.inline-form { display: grid; gap: 10px; align-items: end; margin-bottom: 18px; }
.add-user-form { grid-template-columns: 1fr 1.2fr 1fr .8fr auto; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
th { color: #656b7e; background: #f7f8fb; font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); }
.user-row-form { display: grid; grid-template-columns: 140px 90px 145px minmax(180px, 1fr) auto; gap: 10px; align-items: center; }
.user-row-form input, .user-row-form select { min-height: 38px; padding: 8px 10px; }
.switch-line { flex-direction: row; align-items: center; }
.last-login { color: var(--muted); font-size: 12px; }
.mono { max-width: 170px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.log-payload { max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.empty-cell { padding: 24px; text-align: center; color: var(--muted); }
code { padding: 3px 6px; color: #4a33c0; background: #f0edff; border-radius: 6px; }

.toast-container { position: fixed; z-index: 200; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { max-width: 380px; padding: 13px 15px; color: #fff; background: #303448; border-radius: 12px; box-shadow: 0 16px 36px rgba(20,22,34,.25); opacity: 0; transform: translateY(10px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #167c58; }
.toast-error { background: #b93249; }

@media (max-width: 980px) {
  .admin-grid { grid-template-columns: 1fr; }
  .add-user-form { grid-template-columns: 1fr 1fr; }
  .add-user-form .btn { width: 100%; }
}

@media (max-width: 700px) {
  .topbar { align-items: flex-start; padding: 10px 14px; }
  .brand small, .user-chip { display: none; }
  .top-actions { gap: 4px; }
  .top-actions .btn { min-height: 38px; padding: 8px 10px; font-size: 12px; }
  .app-main, .admin-main { width: min(100% - 20px, 1520px); margin-top: 14px; }
  .calendar-card, .panel { border-radius: 14px; padding: 14px; }
  .calendar-heading { align-items: flex-start; }
  .calendar-heading p { font-size: 13px; }
  .calendar-heading .btn { white-space: nowrap; }
  .calendar-heading { flex-direction: column; }
  .calendar-actions { width: 100%; justify-content: flex-start; }
  .form-grid.two { grid-template-columns: 1fr; }
  .modal-card { padding: 18px; }
  .fc .fc-toolbar { align-items: flex-start; gap: 9px; }
  .fc .fc-toolbar.fc-header-toolbar { flex-wrap: wrap; }
  .fc .fc-toolbar-chunk:nth-child(2) { order: -1; width: 100%; }
  .fc .fc-toolbar-title { text-align: center; }
  .setup-banner { align-items: flex-start; flex-direction: column; }
  .add-user-form { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
}
