:root {
  --bg: #f4f6f8;
  --surface: #fff;
  --ink: #1d2733;
  --muted: #5d6b7a;
  --line: #d5dce3;
  --accent: #1f5fa8;
  --accent-ink: #fff;
  --danger: #b3261e;
  --p: #87CEFA;
  --t: #90EE90;
  --u: #F08080;
  --today-bg: #FFE4E1;
  --today-ink: #8B0000;
  --meet-bg: #ff0000;
  --meet-ink: #fff;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); display: flex; flex-direction: column; min-height: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---- düğmeler / alanlar ---- */
.btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 5px 12px; cursor: pointer; min-height: 30px;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select, input[type=text], input[type=password], input[type=number], input[type=date], textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; min-height: 30px;
}

/* ---- üst çubuk ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 600; font-size: 16px; }
.filters { display: flex; align-items: center; gap: 8px; }
.lbl { color: var(--muted); }
.userbox { display: flex; align-items: center; gap: 10px; }
.person-filter { position: relative; }
.popup {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 220px; max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 6px;
}
.popup hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu-item { display: flex; gap: 8px; align-items: center; padding: 5px 6px; cursor: pointer; border-radius: 3px; white-space: nowrap; }
.menu-item:hover { background: var(--bg); }

/* ---- sekmeler ---- */
.tabs { display: flex; gap: 2px; padding: 8px 16px 0; background: var(--bg); overflow-x: auto; flex: none; }
.tab {
  background: #e6ebf0; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0;
  padding: 7px 16px; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--surface); font-weight: 600; position: relative; top: 1px; }
