:root {
  --bg-0: #050714;
  --bg-1: #0a0e25;
  --bg-2: #101638;
  --panel: #191d3f;
  --panel-2: #212650;
  --line: #363d75;
  --text: #ecf1ff;
  --muted: #a8b0d6;
  --accent: #3ca8ff;
  --accent-2: #5f7cff;
  --ok: #30ba64;
  --warn: #ffb300;
  --danger: #ff5f5f;
  --shadow: 0 18px 46px rgba(1, 4, 14, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "SF Pro Text", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 460px at 28% -8%, rgba(74, 117, 255, 0.16) 0%, transparent 60%),
    radial-gradient(700px 420px at 86% 8%, rgba(60, 168, 255, 0.12) 0%, transparent 64%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 50%, var(--bg-2) 100%);
  padding: 0.7rem;
}

.bg-orb {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 0.6rem;
  min-height: calc(100vh - 1.4rem);
}

.left-nav {
  border: 1px solid #252b57;
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #12173a 0%, #0d1331 100%);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.55rem;
  display: grid;
  align-content: start;
  gap: 0.36rem;
  min-height: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.nav-workspace {
  margin: 0 0 0.22rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.nav-pill,
.nav-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 0.46rem;
  padding: 0.34rem 0.4rem;
  text-align: left;
  cursor: pointer;
}

.nav-pill {
  background: #2a2f62;
}

.nav-item {
  color: #d3daf7;
}

.nav-item.active,
.nav-pill.active {
  border-color: #4c5cc0;
  background: #313875;
}

.nav-search {
  border: 1px solid #2f376d;
  border-radius: 0.46rem;
  padding: 0.34rem 0.42rem;
  background: #151b41;
  color: var(--text);
}

.nav-section {
  margin-top: 0.2rem;
  display: grid;
  gap: 0.2rem;
  min-height: 0;
}

.nav-section p {
  margin: 0.12rem 0;
  font-size: 0.73rem;
  color: var(--muted);
}

.nav-projects {
  height: calc(100vh - 120px);
}

.workspace-main {
  min-width: 0;
}

.topbar {
  border: 1px solid #262d5f;
  border-radius: 0.8rem;
  background: linear-gradient(180deg, #12163a 0%, #101436 100%);
  box-shadow: var(--shadow);
  padding: 0.62rem 0.74rem;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 0.58rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0.08rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h2,
h3 {
  margin: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.top-actions-utility {
  color: var(--muted);
  font-size: 0.78rem;
}

.util-link {
  border: 1px solid #2c3469;
  border-radius: 999px;
  padding: 0.19rem 0.45rem;
}

.layout {
  display: block;
}

.panel {
  border: 1px solid #2a336b;
  border-radius: 0.8rem;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  box-shadow: var(--shadow);
  padding: 0.6rem;
}

.surface {
  border: 1px solid #2a336b;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.panel-head h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid #3a4484;
  border-radius: 0.5rem;
  padding: 0.34rem 0.46rem;
  background: #171d45;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #8f9acb;
}

.card-list {
  display: grid;
  gap: 0.26rem;
  max-height: calc(100vh - 216px);
  overflow: auto;
  padding-right: 0.08rem;
}

.nav-project-list {
  max-height: calc(100vh - 190px);
  gap: 0.2rem;
}

.project-card {
  border: 1px solid #33407e;
  border-radius: 0.62rem;
  background: #2c325f;
  padding: 0.36rem 0.44rem;
  cursor: pointer;
  transition: border-color 0.18s ease;
}

.project-card:hover {
  border-color: #4f66ce;
}

.project-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(60, 168, 255, 0.45);
}

.project-row,
.meta-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
}

.nav-project-list .project-card {
  padding: 0.28rem 0.34rem;
}

.nav-project-list .project-card strong {
  font-size: 0.82rem;
}

.nav-project-list .muted {
  font-size: 0.75rem;
}

.nav-project-list .meta-row {
  font-size: 0.72rem;
  gap: 0.2rem;
}

.meta-row {
  font-size: 0.79rem;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.badge {
  font-size: 0.69rem;
  border-radius: 0.4rem;
  padding: 0.1rem 0.34rem;
  border: 1px solid;
}

.badge.ontrack {
  color: #dff8e9;
  border-color: #2f905a;
  background: #227749;
}

.badge.risk {
  color: #fff2d6;
  border-color: #b87d16;
  background: #a66e0f;
}

.badge.delayed {
  color: #ffe3e3;
  border-color: #bc5050;
  background: #9f3e3e;
}

.kpi-grid {
  margin: 0.52rem 0 0.58rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 0.26rem;
}

.project-mini-kpi-grid {
  margin: 0.42rem 0 0.5rem;
  display: grid;
  grid-template-columns: repeat(8, minmax(74px, 1fr));
  gap: 0.22rem;
}

.kpi-card {
  border: 1px solid #364383;
  border-radius: 0.55rem;
  background: #2c335f;
  padding: 0.28rem 0.36rem;
}

.kpi-card p {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #9faddb;
}

.kpi-card strong {
  display: block;
  margin-top: 0.08rem;
  font-size: 1rem;
}

.kpi-card-secondary {
  opacity: 0.62;
}

.filter-kpi {
  cursor: pointer;
  user-select: none;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.filter-kpi:hover {
  border-color: #5c7ef7;
  transform: translateY(-1px);
}

.filter-kpi.active-filter {
  border-color: #56c7ff;
  box-shadow: inset 0 0 0 1px rgba(86, 199, 255, 0.45);
  background: #333e78;
}

.detail-panel {
  min-height: calc(100vh - 98px);
}

.detail-full-width {
  margin-top: 0.5rem;
}

.section-title {
  margin-top: 0.52rem;
  margin-bottom: 0.26rem;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9dabd8;
}

.section-title-subtle {
  opacity: 0.7;
}

.project-split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0.5rem;
  align-items: start;
}

.project-main-column {
  min-width: 0;
}

.weekly-due-panel {
  border: 1px solid #8fa5e6;
  border-radius: 0.56rem;
  background: #f7f9ff;
  padding: 0.34rem;
  position: sticky;
  top: 0.46rem;
}

.weekly-due-filter {
  display: grid;
  gap: 0.2rem;
  font-size: 0.74rem;
  color: #22315c;
}

.weekly-due-filter select {
  background: #ffffff;
  color: #1b2748;
  border: 1px solid #93a8e8;
}

.weekly-due-list {
  display: grid;
  gap: 0.22rem;
  margin-top: 0.3rem;
}

.weekly-level-heading {
  margin: 0.16rem 0 0.04rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2c3f77;
}

.weekly-due-item {
  text-align: left;
  border: 1px solid #9fb2eb;
  border-radius: 0.45rem;
  background: #ffffff;
  padding: 0.26rem 0.32rem;
  color: #182440;
}

.weekly-due-item:hover {
  border-color: #5f83e9;
  background: #eef3ff;
}

.weekly-due-item strong {
  display: block;
  font-size: 0.8rem;
  color: #152245;
}

.weekly-due-item .muted {
  margin-top: 0.08rem;
  font-size: 0.72rem;
  color: #4b5f93;
}

.task-level-heading {
  margin: 0.52rem 0 0.22rem;
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #041226;
  background: linear-gradient(180deg, #66d0ff 0%, #2eaef6 55%, #2295df 100%);
  border: 1px solid #7ee0ff;
  border-radius: 0.55rem;
  padding: 0.28rem 0.52rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 4px 12px rgba(24, 132, 210, 0.35);
  width: fit-content;
}

.activity-item {
  border: 1px solid #39478b;
  border-radius: 0.52rem;
  background: #2e3565;
  padding: 0.28rem 0.38rem;
  margin-bottom: 0.22rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.36rem;
  align-items: start;
}

.activity-item:hover {
  border-color: #5771df;
}

.activity-item.task-drop-active {
  border-color: #4dc0ff;
  box-shadow: inset 0 0 0 1px rgba(77, 192, 255, 0.45);
}

.activity-main {
  cursor: pointer;
}

.activity-main strong {
  font-size: 0.84rem;
}

.activity-main .muted {
  margin-top: 0.08rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.78rem;
}

.task-detail {
  display: none;
  margin-top: 0.19rem;
}

.activity-item.expanded .task-detail {
  display: block;
}

  .task-risk {
    margin: 0 0 0.2rem;
    font-size: 0.74rem;
  }

  .task-risk {
    font-weight: 700 !important;
  }

.task-attachments {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.24rem;
}

.task-updates {
  display: grid;
  gap: 0.18rem;
  margin-bottom: 0.28rem;
}

.task-update-list {
  display: grid;
  gap: 0.2rem;
}

.task-update-item {
  border: 1px solid #46539a;
  border-radius: 0.42rem;
  background: #252d5f;
  padding: 0.22rem 0.28rem;
}

.task-update-item p {
  margin: 0.08rem 0 0;
  font-size: 0.74rem;
}

.task-update-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.task-update-date {
  min-width: 96px;
}

.task-update-status {
  min-width: 90px;
}

.task-update-delay {
  min-width: 76px;
  text-align: center;
}

.task-update-risk,
.task-update-note {
  margin: 0.1rem 0 0;
}

.task-update-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  gap: 0.28rem;
}

.attachment-item {
  border: 1px solid #46529b;
  border-radius: 0.45rem;
  padding: 0.21rem 0.3rem;
  background: #252c5a;
}

.attachment-item a {
  color: #9cd3ff;
  text-decoration: none;
  font-size: 0.74rem;
}

.attachment-meta {
  margin-top: 0.1rem;
  color: #95a5d8;
  font-size: 0.66rem;
}

.attachment-preview {
  margin-top: 0.18rem;
  max-width: 170px;
  max-height: 110px;
  border-radius: 0.35rem;
  border: 1px solid #4d5ca7;
  display: block;
  object-fit: cover;
}

.activity-actions {
  display: flex;
  align-items: center;
}

.project-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.add-task-toggle {
  margin-top: 0.45rem;
  width: 100%;
}

.add-task-panel {
  display: none;
}

.add-task-panel.open {
  display: block;
}

.add-task-form {
  margin-top: 0.16rem;
}

.print-footer {
  display: none;
}

button {
  border: 0;
  border-radius: 0.5rem;
  padding: 0.24rem 0.48rem;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, #38b4ff 0%, #2496ec 100%);
  color: #051224;
  font-weight: 700;
}

.btn-secondary,
.toggle-btn,
#cancelDialog,
#cancelEditProjectDialog,
#cancelResourceDialog,
.remove-file-btn,
#closeAttachmentViewer,
.hero-tag {
  background: #2e396f;
  color: #dce5ff;
  border: 1px solid #44539d;
}

.toggle-btn {
  min-width: 84px;
}

.resource-list {
  display: grid;
  gap: 0.2rem;
}

.resource-item {
  border: 1px solid #3a4788;
  border-radius: 0.48rem;
  background: #2d3464;
  padding: 0.26rem 0.34rem;
}

.resource-item strong {
  display: block;
  font-size: 0.82rem;
}

.project-number-input {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.3rem;
}

.project-prefix {
  border: 1px solid #3a4484;
  border-radius: 0.44rem;
  background: #171d45;
  color: #9eabd7;
  padding: 0.33rem 0.45rem;
  font-weight: 600;
}

.resource-type {
  border: 1px solid #3a4484;
  border-radius: 0.5rem;
  padding: 0.34rem 0.46rem;
  margin: 0;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.18rem;
}

.radio-row input {
  width: auto;
}

.dialog-form {
  display: grid;
  gap: 0.34rem;
  padding: 0.7rem;
}

.task-update-form {
  border-top: 1px solid #3c498f;
  padding-top: 0.24rem;
  display: grid;
  gap: 0.24rem;
}

dialog {
  border: 1px solid #32407d;
  border-radius: 0.7rem;
  width: min(560px, 92vw);
  padding: 0;
  color: var(--text);
  background: #1a224c;
  box-shadow: 0 35px 80px rgba(2, 4, 12, 0.7);
}

menu {
  margin: 0.08rem 0 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.34rem;
}

.attachment-dropzone {
  border: 1px dashed #4f5eb0;
  border-radius: 0.48rem;
  background: #232b5a;
  padding: 0.28rem 0.38rem;
  cursor: pointer;
}

.attachment-dropzone p {
  margin: 0;
  font-size: 0.73rem;
  color: #9eabd7;
}

.attachment-dropzone input[type="file"] {
  display: none;
}

.attachment-dropzone.drag-active {
  border-color: #56c7ff;
  background: #2b3d72;
}

.selected-file-list {
  display: grid;
  gap: 0.18rem;
}

.selected-file-item {
  border: 1px solid #46539a;
  border-radius: 0.4rem;
  background: #2a3262;
  padding: 0.19rem 0.28rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.26rem;
  font-size: 0.72rem;
  color: #bcc8ea;
}

#attachmentViewer {
  width: min(96vw, 1200px);
  height: min(92vh, 860px);
  padding: 0;
  grid-template-rows: auto 1fr;
  background: #0f1532;
}

#attachmentViewer[open] {
  display: grid;
}

#resourcesDialog {
  width: min(720px, 94vw);
  padding: 0;
}

