:root {
  --solar-navy: #0b1f3a;
  --solar-navy-2: #122d52;
  --solar-amber: #f59e0b;
  --solar-amber-dark: #d97706;
  --solar-emerald: #10b981;
  --solar-cyan: #0ea5e9;
  --solar-bg: #f1f5f9;
  --solar-card: #ffffff;
  --solar-border: #e2e8f0;
  --solar-text: #0f172a;
  --solar-muted: #64748b;
  --sidebar-width: 272px;
  --sidebar-collapsed: 78px;
  --bottom-nav-height: 68px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background-color: var(--solar-bg);
  color: var(--solar-text);
}

.sdms-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sdms-icon-sm {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sdms-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==================== APP SHELL & COLLAPSIBLE SCROLLING SIDEBAR ==================== */
.sdms-shell {
  display: flex;
  min-height: 100vh;
}

.sdms-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #09182e 0%, #0f294a 55%, #13345c 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width 0.25s ease, transform 0.25s ease;
  box-shadow: 4px 0 24px rgba(2, 6, 23, 0.18);
}

.sdms-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sdms-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: #fff;
}

.sdms-brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.sdms-brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
}

.sdms-brand-text {
  min-width: 0;
  line-height: 1.2;
}

.sdms-brand-title {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sdms-brand-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sdms-collapse-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.sdms-collapse-btn:hover {
  background: rgba(245, 158, 11, 0.28);
  color: #fbbf24;
}

/* Independent Scrollable Menu Area when menus exceed viewport */
.sdms-sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.45) transparent;
}

.sdms-sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.sdms-sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sdms-sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.45);
  border-radius: 999px;
}

.sdms-sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(245, 158, 11, 0.75);
}

.sdms-menu-group {
  margin-bottom: 10px;
}

.sdms-group-toggle {
  width: 100%;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.sdms-group-toggle:hover {
  color: #fbbf24;
}

.sdms-group-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sdms-group-items.collapsed-group {
  display: none;
}

.sdms-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.sdms-nav-link:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.sdms-nav-link.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.95), rgba(234, 88, 12, 0.92));
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}

.sdms-sidebar-footer {
  padding: 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(5, 14, 28, 0.45);
  flex-shrink: 0;
}

.sdms-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sdms-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sdms-main-wrap {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

/* Collapsed sidebar state (Desktop) */
body.sidebar-collapsed .sdms-sidebar {
  width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sdms-main-wrap {
  margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sdms-brand-text,
body.sidebar-collapsed .sdms-nav-label,
body.sidebar-collapsed .sdms-group-toggle,
body.sidebar-collapsed .sdms-user-meta {
  display: none !important;
}

body.sidebar-collapsed .sdms-nav-link {
  justify-content: center;
  padding: 11px;
}

body.sidebar-collapsed .sdms-sidebar-header {
  justify-content: center;
  padding: 14px 8px;
}

body.sidebar-collapsed .sdms-brand {
  display: none;
}

body.sidebar-collapsed .sdms-user-pill {
  justify-content: center;
}

/* Top Navbar */
.sdms-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--solar-border);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sdms-content {
  padding: 22px;
  flex: 1;
}

/* ==================== MOBILE BOTTOM ICON NAVIGATION ==================== */
.sdms-mobile-bottom-nav {
  display: none;
}

.sdms-sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .sdms-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .sdms-sidebar.mobile-open {
    transform: translateX(0);
  }

  .sdms-sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1035;
  }

  .sdms-main-wrap {
    margin-left: 0 !important;
    padding-bottom: calc(var(--bottom-nav-height) + 14px);
  }

  .sdms-content {
    padding: 14px;
  }

  .sdms-topbar {
    padding: 10px 14px;
  }

  .sdms-mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--bottom-nav-height);
    background: #0b1f3a;
    border-top: 2px solid #f59e0b;
    box-shadow: 0 -6px 24px rgba(2, 6, 23, 0.25);
    z-index: 1030;
    padding: 4px 6px env(safe-area-inset-bottom, 4px);
  }

  .sdms-bottom-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 6px 4px;
    border-radius: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    min-width: 0;
  }

  .sdms-bottom-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sdms-bottom-item.active,
  .sdms-bottom-item:hover {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.14);
  }
}

/* ==================== SOLAR LOGIN PAGE ==================== */
.sdms-login-page {
  min-height: 100vh;
  background-image: linear-gradient(125deg, rgba(8, 22, 44, 0.84) 0%, rgba(12, 34, 62, 0.72) 55%, rgba(217, 119, 6, 0.35) 100%),
                    url('/images/solar-panels-bg.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.sdms-login-wrapper {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.45);
}

.sdms-login-hero {
  padding: 40px 36px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(160deg, rgba(11, 31, 58, 0.85), rgba(14, 165, 233, 0.2));
}

.sdms-login-card {
  padding: 36px 34px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--solar-text);
}

.sdms-role-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #f1f5f9;
  padding: 5px;
  border-radius: 12px;
}

.sdms-role-tab {
  border: none;
  background: transparent;
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.sdms-role-tab.active {
  background: linear-gradient(135deg, #0b1f3a, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.25);
}

@media (max-width: 767.98px) {
  .sdms-login-wrapper {
    grid-template-columns: 1fr;
  }
  .sdms-login-hero {
    padding: 26px 22px;
  }
  .sdms-login-card {
    padding: 26px 20px;
  }
}

/* ==================== DASHBOARD & CARDS ==================== */
.sdms-card {
  background: var(--solar-card);
  border: 1px solid var(--solar-border);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}

.sdms-hero-banner {
  background: linear-gradient(135deg, #0b1f3a 0%, #143b6b 60%, #b45309 100%);
  color: #fff;
  border-radius: 18px;
  padding: 24px 26px;
  box-shadow: 0 12px 30px rgba(11, 31, 58, 0.22);
}

.sdms-kpi-card {
  border-radius: 16px;
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.sdms-kpi-amber { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.sdms-kpi-navy { background: linear-gradient(135deg, #0b1f3a, #1e40af); }
.sdms-kpi-emerald { background: linear-gradient(135deg, #059669, #10b981); }
.sdms-kpi-cyan { background: linear-gradient(135deg, #0284c7, #06b6d4); }

.sdms-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sdms-table thead th {
  background: #f8fafc;
  color: #334155;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--solar-border);
  white-space: nowrap;
}

.sdms-table tbody td {
  vertical-align: middle;
  font-size: 0.88rem;
}

.sdms-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 180px;
  padding-top: 16px;
}

.sdms-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.sdms-chart-bar {
  width: 100%;
  max-width: 38px;
  min-height: 6px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #f59e0b, #1d4ed8);
  transition: height 0.4s ease;
}

/* Firm Printable Letterhead Header */
.sdms-firm-letterhead {
  border: 1px solid var(--solar-border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.sdms-firm-header-img {
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  display: block;
}

.sdms-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--solar-border);
}

@media print {
  .sdms-sidebar,
  .sdms-topbar,
  .sdms-mobile-bottom-nav,
  .no-print {
    display: none !important;
  }
  .sdms-main-wrap {
    margin-left: 0 !important;
    padding-bottom: 0 !important;
  }
  .sdms-content {
    padding: 0 !important;
  }
  .sdms-card {
    box-shadow: none !important;
    border-color: #cbd5e1 !important;
  }
}
