/* Minimal arayüz, logoya uyumlu: beyaz zemin, siyah vurgu; renk sadece kişilere ve tabloya ait.
   Varsayılan koyu tema; açık tema düğmeyle seçilir (html[data-theme]).
   Köşeler squircle (destekleyen tarayıcılarda corner-shape, diğerlerinde hafif yuvarlak). */
:root {
  color-scheme: light;
  /* Göz yormayan kırık beyaz: saf beyaz yok, sıcak gri tonlar, yumuşak kontrast */
  --bg: #e9e8e4; --card: #f4f3ef; --text: #232326; --muted: #6c6b70;
  --fill: #e5e4df; --fill-2: #dbdad4; --empty: #e0dfd9; --line: #dad9d3;
  --accent: #3b3a40; --accent-hover: #47464d; --accent-text: #f1f0ec;
  --danger: #b5473e; --ok: #3f7d52;
  --r-lg: 14px; --r-md: 10px; --r-sm: 8px; --r-xs: 2px;
  --shadow: 0 1px 2px rgba(60, 55, 45, .05);
  --border: 1px solid var(--line);
  /* Gölgeler ve perdeler de temaya göre: açıkta sıcak ve hafif, koyuda derin */
  --shadow-float: 0 8px 22px rgba(60, 55, 45, .18), 0 2px 5px rgba(60, 55, 45, .10);
  --shadow-pop: 0 18px 44px rgba(60, 55, 45, .20);
  --backdrop: rgba(205, 202, 194, .45);
  --edge: rgba(60, 55, 45, .12);
  --logo-filter: brightness(.96) drop-shadow(0 0 .5px rgba(60, 55, 45, .45));
  /* Buzlu cam (telefondaki sabit buton) */
  --glass-bg: rgba(255, 255, 253, .80); --glass-bg-hover: rgba(255, 255, 253, .92);
  --glass-text: #111113; --glass-border: rgba(60, 55, 45, .16); --glass-shine: rgba(255, 255, 255, .95);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0d; --card: #161618; --text: #f2f2f0; --muted: #8d8d93;
  --fill: #202023; --fill-2: #2a2a2e; --empty: #222225; --line: #232326;
  --accent: #f2f2f0; --accent-hover: #ffffff; --accent-text: #111113;
  --danger: #ff6b5e; --ok: #5fc47e;
  --shadow: none;
  --shadow-float: 0 10px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, .55);
  --backdrop: rgba(0, 0, 0, .35);
  --edge: rgba(255, 255, 255, .08);
  --logo-filter: none;
  --glass-bg: rgba(120, 120, 128, .42); --glass-bg-hover: rgba(140, 140, 148, .50);
  --glass-text: #ffffff; --glass-border: rgba(255, 255, 255, .28); --glass-shine: rgba(255, 255, 255, .22);
}
@supports (corner-shape: squircle) {
  :root { --r-lg: 20px; --r-md: 14px; --r-sm: 10px; --r-xs: 3px; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.card, button, input, .modal-card, .grid .c, .dot, .sw span, .userlist details, .latest {
  corner-shape: squircle;
}

button, input { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 0; border-radius: var(--r-sm); padding: 11px 18px;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background .15s, opacity .15s, transform .1s;
}
button:active:not(:disabled) { transform: scale(.98); }
:where(button:not(.ghost)):hover:not(:disabled) { background: var(--accent-hover); }
html { scrollbar-color: var(--fill-2) var(--bg); }
.gridwrap { scrollbar-color: var(--fill-2) transparent; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button.ghost { background: var(--fill); color: var(--text); font-weight: 500; }
button.ghost:hover:not(:disabled) { background: var(--fill-2); }
input {
  border: 0; background: var(--fill); border-radius: var(--r-sm); padding: 11px 14px; min-width: 0;
  transition: box-shadow .15s;
}
input::placeholder { color: var(--muted); }
input:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--text); }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 0; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; font-weight: 400; }
.card {
  background: var(--card); border: var(--border); border-radius: var(--r-lg); padding: 20px; min-width: 0;
  box-shadow: var(--shadow);
}

