:root {
  --green-dark: #1e3a0f;
  --green-mid: #2d5016;
  --green-light: #4a7c1f;
  --green-pale: #e8f0d8;
  --earth: #8b6914;
  --earth-light: #c49a2a;
  --cream: #f5f0e8;
  --cream-dark: #ede5d0;
  --text-dark: #1a2409;
  --text-mid: #3d5220;
}

body { background: var(--cream); font-family: 'Segoe UI', sans-serif; }

.un-navbar {
  background: var(--green-dark);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.un-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.un-brand svg { width: 32px; height: 32px; }

.un-nav-links { display: flex; gap: 8px; align-items: center; }
.un-nav-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.15s;
}
.un-nav-links a:hover { background: rgba(255,255,255,0.12); color: #fff; }

.un-sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--green-dark);
  position: fixed;
  top: 0; left: 0;
  padding-top: 0;
}

.un-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.un-sidebar a {
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}

.un-sidebar a:hover, .un-sidebar a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.un-sidebar a.logout {
  position: absolute;
  bottom: 20px;
  width: 100%;
}

.un-main { margin-left: 220px; padding: 30px; }

.un-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(45,80,22,0.08);
  border: 1px solid var(--cream-dark);
  padding: 1.25rem;
}

.un-stat {
  border-radius: 14px;
  padding: 20px;
  color: #fff;
}

