:root {
  --bg: #111319;
  --surface: #1a1d25;
  --surface-2: #232733;
  --line: #2c313e;
  --text: #eef0f4;
  --muted: #9aa1b1;
  --red: #e5383b;
  --red-soft: rgba(229, 56, 59, 0.14);
  --green: #3ccf7a;
  --amber: #f0a43a;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; flex: none; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.good { color: var(--green); margin: 0 0 6px; }
.err { color: #ff7b7d; min-height: 1.4em; margin: 10px 0 0; }

.boot { display: grid; place-items: center; min-height: 100dvh; }
.boot img { width: 72px; height: 72px; border-radius: 18px; opacity: .85; }

/* ----- üst çubuk ----- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; min-height: 56px;
  background: rgba(17, 19, 25, 0.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-logo { width: 8px; }
.bar-actions { display: flex; gap: 4px; }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px;
  border: 0; border-radius: 12px; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

.page { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; display: grid; gap: 14px; }
.section { font-size: 15px; font-weight: 600; color: var(--muted); margin: 10px 2px -4px; text-transform: uppercase; letter-spacing: .04em; }

/* ----- alarm anahtarı ----- */
.arm {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 18px; border-radius: var(--radius); cursor: pointer; text-align: left;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  transition: background .2s, border-color .2s;
}
.arm:disabled { cursor: default; opacity: .7; }
.arm.on { background: linear-gradient(135deg, rgba(229,56,59,.22), rgba(229,56,59,.08)); border-color: rgba(229,56,59,.55); }
.arm-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); }
.arm-icon svg { width: 28px; height: 28px; }
.arm.on .arm-icon { background: var(--red); color: #fff; }
.arm-text { flex: 1; display: grid; gap: 2px; }
.arm-text strong { font-size: 19px; }
.arm-text small { color: var(--muted); font-size: 13.5px; }
.switch { width: 50px; height: 30px; border-radius: 99px; background: #3a3f4c; position: relative; flex: none; transition: background .2s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.arm.on .switch { background: var(--red); }
.arm.on .switch span { transform: translateX(20px); }

.cam { display: flex; align-items: center; gap: 10px; padding: 0 4px; font-size: 14px; color: var(--muted); }
.cam i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.cam.ok i { background: var(--green); box-shadow: 0 0 0 4px rgba(60,207,122,.15); }
.cam.bad { color: var(--amber); }
.cam.bad i { background: var(--amber); }

/* ----- duyuru kutusu ----- */
.notice {
  display: flex; gap: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--red-soft); border: 1px solid rgba(229,56,59,.4);
}
.notice.warn { background: rgba(240,164,58,.1); border-color: rgba(240,164,58,.4); }
.notice > svg { color: var(--red); margin-top: 2px; }
.notice.warn > svg { color: var(--amber); }
.notice p { margin: 4px 0 0; font-size: 14px; color: #d4d7de; }
.notice .btn { margin-top: 10px; }

/* ----- kutucuklar ----- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  font-weight: 600;
}
.tile svg { width: 26px; height: 26px; color: var(--red); }
.tile:active { background: var(--surface-2); }

/* ----- olay listesi ----- */
.events { display: grid; gap: 8px; }
.event {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.event:active { background: var(--surface-2); }
.event img, .event .ph { width: 84px; height: 56px; border-radius: 9px; object-fit: cover; background: var(--surface-2); flex: none; }
.event .ph { display: grid; place-items: center; color: var(--muted); }
.ev-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.ev-text strong { font-size: 15px; font-weight: 600; }
.ev-text small { color: var(--muted); font-size: 13px; }
.ev-text small.alarm { color: #ff8f91; }
.event > svg { color: var(--muted); }
.empty { text-align: center; padding: 24px 0; }

/* ----- görüntüleyici ----- */
.viewer { display: grid; place-items: center; min-height: calc(100dvh - 120px); background: #000; position: relative; }
.viewer img, .viewer video { width: 100%; max-height: calc(100dvh - 120px); object-fit: contain; background: #000; }
.viewer #msg { position: absolute; inset: auto 16px 50% 16px; text-align: center; transform: translateY(50%); }
.caption { text-align: center; margin: 12px; color: var(--muted); }

/* ----- kartlar, düğmeler, form ----- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { font-size: 17px; margin-bottom: 10px; }
.card p { margin: 0 0 8px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.tips ul { margin: 0; padding-left: 18px; color: #d4d7de; font-size: 14px; display: grid; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger { color: #ff8f91; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

.login { max-width: 380px; margin: 0 auto; padding: 12vh 20px 40px; text-align: center; }
.login .logo { width: 84px; height: 84px; border-radius: 22px; }
.login h1 { font-size: 26px; margin: 14px 0 24px; }
.login form { text-align: left; display: grid; gap: 10px; }
.login label { font-size: 14px; color: var(--muted); }
input[type=password] {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px;
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
}
input:focus-visible, .btn:focus-visible, .arm:focus-visible, .tile:focus-visible, .event:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px;
}

/* ----- bildirim balonu ----- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; z-index: 20;
  background: #2b3040; color: var(--text); box-shadow: 0 8px 30px rgba(0,0,0,.45); font-weight: 600;
}
#toast.ok { background: #1f5f3a; }
#toast.err { background: #8d2124; }
