:root {
  --ink: #1c1f26;
  --muted: #6b7280;
  --border: #e5e7ec;
  --accent: #e27e3a;
  --accent-ink: #ffffff;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --won: #1a7f37;
  --lost: #b42318;
  --claim: #b45309;
  --claim-bg: #fff8ec;
  --radius: 10px;
  --sidebar-collapsed: 64px;
  --sidebar-expanded: 250px;
  --font-display: "Poppins", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-collapsed);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 50;
  transition: width 0.18s ease, box-shadow 0.18s ease;
}

.sidebar:hover {
  width: var(--sidebar-expanded);
  box-shadow: 6px 0 24px rgba(20, 22, 30, 0.1);
}

.sidebar-peek {
  position: absolute;
  top: 28px;
  left: 0;
  width: var(--sidebar-collapsed);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 0.15s ease;
}

.sidebar:hover .sidebar-peek {
  opacity: 0;
  pointer-events: none;
}

.sidebar-inner {
  width: var(--sidebar-expanded);
  height: 100%;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.sidebar:hover .sidebar-inner {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-field label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-field select {
  width: 100%;
}

/* ---------- Main layout ---------- */

.main {
  margin-left: var(--sidebar-collapsed);
}

.topbar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 26px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.topbar .btn-primary {
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
}

.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}

.brand-sub {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 14px rgba(226, 126, 58, 0.32);
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }

.panel {
  margin: 22px 32px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 2px 10px rgba(20, 22, 30, 0.04);
}

.panel.hidden { display: none; }

#intakeForm {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input, select {
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
}

.field-actions {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.status-msg {
  font-size: 13px;
  color: var(--muted);
}

.load-status {
  display: block;
  margin: 16px 32px 0;
}

.table-wrap {
  margin: 20px 32px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: 0 2px 10px rgba(20, 22, 30, 0.04);
}

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

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover { color: var(--ink); }

th.sortable::after {
  content: "";
  display: inline-block;
  width: 10px;
  margin-left: 4px;
}

th.sort-asc::after { content: "▲"; font-size: 9px; }
th.sort-desc::after { content: "▼"; font-size: 9px; }

th.sort-asc, th.sort-desc { color: var(--accent); }

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover { background: #fafbfc; }

.project-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.project-link:hover { text-decoration: underline; }

tr.row-unassigned { background: var(--claim-bg); }
tr.row-unassigned:hover { background: #fef1dc; }

td select, td input {
  font-size: 13px;
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

td input[type="number"] { width: 100px; }

.select-claim {
  border: 1px solid var(--claim);
  color: var(--claim);
  font-weight: 600;
}

.badge-unassigned {
  margin-left: 8px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--claim);
}

.status-won { color: var(--won); font-weight: 600; }
.status-lost { color: var(--lost); font-weight: 600; }

.job-number {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------- Project files modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden { display: none; }

.files-modal {
  width: min(520px, 90vw);
  max-height: 80vh;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(20, 22, 30, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.files-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.files-modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.files-breadcrumb {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.crumb-link {
  cursor: pointer;
  color: var(--accent);
}

.crumb-link:hover { text-decoration: underline; }

.btn-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
}

.btn-close:hover { color: var(--ink); }

.files-list {
  overflow-y: auto;
  padding: 8px;
}

.files-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.files-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.files-item:hover { background: var(--bg); }

.files-item-inert {
  cursor: default;
  opacity: 0.5;
}

.files-item-inert:hover { background: transparent; }

.files-item-icon { font-size: 18px; }

.files-item-name { font-size: 14px; }
