:root {
  --brand:#0F3A53;
  --line:#e5e7eb;
  --bg:#f7f7f8;
}

* { box-sizing:border-box }

body {
  margin:0;
  background:var(--bg);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}
/* === Unified Accent + Orange Theme === */
:root {
  --accent-orange: #ff7a00;          /* standard brand orange */
  --accent-orange-hover: #e26f00;    /* slightly darker hover */
  --accent-orange-light: #fff4e6;    /* pale background tint */
}

/* --- Universal orange accent for section dividers and headers --- */
.section-divider,
.border-bottom.border-2 {
  border-color: var(--accent-orange) !important;
}

/* --- Card accent borders --- */
.card-accent {
  border-left: 4px solid var(--accent-orange) !important;
}

/* --- Table header and border tint --- */
.table-warning,
.table-warning > td,
.table-warning > th {
  background-color: var(--accent-orange-light) !important;
  border-color: var(--accent-orange) !important;
}

/* --- Warning/Due badges --- */
.badge.bg-warning,
.badge.text-bg-warning {
  background-color: var(--accent-orange) !important;
  color: #fff !important;
}

/* --- Buttons (for things like Export CSV, Refresh Data) --- */
.btn-outline-warning {
  border-color: var(--accent-orange) !important;
  color: var(--accent-orange) !important;
}
.btn-outline-warning:hover {
  background-color: var(--accent-orange) !important;
  color: #fff !important;
}

/* --- Page header (hybrid style) consistency --- */
.page-header {
  border-bottom: 3px solid var(--accent-orange) !important;
}
.page-header:hover {
  border-color: var(--accent-orange-hover) !important;
}


.topbar {
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:10px 16px;
  background:#fff;
  border-bottom:1px solid var(--line);
}

.brand {
  display:flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  color:var(--brand);
  font-weight:700;
}

/* scalable logo */
.brand img {
  height: clamp(32px, 5vw, 60px); /* scales with screen size */
  display:block;
}

