/* Intrepid FMS — theme derived from the logo (rust wordmark, charcoal tagline) */
:root {
  --rust:        #CE5427;
  --rust-dark:   #A63F1B;
  --rust-light:  #F3D9CD;
  --rust-tint:   #FCF1EC;
  --charcoal:    #2E2A27;
  --slate:       #6B6560;
  --line:        #E5E0DB;
  --bg:          #F7F5F3;
  --card:        #FFFFFF;
  --green:       #2F7D5D;
  --green-tint:  #E3F2EA;
  --amber:       #B8760C;
  --amber-tint:  #FBEFD8;
  --red:         #B03030;
  --red-tint:    #FAE3E3;
  --blue:        #2C5F8A;
  --blue-tint:   #E2EDF6;
  --radius:      10px;
  --shadow:      0 1px 2px rgba(46,42,39,.06), 0 4px 14px rgba(46,42,39,.05);
  --sidebar-w:   242px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--charcoal);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--rust); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ------------------------------------------------------------- sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #FFFFFF; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 20;
}
.sidebar__brand {
  padding: 20px 18px 16px; border-bottom: 1px solid var(--line);
}
.sidebar__brand img { width: 100%; max-width: 180px; height: auto; display: block; }
.sidebar__nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav__label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--slate); padding: 14px 10px 6px;
}
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 2px; border-radius: 8px;
  color: var(--charcoal); font-weight: 500; text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.nav__item:hover { background: var(--rust-tint); color: var(--rust-dark); text-decoration: none; }
