/* ------------------------------------------------------------------ */
/* Tasarım sistemi                                                     */
/* ------------------------------------------------------------------ */
:root {
  color-scheme: dark;
  --bg: #070c13;
  --bg-soft: #0b1320;
  --surface: #0f1926;
  --surface-2: #142130;
  --surface-3: #1b2b3d;
  --line: #23364b;
  --line-strong: #35516c;
  --text: #eef5fd;
  --muted: #95a9bf;
  --faint: #6d839a;
  --primary: #38bdf8;
  --primary-2: #0ea5e9;
  --on-primary: #04121d;
  --live: #34d399;
  --live-2: #10b981;
  --warn: #fbbf24;
  --danger: #fb7185;
  --danger-2: #f43f5e;
  --glass: rgba(5, 12, 20, .68);
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius: 13px;
  --radius-sm: 10px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .30);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f1f5fa;
    --bg-soft: #e8eef7;
    --surface: #ffffff;
    --surface-2: #f6f9fd;
    --surface-3: #eaf1fa;
    --line: #d8e2ef;
    --line-strong: #b9cbe0;
    --text: #102033;
    --muted: #5b7189;
    --faint: #73879c;
    --primary: #0284c7;
    --primary-2: #0369a1;
    --on-primary: #ffffff;
    --live: #059669;
    --live-2: #047857;
    --warn: #b45309;
    --danger: #dc2626;
    --danger-2: #b91c1c;
    --glass: rgba(255, 255, 255, .78);
    --shadow: 0 20px 55px rgba(26, 48, 74, .14);
    --shadow-soft: 0 8px 24px rgba(26, 48, 74, .10);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(950px 520px at 8% -12%, rgba(56, 189, 248, .13), transparent 62%),
    radial-gradient(760px 460px at 100% 0%, rgba(52, 211, 153, .07), transparent 58%),
    var(--bg);
  background-attachment: fixed;
}
body.no-scroll { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 680; letter-spacing: -.02em; }
h1 { font-size: clamp(1.55rem, 2.6vw, 2.15rem); line-height: 1.15; }
h2 { font-size: 1.04rem; line-height: 1.25; }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mono { font-family: var(--mono); font-size: .82rem; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.12em;
  height: 1.12em;
  display: inline-block;
  flex: none;
  vertical-align: -.16em;
  pointer-events: none;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 9px 13px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  transform: translateY(-150%);
  transition: transform .18s ease;
}
.skip-link:focus { transform: translateY(0); }

/* ------------------------------------------------------------------ */
/* Üst çubuk                                                           */
/* ------------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(14px, 2.5vw, 28px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(130%);
}
.topbar-main { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 13px;
  color: var(--on-primary);
  background: linear-gradient(145deg, var(--primary), var(--live));
  box-shadow: 0 8px 24px rgba(56, 189, 248, .22);
}
.brand-mark .icon { width: 21px; height: 21px; }
.brand-copy { display: grid; min-width: 0; line-height: 1.2; }
.brand-copy strong {
  font-size: 1rem;
  letter-spacing: -.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 32vw;
}
.brand-copy small { color: var(--muted); font-size: .76rem; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 560;
  white-space: nowrap;
}
.status-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--faint);
}
.status-chip.ok { color: var(--text); border-color: color-mix(in srgb, var(--live) 40%, var(--line)); }
.status-chip.ok .status-dot { background: var(--live); box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 15%, transparent); }
.status-chip.err { color: var(--text); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.status-chip.err .status-dot { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent); }

.main-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 620;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.nav-btn:hover { color: var(--text); background: color-mix(in srgb, var(--surface-3) 65%, transparent); }
.nav-btn.is-active { color: var(--text); background: var(--surface-3); box-shadow: 0 1px 0 rgba(255, 255, 255, .04); }
.top-actions { display: flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------------ */
/* Ana yerleşim                                                        */
/* ------------------------------------------------------------------ */
.app-main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2.2vw, 26px);
}
.view { min-width: 0; }
.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 376px;
  gap: 18px;
  align-items: start;
}
.side { display: grid; gap: 14px; align-content: start; min-width: 0; }

.card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 42%),
    var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 17px;
}

/* ------------------------------------------------------------------ */
/* Video                                                               */
/* ------------------------------------------------------------------ */
.video-card { padding: 10px; display: flex; flex-direction: column; gap: 9px; }
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid #000;
  border-radius: calc(var(--radius-xl) - 8px);
  background: #02060a;
}
.stream-zoom {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transition: transform .22s ease;
  will-change: transform;
}
#stream {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  user-select: none;
  -webkit-user-drag: none;
}
.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .56), transparent 23%, transparent 70%, rgba(0, 0, 0, .42));
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 29px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: var(--glass);
  color: #f7fbff;
  font-size: .76rem;
  font-weight: 620;
  letter-spacing: .015em;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.live-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}