/* nav links */
nav a {
  margin-left:14px;
  text-decoration:none;
  color:#111;
  padding:6px 8px;
  border-radius:6px;
}
nav a:hover { background:#f2f2f2; }

.page { padding:16px; }

.button {
  display:inline-block;
  padding:8px 12px;
  border-radius:8px;
  border:1px solid var(--line);
  background:#fff;
  text-decoration:none;
  color:#111;
}
.button:hover { background:#f6f6f7; }

/* Light mode (default) */
.text-dark { color: #212529 !important; }

/* Dark mode friendly text */
.dark-mode-text-light { color: #f8f9fa !important; }

/* Automatic dark mode detection */
@media (prefers-color-scheme: dark) {
  .brand span {
    color: #f8f9fa !important;
  }
}

/* --- Top controls alignment fix --- */
.top-controls .btn-sm {
  font-size: 0.8rem;       /* readable size */
  padding: .25rem .5rem;   /* balanced padding */
  line-height: 1.3;
}

.top-controls .form-select-sm,
.top-controls .form-control-sm {
  font-size: 0.8rem;
  padding: .25rem .5rem;
  height: 2rem;            /* consistent height */
}

/* ---- Calibration Data Fix: Make DP inputs match SP/Temp ---- */
.dp-input {
  border: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  text-align: center !important;
  width: 100% !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  color: inherit !important;
  font-size: inherit !important;
  line-height: normal !important;
}

.dp-input:focus {
  outline: none !important;
  box-shadow: none !important;
}

#dp-body td {
  padding: 4px 6px !important;
  vertical-align: middle !important;
}
/* --- Header Brand Text --- */
.app-brand-text {
  color: #0f3a53 !important;        /* dark blue for contrast */
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  letter-spacing: 0.3px;
  font-weight: 700;
  text-shadow: 0 0 1px rgba(255,255,255,0.4); /* subtle contrast edge */
}

.navbar {
  background-color: #ffffff !important;
  border-bottom: 3px solid #ff7b00;
}
/* --- Hybrid Page Header: unified across all modules --- */
.page-header {
  background: #fff;
  border-bottom: 3px solid #ff7b00; /* brand orange accent */
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h4 {
  font-weight: 700;
  color: #0F3A53;  /* brand dark blue */
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header h4 i {
  color: #ff7b00;
  font-size: 1.2rem;
}

/* optional hover accent */
.page-header:hover {
  border-color: #e26f00;
}
.alert {
  transition: opacity 0.5s ease-in-out;
}

/* === Compact Table + Form Text Size === */
.table {
  font-size: 0.8rem !important;       /* smaller table text */
}

.table input,
.table select,
.table .form-control,
.table .form-select {
  font-size: 0.8rem !important;       /* match form controls */
  padding: 0.2rem 0.35rem !important; /* tighter spacing */
  height: auto !important;
}

.table > :not(caption) > * > * {
  padding: 0.3rem 0.4rem !important;  /* less cell padding */
  vertical-align: middle !important;
}

/* General cleanup for smaller column padding */
.table > :not(caption) > * > * {
  padding: 0.3rem 0.4rem !important;
  vertical-align: middle !important;
}

/* Optional: tighter form controls in table */
.table input,
.table select,
.table .form-control,
.table .form-select {
  font-size: 0.8rem !important;
  padding: 0.2rem 0.35rem !important;
  height: auto !important;
}

/* === Narrow columns for Admin Meters Table === */

/* Checkbox (select) column */
.table th:first-child,
.table td:first-child {
  width: 50px !important;
  text-align: center !important;
  padding: 0 !important;
}

/* Battery */
.table th:nth-child(2),
.table td:nth-child(2) {
  width: 155px !important;
  text-align: center !important;
}

/* Meter */
.table th:nth-child(3),
.table td:nth-child(5) {
  width: 155px !important;
  text-align: center !important;
}


/* FlowCal ID */
.table th:nth-child(4),
.table td:nth-child(4) {
  width: 100px !important;
  text-align: center !important;
}

/* Frequency*/
.table th:nth-child(5),
.table td:nth-child(5) {
  width: 100px !important;
  text-align: center !important;
}

/* Status */
.table th:nth-child(6),
.table td:nth-child(6) {
  width: 80px !important;
  text-align: center !important;
}

/* Meter Type */
.table th:nth-child(7),
.table td:nth-child(7) {
  width: 80px !important;
  text-align: center !important;
}

/* meter SN*/
.table th:nth-child(8),
.table td:nth-child(8) {
  width: 110px !important;
  text-align: center !important;
}

/* Tube SN */
.table th:nth-child(9),
.table td:nth-child(9) {
  width: 110px !important;
  text-align: center !important;
}

/* Last Plate Size */
.table th:nth-child(10),
.table td:nth-child(10) {
  width: 60px !important;
  text-align: center !important;
}

/* Plate Size */
.table th:nth-child(11),
.table td:nth-child(11) {
  width: 60px !important;
  text-align: center !important;
}

/* Tube Size */
.table th:nth-child(12),
.table td:nth-child(12) {
  width: 60px !important;
  text-align: center !important;
}

/* "Actions" column with Save + History */
.table th:last-child,
.table td:last-child {
  width: 150px !important;  /* adjust if your buttons wrap */
  text-align: center !important;
}

/* Optional: Slightly smaller Save/History buttons */
.table .btn {
  font-size: 0.65rem !important;
  padding: 0.2rem 0.4rem !important;
  line-height: 1.1;
}


/* === Compact, clean CDP table layout === */
.table.cdp-table {
  font-size: 0.85rem !important;
  width: 100%;
  border-collapse: collapse;
}

/* ID */
.table.cdp-table th:first-child,
.table.cdp-table td:first-child {
  width: 40px !important;
  text-align: center !important;
  white-space: nowrap !important;
}

/* Name */
.table.cdp-table th:nth-child(2),
.table.cdp-table td:nth-child(2) {
  width: 220px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Field */
.table.cdp-table th:nth-child(3),
.table.cdp-table td:nth-child(3) {
  width: 130px !important;
  white-space: nowrap !important;
}

/* Purchaser */
.table.cdp-table th:nth-child(4),
.table.cdp-table td:nth-child(4) {
  width: 160px !important;
  white-space: nowrap !important;    /* ✅ stops multi-line names */
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Purchaser Meter ID */
.table.cdp-table th:nth-child(5),
.table.cdp-table td:nth-child(5) {
  width: 100px !important;
  text-align: center !important;
  white-space: nowrap !important;
}

/* Lat / Lng */
.table.cdp-table th:nth-child(6),
.table.cdp-table td:nth-child(6),
.table.cdp-table th:nth-child(7),
.table.cdp-table td:nth-child(7) {
  width: 110px !important;
  text-align: right !important;
  font-family: monospace;
  font-size: 0.8rem !important;
  white-space: nowrap !important;
}

/* Actions */
.table.cdp-table th:last-child,
.table.cdp-table td:last-child {
  width: 75px !important;
  text-align: center !important;
}

/* Compact row spacing */
.table.cdp-table > :not(caption) > * > * {
  padding: 0.35rem 0.4rem !important;
  vertical-align: middle !important;
}

/* Optional: Tooltip for long purchaser names */
.table.cdp-table td[title] {
  cursor: help;
}

/* --- Clean, precise look for Lat/Lng columns --- */
.table.cdp-table th:nth-child(6),
.table.cdp-table td:nth-child(6),
.table.cdp-table th:nth-child(7),
.table.cdp-table td:nth-child(7) {
  width: 110px !important;
  text-align: right !important;
  font-family: 'Roboto Mono', 'Menlo', 'Consolas', 'DejaVu Sans Mono', monospace !important;
  font-feature-settings: "tnum" 1, "lnum" 1;  /* enable tabular lining numerals */
  font-variant-numeric: tabular-nums lining-nums; /* consistent number width */
  font-size: 0.82rem !important;
  line-height: 1.2;
  color: #1c1c1c;
  white-space: nowrap !important;
}

/* --- Fix header alignment for CDP table --- */
.table.cdp-table th {
  vertical-align: middle !important;     /* centers header text vertically */
  padding-top: 0.35rem !important;       /* matches cell padding */
  padding-bottom: 0.35rem !important;
  font-size: 0.85rem !important;         /* match body font size */
  line-height: 1.2 !important;
  white-space: nowrap !important;        /* prevent wrapping like Lat/Lng */
}

/* keep numeric headers (Lat/Lng) right aligned like their data */
.table.cdp-table th:nth-child(6),
.table.cdp-table th:nth-child(7) {
  text-align: right !important;
}


/* Due this Month/Index Card */

/* --- Balance the Due This Month table column widths --- */
.card.due-this-month .table {
  table-layout: fixed;   /* forces consistent column width distribution */
  width: 100%;
}

/* Column width balance */
.card.due-this-month .table th:first-child,
.card.due-this-month .table td:first-child {
  width: 55%; /* Meter column */
}

.card.due-this-month .table th:nth-child(2),
.card.due-this-month .table td:nth-child(2) {
  width: 25%; /* Frequency column (shifted more center) */
  text-align: center;    /* visually centered */
}

.card.due-this-month .table th:last-child,
.card.due-this-month .table td:last-child {
  width: 20%; /* Next Test Date */
  text-align: right !important;
}

/* Keep table compact */
.card.due-this-month .table td,
.card.due-this-month .table th {
  padding: 0.45rem 0.5rem !important;
  vertical-align: middle;
}

/* === Out of Service (OOS) Table — balanced version === */
.table.oos-table {
  width: 100%;
  table-layout: auto;   /* let browser calculate smart widths */
  font-size: 0.65rem;
}

/* Meter — wider for long names */
.table.oos-table th:first-child,
.table.oos-table td:first-child {
  min-width: 100px !important;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* FlowCal ID */
.table.oos-table th:nth-child(2),
.table.oos-table td:nth-child(2) {
  width: 80px;
  text-align: center;
  white-space: nowrap;
}

/* Field */
.table.oos-table th:nth-child(3),
.table.oos-table td:nth-child(3) {
  width: 80px;
  text-align: left;
  white-space: nowrap;
}

/* Battery */
.table.oos-table th:nth-child(4),
.table.oos-table td:nth-child(4) {
  width: 120px;
  text-align: left;
  white-space: nowrap;
}

/* Frequency */
.table.oos-table th:nth-child(5),
.table.oos-table td:nth-child(5) {
  width: 120px;
  text-align: center;
  white-space: nowrap;
}

/* Date OOS */
.table.oos-table th:nth-child(6),
.table.oos-table td:nth-child(6) {
  width: 120px;
  text-align: center;
  white-space: nowrap;
}

/* Status */
.table.oos-table th:nth-child(7),
.table.oos-table td:nth-child(7) {
  width: 80px;
  text-align: center;
  white-space: nowrap;
}

/* Actions */
.oos-page .table th:last-child,
.oos-page .table td:last-child {
  width: 240px !important;   /* was 200px — gives more breathing room */
  text-align: right !important;
  white-space: nowrap;
  padding-right: 0.6rem !important; /* slight right padding for visual balance */
}

/* Compact but readable row height */
.table.oos-table th,
.table.oos-table td {
  padding: 0.45rem 0.5rem !important;
  vertical-align: middle;
}

/* Make buttons play nice side-by-side */
.table.oos-table .btn {
  font-size: 0.65rem !important;
  padding: 0.2rem 0.45rem !important;
  line-height: 1.1;
  margin-left: 0.15rem;
}

/* --- Fix Inventory table alignment and spacing --- */
.inventory-page table.table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

/* General table cell settings */
.inventory-page table.table th,
.inventory-page table.table td {
  padding: 0.45rem 0.5rem !important;
  vertical-align: middle !important;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Item */
.inventory-page table.table th:nth-child(1),
.inventory-page table.table td:nth-child(1) {
  width: 18%;
  text-align: left;
  white-space: normal;       /* allow wrapping */
  word-wrap: break-word;     /* break long names */
}

/* Category */
.inventory-page table.table th:nth-child(2),
.inventory-page table.table td:nth-child(2) {
  width: 10%;
  text-align: center;
}

/* Qty + Min + Unit */
.inventory-page table.table th:nth-child(3),
.inventory-page table.table td:nth-child(3),
.inventory-page table.table th:nth-child(4),
.inventory-page table.table td:nth-child(4),
.inventory-page table.table th:nth-child(5),
.inventory-page table.table td:nth-child(5) {
  width: 7%;
}

/* Location */
.inventory-page table.table th:nth-child(6),
.inventory-page table.table td:nth-child(6) {
  width: 20%;
  text-align: left;
  white-space: normal;
  word-wrap: break-word;
}

/* Notes */
.inventory-page table.table th:nth-child(7),
.inventory-page table.table td:nth-child(7) {
  width: 25%;
  text-align: left;
  white-space: normal;
  word-wrap: break-word;
}

/* Actions */
.inventory-page table.table th:nth-child(8),
.inventory-page table.table td:nth-child(8) {
  width: 6%;
  text-align: center;
  white-space: nowrap;
}

/* Parts Page */
.btn-orange {
    background-color: #ff7b00 !important;
    border-color: #ff7b00 !important;
    color: #fff !important;
    padding: 0.45rem 0.9rem !important;
    border-radius: 8px !important;
}
.btn-orange:hover {
    background-color: #e26f00 !important;
    border-color: #e26f00 !important;
}
.btn-orange-outline {
    border: 2px solid #ff7b00 !important;
    color: #ff7b00 !important;
    background: #fff !important;
    border-radius: 8px !important;
}

.btn-orange-outline:hover {
    background-color: #fff4e6 !important;
    border-color: #ff7b00 !important;
}
.export-btn {
    padding: 0.25rem 0.55rem !important;
    font-size: 0.78rem !important;
    display: flex;
    align-items: center;
    gap: 4px;
}
.export-btn i {
    font-size: 0.9rem;
}
.parts-btn i {
    font-size: 1rem;
}
.parts-btn {
    font-size: 0.9rem !important;
}
.gap-2 {
    gap: 0.5rem !important;
}