.resources-dialog-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
}

.resources-dialog-body {
  padding: 0.48rem;
  display: grid;
  gap: 0.45rem;
}

.resources-dialog-actions {
  display: flex;
  justify-content: flex-end;
}

#attachmentViewer::backdrop {
  background: rgba(0, 2, 9, 0.72);
}

.attachment-viewer-head {
  padding: 0.4rem 0.58rem;
  border-bottom: 1px solid #2f3b79;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.attachment-viewer-body {
  padding: 0.34rem;
  min-height: 0;
}

.attachment-viewer-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.attachment-viewer-frame {
  width: 100%;
  height: 100%;
  border: 1px solid #2f3b79;
  border-radius: 0.4rem;
  background: #fff;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .left-nav {
    display: none;
  }

  .layout {
    display: block;
  }

  .detail-panel {
    min-height: unset;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(92px, 1fr));
  }

  .project-mini-kpi-grid {
    grid-template-columns: repeat(4, minmax(80px, 1fr));
  }

  .task-update-grid {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }

  .card-list {
    max-height: none;
  }

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

  .weekly-due-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  body {
    padding: 0.45rem;
  }

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

  .top-actions,
  .top-actions-utility {
    flex-wrap: wrap;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(100px, 1fr));
  }

  .project-mini-kpi-grid {
    grid-template-columns: repeat(3, minmax(82px, 1fr));
  }

  .task-update-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
  }

  .left-nav,
  .topbar,
  .kpi-grid,
  #activityForm,
  .activity-actions,
  .project-actions,
  .task-update-form,
  .add-task-toggle {
    display: none !important;
  }

  .app-shell,
  .workspace-main,
  .layout,
  .dashboard-col {
    display: block !important;
    min-height: auto !important;
  }

  .panel,
  .surface,
  .detail-panel,
  .detail-full-width {
    background: #fff !important;
    border: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #projectDetail,
  #projectDetail * {
    color: #000 !important;
  }

  .section-title {
    margin-top: 0.5rem;
    margin-bottom: 0.2rem;
  }

  .activity-item {
    border: 1px solid #aaa !important;
    background: #fff !important;
    break-inside: auto;
    page-break-inside: auto;
  }

  .activity-main .muted {
    white-space: normal !important;
    overflow: visible !important;
  }

  .task-detail {
    display: block !important;
  }

  .attachment-item {
    border: 1px solid #ccc !important;
    background: #fff !important;
  }

  .task-update-list {
    display: table !important;
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.15rem;
  }

  .task-update-list::before {
    content: "Date    Status    Delay    Risk    Summary";
    display: block;
    font-weight: 700;
    border-bottom: 1px solid #777;
    padding: 0.08rem 0;
    margin-bottom: 0.08rem;
    white-space: pre;
  }

  .task-update-item {
    display: grid !important;
    grid-template-columns: 120px 110px 90px 1fr;
    gap: 0.3rem 0.45rem;
    border: 1px solid #d0d0d0 !important;
    background: #fff !important;
    padding: 0.12rem 0.18rem !important;
    margin-bottom: 0.1rem;
  }

  .task-update-head {
    display: contents !important;
  }

  .task-update-date {
    grid-column: 1;
  }

  .task-update-status {
    grid-column: 2;
    color: #000 !important;
  }

  .task-update-delay {
    grid-column: 3;
    border: 1px solid #777 !important;
    background: transparent !important;
    color: #000 !important;
    border-radius: 0.2rem !important;
    padding: 0.02rem 0.14rem !important;
    display: inline-block;
    width: fit-content;
  }

  .task-update-risk {
    grid-column: 4;
    font-weight: 700;
    margin: 0 !important;
  }

  .task-update-note {
    grid-column: 1 / -1;
    margin: 0 !important;
  }

  .attachment-preview {
    max-width: 220px;
    max-height: 160px;
  }

  .attachment-preview {
    display: none !important;
  }

  .badge {
    border: 1px solid #777 !important;
    background: transparent !important;
    color: #000 !important;
  }

  .print-footer {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0.2cm;
    justify-content: space-between;
    font-size: 10pt;
    color: #000 !important;
    padding: 0 0.5cm;
  }

  .print-page::after {
    content: counter(page);
  }
}