.live-badge.live .dot { background: var(--live); animation: live-pulse 1.9s ease-out infinite; }
.live-badge.err .dot { background: var(--danger); }
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .42); }
  55% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
}
.video-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  pointer-events: auto;
}
.video-actions .btn {
  min-height: 34px;
  padding: 6px 9px;
  border-color: rgba(255, 255, 255, .16);
  background: var(--glass);
  color: #f8fbff;
  backdrop-filter: blur(8px);
}
.video-actions .btn:hover { border-color: rgba(255, 255, 255, .38); }
.video-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 22px;
  text-align: center;
  background: rgba(3, 8, 13, .86);
  color: #dcebf8;
}
.video-empty strong { font-size: 1.04rem; }
.video-empty span { font-size: .86rem; color: #a9c0d5; }
.video-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px;
  color: var(--muted);
  font-size: .78rem;
}
.foot-item { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.foot-item .icon { opacity: .8; }

/* ------------------------------------------------------------------ */
/* Kart başlıkları / PTZ                                               */
/* ------------------------------------------------------------------ */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}
.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: .68rem;
  font-weight: 760;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.card-head h2 { font-size: .99rem; }
.mini-badge {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .67rem;
  font-weight: 650;
  white-space: nowrap;
}
.control-card { padding-bottom: 15px; }
.ptz-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 258px);
  margin: 0 auto;
}
.ptz-btn {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 50px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .05), transparent),
    var(--surface-2);
  color: var(--text);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background .14s ease, border-color .14s ease, transform .08s ease, color .14s ease;
}
.ptz-btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.ptz-btn:active,
.ptz-btn.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
  transform: translateY(1px);
}
.ptz-btn:disabled { opacity: .42; cursor: not-allowed; }
.ptz-btn .icon { width: 21px; height: 21px; }
.ptz-center {
  border-radius: 50%;
  border-color: var(--line-strong);
  background: var(--surface-3);
}
.ptz-center .icon { width: 24px; height: 24px; }
.ptz-left { transform: rotate(-90deg); }
.ptz-right { transform: rotate(90deg); }
.ptz-down { transform: rotate(180deg); }
.ptz-ul { transform: rotate(-45deg); }
.ptz-ur { transform: rotate(45deg); }
.ptz-dl { transform: rotate(-135deg); }
.ptz-dr { transform: rotate(135deg); }
.ptz-help {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: .77rem;
  text-align: center;
}
.zoom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.zoom-head .eyebrow { margin: 0; }
.zoom-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 650;
}
.zoom-row { display: flex; gap: 7px; margin-top: 8px; }
.zoom-row .btn { flex: 1; }
.btn-zoom-reset { flex: 1.2 !important; font-family: var(--mono); font-size: .78rem; }

/* ------------------------------------------------------------------ */
/* Durum / bilgi kartları                                              */
/* ------------------------------------------------------------------ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px 14px;
  margin: 11px 0 0;
}
.stat-grid > div { min-width: 0; }
.stat-grid dt {
  color: var(--faint);
  font-size: .66rem;
  font-weight: 720;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.stat-grid dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: .87rem;
  font-weight: 570;
}
.stat-grid.compact { gap: 10px 12px; }
.stat-grid.compact dd { font-size: .84rem; }
.stat-grid.device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#st-note { margin-top: 11px; }
.insight-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 9%, transparent), transparent 60%),
    var(--surface);
}
.insight-card strong { display: block; margin-bottom: 2px; font-size: .86rem; }
.insight-card p { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.icon-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--line));
  border-radius: 11px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.icon-badge .icon { width: 19px; height: 19px; }

/* ------------------------------------------------------------------ */
/* Düğmeler                                                            */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: .84rem;
  font-weight: 610;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .08s ease;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.btn:focus-visible,
