:root{--blue:#3b82f6;--blue-dark:#1d56b0;--blue-light:#dbeafe;--text:#111827;--text-muted:#6b7280;--text-hint:#9ca3af;--bg:#f9fafb;--surface:#ffffff;--border:rgba(0,0,0,0.08);--border-md:rgba(0,0,0,0.14);--success:#16a34a;--success-bg:#f0fdf4;--warn-bg:#fffbeb;--warn:#b45309;--danger:#dc2626;--danger-bg:#fef2f2;--radius:10px;--radius-sm:6px;}
*{box-sizing:border-box;margin:0;padding:0;}
html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell {
  max-width: 1400px;     /* same as .wrapper */
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;    /* horizontal padding */

}

/* GLOBAL NAV: consistent baseline on large screens */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;              /* fixed bar height */
  max-height: 64px;
  padding-inline: 23px;
  box-sizing: border-box;
}

/* Inner flex row fills the bar */
.nav-inner {
  display: flex;
  align-items: center;        /* vertical alignment on a single line */
  justify-content: space-between;
  height: 100%;               /* match nav height */
}

.nav-logo img {
  height: clamp(28px, 8vw, 36px);
  display: block;
  gap: clamp(0.5rem, 3vw, 1.5rem);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-tag {
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 550;
  color: var(--blue);
  background: var(--blue-light);
  padding: 3px 10px;
  border-radius: 20px;
  margin: 0;
  white-space: nowrap;
}

/* Version text (v3.0) */
.nav-right span:last-child {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.wrapper {
  padding: 1rem;
  text-align: left;
  flex: 1;
}

.page-title{font-size:20px;font-weight:600;color:var(--text);margin-bottom:4px;}
.page-sub{font-size:13px;color:var(--text-muted);margin-bottom:1.5rem;}

.tabs {
  display:flex;
  gap:2px;
  border-bottom:1px solid var(--border);
  margin-bottom: 0.7rem;
  overflow-x: auto;        /* allow horizontal scroll */
  overflow-y: hidden;      /* prevent vertical scroll */
  -webkit-overflow-scrolling: touch;  /* smooth scroll on iOS */
}
.tab{padding:9px 15px;font-size:13px;font-family:'DM Sans',sans-serif;font-weight:500;border:none;background:none;cursor:pointer;color:var(--text-muted);border-bottom:2px solid transparent;margin-bottom:-1px;white-space:nowrap;transition:color .15s;}
.tab:hover{color:var(--text);}.tab.on{color:var(--blue);border-bottom-color:var(--blue);}

.card {
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:1rem 1.3rem;
  margin-bottom:0.6rem;
}
.card-title {
  font-size:14px;
  font-weight:600;
  color:var(--text);
  margin-bottom:1rem;
}
.card-row {
  display: flex;
  gap: 2rem;          /* space between the two cards */
  align-items: stretch;
}

/* let them share the row and wrap on small screens */
.card-row .card {
  flex: 1 1 0;
  margin-bottom: 0;   /* row itself already has bottom margin */
}

/* optional: stack vertically on very small screens */
@media (max-width: 800px) {
  .card-row {
    flex-direction: column;
  }
}
.metric-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:1rem;}
.metric{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius-sm);padding:.85rem 1rem;}
.mlabel{font-size:11px;font-weight:500;color:var(--text-muted);margin-bottom:4px;text-transform:uppercase;letter-spacing:.04em;}
.mval{font-size:20px;font-weight:600;color:var(--text);}.msub{font-size:11px;color:var(--text-hint);margin-top:2px;}

.g2 {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}

/* Temperature & density layout: left column wider than right */
.g2-temp {
  grid-template-columns: minmax(0, 60fr) minmax(0, 40fr);
}

/* Optional: stack at small widths */
@media (max-width: 900px) {
  .g2-temp {
    grid-template-columns: 1fr;
  }
}

.g3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px;}
.g4{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;}
label{font-size:12px;font-weight:500;color:var(--text-muted);display:block;margin-bottom:5px;text-transform:uppercase;letter-spacing:.04em;}
input,select{width:100%;font-size:13px;font-family:'DM Sans',sans-serif;padding:8px 11px;border:1px solid var(--border-md);border-radius:var(--radius-sm);background:var(--surface);color:var(--text);outline:none;transition:border-color .15s;}
input:focus,select:focus{border-color:var(--blue);}
.hint{font-size:11px;color:var(--text-hint);margin-top:4px;}

