:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f6f8fc;
  --text: #171b2a;
  --muted: #6e7890;
  --line: #e6eaf2;
  --accent: #5551e8;
  --accent-dark: #413dc7;
  --amber: #b66a10;
  --blue: #496b9b;
  --rose: #a24f61;
  --green: #168668;
  --shadow: 0 16px 36px rgba(45, 55, 90, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 4%, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(135deg, #eef3ff 0%, #f8f7fb 52%, #f4eff8 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 48px);
  margin: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 30px 70px rgba(48, 58, 94, 0.13);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.card h3,
.section-heading h3 {
  margin: 0;
}

.brand h1 {
  font-size: 1.2rem;
}

.brand p,
.muted,
.eyebrow {
  color: var(--muted);
}

.brand p,
.eyebrow {
  font-size: 0.82rem;
}

.eyebrow {
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #eef1ff;
  color: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.topbar h2 {
  font-size: 1.7rem;
}

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

.search-input,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

.search-input {
  width: min(340px, 36vw);
  padding: 10px 12px;
}

.content {
  display: grid;
  gap: 22px;
  padding: 0;
  background: #fbfcff;
}

.content > .table-wrap,
.content > .capture-grid,
.content > .detail-layout,
.content > .stack,
.content > .card,
.content > .cards,
.content > .empty-state {
  margin: 26px 28px 40px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 22px;
}

.dashboard-frame {
  display: grid;
  min-height: calc(100vh - 145px);
  background: #fbfcff;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 40px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.dashboard-hero h3 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.dashboard-hero p {
  max-width: 740px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.stat-pill {
  display: grid;
  gap: 6px;
  padding: 18px 28px;
  border-right: 1px solid var(--line);
}

.stat-pill:last-child {
  border-right: 0;
}

.stat-pill span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.stat-pill strong {
  font-size: 1.28rem;
}

.dashboard-workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  min-height: 620px;
}

.dashboard-left-panel,
.dashboard-main-panel,
.dashboard-right-panel {
  padding: 28px 28px 36px;
}

.dashboard-left-panel,
.dashboard-main-panel {
  border-right: 1px solid var(--line);
}

.dashboard-left-panel,
.dashboard-right-panel {
  background: #ffffff;
}

.dashboard-main-panel {
  background: #fbfcff;
}

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

.panel-heading h3 {
  margin: 0;
  font-size: 1.08rem;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-heading > span {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #eef1ff;
  color: var(--accent);
  font-weight: 800;
}

.panel-heading.small {
  margin-bottom: 12px;
}

.focus-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  position: relative;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.focus-item.featured {
  padding-top: 0;
}

.focus-item h4,
.project-row h4,
.queue-item h4 {
  margin: 0;
  font-size: 0.98rem;
}

.focus-item p,
.project-row p,
.queue-item p {
  margin: 4px 0;
  color: var(--muted);
  line-height: 1.45;
}

.focus-item strong {
  display: block;
  margin-top: 8px;
  font-size: 0.92rem;
}

.focus-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eef1ff;
  color: var(--accent);
  font-weight: 800;
}

.focus-meta {
  grid-column: 2;
}

.project-list,
.queue-list {
  display: grid;
  gap: 12px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 28px rgba(45, 55, 90, 0.04);
}

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

.project-row-main h4,
.project-row-main p {
  max-width: 100%;
}

.project-row-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.queue-block {
  display: grid;
  gap: 10px;
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.queue-block:last-child {
  border-bottom: 0;
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid #edf0f6;
}

.queue-item:last-child {
  border-bottom: 0;
}

.stack {
  display: grid;
  gap: 14px;
}

.section {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h3 {
  font-size: 1rem;
}

.cards {
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.compact-card {
  box-shadow: none;
}

.card-row,
.actions-row,
.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-row {
  justify-content: space-between;
}

.card-title {
  display: grid;
  gap: 3px;
}

.card-title h3,
.card-title h4 {
  margin: 0;
}

.card-title h4 {
  font-size: 1rem;
}

.meta-row {
  color: var(--muted);
  font-size: 0.9rem;
}

.next-action {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8ece8;
  color: #39443d;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.high,
.badge.critical,
.badge.due-soon,
.badge.scope-risk,
.badge.revision-risk {
  background: #f7e4dd;
  color: var(--rose);
}

.badge.normal,
.badge.active,
.badge.delivery-ready {
  background: #e4efe8;
  color: var(--green);
}

.badge.waiting,
.badge.waiting-client,
.badge.follow-up-needed {
  background: #e5edf5;
  color: var(--blue);
}

.badge.low,
.badge.paused {
  background: #ece9df;
  color: var(--amber);
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  padding: 0 14px;
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.ghost-button {
  padding: 0 12px;
  background: white;
  color: var(--text);
  border-color: var(--line);
}

.ghost-button {
  background: transparent;
}

.text-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
}

.icon-button {
  width: 38px;
  background: white;
  border-color: var(--line);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
}

.detail-panel {
  display: grid;
  gap: 14px;
}

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

.key-value div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.key-value span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

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

.capture-box textarea,
.capture-editor {
  width: 100%;
  min-height: 220px;
  padding: 12px;
}

.capture-editor {
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  line-height: 1.5;
  white-space: pre-wrap;
  outline: none;
}

.capture-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 105, 92, 0.12);
}

.capture-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.template-list {
  display: grid;
  gap: 10px;
}

.template-button {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
}

.template-output {
  min-height: 120px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  white-space: pre-wrap;
}

.dialog {
  width: min(860px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(32, 40, 34, 0.35);
}

.dialog-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.dialog-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  color: var(--text);
  font-weight: 500;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.advanced {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.advanced summary {
  cursor: pointer;
  font-weight: 800;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    margin: 0;
    min-height: 100vh;
    border-radius: 0;
  }

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav-item {
    text-align: center;
  }

  .topbar,
  .dashboard-grid,
  .dashboard-workspace,
  .detail-layout,
  .capture-grid {
    grid-template-columns: 1fr;
  }

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

  .dashboard-hero {
    display: grid;
    padding: 24px;
  }

  .dashboard-left-panel,
  .dashboard-main-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    display: grid;
  }

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

  .search-input {
    width: 100%;
  }
}

@media (min-width: 981px) and (max-width: 1400px) {
  .dashboard-workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .dashboard-main-panel {
    border-right: 0;
  }

  .dashboard-right-panel {
    grid-column: 2;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding-top: 0;
    background: #fbfcff;
  }

  .queue-block {
    margin: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(45, 55, 90, 0.04);
  }

  .queue-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .dashboard-right-panel {
    grid-template-columns: 1fr;
  }

  .queue-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content,
  .topbar,
  .sidebar {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .form-grid,
  .key-value {
    grid-template-columns: 1fr;
  }

  .topbar-actions > * {
    width: 100%;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .stat-pill {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .project-row,
  .queue-item {
    grid-template-columns: 1fr;
  }

  .project-row-meta {
    justify-content: flex-start;
    white-space: normal;
  }
}
