/* Mapmatics operations dashboard — the public site's gridframe language,
   made operational. Paper ground, hairline rules, Inter Tight for voice,
   IBM Plex Mono for anything that reads like fieldbook data. */

:root {
  --paper: #F7F6F2;
  --card: #FDFCFA;
  --ink: #111311;
  --slate: #686E68;
  --line: #CECDC5;
  --pm: #969892;
  --forest: #304A3A;
  --forest-2: #263B2E;
  --cream: #F5F0D6;
  --hv: #3D5847;
  --ef: #96684A;
  --pb: #5A6E83;
  --amber: #A66B2E;
  --pad: clamp(20px, 3vw, 40px);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
::selection { background: var(--forest); color: var(--cream); }

/* ---- top bar ---- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 500;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 var(--pad);
  display: flex; align-items: center; gap: 28px; height: 58px;
}
.topbar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.topbar-logo img { height: 22px; display: block; }
.topbar-logo .word { height: 15px; }
.topbar-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--pm); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 2px; margin-left: 2px;
}
.topbar-nav { display: flex; gap: 4px; margin-left: 10px; flex: 1; }
.topbar-link {
  text-decoration: none; font-size: 13.5px; font-weight: 500; color: var(--slate);
  padding: 6px 11px; border-radius: 3px; transition: color .18s, background .18s;
}
.topbar-link:hover { color: var(--ink); }
.topbar-link.active { color: var(--ink); background: rgba(48, 74, 58, .09); }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--slate); }
.topbar-user a { color: inherit; }
.btn-signout {
  font: inherit; font-size: 12.5px; color: var(--slate); background: none;
  border: 1px solid var(--line); border-radius: 3px; padding: 4px 11px; cursor: pointer;
}
.btn-signout:hover { color: var(--ink); border-color: var(--slate); }

/* ---- page scaffolding ---- */
.page { max-width: 1280px; margin: 0 auto; padding: 30px var(--pad) 70px; }
.page-full { max-width: none; padding: 0; }

.kicker {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--forest);
  display: flex; align-items: center; gap: 8px;
}
.kicker::before { content: ""; width: 18px; height: 1px; background: var(--forest); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-head h1 { font-size: 27px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; }
.page-head .actions { display: flex; gap: 10px; }

.btn {
  display: inline-block; text-decoration: none; font: inherit; font-size: 13.5px; font-weight: 550;
  padding: 8px 16px; border-radius: 3px; cursor: pointer; transition: background .18s, color .18s;
}
.btn-primary { background: var(--forest); color: var(--cream); border: 1px solid var(--forest); }
.btn-primary:hover { background: var(--forest-2); }
.btn-ghost { background: none; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--slate); }
.btn-small { font-size: 12.5px; padding: 5px 11px; }
.btn-danger { background: none; color: #7A3B2E; border: 1px solid var(--line); }
.btn-danger:hover { border-color: #7A3B2E; }

/* ---- kpi strip: rules, not boxes ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); margin-bottom: 34px; }
.kpi { padding: 18px 20px 16px 0; border-right: 1px solid var(--line); }
.kpi + .kpi { padding-left: 20px; }
.kpi:last-child { border-right: none; }
.kpi .num { font-family: var(--mono); font-size: 30px; font-weight: 500; line-height: 1.1; }
.kpi .lbl { font-size: 12.5px; color: var(--slate); margin-top: 3px; }

/* ---- cards & sections ---- */
.section { margin-bottom: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.section-head .more { font-size: 12.5px; color: var(--slate); text-decoration: none; }
.section-head .more:hover { color: var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 4px; }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.tbl th {
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .13em;
  text-transform: uppercase; color: var(--pm); text-align: left;
  padding: 9px 14px; border-bottom: 1px solid var(--ink); white-space: nowrap;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(48, 74, 58, .035); }
.tbl a.rowlink { font-weight: 550; text-decoration: none; }
.tbl a.rowlink:hover { text-decoration: underline; }
.tbl .mono, .mono { font-family: var(--mono); font-size: 12.5px; }
.tbl .dim { color: var(--slate); }

.empty {
  border: 1px dashed var(--line); border-radius: 4px; background: none;
  padding: 34px 20px; text-align: center; color: var(--slate); font-size: 13.5px;
}

/* ---- chips ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 550;
  padding: 2px 9px; border-radius: 20px; border: 1px solid var(--line); white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--slate); }
.chip-play { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; }

/* ---- filter bar ---- */
.filterbar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; align-items: center; }
.filterbar select, .filterbar input[type="text"], .filterbar input[type="search"] {
  font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 3px; background: var(--card); color: var(--ink);
}
.filterbar input[type="search"] { min-width: 210px; }
.filterbar .clear { font-size: 12.5px; color: var(--slate); }

/* ---- activity ledger ---- */
.ledger { border-top: 1px solid var(--ink); }
.ledger-row { display: grid; grid-template-columns: 118px 74px 1fr; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ledger-row .when { font-family: var(--mono); font-size: 11.5px; color: var(--pm); padding-top: 2px; }
.ledger-row .who { font-family: var(--mono); font-size: 11.5px; color: var(--forest); padding-top: 2px; }
.ledger-row .what a { font-weight: 550; text-decoration: none; }
.ledger-row .what a:hover { text-decoration: underline; }
.ledger-row .what .note { color: var(--slate); }

/* ---- board columns ---- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.board-col h3 {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .13em;
  text-transform: uppercase; color: var(--slate); display: flex; gap: 8px; align-items: center;
  padding-bottom: 8px; border-bottom: 1px solid var(--ink); margin-bottom: 10px;
}
.board-col h3 .n { margin-left: auto; color: var(--pm); }
.board-card {
  display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line);
  border-radius: 4px; padding: 10px 12px; margin-bottom: 8px; transition: border-color .18s;
}
.board-card:hover { border-color: var(--slate); }
.board-card .j { font-size: 13.5px; font-weight: 550; line-height: 1.35; }
.board-card .c { font-size: 12px; color: var(--slate); margin-top: 2px; }
.board-card .meta { font-family: var(--mono); font-size: 10.5px; color: var(--pm); margin-top: 6px; }

/* ---- forms ---- */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 26px 28px; max-width: 640px; }
.form-card p { margin-bottom: 15px; }
.form-card label { display: block; font-size: 12.5px; font-weight: 550; color: var(--slate); margin-bottom: 4px; }
.form-card input, .form-card select, .form-card textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 3px; background: var(--paper); color: var(--ink);
}
.form-card input:focus, .form-card select:focus, .form-card textarea:focus,
.filterbar input:focus, .filterbar select:focus {
  outline: 2px solid var(--forest); outline-offset: 1px;
}
.form-card .helptext { display: block; font-size: 11.5px; color: var(--pm); margin-top: 3px; }
.form-card .errorlist { color: #7A3B2E; font-size: 12.5px; list-style: none; margin-bottom: 6px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---- messages ---- */
.messages { position: fixed; top: 68px; right: 22px; z-index: 900; transition: opacity .5s; }
.message {
  background: var(--forest); color: var(--cream); font-size: 13px;
  padding: 9px 16px; border-radius: 3px; margin-bottom: 8px; box-shadow: 0 4px 18px rgba(17, 19, 17, .18);
}

/* ---- login ---- */
.login-shell { min-height: 100vh; display: grid; place-items: center; background: var(--paper); position: relative; overflow: hidden; }
.login-card { width: min(380px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 38px 36px; position: relative; z-index: 2; }
.login-card .mark { height: 40px; margin-bottom: 18px; }
.login-card h1 { font-size: 20px; font-weight: 650; letter-spacing: -.015em; margin: 8px 0 22px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 550; color: var(--slate); margin-bottom: 4px; }
.login-card input { width: 100%; font: inherit; font-size: 14.5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); margin-bottom: 15px; }
.login-card input:focus { outline: 2px solid var(--forest); outline-offset: 1px; }
.login-card .btn { width: 100%; text-align: center; padding: 10px; }
.login-err { color: #7A3B2E; font-size: 13px; margin-bottom: 12px; }
.login-foot { margin-top: 20px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--pm); text-align: center; }

/* ---- map page ---- */
.map-shell { display: grid; grid-template-columns: 1fr 330px; height: calc(100vh - 58px); }
#opsmap { height: 100%; background: var(--paper); }
.map-side { border-left: 1px solid var(--line); background: var(--card); overflow-y: auto; padding: 20px 20px 40px; }
.map-side h2 { font-size: 15px; font-weight: 650; margin: 4px 0 2px; }
.map-side .sub { font-size: 12px; color: var(--slate); margin-bottom: 14px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 12px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--slate); }
.map-legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.side-job { display: block; text-decoration: none; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); padding: 9px 11px; margin-bottom: 8px; transition: border-color .18s; }
.side-job:hover { border-color: var(--slate); }
.side-job .j { font-size: 13px; font-weight: 550; line-height: 1.3; }
.side-job .c { font-size: 11.5px; color: var(--slate); }
.side-job .meta { font-family: var(--mono); font-size: 10px; color: var(--pm); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.side-job .meta .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.side-count { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--pm); margin-bottom: 10px; }

