/* Fulford Forge — shared design tokens + components (main SPA + library can align) */
:root {
  --forge-bg: #ece2d2;
  --forge-raised: #f3ecdd;
  --forge-surface: #faf4e9;
  --forge-border: #e3d9c5;
  --forge-accent: #b56a31;
  --forge-accent-2: #c8824a;
  --forge-ink: #2f2a22;
  --forge-primary: #3a342b;
  --forge-secondary: #6b6253;
  --forge-tertiary: #948a78;
  --forge-danger: #c4493d;
  --forge-success: #4e7d3f;
  --forge-warn: #b07a1f;
  --forge-shadow-card: 0 1px 3px 0 rgba(60, 45, 25, 0.1), 0 1px 2px 0 rgba(60, 45, 25, 0.06);
  --forge-shadow-lg: 0 16px 40px -8px rgba(60, 45, 25, 0.22);
  --forge-font-display: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --forge-font-body: Inter, system-ui, sans-serif;
  --forge-font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
  --forge-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  transition-timing-function: var(--forge-ease);
}

body.forge-body {
  font-family: var(--forge-font-body);
  color: var(--forge-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  background-color: var(--forge-bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(181, 101, 49, 0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(154, 107, 63, 0.05), transparent 55%),
    linear-gradient(180deg, rgba(236, 226, 210, 0.94), rgba(228, 217, 198, 0.97)),
    url("/fulford-bg.jpg");
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  background-position: center, center, center, center;
  background-size: cover, cover, cover, cover;
  background-attachment: fixed, fixed, fixed, fixed;
}

.font-display {
  font-family: var(--forge-font-display);
  letter-spacing: -0.02em;
}

.font-doto {
  font-family: var(--forge-font-body);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.modal-backdrop {
  background: rgba(48, 38, 26, 0.42);
  backdrop-filter: blur(4px);
}

.fade-in {
  animation: forgeFadeIn 0.15s var(--forge-ease);
}

@keyframes forgeFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-btn {
  font-family: var(--forge-font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--forge-secondary);
  transition: all 0.15s;
  padding: 9px 12px;
  position: relative;
  text-align: left;
  width: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--forge-ink);
  background: rgba(181, 101, 49, 0.08);
}

.tab-active {
  color: var(--forge-ink) !important;
  font-weight: 600;
  background: rgba(181, 101, 49, 0.12);
}

.tab-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--forge-accent);
  border-radius: 2px;
}

.status-pill {
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--forge-font-body);
  font-size: 11px;
  font-weight: 500;
}

.priority-high {
  color: var(--forge-danger);
}
.priority-medium {
  color: var(--forge-warn);
}
.priority-low {
  color: var(--forge-success);
}

.n-label {
  font-family: var(--forge-font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--forge-tertiary);
}