/* Tema düğmesi */
.themebtn {
  width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; flex: none;
  font-size: 18px; line-height: 1;
}
.login .themebtn { position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
.topbtns { display: flex; gap: 8px; align-items: center; }
.msg { min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* Giriş */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: 12px; padding: 16px; }
.apk-card {
  width: 100%; max-width: 340px; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card); border: var(--border); border-radius: var(--r-lg); corner-shape: squircle;
  color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: background .15s, transform .1s;
}
.apk-card:hover { background: var(--fill); }
.apk-card:active { transform: scale(.98); }
.apk-card:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.apk-icon {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border-radius: var(--r-md); corner-shape: squircle; background: rgba(61, 220, 132, .14); color: #2fbf6f;
}
.apk-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; text-align: left; }
.apk-text b { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.apk-text small { font-size: 12.5px; color: var(--muted); }
.apk-arrow { margin-left: auto; flex: none; color: var(--muted); }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; text-align: center; padding: 28px 24px; }
.login-card p.muted { margin: 0 0 4px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); }
.login-card input { font-size: 22px; color: var(--text); text-align: center; letter-spacing: .3em; padding: 14px; }
.logo { width: 88px; height: 88px; margin: 0 auto; display: block; filter: var(--logo-filter); }
.login-card label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; color: var(--text); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

/* Uygulama */
.app {
  max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px;
  padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 4px 0; }
.who { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; letter-spacing: -.01em; min-width: 0; }
.top .ghost { height: 40px; padding: 0 14px; font-size: 14px; }
.dot { width: 13px; height: 13px; border-radius: 3px; display: inline-block; flex: none; vertical-align: -2px; box-shadow: inset 0 0 0 1px var(--edge); }
@supports (corner-shape: squircle) { .dot { border-radius: 4px; } }
.actions { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.big { font-size: 19px; padding: 20px 16px; border-radius: var(--r-md); letter-spacing: -.01em; }
.big.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .big.shake { animation: none; } }
.actions .msg { margin: 0 4px 2px; text-align: center; }
.actions .msg:empty { display: none; }

