:root {
  --teal: #2da8a8;
  --teal-light: #4ecdc4;
  --teal-pale: #e8f7f7;
  --teal-glow: rgba(45, 168, 168, 0.25);
  --dark: #1a1f22;
  --dark-soft: #243035;
  --sidebar: #1e2629;
  --gray: #636e72;
  --gray-light: #b2bec3;
  --white: #ffffff;
  --bg: #ffffff;
  --surface: #f8fafa;
  --border: #e8ecec;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(26, 31, 34, 0.04), 0 4px 12px rgba(26, 31, 34, 0.04);
  --shadow-lg: 0 8px 30px rgba(26, 31, 34, 0.08);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 280px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--dark);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== LOGIN ========== */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-brand {
  background: linear-gradient(145deg, var(--dark) 0%, #1a3538 50%, var(--teal) 120%);
  color: var(--white);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.5;
}

.auth-brand-inner {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

.auth-brand-inner > a {
  display: inline-flex;
  align-items: center;
  background: var(--white);
  padding: 0.55rem 0.9rem;
  border-radius: 12px;
  margin-bottom: 2.5rem;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  text-decoration: none;
}

.auth-brand-inner > a:hover {
  text-decoration: none;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
}

.auth-brand img.logo {
  height: 48px;
  width: auto;
  display: block;
}

.auth-brand h1 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.auth-brand h1 span { color: var(--teal-light); }

.auth-brand p {
  color: rgba(255,255,255,0.75);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.auth-features {
  list-style: none;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}

.auth-features li::before {
  content: '✓';
  width: 22px;
  height: 22px;
  background: rgba(78, 205, 196, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--teal-light);
  flex-shrink: 0;
}

.auth-preview {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.15);
}

.auth-preview-label {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.65);
}

.auth-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.auth-preview-tile {
  position: relative;
  border: none;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0,0,0,0.2);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.auth-preview-tile:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 1;
}

.auth-preview-tile img {
  width: 100%;
  display: block;
  aspect-ratio: 16/10;
  object-fit: cover;
  object-position: top;
  transition: transform 0.4s ease;
}

.auth-preview-tile:hover img {
  transform: scale(1.06);
}

.auth-preview-zoom {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(45, 168, 168, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s, transform 0.2s;
}

.auth-preview-tile:hover .auth-preview-zoom {
  opacity: 1;
  transform: scale(1);
}

.auth-preview-cap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  text-align: left;
}

.auth-preview-link {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--teal-light);
  text-decoration: none;
}

.auth-preview-link:hover { text-decoration: underline; }

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--white);
}

.auth-form-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-form-wrap .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--gray);
  margin-bottom: 1.5rem;
  text-decoration: none;
}

.auth-form-wrap .back-link:hover { color: var(--teal); text-decoration: none; }

.auth-form-wrap h2 {
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.auth-form-wrap .subtitle {
  color: var(--gray);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--dark-soft);
}

.form-group input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(45, 168, 168, 0.25);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.form-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--gray);
}

.forgot-link {
  color: var(--teal);
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
}

.forgot-link:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border-radius: 50px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-light));
  color: var(--white);
  box-shadow: 0 4px 18px var(--teal-glow);
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--teal-glow);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.auth-error {
  background: #fef5f5;
  color: #c0392b;
  border: 1px solid #fde8e8;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: none;
}

.auth-error.show { display: block; }

.auth-success {
  background: var(--teal-pale);
  color: var(--teal);
  border: 1px solid rgba(45, 168, 168, 0.3);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: none;
}

.auth-success.show { display: block; }

.demo-hint {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--gray);
  border: 1px dashed rgba(45, 168, 168, 0.3);
}

.demo-hint strong { color: var(--teal); }

.auth-footer-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--gray);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 31, 34, 0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: min(440px, 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--dark), var(--dark-soft));
  color: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 1.05rem; }

.modal-close {
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.modal-body { padding: 1.5rem; }

.modal-body p {
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 1rem 0.85rem 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  width: 100%;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.sidebar-logo:hover {
  text-decoration: none;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.16);
}

.sidebar-logo img {
  width: 100%;
  height: auto;
  max-height: 42px;
  object-fit: contain;
  object-position: center;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 0.75rem 0.75rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  margin-bottom: 0.15rem;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
  text-decoration: none;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(45,168,168,0.35), rgba(78,205,196,0.2));
  color: var(--white);
  border: 1px solid rgba(78, 205, 196, 0.25);
}

.nav-item .badge {
  margin-left: auto;
  background: #e74c3c;
  color: white;
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 50px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--teal-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-info .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .role {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
}

.logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  transition: var(--transition);
}

.logout-btn:hover { color: #ff8a80; background: rgba(255,255,255,0.06); }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid rgba(45, 168, 168, 0.1);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(45, 168, 168, 0.2);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  position: relative;
  transition: var(--transition);
}

.topbar-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.topbar-btn .notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid white;
}

.dashboard-body {
  padding: 1.25rem 1.75rem 1.5rem;
  flex: 1;
  background: var(--white);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: none;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: rgba(45, 168, 168, 0.35);
  box-shadow: var(--shadow);
}

.kpi-card .label {
  font-size: 0.78rem;
  color: var(--gray);
  margin-bottom: 0.35rem;
}

.kpi-card .value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
}

.kpi-card .value.teal { color: var(--teal); }

.kpi-card .trend {
  font-size: 0.75rem;
  margin-top: 0.35rem;
}

.kpi-card .trend.up { color: #27ae60; }
.kpi-card .trend.warn { color: #e67e22; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: none;
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--teal-pale);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.panel-header a {
  font-size: 0.8rem;
  font-weight: 600;
}

.panel-body { padding: 1rem 1.25rem; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  height: 160px;
  padding-top: 0.5rem;
}

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

.chart-bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(180deg, var(--teal-light), var(--teal));
  border-radius: 6px 6px 0 0;
  transition: height 0.8s ease;
  min-height: 8px;
}

.chart-bar-col span {
  font-size: 0.68rem;
  color: var(--gray);
}

.alert-feed { display: flex; flex-direction: column; gap: 0.65rem; }

.alert-item {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border-left: 3px solid var(--teal);
  font-size: 0.82rem;
}

.alert-item.urgent {
  border-left-color: #e74c3c;
  background: #fef5f5;
}

.alert-item.warn {
  border-left-color: #f39c12;
  background: #fffbf0;
}

.alert-item .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--gray);
  margin-bottom: 0.25rem;
}

.alert-item strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray);
  border-bottom: 1px solid var(--teal-pale);
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--teal-pale);
}

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

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-pill.ok { background: var(--teal-pale); color: var(--teal); }
.status-pill.pending { background: #fff3e0; color: #e67e22; }
.status-pill.alert { background: #fef5f5; color: #c0392b; }

.demo-banner {
  background: linear-gradient(90deg, var(--teal-pale), rgba(78,205,196,0.15));
  border: 1px solid rgba(45, 168, 168, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  color: var(--dark-soft);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.demo-banner a { font-weight: 600; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dark);
  padding: 0.35rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 45;
}

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

@media (max-width: 768px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { padding: 2rem; min-height: auto; }
  .auth-brand img.logo { height: 40px; }
  .auth-brand-inner > a { margin-bottom: 1.5rem; padding: 0.45rem 0.75rem; }
  .auth-features { display: none; }

  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }

  .mobile-menu-btn { display: flex; }

  .kpi-grid { grid-template-columns: 1fr; }

  .dashboard-body { padding: 1rem; }

  .topbar { padding: 0.75rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .modal { animation: none; }
  .kpi-card:hover { transform: none; }
}
