:root {
  --bg-page: #f9f8f6; --bg-card: #ffffff; --bg-subtle: #fafaf8; --bg-hover: rgba(17,17,17,.03);
  --border-card: #e5e2dc; --border-subtle: #f0eee9; --border-dashed: #d8d4ce;
  --text-primary: #111111; --text-secondary: #6f6f6f; --text-muted: #bbbbbb;
  --btn-primary-bg: #111111; --btn-primary-text: #f9f8f6;
  --btn-secondary-bg: #f4f2ee; --btn-secondary-text: #111111; --btn-secondary-hover: #ebe8e2;
  --input-bg: #ffffff; --input-border: #e5e2dc; --input-border-focus: #111111; --input-focus-ring: rgba(17,17,17,.07);
  --toggle-track: #ebe8e2; --toggle-thumb: #ffffff;
  --danger: #9b2335; --danger-bg: #fbeff1; --overlay: rgba(17,17,17,.28);
  --shadow-card: 0 1px 4px rgba(0,0,0,.03); --shadow-lifted: 0 8px 48px rgba(0,0,0,.06);
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --serif: "DM Serif Display", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --sheet-font: Calibri, Carlito, "Segoe UI", Arial, sans-serif;
}
html.dark {
  --bg-page: #0e0e10; --bg-card: #18181b; --bg-subtle: #202024; --bg-hover: rgba(244,235,215,.04);
  --border-card: rgba(244,235,215,.12); --border-subtle: rgba(244,235,215,.08); --border-dashed: rgba(244,235,215,.28);
  --text-primary: #f4ebd7; --text-secondary: rgba(244,235,215,.66); --text-muted: rgba(244,235,215,.4);
  --btn-primary-bg: #f4ebd7; --btn-primary-text: #111111;
  --btn-secondary-bg: #27272a; --btn-secondary-text: #f4ebd7; --btn-secondary-hover: #333338;
  --input-bg: #1f1f23; --input-border: rgba(244,235,215,.15); --input-border-focus: #f4ebd7; --input-focus-ring: rgba(244,235,215,.18);
  --toggle-track: #27272a; --toggle-thumb: #121214;
  --danger: #e2788a; --danger-bg: rgba(226,120,138,.1); --overlay: rgba(0,0,0,.55);
  --shadow-card: 0 1px 4px rgba(0,0,0,.4); --shadow-lifted: 0 8px 48px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-page); color: var(--text-primary); font: 15px/1.5 var(--sans);
  text-transform: lowercase; transition: background .25s, color .25s;
}
.hidden { display: none !important; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.meta { color: var(--text-secondary); font-size: 12.3px; margin: 0; }
.brand { font-family: var(--serif); font-size: 20.8px; letter-spacing: -.01em; font-weight: 400; margin: 0; white-space: nowrap; }
.title { font-family: var(--serif); font-size: 22px; letter-spacing: -.01em; font-weight: 400; margin: 0; }
.label { color: var(--text-secondary); font-size: 13.6px; margin: 12px 0 6px; display: block; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--r-md); background: var(--btn-secondary-bg); color: var(--btn-secondary-text);
  font: 500 14px/1 var(--sans); text-transform: lowercase; cursor: pointer; transition: background .2s, transform .1s; white-space: nowrap;
}
.btn:hover { background: var(--btn-secondary-hover); }
.btn:active { transform: scale(.975); }
.btn.primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn.primary:hover { opacity: .9; }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn:focus-visible, .input:focus-visible { outline: 2px solid var(--input-border-focus); outline-offset: 2px; }

.input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--input-border); border-radius: var(--r-md);
  background: var(--input-bg); color: var(--text-primary); font: 15.2px/1.4 var(--sans); text-transform: none;
}
.input:focus { outline: none; border-color: var(--input-border-focus); box-shadow: 0 0 0 3px var(--input-focus-ring); }
textarea.input { resize: vertical; font-size: 14px; }

.card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.error { background: var(--danger-bg); color: var(--danger); border-radius: var(--r-md); padding: 10px 12px; font-size: 13.6px; margin-top: 10px; text-transform: none; }
.empty { border: 1px dashed var(--border-dashed); border-radius: var(--r-lg); padding: 40px 16px; text-align: center; color: var(--text-secondary); margin: 24px auto; max-width: 520px; }
.empty .btn { margin-top: 12px; }