/* Yönetici paneli */
h3 { font-size: 12px; font-weight: 600; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.admin h3:first-child, .admin form > h3:first-child { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.fields input { color: var(--text); font-size: 16px; width: 100%; }
/* Şifre kutusu: sağında kopyala + rastgele üret */
.pw-field { position: relative; display: block; }
.pw-field input { padding-right: 84px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.pw-btn {
  position: absolute; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center; background: transparent; color: var(--muted); border-radius: var(--r-sm);
}
.pw-btn:hover:not(:disabled) { background: var(--fill-2); color: var(--text); }
.pw-btn:active:not(:disabled) { transform: translateY(-50%) scale(.94); }
#pwGen { right: 4px; }
#pwCopy { right: 40px; }
.pw-btn.done { color: var(--ok); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { position: relative; cursor: pointer; }
.sw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sw span { display: block; width: 30px; height: 30px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--edge); }
@supports (corner-shape: squircle) { .sw span { border-radius: 9px; } }
.sw input:checked + span { outline: 2px solid var(--text); outline-offset: 2px; }
.sw input:focus-visible + span { outline: 2px dashed var(--text); outline-offset: 3px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
button.danger { color: var(--danger); }
.userlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.userlist li.empty { padding: 4px 0; }
.userlist details { background: var(--fill); border-radius: var(--r-md); }
.userlist details[open] { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fill-2); }
.userlist summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.userlist summary::-webkit-details-marker { display: none; }
.userlist summary::after { content: '›'; margin-left: auto; color: var(--muted); font-size: 18px; line-height: 1; transition: transform .15s; }
.userlist details[open] summary::after { transform: rotate(90deg); }
.userlist summary .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userlist .edit { padding: 0 14px 14px; }
.userlist .edit input { background: var(--fill); }
.adminpw { margin-top: 10px; padding-top: 6px; border-top: 1px solid var(--line); }

.daytitle { margin: 0 0 6px; letter-spacing: -.01em; text-transform: capitalize; }

/* Tablo (harita): her saat bir satır, 60 dakika */
.gridhead { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 0 0 14px; }
.gridhead h2 { margin: 0; }
.latest {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; margin-left: auto;
  padding: 6px 12px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  background: var(--fill); color: var(--text);
}
.latest:hover { background: var(--fill-2); }
.latest .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.latest .when { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.scrollhint { display: none; margin: -6px 0 10px; }

.gridwrap { position: relative; }
.grid {
  display: grid; grid-template-columns: 22px repeat(60, minmax(0, 1fr));
  gap: 3px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.grid .h { display: flex; align-items: center; justify-content: flex-end; padding-right: 5px; white-space: nowrap; }
.grid .mlabel { height: 14px; white-space: nowrap; overflow: visible; }
.grid .c { height: 13px; background: var(--empty); border-radius: var(--r-xs); cursor: pointer; padding: 0; min-width: 0; transition: none; }
.grid .c:active { transform: none; }
.grid .c.now { box-shadow: inset 0 0 0 1.5px var(--muted); }
.grid .c.sel { outline: 2px solid var(--text); outline-offset: 1px; position: relative; z-index: 1; }

/* Dar ekran (telefon dikey/yatay, tablet): kutular sabit ve dokunulabilir, tablo yana kayar,
   saat sütunu solda sabit kalır */
@media (max-width: 960px) {
  .scrollhint { display: block; }
  .gridwrap {
    overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; padding: 3px 0 8px;
  }
  .grid { grid-template-columns: 30px repeat(60, 18px); gap: 3px; font-size: 11px; width: max-content; }
  .grid .c { height: 18px; }
  .grid .mlabel { height: 16px; }
  .grid .h, .grid .corner {
    position: sticky; left: 0; z-index: 2; background: var(--card);
    color: var(--text); font-weight: 600; padding-right: 7px;
  }
}

.cellinfo { min-height: 1.4em; margin: 14px 0 0; }
.cellinfo.active { color: var(--text); }
.cellinfo .dot { margin-left: 2px; }
.who-item { display: inline-flex; align-items: center; gap: 4px; }
.unpaint {
  width: 26px; height: 26px; padding: 0; margin-left: 2px; display: inline-grid; place-items: center;
  font-size: 17px; line-height: 1; font-weight: 500; color: var(--danger); border-radius: var(--r-xs);
}

/* Günün kayıtları */
.log, .days, .legend { list-style: none; margin: 0; padding: 0; }
/* Kompakt: kayıtlar ve renkler yan yana (dar ekranda alt alta), kayıtlar sayfalı */
.pair { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; align-items: start; }
@media (max-width: 760px) { .pair { grid-template-columns: 1fr; } }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; min-height: 32px; }
.cardhead h2 { margin: 0; }
.pager { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.pager .ghost { width: 32px; height: 32px; padding: 0; font-size: 18px; line-height: 1; }
.log { display: flex; flex-direction: column; }
.log li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log li.empty { padding: 6px 0; }
.log .row {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left;
  background: transparent; color: var(--text); font-weight: 400; padding: 7px 6px; border-radius: var(--r-xs); font-size: 14px;
}
.log .row:hover { background: var(--fill); }
.log .time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3.2em; }
.log .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .me .name { font-weight: 650; }
.log .del { padding: 6px 12px; font-size: 13px; flex: none; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend li {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; font-size: 13px;
  background: var(--fill); border-radius: var(--r-sm); corner-shape: squircle;
}
.legend .me { font-weight: 650; }

/* Telefon */
@media (max-width: 520px) {
  .app { gap: 10px; padding-top: 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .card { padding: 16px; }
  .actions { padding: 10px; }
  .fields { grid-template-columns: 1fr; }
  .btns button { flex: 1; }
}

/* Yatay telefon: ekran kısa, üst kısmı sıkılaştır */
/* Telefon: "Şimdi işedim" ekranın altında sabit, büyük ve başparmakla kolay basılır.
   Sayfanın altına buton kadar boşluk bırakılır; en alta kaydırınca hiçbir şeyin üstünü kapatmaz. */
@media (max-width: 700px), (pointer: coarse) and (max-height: 500px) {
  .actions {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    padding: 10px max(12px, env(safe-area-inset-right)) max(24px, calc(env(safe-area-inset-bottom) + 12px)) max(12px, env(safe-area-inset-left));
    background: transparent; border: 0; border-radius: 0; box-shadow: none; gap: 8px;
    pointer-events: none;
  }
  .actions > * { pointer-events: auto; }
  .actions .big:hover:not(:disabled) { background: var(--glass-bg-hover); }
  .actions { align-items: center; }
  .big {
    /* iPhone tarzı buzlu cam: yarı saydam, arkasını bulanıklaştırır */
    width: min(260px, 100%); min-height: 62px; font-size: 19px; border-radius: 999px; corner-shape: round;
    background: var(--glass-bg); color: var(--glass-text); font-weight: 700;
    -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-float), inset 0 1px 0 var(--glass-shine);
  }
  /* Mesaj butonun üstünde kısa süre görünen bir baloncuk */
  .actions .msg {
    order: -1; align-self: center; margin: 0; padding: 8px 14px; border-radius: var(--r-md);
    background: var(--card); border: var(--border); box-shadow: var(--shadow-float); font-weight: 600;
  }
  .app:has(#actions:not([hidden])) { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
}

@media (orientation: landscape) and (max-height: 500px) {
  .app { gap: 10px; padding-top: 8px; }
  .card { padding: 14px; }
  .big { padding: 13px 16px; font-size: 18px; min-height: 56px; }
  .login { place-items: start center; }
  .login-card { gap: 10px; padding: 18px 20px; }
  .logo { display: none; }
}

/* Onay penceresi */
body.modal-open { overflow: hidden; }
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: fade .15s ease-out;
}
.modal-card {
  width: 100%; max-width: 360px; max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--card); border-radius: var(--r-lg); padding: 26px 20px 20px;
  text-align: center; box-shadow: var(--shadow-pop); animation: pop .18s ease-out;
}
.modal-card h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 10px; }
.modal-card p { margin: 0 0 22px; font-size: 15px; line-height: 1.5; color: var(--muted); }
.modal-card .dontask {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: -6px 0 18px; font-size: 14px; color: var(--muted); cursor: pointer;
}
.modal-btns { display: flex; gap: 8px; }
.modal-btns button { flex: 1; padding: 14px 16px; font-size: 16px; }
button.danger-fill, :where(button.danger-fill):hover:not(:disabled) { background: var(--danger); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@media (prefers-reduced-motion: reduce) { .modal, .modal-card { animation: none; } }

/* Tam ekran engelleyici ekranlar: zorunlu güncelleme ve internet yok */
.gate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: var(--bg); overflow-y: auto;
  padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.gate-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.gate-card h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 0; }
.gate-card p { margin: 0; }
.gate-card .ver { font-size: 15px; }
.gate-card .notes {
  text-align: left; background: var(--card); border: var(--border); border-radius: var(--r-md); padding: 14px 16px;
  max-height: 40vh; overflow-y: auto; corner-shape: squircle;
}
.gate-card .notes h3 { margin: 0 0 8px; }
.gate-card .notes ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.gate-card button { padding: 15px; font-size: 17px; margin-top: 4px; }
.gate-icon { margin: 0 auto; color: var(--muted); }
#offlineGate { z-index: 110; }
