:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --green: #059669;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-green { color: var(--green); }
.text-muted { color: var(--muted); }

/* Toast */
#toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
  max-width: 380px;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

/* Login — Koyu Konsol / Split-Screen Yönetici Tasarımı */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 15% 20%, #1e1b4b 0%, #090d16 55%, #030712 100%);
  padding: 24px;
}
.login-shell {
  width: 100%;
  max-width: 940px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.65);
  background: #0f172a;
}
.login-visual {
  position: relative;
  padding: 44px 40px;
  background: linear-gradient(155deg, #111827 0%, #1e1b4b 58%, #312e81 100%);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.visual-grid-bg {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}
.visual-content { position: relative; z-index: 1; }
.login-badge {
  display: inline-block;
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
  font-weight: 800;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 999px;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}
.login-visual h1 {
  margin: 0 0 14px;
  font-size: 36px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.login-visual h1 span { color: #fbbf24; }
.visual-desc {
  margin: 0 0 26px;
  color: #cbd5e1;
  line-height: 1.65;
  font-size: 14px;
}
.visual-pills { display: flex; flex-direction: column; gap: 10px; }
.v-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}
.visual-footer {
  position: relative;
  z-index: 1;
  margin-top: 28px;
  font-size: 12px;
  color: #94a3b8;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
}
.login-card {
  width: 100%;
  background: #0b1120;
  color: #f8fafc;
  padding: 44px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-card-top { margin-bottom: 24px; }
.lock-emblem {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(99,102,241,0.25));
  border: 1px solid rgba(251, 191, 36, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}
.login-card h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; color: #ffffff; }
.login-card .muted { color: #94a3b8; margin: 0; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card .field label { color: #cbd5e1; }
.login-card input[type="email"],
.login-card input[type="password"] {
  background: #111827;
  border: 1px solid #334155;
  color: #f8fafc;
  padding: 11px 13px;
}
.login-card input:focus {
  outline: none;
  border-color: #fbbf24;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.15);
}
.btn-admin-login {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0b1120;
  font-weight: 800;
  padding: 12px 16px;
  font-size: 14px;
}
.btn-admin-login:hover:not(:disabled) {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}
.login-security-note {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}
@media (max-width: 800px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { padding: 28px 24px; }
  .login-card { padding: 28px 24px; }
}

/* Layout */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.brand-title { font-weight: 800; font-size: 16px; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.nav-menu {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.nav-item {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.admin-name { font-weight: 700; font-size: 13px; }
.admin-email { font-size: 11px; color: #94a3b8; }

.main-content {
  padding: 28px 32px;
  overflow-x: hidden;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-header h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.page-header p { margin: 0; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.stat-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.stat-val { font-size: 28px; font-weight: 800; margin-top: 4px; }

/* Cards & Grid */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.card-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.empty-state { text-align: center; padding: 40px; color: var(--muted); font-weight: 600; }

.tenants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.tenant-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.tenant-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tenant-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tenant-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: #f8fafc;
  padding: 4px;
}
.tenant-logo-fallback {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tenant-name { font-weight: 800; font-size: 15px; }
.tenant-code { font-size: 12px; color: var(--muted); font-family: monospace; }
.badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-passive { background: #f1f5f9; color: #475569; }

.tenant-meta {
  font-size: 12.5px;
  color: #334155;
  display: grid;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.tenant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Forms & Buttons */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 700; color: #334155; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
}
textarea { resize: vertical; }
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.select-input { width: auto; min-width: 220px; font-weight: 700; }

.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.span-2 { grid-column: span 2; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] { width: 46px; height: 38px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 2px; cursor: pointer; }

.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 15px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: #0f172a; }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover:not(:disabled) { background: #fecaca; }
.btn-ghost { background: transparent; color: #64748b; border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; color: #0f172a; }
.sidebar .btn-ghost { color: #cbd5e1; border-color: rgba(255,255,255,0.2); }
.sidebar .btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* Info Banner & Contract */
.info-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  margin-bottom: 16px;
}
.logo-upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-preview {
  height: 48px;
  max-width: 120px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  background: #fff;
}
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}
.radio-card:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.html-upload-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-family: monospace;
  font-weight: 700;
  cursor: pointer;
}
.chip:hover { background: #dbeafe; border-color: var(--primary); color: var(--primary); }

.custom-fields-list { display: flex; flex-direction: column; gap: 10px; }
.custom-field-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1.4fr auto auto;
  gap: 8px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-card {
  background: #fff;
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 800; }
.icon-btn {
  border: 0;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}
.modal-body { padding: 20px 22px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.section-label {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.collapsible {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  background: #f8fafc;
}
.collapsible summary { cursor: pointer; font-weight: 700; font-size: 13px; }
.init-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 12px 14px;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.checkbox-row input { width: auto; }

@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .form-grid-3, .form-grid-2, .mode-switch, .stats-grid { grid-template-columns: 1fr; }
  .custom-field-row { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
