/* ============================================================
   Sales Tracker — light UI refresh (v9)
   Matches the Kloudtech Task Manager look: white page,
   airy white cards, muted header links, fully-rounded pills.
   Every legacy class hook is preserved so no feature changes.
   Brand: petrol gray #545456, Kloudtech yellow #FBD008.
   ============================================================ */
:root {
  --ink:        #3b3a3f;   /* body text */
  --heading:    #08060d;   /* headings / titles (near-black) */
  --ink-soft:   #888888;   /* muted / secondary text */
  --ink-faint:  #888888;   /* faint labels (kept as token; same muted grey) */
  --link:       #3a86ff;   /* clickable links */
  --chip-dark:  #08060d;   /* dark text on light-shaded chips */
  --paper:      #fafafa;   /* light page background */
  --card:       #ffffff;
  --line:       #e9e8e6;
  --line-soft:  #f0efec;
  --petrol:     #545456;   /* brand gray (primary) */
  --petrol-dk:  #3c3d3f;
  --petrol-bg:  #f2f2f1;
  --accent:     #fbd008;   /* Kloudtech yellow */
  --accent-dk:  #d9b400;
  --accent-ink: #6e5a00;
  --amber:      #b26f12;
  --amber-bg:   #fbe7cf;
  --red:        #c0392b;   /* error messages */
  --red-bg:     #f7ddd9;
  --green:      #2e7d45;
  --green-bg:   #d9efe0;
  --grey-bg:    #eeeeec;
  --font-body:  system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-disp:  var(--font-body);
  --font-mono:  "IBM Plex Mono", ui-monospace, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(30, 30, 30, .04), 0 1px 12px rgba(30, 30, 30, .04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--link); }
h1, h2, h3 { font-family: var(--font-disp); letter-spacing: -.01em; color: var(--heading); }
h1 { font-size: 25px; font-weight: 800; margin: 20px 0 14px; }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; }

