/* =========================================
   RESET & BASE
========================================= */
:root {
  --bg-color: #0f172a;
  /* Navy Blue Deep */
  --card-bg: #1e293b;
  /* Slate 800 */
  --text-main: #f1f5f9;
  /* Slate 100 */
  --text-muted: #94a3b8;
  /* Slate 400 */
  --primary: #3b82f6;
  /* Blue 500 */
  --primary-hover: #2563eb;
  /* Blue 600 */
  --success: #10b981;
  /* Emerald 500 */
  --danger: #ef4444;
  /* Red 500 */
  --border: #334155;
  /* Slate 700 */
  --radius: 16px;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

main {
  animation: fadeIn 0.4s ease-out;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

/* =========================================
   NAVBAR
========================================= */
.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.8);
  /* Glass effect base */
  backdrop-filter: blur(12px);
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo {
  font-weight: 800;
  font-size: 24px;
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.nav-item {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 99px;
  transition: all 0.2s ease;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: white;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nav-right {
  display: flex;
  align-items: center;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 8px 20px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--danger);
  color: white;
}

/* =========================================
   LAYOUT DASHBOARD
========================================= */
.dashboard-container {
  max-width: 1400px;
  margin: 40px auto;
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 40px;
  padding: 0 24px;
}

/* =========================================
   PROFILE SECTION
========================================= */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 32px;
  background: var(--card-bg);
  padding: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.profile-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg-color);
  box-shadow: 0 0 0 2px var(--primary);
}

.profile-info h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
  color: white;
}

.profile-role {
  color: var(--text-muted);
  font-size: 16px;
  display: block;
  margin-bottom: 16px;
}

.btn-edit-profile {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: 0.2s;
}

.btn-edit-profile:hover {
  background: var(--primary);
  color: white;
}

/* Balance Big Display */
.balance-section {
  text-align: left;
}

.profile-balance {
  font-size: 64px;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -2px;
  margin: 10px 0;
}

.balance-label {
  color: var(--text-muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* =========================================
   STATS CARDS
========================================= */
.summary-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.summary-box {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.summary-box:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.summary-title {
  font-size: 14px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 12px;
}

.summary-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--success);
}

/* =========================================
   CHART SECTION
========================================= */
.chart-box {
  background: var(--card-bg);
  padding: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.chart-title {
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.btn-predict {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transition: 0.2s;
}

.btn-predict:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* =========================================
   RIGHT PANEL (TEAM)
========================================= */
.right-panel {
  position: sticky;
  top: 100px;
  height: fit-content;
}

.team-box {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.team-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-title::before {
  content: "";
  display: block;
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
}

.team-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.team-user:last-child {
  border-bottom: none;
}

.team-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.team-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #334155;
}

.team-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.team-role {
  font-size: 12px;
  color: var(--text-muted);
}

.team-score {
  font-weight: 700;
  font-size: 15px;
}

.score-positive {
  color: var(--success);
}

.score-negative {
  color: var(--danger);
}

/* =========================================
   LOGIN PAGE
========================================= */
body.centered {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  padding: 40px;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.login-card h2 {
  margin-bottom: 32px;
  font-size: 24px;
  font-weight: 700;
  color: white;
}

.login-card input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: white;
  font-size: 15px;
  outline: none;
  transition: 0.2s;
}

.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.login-card button {
  width: 100%;
  background: var(--primary);
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  color: white;
  cursor: pointer;
  font-weight: 600;
  margin-top: 16px;
  transition: 0.2s;
}

.login-card button:hover {
  background: var(--primary-hover);
}

.msg.error {
  margin-top: 16px;
  color: var(--danger);
  font-size: 14px;
  background: rgba(239, 68, 68, 0.1);
  padding: 10px;
  border-radius: 8px;
  display: none;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 1024px) {
  .dashboard-container {
    grid-template-columns: 1fr;
  }

  .right-panel {
    position: static;
  }
}

/* =========================================
   MODAL STYLES
========================================= */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--card-bg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: white;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 20px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Form Elements inside Modal */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: white;
  font-size: 14px;
  outline: none;
  transition: 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
  border-color: var(--text-muted);
}

/* =========================================
   INVOICE MODAL ENHANCEMENTS
========================================= */
.modal-lg {
  max-width: 800px;
}

.invoice-form-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-section {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.form-section h4 {
  margin-bottom: 15px;
  color: var(--primary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.invoice-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inv-item-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.inv-item-select {
  flex: 3;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-color);
  border: 1px solid var(--border);
  color: white;
}

.inv-item-qty {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-color);
  border: 1px solid var(--border);
  color: white;
  text-align: center;
}

.btn-remove-item {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.btn-remove-item:hover {
  background: #ef4444;
  color: white;
}

.recurrence-box {
  border-left: 4px solid var(--primary);
}

.recurrence-details {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px dashed var(--border);
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked+.slider {
  background-color: var(--primary);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* =========================================
   LOADING OVERLAY
========================================= */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.4s ease, visibility 0.4s;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(59, 130, 246, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-main);
  text-transform: uppercase;
  font-size: 14px;
}

/* =========================================
   INVITATION HIERARCHY
========================================= */
.team-group-collapsible {
  transition: border-color 0.3s ease;
}

.team-group-collapsible:hover {
  border-color: var(--primary) !important;
}

.team-header:hover {
  background: rgba(59, 130, 246, 0.2) !important;
}

.collapse-icon {
  font-size: 0.7rem;
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.team-members-content {
  transition: all 0.3s ease;
}

.member-cb:checked+span {
  color: var(--primary);
  font-weight: 500;
}