.nav-btn:focus-visible,
.ptz-btn:focus-visible,
.settings-tab:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn-primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: var(--on-primary);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 20%, transparent);
}
.btn-primary:hover { border-color: transparent; background: linear-gradient(180deg, #67d4fb, var(--primary)); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
}
.btn-danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 20%, var(--surface)); }
.btn-glass {
  border-color: rgba(255, 255, 255, .16);
  background: var(--glass);
  color: #f8fbff;
  backdrop-filter: blur(8px);
}
.btn-sm { min-height: 31px; padding: 5px 8px; font-size: .77rem; border-radius: 8px; }
.btn-square { width: 40px; min-width: 40px; height: 40px; padding: 0; flex: none; }
.btn-square .icon { width: 18px; height: 18px; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.divider { height: 1px; margin: 15px 0; background: var(--line); }

/* ------------------------------------------------------------------ */
/* Formlar                                                             */
/* ------------------------------------------------------------------ */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 560;
}
.field > span b { color: var(--text); font-weight: 680; }
input[type="text"],
input[type="password"],
input:not([type]),
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
input[type="text"]:focus,
input[type="password"]:focus,
input:not([type]):focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
input::placeholder { color: var(--faint); }
input[type="range"] {
  width: 100%;
  min-height: 28px;
  accent-color: var(--primary);
  cursor: pointer;
}
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.check,
.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: .86rem;
  cursor: pointer;
}
.check input,
.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}
.field-wide { grid-column: 1 / -1; }
.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}
.inline-form .field { flex: 1 1 220px; }
.hint { margin-top: 12px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--text);
  font-size: .81rem;
  line-height: 1.45;
}
.alert .icon { margin-top: 1px; color: var(--danger); }
.alert-warn {
  border-color: color-mix(in srgb, var(--warn) 42%, var(--line));
  background: color-mix(in srgb, var(--warn) 8%, var(--surface));
}
.alert-warn .icon { color: var(--warn); }