/* ------------------------------------------------ top bar (light) */
.topbar { background: transparent; color: var(--ink); }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 22px 20px 4px;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
}
.brand {
  text-decoration: none; display: flex; align-items: center; gap: 14px;
}
.brand-logo { width: 46px; height: 46px; display: inline-block; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.brand-name { font-family: var(--font-disp); font-weight: 400; font-size: 24px; color: var(--heading); }
.brand-sub  { font-size: 13px; color: var(--ink-soft); }

.userbox { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.signed-in { font-size: 14px; color: var(--ink-soft); }
.signed-in strong { color: var(--heading); font-weight: 400; }
.logout-link {
  font-size: 14px; color: var(--heading);
  text-decoration: underline; text-underline-offset: 2px;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; background: #fff;
}
.logout-link:hover { background: var(--grey-bg); }

/* left-aligned pill tab row below the header */
.nav {
  max-width: 1200px; margin: 8px auto 0; padding: 0 20px 6px;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start;
}
.nav a {
  color: var(--heading); text-decoration: none; font-weight: 400;
  padding: 9px 18px; border-radius: 999px; font-size: 14px; background: #fff;
  border: 1px solid var(--line);
}
.nav a:hover { background: var(--grey-bg); }
.nav a.on { background: var(--heading); color: #fff; border-color: var(--heading); font-weight: 500; }
.username { font-size: 13px; color: var(--ink-soft); }
@media (max-width: 620px) {
  .topbar-inner { padding-top: 18px; }
  .brand-name { font-size: 21px; }
  .userbox { margin-left: 0; width: 100%; }
}


/* ------------------------------------------------ layout */
.wrap { max-width: 1200px; margin: 0 auto; padding: 18px 20px 48px; }
.foot {
  max-width: 1200px; margin: 0 auto; padding: 18px 20px 34px;
  color: var(--ink-faint); font-size: 12.5px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px;
}

/* ------------------------------------------------ gauge (signature) */
.gauge-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 14px; align-items: center; margin: 10px 0; }
.gauge-label { font-size: 14px; }
.gauge-track {
  height: 26px; background: var(--grey-bg); border-radius: 999px; overflow: hidden;
  border: 1px solid var(--line); position: relative;
}
.gauge-fill { height: 100%; border-radius: 999px 0 0 999px; min-width: 2px; }
.gauge-fill.committed { background: repeating-linear-gradient(-45deg, #8a8b8e, #8a8b8e 8px, #a0a1a4 8px, #a0a1a4 16px); }
.gauge-fill.actual { background: var(--accent); border: 1px solid #e5c000; }
.gauge-num { font-family: var(--font-mono); font-size: 15px; text-align: right; }
.gauge-pct { color: var(--ink-soft); font-size: 12px; margin-left: 6px; }
@media (max-width: 620px) { .gauge-row { grid-template-columns: 100px 1fr 80px; } }

/* ------------------------------------------------ stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 860px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .k { font-size: 12.5px; color: var(--ink-soft); }
.tile .v { font-family: var(--font-mono); font-size: 24px; margin-top: 3px; }
.tile.warn .v { color: var(--amber); }
.tile.alert .v { color: var(--red); }
.tile.good .v { color: var(--accent-ink); }

/* ------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 500; padding: 9px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #fbfaf4; }
tr.row-urgent td { box-shadow: inset 3px 0 0 var(--red); background: #fdf4f3; }
tr.row-follow td { box-shadow: inset 3px 0 0 var(--amber); background: #fdf8ef; }
td.num, th.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* Account names: black text, no bold, no link-blue (still clickable via the row) */
tr.row-link td a { color: var(--heading); text-decoration: none; }
tr.row-link td a:hover { text-decoration: underline; }
/* Neutralise the <strong> wrapper used on names & group headers so nothing renders bold */
tr.row-link td a strong,
tr.group-row td strong { font-weight: 400; color: var(--heading); }

/* ------------------------------------------------ drag to rearrange */
.drag-handle {
  display: inline-block; cursor: grab; user-select: none;
  color: var(--ink-faint); font-size: 13px; line-height: 1;
  padding: 2px 6px 2px 0; margin-right: 2px; vertical-align: middle;
}
.drag-handle:active { cursor: grabbing; }
tr.group-row:hover .drag-handle,
tr.row-link:hover .drag-handle { color: var(--ink-soft); }
tr.dragging { opacity: .45; }
tr.drop-above td { box-shadow: inset 0 3px 0 var(--accent-dk); }
tr.drop-below td { box-shadow: inset 0 -3px 0 var(--accent-dk); }
/* keep the urgent/follow-up left bar visible while showing a drop line */
tr.row-urgent.drop-above td { box-shadow: inset 3px 0 0 var(--red), inset 0 3px 0 var(--accent-dk); }
tr.row-urgent.drop-below td { box-shadow: inset 3px 0 0 var(--red), inset 0 -3px 0 var(--accent-dk); }
tr.row-follow.drop-above td { box-shadow: inset 3px 0 0 var(--amber), inset 0 3px 0 var(--accent-dk); }
tr.row-follow.drop-below td { box-shadow: inset 3px 0 0 var(--amber), inset 0 -3px 0 var(--accent-dk); }

.reorder-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px);
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; z-index: 999;
}
.reorder-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------ chips / pills */
.chip {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; white-space: nowrap; line-height: 1.5;
}
.chip-open     { background: var(--grey-bg); color: var(--petrol-dk); }
.chip-won      { background: var(--green-bg);  color: var(--green); }
.chip-lost     { background: var(--grey-bg);   color: var(--ink-soft); }
.chip-deferred { background: var(--amber-bg);  color: var(--amber); }
.chip-urgent   { background: var(--red-bg);    color: var(--red); }
.chip-follow   { background: var(--amber-bg);  color: var(--amber); }

/* ------------------------------------------------ forms */
label { display: block; font-size: 13px; margin: 12px 0 5px; }
input[type=text], input[type=number], input[type=password], input[type=date],
select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus, a:focus {
  outline: 2px solid var(--accent-dk); outline-offset: 1px;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 10px 0; }
.check input { width: 17px; height: 17px; accent-color: var(--petrol-dk); }

.btn {
  display: inline-block; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 500; font-size: 14px; text-decoration: none;
  padding: 9px 18px; background: var(--accent); color: #2f3032;
}
.btn:hover { background: var(--accent-dk); }
.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--grey-bg); color: var(--ink); }
main .btn-ghost { border-color: var(--line); color: var(--ink-soft); }
main .btn-ghost:hover { background: var(--grey-bg); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #9c2a22; }

/* ------------------------------------------------ filter bar */
.filterbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.filterbar .f { min-width: 150px; flex: 1; }
.filterbar .f.small { flex: 0; min-width: 130px; }
.filterbar label { margin-top: 0; }

/* ------------------------------------------------ misc */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin: 14px 0; }
.flash-ok  { background: var(--green-bg); color: var(--green); }
.flash-err { background: var(--red-bg); color: var(--red); }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.mt { margin-top: 16px; }
.pagehead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pagehead h1 { margin-right: auto; }
.empty { padding: 30px; text-align: center; color: var(--ink-faint); }

.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.history li:last-child { border-bottom: 0; }
.history .meta { color: var(--ink-soft); font-size: 12px; font-family: var(--font-mono); }

.bar-mini { height: 9px; background: var(--grey-bg); border-radius: 999px; overflow: hidden; }
.bar-mini > span { display: block; height: 100%; background: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .gauge-fill { transition: width .6s ease; }
}

/* login */
.login-wrap { max-width: 400px; margin: 10vh auto 0; padding: 0 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; }
.login-brand { font-family: var(--font-disp); font-weight: 800; font-size: 21px; display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.login-brand .brand-logo { width: 34px; height: 34px; }

/* map legend */
.map-legend { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); flex-wrap: wrap; }
.map-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-left: 10px; border: 1px solid rgba(0,0,0,.15); }
.map-legend i:first-child { margin-left: 0; }

