:root {
  color-scheme: dark;
  --bg-main: #0b1022;
  --bg-main-2: #111831;
  --bg-card: rgba(23, 28, 49, 0.82);
  --bg-card-solid: #171c31;
  --bg-sidebar: rgba(15, 20, 39, 0.94);
  --bg-field: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-main: #ffffff;
  --text-muted: #9ca3af;
  --primary: #d95cff;
  --primary-2: #875cff;
  --secondary: #00e5ff;
  --accent: #2f80ed;
  --success: #00f5a0;
  --warning: #ffcc00;
  --danger: #ff4d6d;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar-width: 280px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-main: #f2f6ff;
  --bg-main-2: #e9effb;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-solid: #ffffff;
  --bg-sidebar: rgba(255, 255, 255, 0.92);
  --bg-field: rgba(15, 23, 42, 0.045);
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.15);
  --text-main: #101626;
  --text-muted: #667085;
  --primary: #a855f7;
  --primary-2: #6d5dfc;
  --secondary: #00a5c7;
  --accent: #2563eb;
  --success: #0eaa74;
  --warning: #b58500;
  --danger: #e11d48;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-main);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", "Tahoma", "Arial", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(217, 92, 255, 0.16), transparent 32rem),
    radial-gradient(circle at top right, rgba(0, 229, 255, 0.12), transparent 28rem),
    linear-gradient(135deg, var(--bg-main), var(--bg-main-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 75%);
}

button,
input,
textarea,
select {
  font: inherit;
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

html[dir="ltr"] .app-shell {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  background: var(--bg-sidebar);
  border-inline-end: 1px solid var(--border);
  backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  gap: 28px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 35px rgba(217, 92, 255, 0.33);
}

.brand strong {
  display: block;
  font-size: 1rem;
}

.brand span,
.sidebar-card p,
.page-subtitle,
.section-heading p,
.kpi-card small,
.mini-label {
  color: var(--text-muted);
}

.brand span {
  display: block;
  margin-top: 3px;
  font-size: 0.8rem;
}

.side-nav {
  display: grid;
  gap: 10px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: 0.22s ease;
}

.side-nav a:hover,
.side-nav a.active {
  color: var(--text-main);
  background: linear-gradient(135deg, rgba(217, 92, 255, 0.18), rgba(0, 229, 255, 0.10));
  border-color: var(--border);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(217, 92, 255, 0.12), rgba(0, 229, 255, 0.06));
}

.sidebar-card p {
  margin: 9px 0 0;
  line-height: 1.7;
  font-size: 0.9rem;
}

.mini-label,
.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--secondary);
  font-weight: 800;
}

.main-content {
  min-width: 0;
  padding: 34px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.22rem;
}

.page-subtitle {
  margin-bottom: 0;
  line-height: 1.7;
}

.top-actions,
.form-actions,
.row-actions,
.section-heading.with-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-button,
.primary-button,
.ghost-button,
.danger-button,
.table-action {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  font-weight: 800;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.icon-button:hover,
.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.table-action:hover {
  transform: translateY(-1px);
}

.icon-button {
  min-width: 46px;
  height: 46px;
  padding: 0 12px;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 14px 35px rgba(47, 128, 237, 0.25);
}

.ghost-button,
.danger-button {
  min-height: 44px;
  padding: 0 16px;
  color: var(--text-main);
  background: var(--bg-field);
  border: 1px solid var(--border);
}

.danger-button {
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 77, 109, 0.92), rgba(217, 92, 255, 0.75));
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

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

.kpi-card,
.panel,
.project-card,
.empty-state {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  overflow: hidden;
}

.kpi-card {
  min-height: 140px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card::after,
.panel::after,
.project-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 34%);
}

.kpi-card span {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.kpi-card strong {
  display: block;
  margin: 8px 0;
  font-size: 2.05rem;
  line-height: 1;
}

.gradient-card {
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.24), transparent 40%),
    linear-gradient(135deg, rgba(217, 92, 255, 0.95), rgba(47, 128, 237, 0.88));
}

.gradient-card span,
.gradient-card small,
.danger-card span,
.danger-card small {
  color: rgba(255, 255, 255, 0.8);
}

.danger-card {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.20), transparent 40%),
    linear-gradient(135deg, rgba(255, 77, 109, 0.9), rgba(217, 92, 255, 0.68));
}

.panel {
  padding: 22px;
  margin-bottom: 22px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 16px;
}