/* ------------------------------------------------------------------ */
/* Ayarlar                                                             */
/* ------------------------------------------------------------------ */
.settings-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 2px 0 18px;
}
.settings-head p { margin-top: 4px; font-size: .86rem; }
.settings-layout {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.settings-nav {
  position: sticky;
  top: 82px;
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.settings-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 610;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.settings-tab:hover { color: var(--text); background: var(--surface-2); }
.settings-tab.is-active {
  border-left-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface-2));
  color: var(--text);
}
.settings-tab .icon { width: 17px; height: 17px; color: var(--faint); }
.settings-tab.is-active .icon { color: var(--primary); }
.settings-panels { display: grid; gap: 15px; min-width: 0; }
.settings-panel { display: grid; gap: 15px; min-width: 0; }
.panel-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.frame-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 17px 13px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent),
    var(--surface-2);
}
.frame-head h2 { font-size: 1rem; }
.frame-head p { margin-top: 3px; color: var(--muted); font-size: .79rem; line-height: 1.45; }
.frame-body { padding: 16px 17px; }
.frame-body > .field + .field { margin-top: 12px; }
.time-panel .frame-body { display: grid; gap: 2px; }
.time-hero {
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.time-label { color: var(--faint); font-size: .68rem; font-weight: 720; letter-spacing: .09em; text-transform: uppercase; }
.time-hero strong { font-family: var(--mono); font-size: clamp(1.25rem, 2.6vw, 1.75rem); letter-spacing: -.03em; }
.time-hero > .muted { font-size: .78rem; }
.maintenance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.maintenance-row + .maintenance-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.maintenance-row > div { min-width: 0; }
.maintenance-row strong { display: block; font-size: .89rem; }
.maintenance-row p { margin-top: 3px; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.maintenance-row .btn { flex: none; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86em;
  color: var(--text);
}
input:disabled, select:disabled, button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.is-disabled { opacity: .55; }
.check-list { display: grid; gap: 2px; margin-bottom: 12px; }
.check-list .check-row { padding: 7px 0; }
.pt-grid { margin-top: 4px; }
.pt-grid .field > span b { font-variant-numeric: tabular-nums; }
.compact-row { margin-top: 0; justify-content: flex-end; }
.backup-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 8px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.backup-head strong { font-size: .84rem; }
.backup-list { display: grid; gap: 6px; }
.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.backup-row > div { display: grid; gap: 2px; min-width: 0; }
.backup-row strong { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.backup-row small { font-size: .69rem; overflow: hidden; text-overflow: ellipsis; }
.backup-row .btn { flex: none; }
.upload-box {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.upload-box strong { font-size: .84rem; }
.upload-box p { margin-top: 3px; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.upload-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 8px;
  align-items: center;
}
.upload-controls input[type="file"] { min-width: 0; font-size: .74rem; }
.upload-controls input[type="file"]::file-selector-button { margin-right: 8px; }
.log-view {
  margin: 0;
  min-height: 180px;
  max-height: 55vh;
  overflow: auto;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .22);
  color: var(--text);
  font: .73rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ */
/* Alt bilgi / bildirim / diyalog                                      */
/* ------------------------------------------------------------------ */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 0 clamp(14px, 2.2vw, 26px) 22px;
  color: var(--muted);
  font-size: .74rem;
}
.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: 22px;
  max-width: min(500px, calc(100% - 28px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: .84rem;
  transform: translateX(-50%);
}
.toast.ok { border-color: color-mix(in srgb, var(--live) 52%, var(--line)); }
.toast.err { border-color: color-mix(in srgb, var(--danger) 58%, var(--line)); }
.dialog {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(2, 7, 12, .70); backdrop-filter: blur(4px); }
.dialog-body { display: grid; gap: 9px; padding: 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { font-size: 1.05rem; }
.dialog-text { color: var(--muted); font-size: .86rem; line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 7px; }

/* ------------------------------------------------------------------ */
/* Giriş sayfası                                                       */
/* ------------------------------------------------------------------ */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  display: grid;
  justify-items: start;
  gap: 7px;
  width: min(390px, 100%);
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 50%),
    var(--surface);
  box-shadow: var(--shadow);
}
.login-card .brand-mark { margin-bottom: 8px; }
.login-card h1 { font-size: 1.4rem; }
.login-card > .muted { margin-bottom: 8px; font-size: .84rem; }
.login-form { display: grid; gap: 12px; width: 100%; margin-top: 5px; }
.login-form label { display: grid; gap: 6px; }
.login-form label span { color: var(--muted); font-size: .79rem; }
.login-note { margin-top: 12px; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ */
/* Tam ekran                                                           */
/* ------------------------------------------------------------------ */
.video-wrap:fullscreen {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: #000;
}
.video-wrap:fullscreen .video-overlay { padding: clamp(12px, 2vw, 24px); }
body.pseudo-fullscreen { overflow: hidden; }
body.pseudo-fullscreen .video-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100vw;
  height: 100dvh;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: #000;
}
body.pseudo-fullscreen .video-wrap .video-overlay { padding: clamp(12px, 2vw, 24px); }

/* ------------------------------------------------------------------ */
/* Duyarlı yerleşim                                                     */
/* ------------------------------------------------------------------ */
@media (max-width: 1160px) {
  .live-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: 15px; }
  .settings-layout { grid-template-columns: 196px minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .live-layout { grid-template-columns: 1fr; }
  .side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-card { grid-row: span 2; }
  .insight-card { grid-column: 1 / -1; }
  .settings-layout { grid-template-columns: 1fr; gap: 13px; }
  .settings-nav {
    position: static;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 5px;
    scrollbar-width: thin;
  }
  .settings-tab {
    flex: 0 0 auto;
    width: auto;
    min-height: 37px;
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: 8px;
  }
  .settings-tab.is-active { border-left-color: transparent; border-bottom-color: var(--primary); }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 9px; padding: 10px 12px; }
  .topbar-main { flex: 1 1 100%; }
  .main-nav { order: 3; flex: 1 1 auto; justify-content: center; }
  .nav-btn { flex: 1; justify-content: center; }
  .top-actions { margin-left: auto; }
  .brand-copy strong { max-width: 44vw; }
  .app-main { padding: 12px; }
  .side { grid-template-columns: 1fr; }
  .control-card { grid-row: auto; }
  .insight-card { grid-column: auto; }
  .video-card { padding: 8px; }
  .video-overlay { flex-direction: column; gap: 8px; }
  .video-actions { justify-content: flex-start; }
  .video-actions .btn { min-height: 33px; }
  .video-foot { font-size: .73rem; }
  .video-foot #video-hint { display: none; }
  .settings-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .frame-head { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .maintenance-row { align-items: flex-start; flex-direction: column; gap: 9px; }
  .maintenance-row .btn { width: 100%; }
  .upload-controls { grid-template-columns: 1fr; }
  .upload-controls .btn { width: 100%; }
  .backup-row { align-items: flex-start; flex-direction: column; }
  .backup-row .btn { width: 100%; }
  .compact-row { width: 100%; justify-content: flex-start; }
  .footer { padding: 0 12px 18px; }
  .brand-copy small { display: none; }
}
@media (max-width: 480px) {
  body { font-size: 14px; }
  .status-chip { padding: 4px 8px; font-size: .73rem; }
  .top-actions .btn { min-height: 33px; padding: 5px 7px; }
  .top-actions .btn-label { display: none; }
  .top-actions .btn .icon { width: 18px; height: 18px; }
  .video-actions { gap: 4px; }
  .video-actions .btn { padding: 5px 7px; font-size: .72rem; }
  .video-actions .btn .icon { width: 15px; height: 15px; }
  .video-actions .btn-label { display: none; }
  .video-actions .btn[aria-label] { min-width: 34px; }
  .stat-grid.device-grid { grid-template-columns: 1fr; }
  .stat-grid { gap: 9px 10px; }
  .ptz-pad { gap: 7px; }
  .ptz-btn { min-height: 46px; }
  .zoom-row .btn { min-height: 36px; }
  .frame-head, .frame-body { padding: 13px; }
  .card { padding: 13px; }
  .video-card { padding: 7px; }
  .settings-head h1 { font-size: 1.45rem; }
  .dialog { width: calc(100% - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
