:root {
  --bg: #0a0e16;
  --surface: #131b2b;
  --surface-2: #0e1521;
  --border: #202b3d;
  --border-strong: #2c3a52;
  --text: #eef2f7;
  --muted: #9fb0c3;
  --faint: #647488;
  --accent: #0891b2;
  --accent-2: #22d3ee;
  --accent-hover: #06b6d4;
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.13);
  --off: #94a3b8;
  --off-bg: rgba(148, 163, 184, 0.12);
  --err: #f87171;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }

/* App bar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 22, 35, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: -0.01em;
}
.logo {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 13px;
}
.brand-tag { color: var(--faint); font-weight: 400; font-size: 12.5px; margin-left: 2px; }
.env-pill {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
}

/* Wrap */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 28px 56px;
  display: grid;
  gap: 18px;
}

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  font-weight: 600;
}
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-actions { display: flex; align-items: center; gap: 8px; }

/* Form */
form.form-grid { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.col-full { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.opt { color: var(--faint); font-weight: 400; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: #54637a; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.25); }
.form-actions { flex-direction: row; align-items: center; gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.btn-primary,
.btn-danger,
.btn-ghost,
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 0 18px;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 0;
  padding: 0 18px;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  padding: 0 14px;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-2); }
.btn-primary:active,
.btn-danger:active,
.btn-ghost:active,
.link-btn:active { transform: translateY(1px); }
.msg { font-size: 12.5px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }
body[data-role="user"] .admin-only { display: none !important; }
.danger-note {
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.09);
  color: #fecaca;
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 12.5px;
}

/* Table */
.table-wrap { overflow-x: auto; }
.table-wrap.compact th, .table-wrap.compact td { padding: 9px 10px; font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  font-weight: 600;
  background: var(--surface-2);
}
th:nth-child(3), td:nth-child(3) { text-align: center; }
.ta-right { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
td a { color: var(--accent-2); text-decoration: none; font-family: var(--mono); font-size: 12.5px; }
td a:hover { text-decoration: underline; }
td.target {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
td.actions { text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--faint); padding: 34px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.on { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: var(--off-bg); color: var(--off); }
.badge.profile { background: rgba(34, 211, 238, 0.1); color: var(--accent-2); font-family: var(--mono); }
.link-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  margin-left: 6px;
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}
.link-btn:hover { border-color: var(--accent); color: var(--accent-2); }
.limit-input { max-width: 92px; padding: 7px 9px; font-size: 12px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.66);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 84px 20px;
  z-index: 50;
}
.modal-overlay.confirm-overlay {
  z-index: 70;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 120px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.15s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 6px;
  line-height: 1;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.modal-actions .msg { margin-right: auto; }
.script-modal { max-width: 720px; }
.confirm-modal { max-width: 420px; }
.settings-modal { max-width: 640px; }
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.script-output {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  outline: none;
  white-space: pre;
}
.script-output:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.25);
}

/* Loader monitoring */
.monitor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.65fr) minmax(0, 1.35fr);
  gap: 0;
}
.monitor-panel {
  padding: 16px 20px 18px;
  border-right: 1px solid var(--border);
}
.monitor-panel:last-child { border-right: 0; }
.monitor-panel h3 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.reason-list { display: grid; gap: 8px; }
.reason-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.reason-name {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reason-count { color: var(--text); font-weight: 700; font-size: 12px; }
.decision-pill {
  display: inline-block;
  min-width: 64px;
  text-align: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
}
.decision-pill.redirect { background: var(--ok-bg); color: var(--ok); }
.decision-pill.stay { background: var(--off-bg); color: var(--off); }
.test-result {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}
.confirm-text {
  color: var(--text);
  font-size: 14px;
}

/* App bar actions + hamburger menü */
.appbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 9px;
  cursor: pointer;
  transition: 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-2); }
.menu { position: relative; }
.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 40;
  animation: modal-in 0.12s ease-out;
}
.menu-dropdown[hidden] { display: none; }
.menu-user {
  padding: 8px 10px 9px;
  font-size: 12px;
  color: var(--faint);
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
  word-break: break-all;
}
.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  min-height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: #fca5a5; }
.menu-item.danger:hover { background: rgba(248, 113, 113, 0.1); }

/* Giriş sayfası */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(34, 211, 238, 0.14), transparent 34%),
    linear-gradient(180deg, #0a0e16 0%, #0d1420 100%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: rgba(19, 27, 43, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}
.login-brand {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 22px;
  font-weight: 760;
  letter-spacing: 0;
}
.login-btn { width: 100%; margin-top: 6px; min-height: 40px; }

.modal.locked .modal-close,
.modal.locked #pw-cancel { display: none; }

@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .monitor-grid { grid-template-columns: 1fr; }
  .monitor-panel { border-right: 0; border-bottom: 1px solid var(--border); }
  .monitor-panel:last-child { border-bottom: 0; }
  .modal-overlay { padding: 60px 16px; }
  .appbar-inner { padding: 0 16px; }
  .wrap { padding: 20px 16px 48px; }
  th, td { padding: 11px 12px; }
}
@media (max-width: 420px) {
  .btn-primary { padding: 9px 13px; font-size: 13px; }
  .brand { font-size: 14.5px; }
}