.btn {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 16px;
  font-size:13px;
  font-family:'DM Sans',sans-serif;
  font-weight:500;
  border:1px solid var(--border-md);
  border-radius:var(--radius-sm);
  background:var(--surface);
  color:var(--text);
  cursor:pointer;
  transition:all .15s;
}
.btn:hover{border-color:var(--blue);color:var(--blue);}
.btn-primary{background:var(--blue);color:#fff;border-color:var(--blue);}
.btn-primary:hover{background:var(--blue-dark);border-color:var(--blue-dark);color:#fff;}
.btn-danger{border-color:#fca5a5;color:var(--danger);}.btn-danger:hover{background:var(--danger-bg);}
.btn-sm{font-size:12px;}

.alert{padding:10px 14px;border-radius:var(--radius-sm);font-size:13px;}
.ainfo{background:var(--blue-light);color:var(--blue-dark);border:1px solid #bfdbfe;}
.asuc{background:var(--success-bg);color:var(--success);border:1px solid #bbf7d0;}
.awarn{background:var(--warn-bg);color:var(--warn);border:1px solid #fde68a;}
.adanger{background:var(--danger-bg);color:var(--danger);border:1px solid #fecaca;}
.tag{display:inline-block;padding:2px 8px;border-radius:20px;font-size:11px;font-weight:500;}
.tgreen{background:#dcfce7;color:#15803d;}.tblue{background:var(--blue-light);color:var(--blue-dark);}.tamber{background:#fef3c7;color:#92400e;}.tred{background:var(--danger-bg);color:var(--danger);}
table{width:100%;border-collapse:collapse;font-size:13px;}
th{text-align:left;padding:8px 10px;color:var(--text-muted);font-weight:500;border-bottom:1px solid var(--border);font-size:12px;text-transform:uppercase;letter-spacing:.04em;}
td{padding:7px 10px;border-bottom:1px solid var(--border);color:var(--text);}
tr:last-child td{border-bottom:none;}tr:hover td{background:var(--bg);}
.fbar{height:5px;border-radius:3px;background:#e5e7eb;margin-top:4px;}
.fbar-fill{height:5px;border-radius:3px;}

.layout{
    padding-top: 1.5rem;
    display:flex;
    gap:1.5rem;
    align-items:flex-start;
}

.sidebar{width:200px;flex-shrink:0;}
.main{flex:1;min-width:0;}

.sidebar-label {
  font-size:11px;
  font-weight:600;
  color:var(--text-muted);
  text-transform:uppercase;
  letter-spacing:.06em;
}

.chip{display:flex;align-items:center;gap:9px;padding:9px 11px;border-radius:var(--radius-sm);border:1px solid var(--border);cursor:pointer;margin-bottom:6px;background:var(--surface);transition:all .15s;}
.chip:hover{border-color:var(--blue-dark);}.chip.sel{border-color:var(--blue);background:var(--blue-light);}
.chip.sel .cname{color:var(--blue-dark);}
.cname{font-size:13px;font-weight:500;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.csub{font-size:11px;color:var(--text-muted);}
.dot{width:10px;height:10px;border-radius:50%;flex-shrink:0;}

.exp-grid {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap:12px;
}

/* Ensure exp-grid stacks on mobile */
@media (max-width: 640px) {
  .exp-grid {
    grid-template-columns: 1fr !important;
  }
}

.exp-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:1.25rem;cursor:pointer;transition:all .15s;}
.exp-card:hover{border-color:var(--blue);box-shadow:0 0 0 3px var(--blue-light);}
.exp-icon{font-size:26px;margin-bottom:10px;}.exp-title{font-size:14px;font-weight:600;margin-bottom:4px;}.exp-sub{font-size:12px;color:var(--text-muted);}
.mono{font-family:'DM Mono',monospace;}
hr{border:none;border-top:1px solid var(--border);margin:1.25rem 0;}

/* Strapping table wrapper: scroll INSIDE the card */
.tscroll {
  max-height: 400px;           /* tune for ≈ 12 rows + header */
  overflow-y: auto;
  overflow-x: auto;
}

/* Normal table */
.tscroll table {
  border-collapse: collapse;
  width: 100%;
}

/* Only affect the tilt tab’s correction table */
#p-tilt .tscroll {
  max-height: 200px;     /* tweak: more height = more visible rows */
  overflow-y: auto;      /* vertical scroll */
  overflow-x: hidden;
}

#p-tilt thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

/* Limit the card height so there is actually something to scroll */
#p-table .card .tscroll {
  max-height: 535px;         /* or whatever fits your layout */
  overflow-y: auto;
  position: relative;        /* anchor for sticky header */
}

/* Keep header row visible while scrolling */
#p-table table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);  /* same as card background so it doesn’t look transparent */
  z-index: 1;
}

footer {
  padding: 1rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-muted);

  display: flex;
  align-items: center;        /* vertical alignment */
  justify-content: center;    /* or 'flex-start' to left-align */
  gap: 8px;
}
footer img {
  height: 23px;
  opacity: .8;
  margin-right: 0;            /* flex gap replaces margin */
}

/* HANDHELD NAV: same size in portrait and landscape */
@media (max-width: 1300px) and (max-height: 1300px) {
  .wrapper {
    max-width: 91%;
    padding: 0.75rem 0.75rem;
  }

  /* Sidebar + main stacked */
  .layout {
    display: block;
  }

  .sidebar {
    margin-bottom: 1rem;
  }

  .sidebar,
  .main {
    width: 100%;
  }

  nav {
    height: 56px;             /* slightly shorter bar */
    max-height: 56px;
  }

  .nav-inner {
    height: 100%;
  }

  .nav-logo img {
    height: 32px;             /* scale logo with bar */
  }

  .nav-tag {
    font-size: 12px;
    padding: 2px 8px;
  }

  .nav-right span:last-child {
    font-size: 12px;
  }
}

/* TABLETS AND SMALLER: stack layout, adjust nav */
@media (max-width: 768px) {
  .wrapper {
    max-width: 95%;
    padding: 1rem 0.75rem;
  }

  /* Stack sidebar above main */
  .layout {
    flex-direction: column;
    gap: 1rem;
  }

  .sidebar,
  .main {
    width: 100%;
  }

  .sidebar {
    margin-bottom: 1rem;
  }

  /* Tank list wraps horizontally */
  #tank-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .chip {
    flex: 1 1 auto;
    min-width: 140px;
  }

  /* Nav adjustments */
  nav {
    height: 56px;
    padding-inline: 1rem;
  }

  .nav-logo img {
    height: 32px;
  }

  .nav-tag {
    font-size: 12px;
    padding: 2px 8px;
    white-space: nowrap;
  }

  .nav-right span:last-child {
    font-size: 12px;
  }

  /* Grids to 2 columns on tablets */
  .g3,
  .g4,
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-height: 480px) {
  /* Nav edge-to-edge */
  nav {
    padding-inline: 0.5rem;
    height: 56px;
  }

  .nav-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav-logo img {
    height: 28px;
  }

  .nav-right {
    gap: 0.75rem;
    margin-left: 0.5rem;    /* small nudge, not 5rem */
  }

  .nav-tag {
    font-size: 11px;
    padding: 2px 6px;
    white-space: nowrap;
  }

  .nav-right span:last-child {
    font-size: 11px;
  }
}

/* PHONES: single column everything */
@media (max-width: 480px) {
  .wrapper {
    max-width: 91%;
    padding: 0.75rem 0.5rem;
  }

  /* Nav edge-to-edge */
  nav {
    padding-inline: 0.5rem;
    height: 56px;
  }

  .nav-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav-logo img {
    height: 28px;
  }

  .nav-right {
    gap: 0.75rem;
    margin-left: 0.5rem;    /* small nudge, not 5rem */
  }

  .nav-tag {
    font-size: 11px;
    padding: 2px 6px;
    white-space: nowrap;
  }

  .nav-right span:last-child {
    font-size: 11px;
  }

  /* All grids to 1 column */
  .g2,
  .g3,
  .g4,
  .metric-grid,
  .exp-grid {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    margin-bottom: 1rem;
  }
}

/* VERY NARROW PHONES */
@media (max-width: 360px) and (max-height: 360px) {
  nav {
    padding-inline: 0.4rem;
  }

  .nav-logo img {
    height: 24px;
  }

  .nav-tag {
    font-size: 10px;
    padding: 2px 5px;
  }

  .nav-right {
    gap: 0.5rem;
  }

  .wrapper {
    padding: 0.5rem 0.4rem;
  }
}