:root {
  --bg: #f6f8f8;
  --panel: #ffffff;
  --panel-soft: #eef5f4;
  --ink: #172022;
  --muted: #657477;
  --line: #d9e3e2;
  --line-strong: #c2d0ce;
  --teal: #0e6670;
  --teal-dark: #0b4f57;
  --moss: #627a4f;
  --amber: #b9782e;
  --red: #a84b43;
  --shadow: 0 18px 52px rgba(18, 32, 34, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(14, 102, 112, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 102, 112, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

code {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

.app-root,
.app-shell {
  min-height: 100vh;
}

.boot-screen,
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand,
.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #15383d;
  color: #ffffff;
}

.brand strong,
.brand span,
.brand-row strong,
.brand-row span {
  display: block;
}

.brand span,
.brand-row span {
  color: #b7c8c6;
  font-size: 12px;
  margin-top: 2px;
}

.auth-card .brand-row span {
  color: var(--muted);
}

.auth-card h1 {
  margin: 26px 0 8px;
}

.form-stack,
.field-list {
  display: grid;
  gap: 12px;
}

.form-stack {
  margin-top: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 10px;
  resize: vertical;
}

textarea {
  line-height: 1.45;
}

.notice {
  margin-top: 14px;
  border: 1px solid #cfe1df;
  background: #f3faf9;
  border-radius: 6px;
  padding: 10px;
  color: var(--teal-dark);
}

.auth-links {
  margin-top: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 380px;
}

.sidebar {
  background: #10282c;
  color: #eef6f5;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.nav-item {
  border: 0;
  color: #cfe0de;
  background: transparent;
  text-align: left;
  padding: 12px 11px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
  background: #1d3b40;
  color: #ffffff;
}

.nav-icon {
  width: 22px;
  text-align: center;
  color: #99bbb8;
  font-size: 12px;
  font-weight: 800;
}

.sync-box {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 16px;
  color: #cfe0de;
  font-size: 12px;
  line-height: 1.4;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.section-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

h3 {
  font-size: 14px;
  margin-bottom: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button,
.icon-button,
.text-button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  padding: 0 13px;
  font-weight: 750;
  font-size: 13px;
}

.primary-button {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  padding: 0;
}

.icon-button {
  min-width: 42px;
  padding: 0 10px;
}

.content {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.kpi,
.panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi {
  padding: 14px;
  box-shadow: none;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  display: block;
  font-size: 25px;
  line-height: 1.1;
  margin-top: 9px;
}

.panel {
  padding: 15px;
  min-width: 0;
}

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

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.project-card,
.report-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
}

.project-card {
  display: grid;
  gap: 10px;
}

.project-card:hover {
  border-color: var(--teal);
}

.project-card strong,
.project-card span,
.project-card small {
  display: block;
}

.project-card span,
.project-card small,
.muted {
  color: var(--muted);
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.phase-tile {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfc;
}

.phase-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.phase-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.mini-list,
.report-stack,
.file-list {
  display: grid;
  gap: 8px;
}

.mini-list button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 10px;
  text-align: left;
}

.mini-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 800;
  text-align: left;
  background: var(--panel-soft);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: top;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 9px;
  white-space: nowrap;
  color: var(--muted);
  background: #fbfcfc;
  font-size: 12px;
}

.phase {
  color: var(--teal-dark);
  font-weight: 800;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  background: var(--moss);
}

.status-dot.risk {
  background: var(--red);
}

.detail-panel {
  border-radius: 0;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  box-shadow: none;
  padding: 22px 18px;
  overflow: auto;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.detail-title h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.detail-code,
.detail-empty {
  color: var(--muted);
  font-size: 13px;
}

.field-list {
  margin-bottom: 18px;
}

.linked-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.report-card p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.report-meta,
.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.report-toolbar {
  margin-top: 10px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.report-body {
  margin-top: 9px;
  font-size: 13px;
}

.report-body strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.report-body ul {
  margin: 0;
  padding-left: 18px;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.readable {
  max-width: 760px;
  line-height: 1.55;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}

.modal::backdrop {
  background: rgba(15, 27, 29, 0.42);
}

.modal-form {
  padding: 18px;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px 12px;
  }

  .brand div:not(.brand-mark),
  .sync-box {
    display: none;
  }

  .nav-item {
    justify-content: center;
    font-size: 0;
  }

  .nav-icon {
    font-size: 12px;
  }

  .detail-panel {
    grid-column: 2;
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
  }

  .brand {
    min-width: 52px;
  }

  .nav {
    display: flex;
  }

  .workspace {
    padding: 16px;
  }

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

  .dashboard-grid,
  .kpis,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    border-left: 0;
    padding: 16px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .icon-button {
    width: 100%;
  }
}
