:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #0f766e;
  --primary-dark: #0b5f58;
  --danger: #b42318;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #f3f5f7 60%, #eef1f4 100%);
  color: var(--text);
}

.container {
  width: min(1400px, 95vw);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, #ffffff 85%, #e2e8f0 15%);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .01em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.nav a {
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
}

.nav form {
  margin: 0;
}

.project-switcher {
  max-width: 260px;
  padding: .32rem .45rem;
  font-size: .86rem;
}

.btn-link {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.92rem;
}

.page {
  padding: 1.2rem 0 2.5rem;
}

.section-head {
  margin-bottom: 0.9rem;
}

h1, h2, h3, h4 {
  margin: 0 0 .4rem;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1.05rem;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 1rem;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .65rem;
}

.card-row:last-child {
  margin-bottom: 0;
}

.auth-card {
  width: min(460px, 95vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin: 2.5rem auto;
}

.stack {
  display: grid;
  gap: .6rem;
}

.grid-form {
  display: grid;
  gap: .55rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
}

.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .8rem;
}

.check-group.compact label {
  font-size: .84rem;
}

label {
  font-size: .83rem;
  color: #475467;
}

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

input, select, textarea {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: .45rem .55rem;
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 35%, white 65%);
  border-color: var(--primary);
}

.btn {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: .47rem .75rem;
  cursor: pointer;
  width: fit-content;
}

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

.btn-sm {
  padding: .36rem .58rem;
  font-size: .83rem;
}

.btn-secondary {
  background: #e8f3f2;
  color: #0f766e;
}

.btn-danger {
  background: var(--danger);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.table-scroll {
  overflow: auto;
}

.budget-table {
  min-width: 1080px;
}

.claim-lines-table {
  min-width: 1120px;
}

.compact-table th,
.compact-table td {
  padding: .38rem .35rem;
}

.attach-cell {
  min-width: 240px;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-width: 150px;
}

.actions-cell form {
  margin: 0;
}

.block {
  display: block;
}

.table th, .table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: .5rem .35rem;
  vertical-align: top;
}

.table th {
  color: #344054;
  font-size: .78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.flash-wrap {
  display: grid;
  gap: .45rem;
  margin-bottom: .8rem;
}

.flash {
  padding: .55rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: .87rem;
}

.flash-error {
  background: #fef3f2;
  border-color: #fecdca;
}

.flash-success {
  background: #ecfdf3;
  border-color: #abefc6;
}

.flash-warning {
  background: #fffaeb;
  border-color: #fedf89;
}

.flash-info {
  background: #eff8ff;
  border-color: #b2ddff;
}

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

.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem;
}

.kpi p {
  margin: .2rem 0;
  font-size: 1.25rem;
  font-weight: 680;
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #edf0f5;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-bottom: .9rem;
}

.project-menu {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: -.2rem 0 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
}

.project-menu-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #344054;
  background: #fff;
  padding: .42rem .65rem;
  text-decoration: none;
  font-size: .88rem;
}

.project-menu-link:hover {
  border-color: #99c8c4;
  color: var(--primary);
}

.project-menu-link.active {
  border-color: color-mix(in srgb, var(--primary) 55%, white 45%);
  background: #e8f3f2;
  color: var(--primary);
  font-weight: 650;
}

.activity-tree {
  display: grid;
  gap: .65rem;
}

.activity-node {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem;
  background: #fcfcfd;
}

.activity-form,
.activity-edit-form {
  margin: 0;
}

.activity-children {
  margin-top: .5rem;
  padding-left: .9rem;
  border-left: 2px solid #e9edf2;
  display: grid;
  gap: .5rem;
}

.cpv-picker {
  position: relative;
  display: grid;
  gap: .35rem;
}

.cpv-results {
  position: absolute;
  top: 2.35rem;
  left: 0;
  right: 0;
  z-index: 10;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 30px rgb(15 23 42 / 12%);
}

.cpv-results button,
.cpv-empty {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #eef1f4;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: .45rem .55rem;
  text-align: left;
  font-size: .82rem;
}

.cpv-results button:hover {
  background: #f8fafc;
}

.cpv-results button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.cpv-selected,
.cpv-static-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.cpv-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid #b6d8d5;
  border-radius: 999px;
  background: #eff8f7;
  color: #0b5f58;
  padding: .2rem .45rem;
  font-size: .78rem;
  line-height: 1.2;
}

.cpv-chip.static {
  color: #344054;
  border-color: var(--line);
  background: #f8fafc;
}

.chip-remove {
  border: 0;
  border-radius: 999px;
  background: #d9eeec;
  color: #0b5f58;
  cursor: pointer;
  padding: 0 .28rem;
  line-height: 1.2;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.map {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kanban {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.kanban-col {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem;
}

.kanban-col header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .4rem;
}

.badge {
  background: #f2f4f7;
  border-radius: 999px;
  padding: .1rem .5rem;
  font-size: .78rem;
}

.badge-danger {
  color: #912018;
  background: #fef3f2;
}

.kanban-items {
  display: grid;
  gap: .55rem;
}

.kanban-card {
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  background: #fcfdff;
  padding: .55rem;
}

.kanban-card h4 {
  margin-bottom: .2rem;
  font-size: .93rem;
}

.status-history {
  margin-top: .45rem;
  font-size: .78rem;
  color: var(--muted);
}

.status-history summary {
  cursor: pointer;
}

.status-history ul {
  margin: .35rem 0 0;
  padding-left: 1rem;
}

.timesheet-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timesheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  margin-bottom: .65rem;
}

.timesheet-toolbar form {
  margin: 0;
}

.table-timesheet th,
.table-timesheet td {
  white-space: nowrap;
  padding: .25rem;
  text-align: center;
}

.table-timesheet .sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  text-align: left;
  min-width: 190px;
  font-size: .82rem;
}

.hours-input {
  width: 58px;
  padding: .2rem .25rem;
  text-align: center;
  font-size: .8rem;
}

.timesheet-cell {
  display: grid;
  gap: .25rem;
  width: 132px;
}

.work-notes-input {
  width: 132px;
  min-height: 42px;
  resize: vertical;
  white-space: normal;
  font-size: .75rem;
  line-height: 1.2;
  padding: .25rem .3rem;
}

.day-total-row td {
  background: #f8fafc;
}

.plain-list {
  margin: 0;
  padding-left: 1.1rem;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .65rem;
}

.report-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcfd;
  padding: .7rem;
}

.compact-top {
  margin-top: .55rem;
}

.compact-bottom {
  margin-bottom: .55rem;
}

.footer {
  padding: .8rem 0 1.4rem;
  color: #667085;
}

@media (max-width: 980px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
  }

  .table {
    font-size: .82rem;
  }
}