/* leaflet popup, restyled to match */
.leaflet-popup-content-wrapper { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 6px 24px rgba(17, 19, 17, .16); }
.leaflet-popup-content { margin: 12px 14px; font-family: "Inter Tight", sans-serif; font-size: 13px; line-height: 1.45; }
.leaflet-popup-tip { background: var(--card); border: 1px solid var(--line); }
.pop-job { font-weight: 650; font-size: 13.5px; }
.pop-client { color: var(--slate); font-size: 12px; margin-bottom: 5px; }
.pop-meta { font-family: var(--mono); font-size: 10.5px; color: var(--pm); margin-bottom: 8px; }
.pop-links a { font-size: 12.5px; font-weight: 550; color: var(--forest); margin-right: 10px; }

/* ---- detail pages ---- */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 26px; align-items: start; }
.meta-card { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 18px 20px; }
.meta-card dl { display: grid; grid-template-columns: 110px 1fr; row-gap: 8px; font-size: 13.5px; }
.meta-card dt { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--pm); padding-top: 2px; }
.meta-card dd { margin: 0; }
.update-form textarea { width: 100%; font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); resize: vertical; }
.update-form textarea:focus { outline: 2px solid var(--forest); outline-offset: 1px; }
.update-form { margin-bottom: 18px; }
.update-form .btn { margin-top: 8px; }

.app-footer { border-top: 1px solid var(--line); padding: 16px var(--pad); font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--pm); text-align: center; }

/* ---- responsive ---- */
@media (max-width: 980px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .topbar-nav { order: 3; width: 100%; overflow-x: auto; }
  .kpis, .board { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: none; }
  .kpi:nth-child(3) { border-top: 1px solid var(--line); padding-left: 0; }
  .kpi:nth-child(4) { border-top: 1px solid var(--line); }
  .map-shell { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .map-side { border-left: none; border-top: 1px solid var(--line); }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Direct-upload progress line (production only) */
.upload-progress {
  width: 100%;
  padding-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--slate);
}