.prose h1 {
  font-family: var(--forge-font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  color: var(--forge-ink);
}
.prose h2 {
  font-family: var(--forge-font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  color: var(--forge-ink);
}
.prose h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1rem 0 0.35rem;
  color: var(--forge-primary);
}
.prose p {
  margin: 0.5rem 0;
  line-height: 1.65;
  color: var(--forge-primary);
}
.prose ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}
.prose ol {
  list-style: decimal;
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}
.prose li {
  margin: 0.25rem 0;
  color: var(--forge-primary);
}
.prose strong {
  font-weight: 600;
  color: var(--forge-ink);
}
.prose code {
  background: #efe6d4;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: #9a6b3f;
  font-family: var(--forge-font-mono);
}
.prose pre {
  background: #f3ece0;
  border: 1px solid var(--forge-border);
  color: var(--forge-primary);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.75rem 0;
}
.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.prose hr {
  border-top: 1px solid var(--forge-border);
  margin: 1.25rem 0;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  border: 1px solid var(--forge-border);
  border-radius: 6px;
  overflow: hidden;
}
.prose th,
.prose td {
  border-bottom: 1px solid var(--forge-border);
  padding: 0.6rem 0.8rem;
  text-align: left;
  font-size: 0.9rem;
  color: var(--forge-primary);
}
.prose th {
  background: #f0e7d6;
  font-weight: 600;
  color: var(--forge-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prose tr:last-child td {
  border-bottom: none;
}

.n-loading {
  font-family: var(--forge-font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--forge-secondary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.n-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--forge-border);
  border-top-color: var(--forge-accent);
  border-radius: 50%;
  animation: forgeSpin 0.7s linear infinite;
}
@keyframes forgeSpin {
  to {
    transform: rotate(360deg);
  }
}

body.forge-body input,
body.forge-body select,
body.forge-body textarea {
  background: #fffdf8 !important;
  border: 1px solid #e0d6c2 !important;
  color: var(--forge-primary) !important;
  border-radius: 6px !important;
  font-family: var(--forge-font-body) !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}
body.forge-body select option {
  background: #fffdf8;
  color: var(--forge-primary);
}
body.forge-body input:focus,
body.forge-body select:focus,
body.forge-body textarea:focus {
  border-color: var(--forge-accent) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(181, 101, 49, 0.18) !important;
}
body.forge-body input::placeholder,
body.forge-body textarea::placeholder {
  color: #a99e8a !important;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d2c6b0;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #c0b39a;
}

.btn-pill {
  border-radius: 6px;
  font-family: var(--forge-font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  letter-spacing: 0;
  transition: all 0.15s;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-pill.bg-nc {
  background: var(--forge-accent);
  color: #fff;
}
.btn-pill.bg-nc:hover {
  background: #c2763a;
}
.btn-pill.bg-ng {
  background: var(--forge-success);
  color: #fff;
}
.btn-pill.bg-ng:hover {
  background: #5c9149;
}
.btn-pill.bg-nr {
  background: var(--forge-danger);
  color: #fff;
}
.btn-pill.bg-nr:hover {
  background: #d0584b;
}
.btn-pill.bg-white {
  background: var(--forge-surface);
  color: var(--forge-primary);
  border-color: #e0d6c2;
}
.btn-pill.bg-white:hover {
  background: #f3ece0;
  border-color: #d8cdb8;
}

.btn-ghost {
  background: transparent;
  border: 1px solid #e0d6c2;
  color: var(--forge-secondary);
  border-radius: 6px;
  font-family: var(--forge-font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  transition: all 0.15s;
  cursor: pointer;
}
.btn-ghost:hover {
  border-color: #c0b39a;
  color: var(--forge-ink);
  background: rgba(154, 107, 63, 0.07);
}
.btn-ghost.text-nr:hover {
  color: var(--forge-danger);
  border-color: #e0b3ac;
  background: rgba(196, 73, 61, 0.08);
}

.n-card-radius {
  border-radius: 10px;
  box-shadow: var(--forge-shadow-card);
}
.n-modal-radius {
  border-radius: 14px;
  box-shadow: var(--forge-shadow-lg);
}

[data-action="toggle"]:hover {
  background: rgba(154, 107, 63, 0.05);
}

.status-pill.bg-tag-green {
  background: #e4eede;
  color: #3f6b3f;
}
.status-pill.bg-tag-yellow {
  background: #f1e8d4;
  color: #8a6a1a;
}
.status-pill.bg-tag-red {
  background: #f4ded8;
  color: #a8453a;
}
.status-pill.bg-tag-blue {
  background: #e2ecf4;
  color: #3a6a8a;
}

#sidebar {
  background: #f3ece0;
  border-right: 1px solid var(--forge-border);
}
@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(60, 45, 25, 0.25);
  }
  #sidebar-backdrop.open {
    display: block;
  }
}

/* Job cards */
.job-card {
  position: relative;
  overflow: hidden;
  background: var(--forge-raised);
  border: 1px solid var(--forge-border);
  border-radius: 10px;
  box-shadow: var(--forge-shadow-card);
}
.job-card-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}
.job-card-stripe.p-high {
  background: var(--forge-danger);
}
.job-card-stripe.p-medium {
  background: var(--forge-warn);
}
.job-card-stripe.p-low {
  background: var(--forge-success);
}
.job-card-stripe.unrealistic {
  background: var(--forge-tertiary);
  opacity: 0.55;
}
.job-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--forge-border);
  background: var(--forge-surface);
  flex-shrink: 0;
}
.job-thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px dashed #d8cdb8;
  background: var(--forge-surface);
  color: var(--forge-tertiary);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.job-actions-secondary {
  opacity: 0.55;
  transition: opacity 0.15s;
}
.job-card:hover .job-actions-secondary,
.job-card:focus-within .job-actions-secondary {
  opacity: 1;
}
.job-actions-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

/* Dashboard sections */
.dash-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.dash-section-title {
  font-family: var(--forge-font-display);
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--forge-ink);
  margin: 0;
}
.dash-visit {
  margin-bottom: 1.75rem;
}
.dash-conditions {
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--forge-border);
  border-radius: 12px;
  background: rgba(250, 244, 233, 0.72);
  box-shadow: var(--forge-shadow-card);
}
.dash-conditions > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}
.dash-conditions > summary::-webkit-details-marker {
  display: none;
}
.dash-conditions > summary .chev {
  color: var(--forge-tertiary);
  transition: transform 0.15s;
  font-size: 12px;
}
.dash-conditions[open] > summary .chev {
  transform: rotate(90deg);
}
.dash-conditions-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--forge-border);
  padding-top: 14px;
}
.dash-conditions-hint {
  font-size: 12px;
  color: var(--forge-secondary);
}