.section-heading p {
  margin: 6px 0 0;
  font-size: 0.92rem;
  line-height: 1.6;
}

.filters-grid {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(2, minmax(170px, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field span {
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text-main);
  background: var(--bg-field);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: color-mix(in srgb, var(--secondary), transparent 25%);
  box-shadow: 0 0 0 4px rgba(0, 229, 255, 0.10);
}

select option {
  color: #111827;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.chart-card {
  min-height: 330px;
}

.chart-card canvas {
  position: relative;
  z-index: 1;
  max-height: 250px;
}

.chart-fallback {
  display: none;
  position: relative;
  z-index: 2;
  margin: 20px 0 0;
  color: var(--text-muted);
  line-height: 1.7;
}

.no-chart .chart-fallback {
  display: block;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.project-card {
  padding: 20px;
}

.project-card > * {
  position: relative;
  z-index: 1;
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.project-card h3 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.project-description {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
  min-height: 44px;
}

.pill,
.status-pill,
.priority-pill,
.risk-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
  border: 1px solid var(--border);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.status-in-progress,
.status-done,
.status-completed {
  color: var(--success);
  background: rgba(0, 245, 160, 0.10);
  border-color: rgba(0, 245, 160, 0.26);
}

.status-delayed,
.risk-high,
.priority-critical {
  color: var(--danger);
  background: rgba(255, 77, 109, 0.10);
  border-color: rgba(255, 77, 109, 0.28);
}

.status-on-hold,
.status-not-started,
.priority-medium,
.risk-medium {
  color: var(--warning);
  background: rgba(255, 204, 0, 0.10);
  border-color: rgba(255, 204, 0, 0.26);
}

.priority-high {
  color: var(--primary);
  background: rgba(217, 92, 255, 0.10);
  border-color: rgba(217, 92, 255, 0.28);
}

.priority-low,
.risk-low {
  color: var(--secondary);
  background: rgba(0, 229, 255, 0.10);
  border-color: rgba(0, 229, 255, 0.24);
}

.project-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.meta-item {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
}

.meta-item span {
  display: block;
  color: var(--text-muted);
  font-size: 0.77rem;
  margin-bottom: 6px;
}

.meta-item strong {
  font-size: 0.92rem;
  word-break: break-word;
}

.progress-row {
  margin: 18px 0;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-weight: 800;
  font-size: 0.86rem;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.35);
}

.countdown-box {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(217, 92, 255, 0.12), rgba(0, 229, 255, 0.08));
  border: 1px solid var(--border);
}

.countdown-box span {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.countdown-box strong {
  font-size: 1.05rem;
}

.countdown-box.expired {
  background: rgba(255, 77, 109, 0.11);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 32px;
  text-align: center;
}

.empty-state p {
  color: var(--text-muted);
  margin: 10px 0 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.admin-grid.single-wide {
  grid-template-columns: 1fr;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.three-cols {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.form-actions {
  justify-content: flex-start;
  margin-top: 4px;
}

.tables-grid {
  display: grid;
  gap: 22px;
}

.table-wrap {
  overflow-x: auto;
  position: relative;
  z-index: 1;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

td {
  font-size: 0.9rem;
}

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

.table-action {
  min-height: 34px;
  padding: 0 10px;
  color: var(--text-main);
  background: var(--bg-field);
  border: 1px solid var(--border);
}

.table-action.edit {
  color: var(--secondary);
}

.table-action.delete {
  color: var(--danger);
}

.toast {
  position: fixed;
  inset-inline: 30px auto;
  bottom: 28px;
  z-index: 30;
  max-width: min(460px, calc(100% - 60px));
  padding: 14px 18px;
  color: #fff;
  background: linear-gradient(135deg, rgba(18, 24, 44, 0.96), rgba(47, 128, 237, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transform: translateY(120px);
  opacity: 0;
  transition: 0.25s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

html[dir="ltr"] .toast {
  inset-inline: auto 30px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1500px) {
  .kpi-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 230px;
  }

  .main-content {
    padding: 24px;
  }

  .charts-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-card {
    margin-top: 0;
  }

  .topbar,
  .section-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .kpi-grid,
  .small-kpis,
  .project-grid,
  .filters-grid,
  .form-grid,
  .form-grid.three-cols {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: span 1;
  }
}

@media (max-width: 540px) {
  .main-content,
  .sidebar {
    padding: 18px;
  }

  .kpi-card,
  .panel,
  .project-card {
    border-radius: 20px;
  }

  .project-meta {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2rem;
  }
}
