/* TotalexMobile — Design System & Supervisor Module Styles */
:root {
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --surface2: #F7F8FA;
  --line: #E1E5EB;
  --ink: #10233F;
  --muted: #5B6B80;
  --brand: #2450D6;
  --brand-soft: #E6ECFB;
  --ok: #17845B;
  --ok-soft: #DFF3EA;
  --warn: #B87A00;
  --warn-soft: #FBEFD2;
  --bad: #C43D3D;
  --bad-soft: #F9E1E1;
  --info: #3B6FA8;
  --info-soft: #E2ECF6;
  --orange: #E07A2F;
  --orange-soft: #FBE6D5;
  --side: #10233F;
  --side-ink: #C9D3E3;
  --map: #E9EEF3;
  --map-street: #FFFFFF;
  --font-tf: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-card: 12px;
  --radius-btn: 8px;
  --radius-pill: 99px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C1524;
    --surface: #131F33;
    --surface2: #182740;
    --line: #243652;
    --ink: #E8EDF5;
    --muted: #93A3BA;
    --brand: #6F93FF;
    --brand-soft: #1E2F57;
    --ok: #4CC593;
    --ok-soft: #12362B;
    --warn: #E8B23A;
    --warn-soft: #3A2F12;
    --bad: #F07A7A;
    --bad-soft: #3F1D1F;
    --info: #7FB1E6;
    --info-soft: #1A2E45;
    --orange: #F0A26A;
    --orange-soft: #40261A;
    --side: #0A111E;
    --side-ink: #9FB0C8;
    --map: #16233A;
    --map-street: #20324F;
  }
}

:root[data-theme="dark"] {
  --bg: #0C1524;
  --surface: #131F33;
  --surface2: #182740;
  --line: #243652;
  --ink: #E8EDF5;
  --muted: #93A3BA;
  --brand: #6F93FF;
  --brand-soft: #1E2F57;
  --ok: #4CC593;
  --ok-soft: #12362B;
  --warn: #E8B23A;
  --warn-soft: #3A2F12;
  --bad: #F07A7A;
  --bad-soft: #3F1D1F;
  --info: #7FB1E6;
  --info-soft: #1A2E45;
  --orange: #F0A26A;
  --orange-soft: #40261A;
  --side: #0A111E;
  --side-ink: #9FB0C8;
  --map: #16233A;
  --map-street: #20324F;
}

/* Master Layout */
.tf-container {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-tf);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

/* Sidebar */
.tf-side {
  background: var(--side);
  color: var(--side-ink);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.tf-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  color: #fff;
  font-weight: 700;
  letter-spacing: .02em;
}

.tf-logo i {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 13px;
  color: #fff;
  font-weight: 800;
}

.tf-logo small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--side-ink);
  letter-spacing: 0;
}

.tf-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.tf-nav-btn {
  background: none;
  border: 0;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-btn);
  color: var(--side-ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
}

.tf-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tf-nav-btn.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(36, 80, 214, 0.35);
}

.tf-nav-btn.soon {
  opacity: 0.45;
  cursor: not-allowed;
}

.tf-badge {
  background: var(--bad);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 11px;
  padding: 1px 7px;
  font-weight: 700;
}

.tf-sidefoot {
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
}

.tf-sidefoot b {
  color: #fff;
  font-size: 13px;
}

/* Main Area */
.tf-main {
  min-width: 0;
  padding: 24px 28px 48px;
  overflow-y: auto;
}