.theme-toggle { width: 44px; height: 24px; border-radius: 9999px; border: 1px solid var(--border-dashed); background: var(--toggle-track); position: relative; cursor: pointer; padding: 0; flex: none; }
.theme-toggle .thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 9999px; background: var(--toggle-thumb); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .35s cubic-bezier(.34,1.56,.64,1); }
html.dark .theme-toggle .thumb { transform: translateX(20px); }

.segmented { display: inline-flex; background: var(--btn-secondary-bg); border-radius: var(--r-lg); padding: 4px; gap: 4px; }
.segmented button { border: 0; background: transparent; color: var(--text-secondary); font: 500 14px var(--sans); text-transform: lowercase; padding: 5px 12px; border-radius: var(--r-md); cursor: pointer; }
.segmented button.on { background: var(--btn-primary-bg); color: var(--btn-primary-text); }

/* giriş */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 28px; display: grid; gap: 12px; }

/* üst çubuk */
.nav { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border-card); background: var(--bg-card); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.nav .spacer { flex: 1; }
.weeknav { display: flex; gap: 4px; align-items: center; }
.week-select { width: auto; height: 36px; padding: 0 8px; font-size: 14px; }
.save-state { min-width: 70px; text-align: right; }
.menu-wrap { position: relative; }
.menu, .ctx { position: absolute; z-index: 50; background: var(--bg-card); border: 1px solid var(--border-card); border-radius: var(--r-md); box-shadow: var(--shadow-lifted); padding: 4px; min-width: 180px; }
.menu { right: 0; top: 42px; }
.menu button, .ctx button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text-primary); padding: 8px 10px; border-radius: var(--r-sm); font: 14px var(--sans); text-transform: lowercase; cursor: pointer; }
.menu button:hover, .ctx button:hover { background: var(--btn-secondary-bg); }
.ctx .sep { height: 1px; background: var(--border-subtle); margin: 4px 0; }
.ctx .swatches { display: grid; grid-template-columns: repeat(8, 20px); gap: 4px; padding: 6px 10px; }
.ctx .swatches span { width: 20px; height: 20px; border-radius: 4px; border: 1px solid rgba(0,0,0,.2); cursor: pointer; }
.hint { padding: 6px 16px; }

