:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --brand: #156e75;
  --brand-2: #243b53;
  --accent: #b54708;
  --good: #137333;
  --warn: #b54708;
  --bad: #b42318;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 228px minmax(680px, 1fr) 420px;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

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

button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

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

.secondary {
  background: white;
  border-color: var(--line);
  color: var(--brand-2);
  padding: 0 12px;
}

.sidebar {
  min-height: 100vh;
  background: #12232f;
  color: white;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #f6c453;
  color: #12232f;
  border-radius: 6px;
  font-weight: 800;
}

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

.brand span {
  color: #b8c4ce;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 9px;
  color: #dbe5ec;
  background: transparent;
  border-color: transparent;
  text-align: left;
  padding: 0 10px;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 6px;
  color: #cbd5df;
  font-size: 12px;
}

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

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

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

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 170px 150px;
  gap: 8px;
  margin-bottom: 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

.search input {
  border: 0;
  outline: 0;
  min-height: 38px;
  width: 100%;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  min-height: 38px;
  padding: 7px 9px;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.table-wrap {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  height: calc(100vh - 236px);
  min-height: 360px;
  scrollbar-gutter: stable;
}

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

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

th {
  position: sticky;
  top: 0;
  background: #eef2f5;
  color: #344054;
  font-size: 12px;
  z-index: 2;
  box-shadow: inset 0 -1px 0 var(--line);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #f0f8f8;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  background: #e7f5f3;
  color: var(--brand);
  white-space: nowrap;
}

.status.won {
  background: #e8f5e9;
  color: var(--good);
}

.status.lost,
.status.cancelled {
  background: #fdecec;
  color: var(--bad);
}

.status.need {
  background: #fff4e5;
  color: var(--warn);
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

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

.detail-panel {
  min-height: 100vh;
  background: white;
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  color: var(--muted);
  gap: 8px;
}

.empty-state strong {
  color: var(--ink);
}

.detail-head {
  display: grid;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-head h2 {
  line-height: 1.25;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.field-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.field {
  display: grid;
  gap: 4px;
}

.field span,
.panel-block h3,
.source-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field strong {
  font-weight: 700;
}

.panel-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.panel-block h3 {
  margin: 0 0 10px;
}

.doc-upload {
  display: grid;
  gap: 8px;
}

.document-list,
.cost-list,
.checklist,
.source-list,
.schedule-list {
  display: grid;
  gap: 8px;
}

.doc-item,
.cost-item,
.check-item,
.source-card,
.schedule-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.doc-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.doc-item a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.county-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.cost-item {
  display: grid;
  grid-template-columns: 1fr 64px 54px 86px;
  gap: 6px;
  align-items: center;
}

.cost-total {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 800;
  margin-top: 10px;
}

.inline-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.source-card {
  background: white;
}

.source-card strong,
.source-card a {
  display: block;
}

.source-card a {
  color: var(--brand);
  margin-top: 6px;
}

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

dialog::backdrop {
  background: rgba(18, 35, 47, 0.36);
}

dialog header,
dialog footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

dialog header {
  margin-bottom: 14px;
}

dialog footer {
  margin-top: 14px;
}

#closeDialogBtn {
  width: 36px;
  background: white;
  border-color: var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

label.full {
  margin-top: 10px;
}

#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #12232f;
  color: white;
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

#toast.visible {
  opacity: 1;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(18, 35, 47, 0.82);
  z-index: 20;
  padding: 18px;
}

.login-screen.active {
  display: grid;
}

.login-box {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  background: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-box .brand-mark {
  margin-bottom: 4px;
}

.login-box h2 {
  margin-bottom: 4px;
}

#loginError {
  color: var(--bad);
  min-height: 18px;
  font-size: 13px;
}

@media (max-width: 1180px) {
  body {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 10px;
  }

  .brand div,
  .nav-button span,
  .sidebar-foot {
    display: none;
  }

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

@media (max-width: 760px) {
  body {
    display: block;
  }

  .sidebar {
    min-height: auto;
    flex-direction: row;
    align-items: center;
  }

  nav {
    grid-auto-flow: column;
    margin-left: auto;
  }

  .app-shell {
    padding: 14px;
  }

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

  .metrics,
  .toolbar,
  .form-grid,
  .field-stack {
    grid-template-columns: 1fr;
  }
}