.nav__item.is-active { background: var(--rust); color: #fff; }
.nav__item.is-active .nav__icon { stroke: #fff; }
.nav__icon { width: 17px; height: 17px; stroke: var(--slate); stroke-width: 1.9; fill: none;
             stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav__item:hover .nav__icon { stroke: var(--rust-dark); }
.nav__count {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--slate);
  background: var(--bg); border-radius: 20px; padding: 1px 7px;
}
.nav__item.is-active .nav__count { background: rgba(255,255,255,.22); color: #fff; }
.sidebar__foot {
  border-top: 1px solid var(--line); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--rust); color: #fff; font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
}
.sidebar__foot .who { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.sidebar__foot .who span { display: block; font-weight: 400; color: var(--slate); font-size: 11px; }

/* -------------------------------------------------------------- layout */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 16px 26px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--slate); font-size: 12.5px; }
.topbar__actions { margin-left: auto; display: flex; gap: 8px; }
.content { padding: 22px 26px 60px; }

/* --------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.card__head h2 { font-size: 14.5px; }
.card__head .link { margin-left: auto; font-size: 12.5px; }
.card__body { padding: 16px; }

/* ----------------------------------------------------------- kpi tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
       padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
       display: block; color: inherit; text-decoration: none; }
a.kpi { transition: border-color .12s ease, transform .12s ease; }
a.kpi:hover { border-color: var(--rust); text-decoration: none; transform: translateY(-1px); }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--rust); }
.kpi__label { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--slate); }
.kpi__value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin-top: 5px; }
.kpi__value small { font-size: 13px; font-weight: 600; color: var(--slate); }
.kpi__meta { font-size: 12px; color: var(--slate); margin-top: 3px; }
.kpi__meta .up { color: var(--green); font-weight: 600; }
.kpi__meta .down { color: var(--red); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 1080px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--slate); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #FBFAF9;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: var(--rust-tint); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .ref { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--slate);
                  white-space: nowrap; }
.nowrap { white-space: nowrap; }
table.data .strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 44px 16px; text-align: center; color: var(--slate); }
.empty svg { width: 34px; height: 34px; stroke: var(--line); stroke-width: 1.5; fill: none; margin-bottom: 8px; }

/* -------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 2.5px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 650; letter-spacing: .02em; white-space: nowrap;
  background: var(--bg); color: var(--slate); border: 1px solid var(--line);
}
.badge--green { background: var(--green-tint); color: var(--green); border-color: transparent; }
.badge--amber { background: var(--amber-tint); color: var(--amber); border-color: transparent; }
.badge--red   { background: var(--red-tint);   color: var(--red);   border-color: transparent; }
.badge--blue  { background: var(--blue-tint);  color: var(--blue);  border-color: transparent; }
.badge--rust  { background: var(--rust-light); color: var(--rust-dark); border-color: transparent; }

.chip { font-size: 11.5px; color: var(--slate); background: var(--bg);
        border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--charcoal); font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .12s ease; font-family: inherit;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn--primary { background: var(--rust); border-color: var(--rust); color: #fff; }
.btn--primary:hover { background: var(--rust-dark); border-color: var(--rust-dark); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--slate); }
.btn--ghost:hover { background: var(--bg); color: var(--charcoal); }
.btn--danger { color: var(--red); }
.btn--danger:hover { background: var(--red-tint); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2; fill: none;
           stroke-linecap: round; stroke-linejoin: round; }

.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #FBFAF9;
  border-radius: var(--radius) var(--radius) 0 0;
}
.filters .spacer { margin-left: auto; }
input[type=text], input[type=date], input[type=number], input[type=email], input[type=password],
select, textarea {
  font-family: inherit; font-size: 13px; color: var(--charcoal);
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background-color: #fff; outline: none;
  transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}
input[type=text]:hover, input[type=date]:hover, input[type=number]:hover, input[type=email]:hover,
select:hover, textarea:hover { border-color: #CFC8C1; }
input:focus, select:focus, textarea:focus {
  border-color: var(--rust); box-shadow: 0 0 0 3px rgba(206,84,39,.13);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }

/* --- select: hide the native control, draw our own chevron ------------- */
select {
  cursor: pointer;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6560' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
}
select:hover { background-color: #FBFAF9; }
select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23CE5427' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
select option { color: var(--charcoal); background: #fff; padding: 6px; }
select:disabled, input:disabled {
  background-color: var(--bg); color: var(--slate); cursor: not-allowed; opacity: 1;
}

/* --- date: custom calendar icon, whole field opens the picker ---------- */
input[type=date] {
  position: relative; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6560' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
}
input[type=date]:hover { background-color: #FBFAF9; }
input[type=date]:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23CE5427' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E");
}
/* stretch the (invisible) native indicator across the field so a click anywhere opens it */
input[type=date]::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; width: auto; height: auto;
  margin: 0; padding: 0; opacity: 0; cursor: pointer;
}
input[type=date]::-webkit-datetime-edit { padding: 0; }
input[type=date]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[type=date]:in-range::-webkit-datetime-edit-year-field,
input[type=date]::-webkit-datetime-edit-text { color: var(--charcoal); }
/* strip the number spinners — the steppers are noise on money/qty fields */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.search { position: relative; }
.search input { padding-left: 30px; width: 240px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
              width: 14px; height: 14px; stroke: var(--slate); stroke-width: 2; fill: none; }

/* --------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field label {
  display: block; font-size: 12px; font-weight: 600; color: var(--slate); margin-bottom: 5px;
}
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: 11.5px; color: var(--slate); margin-top: 4px; }
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 16px; border-top: 1px solid var(--line); background: #FBFAF9;
  border-radius: 0 0 var(--radius) var(--radius);
}
.req { color: var(--rust); }

/* ----------------------------------------------------- signature pad */
.sigpad {
  border: 1px dashed #D6CFC8; border-radius: 10px; background: #fff;
  overflow: hidden;
}
.sigpad.is-signed { border-style: solid; border-color: var(--line); }
.sigpad__area { position: relative; }
.sigpad canvas {
  display: block; width: 100%; height: 168px;
  touch-action: none; cursor: crosshair;
}
/* the signing baseline, drawn behind the ink */
.sigpad__line {
  position: absolute; left: 26px; right: 26px; bottom: 34px;
  border-bottom: 1px solid var(--line); pointer-events: none;
}
.sigpad__line::before {
  content: '×'; position: absolute; left: -2px; bottom: 2px;
  color: var(--slate); font-size: 15px; line-height: 1;
}
.sigpad__hint {
  position: absolute; left: 0; right: 0; bottom: 12px; text-align: center;
  font-size: 12px; color: #B6ADA5; pointer-events: none; transition: opacity .15s ease;
}
.sigpad.is-signed .sigpad__hint, .sigpad.is-signed .sigpad__line { opacity: 0; }
.sigpad__bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-top: 1px solid var(--line); background: #FBFAF9;
}
.sigpad__bar .status { font-size: 12px; color: var(--slate); margin-right: auto; }
.sigpad__bar .status.ok { color: var(--green); font-weight: 600; }
/* captured signature as shown on the report */
.sig-proof {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 6px 10px; display: inline-block; max-width: 320px;
}
.sig-proof img { display: block; width: 100%; height: auto; }

/* ---------------------------------------------------------- pagination */
.pager { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-top: 1px solid var(--line); }
.pager .info { font-size: 12.5px; color: var(--slate); margin-right: auto; }
.pager a, .pager span.cur {
  min-width: 30px; text-align: center; padding: 5px 8px; border-radius: 7px;
  border: 1px solid var(--line); font-size: 12.5px; font-weight: 600;
  color: var(--charcoal); text-decoration: none; background: #fff;
}
.pager a:hover { background: var(--rust-tint); text-decoration: none; }
.pager span.cur { background: var(--rust); border-color: var(--rust); color: #fff; }
.pager .muted { color: var(--line); border-color: var(--line); background: #FBFAF9; }

/* --------------------------------------------------------------- flash */
.flash {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px; margin-bottom: 16px;
  border-radius: 8px; font-size: 13px; font-weight: 500; border: 1px solid transparent;
}
.flash--ok  { background: var(--green-tint); color: var(--green); }
.flash--err { background: var(--red-tint);   color: var(--red); }
.flash svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; flex: none; }

/* ------------------------------------------------------------ pipeline */
.pipeline { display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding: 4px 0; }
.pipe {
  flex: 1; min-width: 112px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 12px; text-decoration: none; color: inherit;
}
.pipe:hover { border-color: var(--rust); text-decoration: none; }
.pipe__n { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.pipe__l { font-size: 11.5px; color: var(--slate); font-weight: 600; }
.pipe__bar { height: 3px; border-radius: 3px; background: var(--rust); margin-top: 8px; opacity: .85; }

/* -------------------------------------------------------------- charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis  { stroke: var(--line); stroke-width: 1; }
.chart .glabel { font-size: 10.5px; fill: var(--slate); }
.chart .gval   { font-size: 10.5px; fill: var(--slate); font-weight: 600; }
.chart .bar { fill: var(--rust); }
.chart .bar:hover { fill: var(--rust-dark); }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; }
.legend span { font-size: 12px; color: var(--slate); display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: block; }

/* --------------------------------------------------------- detail view */
.detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 20px; }
.detail dt { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
             color: var(--slate); margin-bottom: 3px; }
.detail dd { margin: 0 0 2px; font-size: 13.5px; font-weight: 500; }
.detail dd.big { font-size: 17px; font-weight: 700; }
.crumb { font-size: 12.5px; color: var(--slate); margin-bottom: 10px; }
.crumb a { color: var(--slate); }
.crumb a:hover { color: var(--rust); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px;
  border-radius: 50%; background: #fff; border: 2px solid var(--rust);
}
.timeline li.done::before { background: var(--rust); }
.timeline .t { font-size: 13px; font-weight: 600; }
.timeline .m { font-size: 12px; color: var(--slate); }

/* --------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
              background: linear-gradient(160deg, var(--rust-tint), var(--bg) 55%); }
.login-card { width: 100%; max-width: 372px; background: #fff; border: 1px solid var(--line);
              border-radius: 14px; box-shadow: 0 8px 34px rgba(46,42,39,.10); padding: 30px 28px; }
.login-card img { width: 174px; display: block; margin: 0 auto 6px; }
.login-card .tag { text-align: center; color: var(--slate); font-size: 12.5px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 13px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 10px; }
.login-demo { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
              font-size: 12px; color: var(--slate); text-align: center; line-height: 1.7; }
.login-demo code { background: var(--bg); padding: 1px 5px; border-radius: 4px; color: var(--charcoal); }