/* tablo: excel / docs görünümü */
.sheet-wrap { padding: 0 16px 40px; overflow: auto; }
.sheet { display: inline-block; background: #fff; color: #111; text-transform: none; font-family: var(--sheet-font); user-select: none; }
.sheet table { border-collapse: collapse; table-layout: fixed; }
.sheet td { border: 1px solid #8a8a8a; height: 30px; padding: 0 6px; text-align: center; vertical-align: middle; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; position: relative; cursor: cell; }
.sheet .t-title td { background: #e2efda; font-weight: 400; font-size: 22px; height: 58px; letter-spacing: .02em; }
.sheet .t-head td { background: #000; color: #fff; border-color: #000; }
.sheet .t-head.first td { height: 60px; line-height: 1.3; }
.sheet td.num { width: 34px; font-size: 16px; }
.sheet td.name { width: 290px; }
.sheet td.role { width: 192px; }
.sheet td.day { width: 154px; }
.sheet td.tot { width: 64px; font-size: 13px; font-weight: 600; color: #555; background: #f6f6f6; }
.sheet .t-head td.tot { color: #fff; background: #000; }
.sheet tr.row td.name, .sheet tr.row td.role, .sheet tr.row td.num { background: #fff; }
.sheet td.dark { background: #000 !important; }
.sheet td .h { position: absolute; right: 3px; bottom: 1px; font: 600 9.5px var(--mono); opacity: .55; }
.sheet.no-hours td .h, .sheet.no-hours td.tot { display: none; }
.sheet td.sel { box-shadow: inset 0 0 0 2px #1a73e8; }
.sheet td.sel.anchor { box-shadow: inset 0 0 0 3px #1a73e8; }
.sheet td.warn::after { content: ""; position: absolute; top: 0; right: 0; border: 6px solid transparent; border-top-color: #d00; border-right-color: #d00; }
.sheet.avail tr.row td.day { background: #fff; color: #1f4e79; font-weight: 600; font-size: 14px; }
.sheet.avail tr.row td.day.no { background: #fde2e2; color: #9b2335; }
.sheet.avail tr.row td.day.yes { background: #e3eefa; }
.sheet td .note { position: absolute; left: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: #1f4e79; box-shadow: 0 0 0 1px #fff; }
.sheet tr.t-sum td { height: 22px; font: 500 11.5px var(--sans); color: #666; background: #f6f6f6; border-color: #ddd; }
.sheet tr.t-add td { height: 26px; border: 0; background: transparent; text-align: left; }
.sheet tr.t-add button { border: 0; background: none; color: #888; font: 500 13px var(--sans); cursor: pointer; padding: 2px 6px; }
.sheet tr.t-add button:hover { color: #111; }
.sheet.no-hours .noexport, .sheet.no-hours td .note { display: none; }
.sheet .cell-editor { position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; z-index: 30; border: 2px solid #1a73e8; font: 700 17px var(--sheet-font); text-align: center; padding: 0 4px; background: #fff; color: #111; outline: none; text-transform: none; }

/* yan paneller */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--bg-card); border-left: 1px solid var(--border-card); box-shadow: var(--shadow-lifted); z-index: 40; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.6px; color: var(--text-secondary); }
.check input { accent-color: var(--btn-primary-bg); }
.ai-result { background: var(--bg-subtle); border: 1px solid var(--border-card); border-radius: var(--r-md); padding: 12px; font-size: 13.6px; text-transform: none; white-space: pre-wrap; }
.checks { font-size: 13px; text-transform: none; }
.checks li { color: var(--danger); margin: 2px 0; }
.color-rules { display: grid; gap: 6px; }
.color-rules .cr { display: grid; grid-template-columns: 1fr 90px 34px 34px 28px; gap: 6px; align-items: center; }
.color-rules input[type=text] { padding: 5px 8px; font-size: 13px; }
.color-rules input[type=color] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--input-border); border-radius: var(--r-sm); background: none; }
.color-rules button { border: 0; background: none; color: var(--text-secondary); cursor: pointer; font-size: 16px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--btn-primary-bg); color: var(--btn-primary-text); padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-lifted); z-index: 60; font-size: 14px; }

.login-card .btn { justify-content: center; }

@media (max-width: 760px) {
  .nav { gap: 6px; padding: 8px 12px; }
  .nav .brand { width: 100%; font-size: 18px; }
  .nav .spacer, .save-state, .hint, #exportBtn span { display: none; }
  .weeknav { flex: 1; }
  .week-select { flex: 1; min-width: 0; }
  #aiBtn { order: 10; flex: 1; justify-content: center; }
  .sheet-wrap { padding: 8px 0 40px; }
  /* telefonda ad sütunu kayarken sabit kalır, görev sütunu gizlenir */
  .sheet td { font-size: 13px; height: 34px; padding: 0 4px; }
  .sheet td.num, .sheet td.role { display: none; }
  .sheet td.name { width: 120px; white-space: normal; line-height: 1.15; position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 #8a8a8a; }
  .sheet tr.t-add button { white-space: nowrap; }
  .sheet td.day { width: 108px; }
  .sheet .t-title td { font-size: 14px; height: 40px; text-align: left; }
  .sheet .t-head td.name { background: #000; }
  .sheet tr.t-sum td.name { background: #f6f6f6; }
  .sheet tr.t-add td.name { background: var(--bg-page); }
  .sheet tr.t-sum td { font-size: 10px; white-space: normal; line-height: 1.1; }
  .sheet .cell-editor { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  @page { size: A4 landscape; margin: 6mm; }
  body { background: #fff; }
  .nav, .hint, .panel, .toast, .ctx, .empty { display: none !important; }
  .sheet-wrap { padding: 0; overflow: visible; }
  .sheet { zoom: .62; }
  .sheet td .h, .sheet td.tot, .sheet .noexport, .sheet td .note { display: none; }
  .sheet td.sel { box-shadow: none; }
  .sheet td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
