:root {
  --bg-overlay: rgba(6, 12, 28, 0.82);
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-hover: rgba(255, 255, 255, 0.1);
  --text-primary: #e8edf7;
  --text-secondary: #9aa8c4;
  --accent: #4da3ff;
  --accent-hover: #6bb5ff;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --transition: 0.25s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  background: #060c1c url("https://img.magnific.com/free-vector/blue-futuristic-waves-background-with-computer-code-technology_53876-119584.jpg") center / cover fixed no-repeat;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: -1;
}

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

a:hover {
  color: var(--accent-hover);
}

/* Layout */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.navbar-brand span {
  color: var(--accent);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-size: 0.95rem;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
  background: var(--glass-hover);
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Glass cards */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.glass-card-static:hover {
  transform: none;
}

/* Grid */
.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Stats */
.stat-card {
  text-align: center;
  padding: 1.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

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

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.2);
}

.form-control::placeholder {
  color: rgba(154, 168, 196, 0.5);
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 200px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4da3ff, #3b82f6);
  transform: translateY(-1px);
  color: #fff;
}

.btn-secondary {
  background: var(--glass-hover);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.35);
  color: #fff;
}

.btn-success {
  background: rgba(52, 211, 153, 0.2);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.btn-success:hover {
  background: rgba(52, 211, 153, 0.35);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-draft {
  background: rgba(154, 168, 196, 0.2);
  color: var(--text-secondary);
}

.badge-active {
  background: rgba(77, 163, 255, 0.2);
  color: var(--accent);
}

.badge-completed {
  background: rgba(52, 211, 153, 0.2);
  color: var(--success);
}

.badge-deleted {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger);
}

.badge-milestone-pending {
  background: rgba(154, 168, 196, 0.2);
  color: var(--text-secondary);
}

.badge-milestone-in-progress {
  background: rgba(77, 163, 255, 0.2);
  color: var(--accent);
}

.badge-milestone-completed {
  background: rgba(52, 211, 153, 0.2);
  color: var(--success);
}

/* Alerts */
.flash-messages {
  margin-bottom: 1.25rem;
}

.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  border: 1px solid transparent;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-success {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.alert-danger {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.alert-warning {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--warning);
}

.alert-info {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.3);
  color: var(--info);
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 700;
}

.login-logo h1 span {
  color: var(--accent);
}

.login-logo p {
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Plan cards */
.plan-card {
  cursor: pointer;
  position: relative;
}

.plan-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.plan-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.plan-card-desc {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.search-bar .form-control {
  flex: 1;
  min-width: 200px;
}

.search-bar select.form-control {
  max-width: 180px;
}

/* Rich text editor */
.ql-toolbar.ql-snow,
.ql-container.ql-snow {
  border-color: var(--glass-border) !important;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
}

.ql-toolbar.ql-snow {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.ql-container.ql-snow {
  border-top: none;
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  min-height: 200px;
}

.ql-editor {
  color: var(--text-primary);
  min-height: 200px;
}

.ql-snow .ql-stroke {
  stroke: var(--text-secondary);
}

.ql-snow .ql-fill {
  fill: var(--text-secondary);
}

.ql-snow .ql-picker-label {
  color: var(--text-secondary);
}

/* Plan detail */
.plan-description {
  line-height: 1.8;
}

.plan-description h1,
.plan-description h2,
.plan-description h3 {
  margin: 1rem 0 0.5rem;
}

.plan-description p {
  margin-bottom: 0.75rem;
}

.plan-description ul,
.plan-description ol {
  margin: 0.5rem 0 0.75rem 1.5rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meta-item label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.meta-item span {
  font-size: 0.95rem;
}

/* Assets */
.asset-section {
  margin-top: 1.5rem;
}

.asset-section h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.link-asset {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.link-asset a {
  flex: 1;
  word-break: break-all;
  min-width: 0;
}

.file-asset {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-hover);
  border-radius: 8px;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* Image gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  transition: transform var(--transition);
}

.gallery-item:hover {
  transform: scale(1.03);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-sm);
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

/* Link input rows */
.link-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.link-input-row .form-control {
  flex: 1;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  animation: slideIn 0.3s ease;
}

.modal h3 {
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }

  .navbar-nav {
    justify-content: center;
  }

  .main-content {
    padding: 1rem;
  }

  .page-header h1 {
    font-size: 1.4rem;
  }

  .search-bar select.form-control {
    max-width: 100%;
  }

  th, td {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }
}

.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-secondary);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* PWA / standalone app */
@supports (padding: env(safe-area-inset-top)) {
  .navbar {
    padding-top: calc(1rem + env(safe-area-inset-top));
    padding-left: calc(1.5rem + env(safe-area-inset-left));
    padding-right: calc(1.5rem + env(safe-area-inset-right));
  }

  .main-content {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    padding-left: calc(1.5rem + env(safe-area-inset-left));
    padding-right: calc(1.5rem + env(safe-area-inset-right));
  }

  .login-page {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: contain;
  }

  .navbar {
    padding-top: max(1rem, env(safe-area-inset-top));
  }
}

.pwa-install-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: rgba(10, 22, 40, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}

.pwa-install-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.pwa-install-content strong {
  font-size: 0.95rem;
}

.pwa-install-content span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pwa-install-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .pwa-install-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .pwa-install-actions {
    width: 100%;
  }

  .pwa-install-actions .btn {
    flex: 1;
  }
}

/* Milestone timeline */
.milestone-adder {
  border-top: 1px solid var(--glass-border);
  padding-top: 1rem;
}

.milestone-input-row {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.milestone-add-section {
  border-top: 1px solid var(--glass-border);
  padding-top: 1.25rem;
}

.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), rgba(77, 163, 255, 0.15));
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -2rem;
  top: 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #0a1628;
  box-shadow: 0 0 0 2px var(--accent);
  z-index: 1;
}

.timeline-pending .timeline-dot {
  background: var(--text-secondary);
  box-shadow: 0 0 0 2px var(--text-secondary);
}

.timeline-in-progress .timeline-dot {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  animation: pulse-dot 2s ease infinite;
}

.timeline-completed .timeline-dot {
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success);
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent); }
  50% { box-shadow: 0 0 0 6px rgba(77, 163, 255, 0.25); }
}

.timeline-content {
  padding: 1.1rem 1.25rem;
}

.timeline-content:hover {
  transform: none;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.timeline-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.timeline-date {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
}

.timeline-desc {
  margin-top: 0.65rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.timeline-actions {
  border-top: 1px solid var(--glass-border);
  padding-top: 0.75rem;
}

@media (max-width: 768px) {
  .timeline {
    padding-left: 1.5rem;
  }

  .timeline-marker {
    left: -1.5rem;
  }

  .timeline::before {
    left: 0.35rem;
  }
}
