:root {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-card: #1e293b;
  --bg-card-hover: #263449;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --forever: #f59e0b;
  --forever-bg: rgba(245, 158, 11, 0.14);
  --zinzino: #2dd4bf;
  --zinzino-bg: rgba(45, 212, 191, 0.14);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.14);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --warning: #eab308;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

/* AUTHENTICATION VIEWS */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #1e293b 0%, #0b1120 70%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(56, 189, 248, 0.12);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input,
.filter-input,
.filter-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

.input-wrap input.has-eye {
  padding-right: 44px;
}

.input-wrap input:focus,
.filter-input:focus,
.filter-select:focus {
  border-color: var(--primary);
}

.eye-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.eye-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary-dark);
  color: #ffffff;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.auth-links {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

/* APP SHELL LAYOUT */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.sidebar-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.nav-list {
  list-style: none;
  padding: 14px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

.main-area {
  flex: 1;
  margin-left: 260px;
  padding: 24px 28px 90px 28px;
  max-width: 1600px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* GRID & CARDS */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card-forever {
  border-top: 3px solid var(--forever);
}

.card-zinzino {
  border-top: 3px solid var(--zinzino);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-box {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 13px 14px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 20px;
  font-weight: 800;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-forever {
  background: var(--forever-bg);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-zinzino {
  background: var(--zinzino-bg);
  color: #5eead4;
  border: 1px solid rgba(45, 212, 191, 0.3);
}

.badge-owner {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-success {
  background: var(--success-bg);
  color: #4ade80;
}

.badge-danger {
  background: var(--danger-bg);
  color: #f87171;
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
}

/* FILTER BAR */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar .filter-input {
  flex: 1;
  min-width: 220px;
}

.filter-bar .filter-select {
  width: auto;
  min-width: 170px;
}

/* TABLES */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: var(--bg-card);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  font-size: 14px;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr.clickable-row {
  cursor: pointer;
  transition: background 0.12s;
}

tr.clickable-row:hover {
  background: var(--bg-card-hover);
}

tr.owner-row {
  background: rgba(56, 189, 248, 0.06);
}

/* CC BAR CHART */
.cc-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cc-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 180px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.cc-bar-track {
  height: 14px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.cc-bar-personal {
  background: #38bdf8;
  height: 100%;
}

.cc-bar-downline {
  background: #f59e0b;
  height: 100%;
}

/* MATERIALS & PHOTO GALLERY */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.material-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.material-title {
  font-weight: 700;
  font-size: 15px;
  margin-top: 6px;
}

.material-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.material-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}

.photo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s;
}

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

.photo-thumb-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

.photo-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.photo-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.photo-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

/* MODAL / DRAWER */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  width: 100%;
  max-width: 880px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 800;
}

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

/* MOBILE BOTTOM NAV */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding: 6px 8px env(safe-area-inset-bottom, 6px) 8px;
  justify-content: space-around;
}

.bottom-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.bottom-nav-btn.active {
  color: var(--primary);
  background: rgba(56, 189, 248, 0.12);
}

@media (max-width: 1024px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .sidebar {
    display: none;
  }
  .main-area {
    margin-left: 0;
    padding: 16px 14px 86px 14px;
  }
  .bottom-nav {
    display: flex;
  }
  .cc-bar-row {
    grid-template-columns: 75px 1fr 120px;
  }
}