/* Header & Top Bar */
.tf-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tf-title {
  font-size: 22px;
  margin: 0;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.tf-sub {
  color: var(--muted);
  margin-top: 3px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tf-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tf-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tf-chip:hover {
  background: var(--surface2);
}

.tf-chip.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.tf-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.tf-live b {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
  box-shadow: 0 0 0 2px var(--ok-soft);
  animation: tf-pulse 2s infinite;
}

@keyframes tf-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Grids */
.tf-grid { display: grid; gap: 14px; }
.tf-g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tf-g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tf-g2 { grid-template-columns: 2fr 1fr; }
.tf-g6 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Cards */
.tf-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.tf-card h2 {
  font-size: 14.5px;
  margin: 0 0 12px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.tf-card h2 span {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

.tf-sect {
  margin: 22px 0 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Strip of status */
.tf-strip {
  display: flex;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  height: 34px;
  margin: 8px 0 12px;
}

.tf-strip div {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  transition: flex 0.3s ease;
}

.tf-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12.5px;
}

.tf-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tf-legend b {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* KPIs */
.tf-kpi .l {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.tf-kpi .v {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 2px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.tf-kpi .d {
  font-size: 12px;
  color: var(--muted);
}

.tf-up { color: var(--ok); font-weight: 600; }
.tf-down { color: var(--bad); font-weight: 600; }

.tf-kpi.hero {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.tf-kpi.hero .l, .tf-kpi.hero .d {
  color: inherit;
  opacity: 0.8;
}

.tf-kpi.hero .v {
  color: #ffffff;
}

.tf-kpi.hero .tf-up {
  color: #7BE0B4;
}

/* Progress Bars */
.tf-bar {
  height: 7px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 8px;
}

.tf-bar i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.tf-bar.ok i { background: var(--ok); }
.tf-bar.warn i { background: var(--warn); }
.tf-bar.bad i { background: var(--bad); }

.tf-kpi.hero .tf-bar {
  background: rgba(255, 255, 255, 0.15);
  border-color: transparent;
}

.tf-kpi.hero .tf-bar i {
  background: #7BE0B4;
}

/* Status Badges */
.tf-st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.tf-st::before {
  content: "";
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: currentColor;
}

.tf-st.ok { background: var(--ok-soft); color: var(--ok); }
.tf-st.warn { background: var(--warn-soft); color: var(--warn); }
.tf-st.bad { background: var(--bad-soft); color: var(--bad); }
.tf-st.info { background: var(--info-soft); color: var(--info); }
.tf-st.idle { background: var(--surface2); color: var(--muted); }

/* Table */
.tf-tw { overflow-x: auto; }
.tf-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.tf-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tf-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tf-table tr:last-child td { border-bottom: 0; }
.tf-table td.n, .tf-table th.n { text-align: right; }
.tf-table tbody tr.click { cursor: pointer; transition: background 0.1s ease; }
.tf-table tbody tr.click:hover { background: var(--surface2); }

.tf-pct {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.tf-pct .tf-bar {
  width: 70px;
  margin: 0;
}

/* Map Screen */
.tf-mapwrap {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
}

.tf-map {
  position: relative;
  background: var(--map);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
  min-height: 520px;
}

.tf-map svg {
  width: 100%;
  height: 100%;
  display: block;
  min-height: 520px;
}

.tf-pin {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.tf-pin:hover, .tf-pin:focus-visible {
  transform: scale(1.08);
}

.tf-mapleg {
  position: absolute;
  left: 14px;
  bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Map Detail Panel */
.tf-side2 .tf-card {
  position: sticky;
  top: 16px;
}

dl.tf-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 12px 0;
  font-size: 13px;
}

dl.tf-dl dt { color: var(--muted); }
dl.tf-dl dd { margin: 0; text-align: right; font-weight: 600; color: var(--ink); }

/* Buttons & Actions */
.tf-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.tf-btn:hover {
  background: var(--surface2);
}

.tf-btn.p {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.tf-btn.p:hover {
  filter: brightness(1.08);
}

/* Product Card Elements & Placeholders */
.product-no-img {
  width: 100%;
  height: 100%;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2px;
  box-sizing: border-box;
}

.product-no-img span {
  font-size: 8.5px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  line-height: 1.15;
  letter-spacing: -0.2px;
}

.btn-add-product {
  background: #2563eb;
  color: #ffffff !important;
  border: none;
  border-radius: 8px;
  height: 32px;
  min-width: 76px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn-add-product:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}

.tf-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tf-actions .tf-btn {
  padding: 6px 11px;
  font-size: 12.5px;
}

/* Team Grid */
.tf-team {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.tf-vc h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.tf-vc .z {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.tf-vc .hd {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.tf-vc .m {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.tf-vc .m div {
  background: var(--surface2);
  border-radius: 8px;
  padding: 6px 10px;
}

.tf-vc .m small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.tf-vc .m b {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
}

.tf-input-search {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  min-width: 220px;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.tf-input-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Timeline */
.tf-tl {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tf-tl li {
  display: grid;
  grid-template-columns: 52px 14px 1fr;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}

.tf-tl time {
  color: var(--muted);
  text-align: right;
  font-size: 12px;
  font-weight: 600;
}

.tf-tl .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--brand);
  margin-top: 3px;
  position: relative;
  z-index: 1;
}

.tf-tl li::after {
  content: "";
  position: absolute;
  left: 63px;
  top: 18px;
  bottom: -4px;
  width: 2px;
  background: var(--line);
}

.tf-tl li:last-child::after { display: none; }
.tf-tl li.now .dot { background: var(--ok); border-color: var(--ok); }
.tf-tl li.sale .dot { border-color: var(--ok); }
.tf-tl li.cash .dot { border-color: var(--warn); }
.tf-tl li.warn .dot { border-color: var(--bad); }

.tf-tl b { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.tf-tl span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }

/* Alerts */
.tf-al {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px 12px 0;
  border-bottom: 1px solid var(--line);
}

.tf-al:last-child { border-bottom: 0; }

.tf-al .sev {
  align-self: stretch;
  border-radius: 6px;
}

.tf-al.crit .sev { background: var(--bad); }
.tf-al.alta .sev { background: var(--orange); }
.tf-al.media .sev { background: var(--warn); }
.tf-al.inf .sev { background: var(--info); }

.tf-al b { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.tf-al small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.tf-tag {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 8px;
  display: inline-block;
}

.tf-al.crit .tf-tag { background: var(--bad-soft); color: var(--bad); }
.tf-al.alta .tf-tag { background: var(--orange-soft); color: var(--orange); }
.tf-al.media .tf-tag { background: var(--warn-soft); color: var(--warn); }
.tf-al.inf .tf-tag { background: var(--info-soft); color: var(--info); }

/* Responsive adjustments */
@media (max-width: 1100px) {
  .tf-g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tf-g2, .tf-mapwrap { grid-template-columns: 1fr; }
  .tf-g3 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .tf-container {
    grid-template-columns: 1fr;
  }
  .tf-side {
    position: static;
    height: auto;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .tf-logo {
    padding-bottom: 8px;
  }
  .tf-sidefoot {
    display: none;
  }
  .tf-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
  }
  .tf-nav-btn {
    white-space: nowrap;
    padding: 7px 12px;
  }
  .tf-main {
    padding: 16px 14px 36px;
  }
}

@media (max-width: 480px) {
  .tf-g4 { grid-template-columns: 1fr; }
}