.panels { flex: 1; min-height: 0; padding: 0 16px; display: flex; flex-direction: column; }
.panel {
  flex: 1; min-height: 0; background: var(--surface); border: 1px solid var(--line);
  padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow: hidden;
}
.panel[hidden] { display: none; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: none; }
.toolbar .info { color: var(--muted); }
.statusbar {
  flex: none; padding: 6px 16px; background: var(--surface); border-top: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.statusbar span { display: block; overflow: hidden; text-overflow: ellipsis; }

/* ---- toast / modal ---- */
.toasts { position: fixed; right: 16px; bottom: 44px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(460px, calc(100vw - 32px)); }
.toast { background: #243447; color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); }
.toast.warn { background: #8a5a00; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 16px; }
.modal { background: var(--surface); border-radius: 8px; padding: 18px; width: min(520px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 10px; }
.modal-msg { margin: 0 0 16px; line-height: 1.45; }
.modal-text { width: 100%; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---- giriş sayfası ---- */
.login-body { align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 28px; width: min(360px, calc(100vw - 32px)); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.login-card label { color: var(--muted); margin-top: 6px; }
.login-card .btn { margin-top: 14px; }
.login-error { color: var(--danger); margin-top: 6px; }

/* ---- Tabulator (planlama) ---- */
#panel-plan .grid-host { flex: 1; min-height: 0; }
.tabulator { font-size: 13px; border-color: var(--line); background: var(--surface); }
.tabulator .tabulator-header { background: #eef2f6; color: var(--ink); border-bottom: 1px solid var(--line); }
.tabulator .tabulator-header .tabulator-col { background: #eef2f6; }
.tabulator .tabulator-row { min-height: 28px; }
.tabulator .tabulator-row .tabulator-cell { padding: 4px 6px; }
.tabulator .tabulator-row.tabulator-row-even { background: #fafbfc; }
.tabulator .tabulator-cell.cell-ro { color: var(--muted); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); vertical-align: middle; }
.readonly .tabulator .tabulator-cell { cursor: default; }

/* ---- Düz tablo ızgaraları (veri girişi, haftalık, aylık) ---- */
.grid-scroll { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); position: relative; background: #fff; }
table.g { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; }
table.g th, table.g td { border-right: 1px solid #e3e8ed; border-bottom: 1px solid #e3e8ed; padding: 0; overflow: hidden; white-space: nowrap; }
table.g thead th { position: sticky; background: #eef2f6; z-index: 3; text-align: center; font-weight: 500; }
table.g thead tr.r1 th { top: 0; }
table.g td.fx, table.g th.fx { position: sticky; background: #fff; z-index: 2; text-align: left; padding: 3px 6px; text-overflow: ellipsis; }
table.g thead th.fx { z-index: 5; background: #eef2f6; }
table.g td.fx.last, table.g th.fx.last { border-right: 2px solid #9aa7b4; }
table.g td.rowc { border-left: 4px solid transparent; }

/* veri girişi */
table.day th.dh { line-height: 1.15; padding: 3px 0; height: 52px; user-select: none; cursor: default; }
table.day th.dh.today { color: var(--today-ink); background: var(--today-bg); font-weight: 700; }
table.day th.dh.meeting { color: var(--meet-ink); background: var(--meet-bg); font-weight: 700; }
table.day td.dc { text-align: center; cursor: cell; font-weight: 600; height: 28px; }
table.day td.dc.sel { outline: 2px solid #0b3d91; outline-offset: -2px; z-index: 1; }
table.day td.dc[data-s="P"] { background: var(--p); }
table.day td.dc[data-s="T"] { background: var(--t); }
table.day td.dc[data-s="U"] { background: var(--u); }
table.day td.dc.we:not([data-s]) { background: #f3f5f7; }
.readonly table.day td.dc { cursor: default; }
.daybar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.daybar .month-label { min-width: 170px; text-align: center; font-weight: 600; }
.legend { display: inline-flex; gap: 10px; align-items: center; margin-left: auto; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); vertical-align: -2px; margin-right: 3px; }
.ctxmenu { position: fixed; z-index: 80; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.2); padding: 4px 0; min-width: 220px; }
.ctxmenu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 14px; cursor: pointer; }
.ctxmenu button:hover { background: var(--bg); }

/* haftalık */
table.week th.mh { height: 20px; background: #e6e6e6; border-right: 1px solid #a9b2bb; font-weight: 500; text-align: center; }
table.week th.wh { height: 20px; font-size: 10px; line-height: 20px; text-align: left; padding: 0 0 0 2px; background: #eef2f6; border-right: 1px solid #c9d1d9; }
table.week thead tr.r2 th { top: 21px; }
table.week td.wc { height: 22px; border-bottom: 1px solid #d9dfe5; }
table.week td.wc[data-s="P"] { background: var(--p); }
table.week td.wc[data-s="T"] { background: var(--t); }
table.week td.wc[data-s="U"] { background: var(--u); }
table.week td.me, table.week th.me { border-right: 2px solid #5f6b77; }
table.month th.cur { background: #ffe4e1; color: var(--today-ink); }

/* aylık */
table.month th { top: 0; height: 34px; }
table.month td.mc { text-align: center; height: 28px; padding: 0 4px; font-variant-numeric: tabular-nums; }
table.month td.mc .bar { display: flex; height: 100%; align-items: stretch; }
table.month td.mc .seg { display: flex; align-items: center; justify-content: center; font-size: 12px; min-width: 0; }
table.month td.mc .seg.P { background: var(--p); }
table.month td.mc .seg.T { background: var(--t); }
table.month td.mc .seg.U { background: var(--u); }
table.month td.mc.cur { background: #fff8f7; }
table.month tfoot td { position: sticky; bottom: 0; background: #eef2f6; font-weight: 600; text-align: center; border-top: 2px solid #9aa7b4; }
table.month tfoot td.fx { text-align: left; }

@media (max-width: 720px) {
  .topbar { padding: 8px; gap: 8px; }
  .tabs { padding: 6px 8px 0; }
  .panels { padding: 0 8px; }
  .userbox #userInfo { display: none; }
}

/* ---- toplantı notları penceresi ---- */
.modal.wide { width: min(980px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.mt-body { display: grid; grid-template-columns: 190px 1fr; gap: 12px; min-height: 0; flex: 1; }
.mt-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.mt-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; max-height: 55vh; }
.mt-item { text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); cursor: pointer; }
.mt-item:hover { border-color: var(--accent); }
.mt-item.on { background: var(--meet-bg); border-color: var(--meet-bg); color: var(--meet-ink); font-weight: 700; }
.mt-add { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.mt-main { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.mt-head { font-weight: 600; }
.modal.wide.busy { cursor: progress; }
.modal.wide.busy .mt-body, .modal.wide.busy .modal-actions { opacity: .7; }
.mt-text { flex: 1; min-height: 55vh; line-height: 1.45; }
@media (max-width: 640px) {
  .mt-body { grid-template-columns: 1fr; }
  .mt-list { flex-direction: row; overflow-x: auto; max-height: none; }
  .mt-item { white-space: nowrap; }
  .mt-text { min-height: 40vh; }
}