/* Toast + dialog */
#toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--forge-surface);
  border: 1px solid var(--forge-border);
  border-left: 4px solid var(--forge-accent);
  color: var(--forge-primary);
  border-radius: 10px;
  box-shadow: var(--forge-shadow-lg);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
  animation: forgeFadeIn 0.18s var(--forge-ease);
}
.toast.toast-error {
  border-left-color: var(--forge-danger);
}
.toast.toast-success {
  border-left-color: var(--forge-success);
}
.toast.toast-warn {
  border-left-color: var(--forge-warn);
}
.toast-title {
  font-weight: 600;
  color: var(--forge-ink);
  margin-bottom: 2px;
}

#dialog-root.hidden {
  display: none;
}
#dialog-root {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.dialog-panel {
  background: var(--forge-raised);
  border: 1px solid var(--forge-border);
  border-radius: 14px;
  box-shadow: var(--forge-shadow-lg);
  width: min(420px, 100%);
  padding: 20px;
  animation: forgeFadeIn 0.15s var(--forge-ease);
}
.dialog-title {
  font-family: var(--forge-font-display);
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--forge-ink);
  margin: 0 0 8px;
}
.dialog-body {
  font-size: 14px;
  color: var(--forge-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Expense barometer */
.budget-stack {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e8dfcf;
  border: 1px solid var(--forge-border);
  gap: 2px;
}
.budget-seg {
  min-width: 4px;
  transition: flex 0.2s var(--forge-ease);
}
.budget-seg-plan {
  background: linear-gradient(90deg, #b56a31, #c8824a);
}
.budget-seg-asp {
  background: repeating-linear-gradient(
    -45deg,
    #c4b8a4,
    #c4b8a4 4px,
    #d6cbb8 4px,
    #d6cbb8 8px
  );
  opacity: 0.95;
}
.budget-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}
.budget-dot-plan {
  background: #b56a31;
}
.budget-dot-asp {
  background: #c4b8a4;
  background-image: repeating-linear-gradient(
    -45deg,
    #c4b8a4,
    #c4b8a4 2px,
    #d6cbb8 2px,
    #d6cbb8 4px
  );
}
.budget-drivers {
  border-top: 1px solid var(--forge-border);
  padding-top: 8px;
}

/* Municipal road progress on dashboard overview */
.road-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e8dfcf;
  border: 1px solid var(--forge-border);
  overflow: hidden;
}
.road-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #b56a31, #c8824a);
  min-width: 4px;
  transition: width 0.25s var(--forge-ease);
}

/* Job card — realism scale + paths */
.realism-chip {
  --rs: 50;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 1.75rem;
  text-align: center;
  padding: 2px 6px;
  border-radius: 999px;
  color: #fff;
  background: color-mix(in srgb, #c4493d calc(100% - var(--rs) * 1%), #4e7d3f calc(var(--rs) * 1%));
}
.realism-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c4493d 0%, #b07a1f 50%, #4e7d3f 100%);
  outline: none;
  cursor: pointer;
}
.realism-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #faf4e9;
  border: 2px solid #3a342b;
  box-shadow: 0 1px 3px rgba(60,45,25,.25);
  cursor: grab;
}
.realism-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #faf4e9;
  border: 2px solid #3a342b;
  cursor: grab;
}
.job-path-list { display: flex; flex-direction: column; gap: 6px; }
.job-path {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--forge-border);
  border-radius: 8px;
  background: var(--forge-surface);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.job-path:hover { border-color: #c0b39a; }
.job-path.is-selected {
  border-color: var(--forge-accent);
  background: rgba(181,106,49,.08);
}
.job-path input { accent-color: var(--forge-accent); }
.job-path-label { flex: 1; font-size: 13px; font-weight: 500; color: var(--forge-ink); }
.job-path-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.status-chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--forge-border);
  background: transparent;
  color: var(--forge-secondary);
  cursor: pointer;
  font-family: inherit;
}
.status-chip.is-on {
  background: var(--forge-accent);
  border-color: var(--forge-accent);
  color: #fff;
  font-weight: 600;
}
.job-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--forge-secondary);
  cursor: pointer;
  user-select: none;
}
.job-flag input { accent-color: var(--forge-accent); }
.job-comment {
  font-size: 12px;
  color: var(--forge-primary);
  padding: 4px 0;
  border-bottom: 1px solid rgba(227,217,197,.6);
}
.job-comment:last-child { border-bottom: none; }
.job-actions-bar { margin-top: 4px; }

/* Book Library embedded tab */
#app-main.is-library {
  max-width: none;
  padding: 0;
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#app-main.is-library #tab-library {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#app-main.is-library #tab-library.hidden {
  display: none;
}
.library-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh - 0px);
  background: transparent;
}
.library-shell-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--forge-border);
  background: rgba(243, 236, 224, 0.92);
  backdrop-filter: blur(6px);
}
.library-frame {
  flex: 1;
  width: 100%;
  min-height: calc(100vh - 56px);
  border: 0;
  background: transparent;
  display: block;
}
@media (max-width: 767px) {
  .library-frame { min-height: calc(100vh - 110px); }
}
