:root {
  --chassis: #1c2025;
  --chassis-deep: #14181c;
  --line: #2f363e;
  --text: #e9e7e0;
  --muted: #8f98a3;

  --plate: #cfd3cb;
  --plate-edge: #a9aea5;
  --plate-ink: #23272c;
  --bay: #101316;
  --bay-line: #262c33;

  --amber: #ffb23e;
  --green: #53d18a;
  --red: #ff5a4d;
  --standby: #7aa2d6;

  --head: "Barlow Semi Condensed", "Bahnschrift", "Arial Narrow", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  background: var(--chassis);
  color: var(--text);
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 2px; }

/* ---------- Üst çubuk ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px clamp(18px, 5vw, 56px);
  background: var(--chassis-deep);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--head); font-weight: 700; font-size: 1.6rem;
  letter-spacing: .02em; text-decoration: none;
}

/* Menü: kutusuz yazı. Bulunduğun bölümün yanında küçük bir LED yanar. */
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 22px; }
nav a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 0; color: var(--muted); text-decoration: none;
  font-family: var(--head); font-weight: 500; font-size: 1.1rem;
  transition: color .15s;
}
nav a::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #333b44; transition: background .2s, box-shadow .2s;
}
nav a:hover { color: var(--text); }
nav a:hover::before { background: #5a6572; }
nav a.active { color: var(--text); }
nav a.active::before { background: var(--amber); box-shadow: 0 0 8px 1px rgba(255, 178, 62, .65); }
nav a.login { margin-left: 8px; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: #4a535e; }
nav a.login:hover { text-decoration-color: var(--amber); }

/* ---------- Yerleşim ---------- */
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 clamp(18px, 5vw, 56px); }

h1, h2 { font-family: var(--head); font-weight: 700; line-height: 1.05; }
h1 { font-size: clamp(2.6rem, 6.4vw, 4.8rem); letter-spacing: -.01em; max-width: 14ch; }
h2 { font-size: 1.7rem; font-weight: 600; }
p { max-width: 62ch; }
p + p { margin-top: 10px; }
.note { color: var(--muted); font-size: .98rem; }

/* ---------- Karşılama ---------- */
.hero { padding: clamp(40px, 8vw, 84px) 0 clamp(36px, 6vw, 64px); }
.hero-copy p { color: #bdbdb4; margin-top: 20px; font-size: 1.15rem; }

/* ---------- Sunucu ön paneli ---------- */
.plate {
  position: relative; margin-top: clamp(32px, 5vw, 52px);
  padding: 16px 18px 20px;
  color: var(--plate-ink);
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.028) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #d8dcd4, var(--plate) 40%, #c3c7bf);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), inset 0 -3px 0 var(--plate-edge), 0 18px 40px rgba(0,0,0,.45);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}
.plate-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 2px 6px 14px;
}
.plate-name { font-family: var(--head); font-weight: 700; font-size: 1.35rem; letter-spacing: .02em; }
.plate-up { font-size: .92rem; color: #4a4f55; text-align: right; }

.trays { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bay {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 26px 14px 14px;
  background: var(--bay); color: var(--text);
  border: 1px solid var(--bay-line); border-radius: 3px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.6);
}
/* Çekmece kolu */
.bay::before {
  content: ""; position: absolute; top: 9px; left: 14px; right: 14px; height: 4px;
  border-radius: 2px; background: linear-gradient(180deg, #4a525b, #2a3037);
}
.bay-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bay-state { font-size: .85rem; color: var(--muted); }
.bay-name { font-family: var(--head); font-weight: 600; font-size: 1.15rem; line-height: 1.2; }
.bay-role { font-size: .9rem; color: var(--muted); }
.bay-size { font-family: var(--mono); font-size: .78rem; color: #b9b9b0; margin-top: 8px; }

.led {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: #333b44; box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
  transition: background .3s, box-shadow .3s;
}
.led.boot    { background: var(--amber); box-shadow: 0 0 10px 2px rgba(255,178,62,.7); }
.led.ok      { background: var(--green); box-shadow: 0 0 9px 1px rgba(83,209,138,.6); animation: breathe 3.6s ease-in-out infinite; }
.led.active  { background: var(--amber); box-shadow: 0 0 10px 2px rgba(255,178,62,.7); animation: blink .35s steps(2) infinite; }
.led.standby { background: var(--standby); box-shadow: 0 0 6px 0 rgba(122,162,214,.5); opacity: .75; }
.led.fail    { background: var(--red); box-shadow: 0 0 10px 2px rgba(255,90,77,.7); }
@keyframes blink { 50% { opacity: .25; } }
@keyframes breathe {
  0%, 100% { opacity: .55; box-shadow: 0 0 4px 0 rgba(83,209,138,.35); }
  50%      { opacity: 1;   box-shadow: 0 0 10px 2px rgba(83,209,138,.7); }
}
/* Disklerin LED'leri aynı anda değil, sırayla ve hafif kaymış nefes alır */
.bay:nth-child(2) .led.ok { animation-delay: -.9s; }
.bay:nth-child(3) .led.ok { animation-delay: -1.8s; }
.bay:nth-child(4) .led.ok { animation-delay: -2.7s; }

/* ---------- Bölümler: başlık solda, içerik sağda ---------- */
.sec {
  display: grid; grid-template-columns: 200px 1fr; gap: 12px 40px;
  padding: 40px 0; border-top: 1px solid var(--line);
}

/* ---------- Bölmeli LED göstergeler ---------- */
.readouts { margin-top: 16px; display: grid; gap: 14px; max-width: 760px; }
.readout { display: grid; grid-template-columns: 110px 1fr 140px; align-items: center; gap: 16px; }
.r-label { color: #bdbdb4; }
.r-value { font-family: var(--mono); font-size: .95rem; text-align: right; }
.segs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.seg { height: 18px; background: #262c33; border-radius: 1px; transition: background .25s, box-shadow .25s; }
.seg.on.g { background: var(--green); box-shadow: 0 0 6px rgba(83,209,138,.35); }
.seg.on.a { background: var(--amber); box-shadow: 0 0 6px rgba(255,178,62,.35); }
.seg.on.r { background: var(--red);   box-shadow: 0 0 6px rgba(255,90,77,.4); }

/* ---------- Araç listesi ---------- */
.list { list-style: none; margin-top: 14px; max-width: 800px; }
.list li {
  display: grid; grid-template-columns: 190px 1fr auto; gap: 6px 20px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list li:first-child { border-top: 1px solid var(--line); }
.item-name { font-family: var(--head); font-weight: 600; font-size: 1.15rem; }
.item-desc { color: #bdbdb4; }
.tag { font-size: .85rem; color: var(--amber); white-space: nowrap; }

.empty {
  margin-top: 16px; max-width: 520px; padding: 26px 20px;
  border: 1px dashed #3a424b; border-radius: 3px; color: var(--muted);
}

.foot {
  margin-top: 24px; padding: 22px clamp(18px, 5vw, 56px) 30px;
  background: var(--chassis-deep); border-top: 1px solid var(--line);
  color: var(--muted); font-size: .92rem;
}

/* ---------- Küçük ekran ---------- */
@media (max-width: 900px) {
  .trays { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .top { flex-direction: column; align-items: flex-start; gap: 6px; }
  .sec { grid-template-columns: 1fr; }
  .readout { grid-template-columns: 1fr auto; }
  .readout .segs { grid-column: 1 / -1; grid-row: 2; }
  .list li { grid-template-columns: 1fr; }
  .tag { margin-top: 2px; }
  .plate-head { flex-direction: column; gap: 2px; }
  .plate-up { text-align: left; }
}
@media (max-width: 420px) {
  .trays { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .led.active, .led.ok { animation: none; }
  .led, .seg, nav a::before { transition: none; }
}

/* ---------- Disk sağlığı tablosu ---------- */
.table-wrap { overflow-x: auto; margin-top: 14px; max-width: 800px; }
.health { width: 100%; border-collapse: collapse; }
.health th {
  text-align: left; font-weight: 500; font-size: .9rem; color: var(--muted);
  padding: 8px 18px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.health td { padding: 12px 18px 12px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.health td.num { font-family: var(--mono); font-size: .9rem; }
.health td.ok { color: var(--green); }
.health td.bad { color: var(--red); }
.health td.warn { color: var(--amber); }
.health td.dim { color: var(--muted); }

/* ---------- UPS bölümü ---------- */
.ups-status { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

/* Pil çubuğunun rengi seviyeye göre değişir (JS .warn ve .low sınıflarını ekler) */
.readout.inv .seg.on { background: var(--green); box-shadow: 0 0 6px rgba(83,209,138,.35); }
.readout.inv.warn .seg.on { background: var(--amber); box-shadow: 0 0 6px rgba(255,178,62,.35); }
.readout.inv.low .seg.on { background: var(--red); box-shadow: 0 0 6px rgba(255,90,77,.4); }

.facts { margin-top: 22px; max-width: 760px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 32px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { font-family: var(--mono); font-size: .92rem; text-align: right; }
@media (max-width: 720px) { .facts { grid-template-columns: 1fr; } }

/* ---------- Giriş formu ---------- */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.login-form { display: grid; gap: 12px; max-width: 420px; margin-top: 14px; }
.login-form label { color: var(--muted); }
.login-form input[type="password"] {
  font-family: var(--mono); font-size: 1rem; padding: 10px 12px; width: 100%;
  background: var(--chassis-deep); color: var(--text);
  border: 1px solid var(--line); border-radius: 3px;
}
.login-form .check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.login-form .check input { width: 16px; height: 16px; accent-color: var(--amber); }

button {
  font-family: var(--head); font-weight: 600; font-size: 1.05rem;
  padding: 10px 20px; border: 1px solid var(--amber); border-radius: 3px;
  background: var(--amber); color: #1a1200; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--text); border-color: #3a424b; }
button.ghost:hover { border-color: var(--amber); filter: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.btn-row form { margin: 0; }
#login-msg:not(:empty) { color: var(--amber); margin-bottom: 8px; }

/* ---------- Yönetici modu teması ---------- */
.brand-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.admin-badge {
  display: none; align-items: center; gap: 8px;
  font-family: var(--head); font-weight: 600; font-size: .95rem;
  color: var(--amber); background: rgba(255,178,62,.09);
  border: 1px solid rgba(255,178,62,.5); border-radius: 3px; padding: 2px 12px;
}
.admin-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 8px 1px rgba(255,178,62,.7);
}

/* Giriş yapılınca zemin sıcak bir tona kayar, üst çubuğun üstüne kehribar bir şerit ve rozet gelir */
:root.is-admin {
  --chassis: #1f1d1a;
  --chassis-deep: #171512;
  --line: #3a352c;
}
:root.is-admin .admin-badge { display: inline-flex; }
:root.is-admin .top {
  box-shadow: inset 0 3px 0 var(--amber);
  border-bottom-color: rgba(255,178,62,.5);
}
:root.is-admin .foot { border-top-color: rgba(255,178,62,.35); }

/* Menü satırı kırılmasın: "Yönetici" gibi uzun bir etiket gelince LED yazıdan ayrılıyordu */
nav a { white-space: nowrap; }
.top { gap: 16px; }
@media (min-width: 721px) {
  nav { flex-wrap: nowrap; }
}

/* ---------- Sadece yöneticiye görünenler ---------- */
.admin-link { display: none; }
:root.is-admin .admin-link { display: inline-flex; }
.admin-only { display: none; }
:root.is-admin .admin-only { display: grid; }

.sec.wide { grid-template-columns: 1fr; }
.frame-wrap iframe {
  display: block; width: 100%; height: 78vh; min-height: 620px;
  border: 1px solid var(--line); border-radius: 3px; background: var(--bay);
}
.frame-note { margin-top: 10px; }
.frame-note a { color: var(--text); text-underline-offset: 4px; }
