:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8b93a3;
  --accent: #4c8dff;
  --ok: #2fbf71;
  --off: #6b7280;
  --err: #ff5c5c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.ghost:hover { background: var(--panel-2); }

input {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.4em; margin: 0; }

/* ---------- giriş ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p.muted { margin: 0 0 10px; }

/* ---------- üst çubuk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; }
.stats { color: var(--muted); }
#search { margin-left: auto; width: 220px; }
.conn { color: var(--err); font-size: 13px; }
.conn.ok { color: var(--ok); }
.conn.ok::before { content: "● "; }

main { padding: 20px; }

.empty {
  max-width: 520px; margin: 80px auto; text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line); border-radius: 12px; padding: 32px;
}

/* ---------- ekran ızgarası ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.tile {
  display: flex; flex-direction: column;
  padding: 0; text-align: left;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile:focus-visible { outline: 2px solid var(--accent); }

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  display: grid; place-items: center;
}
.screen img { width: 100%; height: 100%; object-fit: contain; display: none; }
.tile.has-frame .screen img { display: block; }
.tile.has-frame .placeholder { display: none; }
.placeholder { color: var(--muted); font-size: 13px; }

.tile.offline .screen img { filter: grayscale(1) brightness(.45); }
.tile.offline.has-frame .placeholder {
  display: block; position: absolute; color: #fff;
  background: rgba(0,0,0,.6); padding: 4px 10px; border-radius: 6px;
}

.tile-info { display: flex; align-items: center; gap: 8px; padding: 10px 12px; min-width: 0; }
.tile-info .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-info .host { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.tile.offline .dot { background: var(--off); }

/* ---------- büyük görüntüleyici ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  background: rgba(5, 6, 9, .96);
}
.viewer[hidden] { display: none; }
.viewer-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.viewer-bar .spacer { flex: 1; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