/* colored identity dots and inline color pickers */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: baseline; margin-right: 2px; border: 1px solid rgba(0,0,0,.12); }
.color-form { display: inline; }
input[type=color] { width: 34px; height: 24px; padding: 1px; border: 1px solid var(--line); border-radius: 5px; background: #fff; cursor: pointer; vertical-align: middle; }

/* dashboard top: stats + gauge on the left, map on the right */
.dash-top { display: grid; grid-template-columns: minmax(380px, 5fr) 6fr; gap: 16px; align-items: stretch; }
.dash-left { display: flex; flex-direction: column; }
.dash-left .tiles { grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
.dash-left > .card { flex: 1; }
.dash-map { display: flex; flex-direction: column; }
.dash-map #acct-map { flex: 1; min-height: 380px; border-radius: var(--radius); overflow: hidden; }
@media (max-width: 980px) {
  .dash-top { grid-template-columns: 1fr; }
  .dash-map #acct-map { min-height: 340px; }
}

/* classification group headers */
tr.group-row td { background: var(--petrol-bg); cursor: pointer; font-size: 13.5px; font-weight: 500; padding-top: 12px; padding-bottom: 12px; border-top: 1px solid var(--line); }
tr.group-row:hover td { background: #eaeae8; }
tr.group-row .caret { display: inline-block; width: 14px; color: var(--ink-soft); }

/* expandable summary rows */
tr.exp-toggle { cursor: pointer; }
tr.exp-toggle:hover td { background: #faf9f5; }
tr.exp-row td { background: #fbfbf9; font-size: 13.5px; border-bottom: 1px solid var(--line-soft); }

/* target progress card: filled target bar, tick marks, balanced spacing */
.gauge-card { display: flex; flex-direction: column; }
.gauge-wrap { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; }
.gauge-track {
  background-image: linear-gradient(to right,
    transparent 0 calc(25% - 1px), rgba(0,0,0,.10) calc(25% - 1px) 25%,
    transparent 25% calc(50% - 1px), rgba(0,0,0,.10) calc(50% - 1px) 50%,
    transparent 50% calc(75% - 1px), rgba(0,0,0,.10) calc(75% - 1px) 75%,
    transparent 75% 100%);
}
.gauge-fill.target { background: var(--petrol-dk); border-right: 3px solid var(--accent); }
.gauge-summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line); margin-top: 12px;
}
.gauge-summary > div { padding: 14px 16px 2px; border-left: 1px solid var(--line); }
.gauge-summary > div:first-child { border-left: 0; padding-left: 0; }
.gauge-summary .k {
  display: block; font-size: 11px; line-height: 1.4;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-soft); font-weight: 500; margin-bottom: 4px;
}
.gauge-summary .v {
  display: block; font-size: 14px; line-height: 1.35; font-weight: 500; color: var(--ink);
}
@media (max-width: 620px) {
  .gauge-summary { grid-template-columns: 1fr; }
  .gauge-summary > div { border-left: 0; padding-left: 0; padding-top: 10px; border-top: 1px dashed var(--line); }
  .gauge-summary > div:first-child { border-top: 0; }
}