.un-btn-primary {
  background: var(--green-mid);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  display: inline-block;
}
.un-btn-primary:hover { background: var(--green-light); color: #fff; }

.un-btn-outline {
  background: transparent;
  color: var(--green-mid);
  border: 1.5px solid var(--green-mid);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}
.un-btn-outline:hover { background: var(--green-mid); color: #fff; }

.un-badge-online { background: #d4edda; color: #155724; border-radius: 6px; padding: 3px 10px; font-size: 12px; }
.un-badge-offline { background: #f8d7da; color: #721c24; border-radius: 6px; padding: 3px 10px; font-size: 12px; }
.un-badge-power { background: #fff3cd; color: #856404; border-radius: 6px; padding: 3px 10px; font-size: 12px; }

.un-alarm { background: #fffbf0; border-left: 3px solid var(--earth); border-radius: 0 8px 8px 0; padding: 10px 12px; margin-bottom: 8px; }
.un-alarm.critical { border-left-color: #dc3545; background: #fff5f5; }

@media (max-width: 768px) {
  .un-sidebar { transform: translateX(-100%); transition: transform 0.25s; z-index: 200; }
  .un-sidebar.open { transform: translateX(0); }
  .un-main { margin-left: 0; padding: 16px; }
  .un-hamburger { display: flex !important; }
  .un-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 199; }
  .un-overlay.open { display: block; }
}

.un-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  background: none;
  border: none;
}
.un-hamburger span { width: 22px; height: 2px; background: #fff; border-radius: 2px; }

/* ── Koyu Kahverengi Tema ── */
body.theme-dark {
  --green-dark:  #1a0e05;
  --green-mid:   #c49a2a;
  --green-light: #e8c060;
  --green-pale:  #3d2414;
  --earth:       #c49a2a;
  --earth-light: #e8c060;
  --cream:       #1e1208;
  --cream-dark:  #2d1c0e;
  --text-dark:   #f0e0c8;
  --text-mid:    #c8a882;
  background:    #1e1208 !important;
  color:         #f0e0c8 !important;
}

body.theme-dark .un-main {
  background: #1e1208;
  color: #f0e0c8;
}

body.theme-dark .un-sidebar {
  background: #1a0e05;
}

body.theme-dark .un-card {
  background: #2d1c0e !important;
  border-color: #4a2c1a !important;
  color: #f0e0c8 !important;
}

body.theme-dark .modal-content {
  background: #2d1c0e;
  border-color: #4a2c1a;
  color: #f0e0c8;
}

body.theme-dark .modal-header {
  background: #1a0e05 !important;
}

body.theme-dark h1, body.theme-dark h2, body.theme-dark h3,
body.theme-dark h4, body.theme-dark h5, body.theme-dark h6,
body.theme-dark p, body.theme-dark span, body.theme-dark label,
body.theme-dark td, body.theme-dark th {
  color: #f0e0c8 !important;
}

body.theme-dark .table {
  color: #f0e0c8;
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255,255,255,0.03);
  --bs-table-hover-bg: rgba(255,255,255,0.05);
  --bs-table-border-color: #4a2c1a;
}

body.theme-dark .table > :not(caption) > * > * {
  background-color: transparent;
  color: #f0e0c8;
  border-color: #4a2c1a;
}

body.theme-dark thead {
  background: #3d2414 !important;
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background-color: #3d2414 !important;
  color: #f0e0c8 !important;
  border-color: #5a3820 !important;
}

body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus {
  background-color: #4a2c1a !important;
  color: #f0e0c8 !important;
  border-color: #c49a2a !important;
  box-shadow: 0 0 0 0.2rem rgba(196,154,42,0.25) !important;
}

body.theme-dark .un-badge-online { background: #1a3d2a !important; color: #4ade80 !important; }
body.theme-dark .un-badge-offline { background: #3d1a1a !important; color: #f87171 !important; }

body.theme-dark .alert-dismissible {
  background: #3d2414;
  color: #f0e0c8;
  border-color: #5a3820;
}

body.theme-dark .btn-secondary,
body.theme-dark .btn-outline-secondary {
  background: #4a2c1a;
  color: #f0e0c8;
  border-color: #5a3820;
}

body.theme-dark .text-muted { color: #a08060 !important; }
body.theme-dark small, body.theme-dark .small { color: #c8a882 !important; }


/* Koyu tema — dashboard kartları */
body.theme-dark .un-card {
  background: #2d1c0e !important;
  border-color: #4a2c1a !important;
  color: #f0e0c8 !important;
}

body.theme-dark [style*="background:var(--green-dark)"],
body.theme-dark [style*="background: var(--green-dark)"] {
  background: #3d2010 !important;
}

body.theme-dark [style*="background:#1e3a0f"],
body.theme-dark [style*="background: #1e3a0f"] {
  background: #2d1608 !important;
}

body.theme-dark [style*="background:#2d5016"],
body.theme-dark [style*="background: #2d5016"] {
  background: #5a3010 !important;
}

body.theme-dark [style*="background:#4a7c1f"],
body.theme-dark [style*="background: #4a7c1f"] {
  background: #7a4a18 !important;
}

body.theme-dark [style*="background:#8b6914"],
body.theme-dark [style*="background: #8b6914"] {
  background: #8b6914 !important;
}

/* Alarm kartları */
body.theme-dark .cust-alarm,
body.theme-dark [style*="background:#fffbf0"],
body.theme-dark [style*="background:#fff5f5"] {
  background: #2d1c0e !important;
  color: #f0e0c8 !important;
}

/* Tablo satırları */
body.theme-dark tbody tr:hover td {
  background: rgba(255,255,255,0.04) !important;
}

/* Badge renklerini koru */
body.theme-dark .un-badge-online { background: #1a4a2a !important; color: #4ade80 !important; }
body.theme-dark .un-badge-offline { background: #4a1a1a !important; color: #f87171 !important; }
body.theme-dark .un-badge-power { background: #4a3a10 !important; color: #fbbf24 !important; }

/* ── Koyu Tema Düzeltmeleri v2 ── */

/* Dashboard istatistik kartları */
body.theme-dark .un-card {
  background: #2d1c0e !important;
  border-color: #4a2c1a !important;
  color: #f0e0c8 !important;
}

/* Yeşil dashboard kartları → koyu yeşil-kahve */
body.theme-dark [class*="col"] > div[style*="background:#1e3a0f"],
body.theme-dark [class*="col"] > div[style*="background:#2d5016"],
body.theme-dark [class*="col"] > div[style*="background:#4a7c1f"],
body.theme-dark [class*="col"] > div[style*="background:#8b6914"] {
  background: #2a1a08 !important;
  border: 1px solid #5a3820 !important;
}

/* Sidebar */
body.theme-dark .un-sidebar {
  background: #160e04 !important;
}

/* Alarm kartları — beyaz arka planı koyu yap */
body.theme-dark .alert-danger,
body.theme-dark [style*="background:#fff5f5"],
body.theme-dark [style*="background:#fffbf0"],
body.theme-dark [style*="background:#fff8f8"],
body.theme-dark [style*="background:white"],
body.theme-dark [style*="background: white"] {
  background: #3d1a1a !important;
  color: #f0e0c8 !important;
  border-color: #7a2a2a !important;
}

/* Profil ve form inputları */
body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark input:not([type="checkbox"]):not([type="radio"]),
body.theme-dark select,
body.theme-dark textarea {
  background: #3d2414 !important;
  color: #f0e0c8 !important;
  border-color: #5a3820 !important;
}

body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus {
  background: #4a2c1a !important;
  border-color: #c49a2a !important;
  box-shadow: 0 0 0 0.2rem rgba(196,154,42,0.2) !important;
}

/* Profil butonları — sarı değil yeşil-kahve */
body.theme-dark .un-btn-primary {
  background: #5a3010 !important;
  border-color: #7a4a20 !important;
}

body.theme-dark .un-btn-outline {
  border-color: #5a3820 !important;
  color: #f0e0c8 !important;
}

/* Tablo */
body.theme-dark .table {
  color: #f0e0c8 !important;
  --bs-table-bg: transparent !important;
  --bs-table-border-color: #4a2c1a !important;
}

body.theme-dark .table > * > * > * {
  background-color: transparent !important;
  color: #f0e0c8 !important;
  border-color: #4a2c1a !important;
}

body.theme-dark thead {
  background: #3d2010 !important;
}

/* Badge */
body.theme-dark .un-badge-online { background: #1a4a2a !important; color: #4ade80 !important; }
body.theme-dark .un-badge-offline { background: #4a1a1a !important; color: #f87171 !important; }

/* Modal */
body.theme-dark .modal-content {
  background: #2d1c0e !important;
  border-color: #5a3820 !important;
  color: #f0e0c8 !important;
}
body.theme-dark .modal-header {
  background: #1a0e05 !important;
  border-color: #5a3820 !important;
}
body.theme-dark .modal-footer {
  border-color: #5a3820 !important;
}

/* Toggle switch */
body.theme-dark .form-check-input {
  background-color: #5a3820 !important;
  border-color: #7a4a20 !important;
}
body.theme-dark .form-check-input:checked {
  background-color: #c49a2a !important;
  border-color: #c49a2a !important;
}

/* Genel yazılar */
body.theme-dark h1, body.theme-dark h2, body.theme-dark h3,
body.theme-dark h4, body.theme-dark h5, body.theme-dark h6 {
  color: #f0e0c8 !important;
}

body.theme-dark .text-muted { color: #a08060 !important; }
body.theme-dark .text-dark { color: #f0e0c8 !important; }
body.theme-dark small { color: #c8a882 !important; }

/* Cream arkaplanlar */
body.theme-dark [style*="background:var(--cream)"],
body.theme-dark [style*="background: var(--cream)"] {
  background: #261608 !important;
}


/* ── Dashboard stat kartları koyu tema ── */
body.theme-dark .un-stat {
  background: #2d1c0e !important;
  border: 1px solid #5a3820 !important;
}

body.theme-dark .un-stat[style*="--green-mid"] { background: #1a3010 !important; }
body.theme-dark .un-stat[style*="--green-light"] { background: #1a3010 !important; }
body.theme-dark .un-stat[style*="--earth"] { background: #2d1c08 !important; }
body.theme-dark .un-stat[style*="--earth-light"] { background: #2d1c08 !important; }

body.theme-dark .un-stat * { color: #f0e0c8 !important; }

/* Alarm listesi kartları koyu tema */
body.theme-dark .alerts-list .alert,
body.theme-dark [class*="alert"][style*="background:#fff"],
body.theme-dark [style*="background:#fff5f5"],
body.theme-dark [style*="background:#fffbf0"] {
  background: #2d1a1a !important;
  border-color: #7a3a3a !important;
  color: #f0e0c8 !important;
}

/* ── Koyu tema kritik düzeltmeler ── */
body.theme-dark .un-card {
  background-color: #2d1c0e !important;
  background: #2d1c0e !important;
}

body.theme-dark .un-main {
  background: #1a0e05 !important;
}

body.theme-dark body,
body.theme-dark {
  background: #1a0e05 !important;
}

/* Alarm kartları */
body.theme-dark .un-card div[style*="background:#fff5f5"],
body.theme-dark .un-card div[style*="background:#fffbf0"],
body.theme-dark div[style*="border-left:3px solid #dc3545"],
body.theme-dark div[style*="border-left: 3px solid #dc3545"] {
  background: #2d1a1a !important;
  color: #f0e0c8 !important;
}

/* Tüm beyaz kartları koyu yap */
body.theme-dark .un-card,
body.theme-dark .card {
  background: #2d1c0e !important;
  color: #f0e0c8 !important;
  border-color: #5a3820 !important;
}

/* ── Stat kart renkleri koyu tema ── */
body.theme-dark .dark-card-1 {
  background: #1a3010 !important;
}
body.theme-dark .dark-card-2 {
  background: #2d1c08 !important;
}

/* Alarm kartı beyaz arka plan */
body.theme-dark .un-card > div[style*="background:#fff"],
body.theme-dark .un-card > div > div[style*="background:#fff5f5"],
body.theme-dark .un-card > div > div[style*="background:#fffbf0"] {
  background: #2d1a1a !important;
  color: #f0e0c8 !important;
}

/* ── Stat kartları — açık tema ── */
.un-stat-green       { background: var(--green-mid) !important; }
.un-stat-green-light { background: var(--green-light) !important; }
.un-stat-earth       { background: var(--earth) !important; }
.un-stat-earth-light { background: var(--earth-light) !important; }

/* ── Stat kartları — koyu tema ── */
body.theme-dark .un-stat-green       { background: #1a3010 !important; }
body.theme-dark .un-stat-green-light { background: #1e3812 !important; }
body.theme-dark .un-stat-earth       { background: #2d1c08 !important; }
body.theme-dark .un-stat-earth-light { background: #3a2410 !important; }

/* un-alarm koyu tema */
body.theme-dark .un-alarm { background: #2d1a1a !important; color: #f0e0c8 !important; }
body.theme-dark .un-alarm.critical { background: #3d1a1a !important; color: #f0e0c8 !important; }
body.theme-dark .un-alarm * { color: #f0e0c8 !important; }

/* Durum badge'leri koyu tema */
body.theme-dark [style*="background:#d1e7dd"] { background: #1a4a2a !important; color: #4ade80 !important; }
body.theme-dark [style*="background:#f8d7da"] { background: #4a1a1a !important; color: #f87171 !important; }
body.theme-dark [style*="background:#fff3cd"] { background: #4a3a10 !important; color: #fbbf24 !important; }
body.theme-dark [style*="background:#cff4fc"] { background: #0a3040 !important; color: #67e8f9 !important; }
body.theme-dark [style*="background:#0d6efd"] { background: #1a3a6a !important; color: #93c5fd !important; }
