:root {
  /* Reckon.ai theming variables (approximate) */
  --brand-primary: #0f1b3d;
  /* deep navy */
  --brand-primary-foreground: #ffffff;
  --brand-secondary: #1e2a55;
  /* darker navy */
  --brand-accent: #0ea5e9;
  /* cyan accent */
  --brand-red: #ef3b2d;
  /* reckon red accent */

  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-alt: #f1f5f9;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #6b7280;

  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
}

.summary-row {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.summary-row div span {
  font-weight: 600;
  color: #007bff;
}


table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

/* Layout */
.layout-root {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top bar: light surface with subtle border, brand icon */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.topbar .brand img {
  width: 24px;
  height: 24px;
}

.topbar .userbar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.topbar .logout {
  color: var(--text);
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
}

.topbar .logout:hover {
  border-color: #cbd5e1;
  background: var(--surface-alt);
}

.menu-btn {
  display: none;
  margin-right: 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  padding: 16px;
  flex: 1;
}

/* Sidebar: rounded panel, muted background */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  height: calc(100vh - 120px);
  position: sticky;
  top: 12px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin: 4px 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}

.sidebar-btn.active,
.sidebar-btn:hover {
  background: #eef2f7;
  border-color: var(--border);
}

.content {
  min-height: 60vh;
}

/* Machine tables styling */
.tables-wrap {
  background: var(--surface);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

table.machines {
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

table.machines thead th {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  z-index: 1;
  font-weight: 600;
  color: var(--text);
}

table.machines th,
table.machines td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
}

table.machines tbody tr:hover {
  background: #f9fbff;
}

table.machines tbody tr:last-child td {
  border-bottom: none;
}

table.machines .name-col {
  text-align: left;
}

table.machines .actions-col {
  width: 120px;
  white-space: nowrap;
}

table.machines .refresh-col {
  width: 90px;
}

table.machines .badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}

table.machines .chip {
  display: inline-block;
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
}

table.machines .checkbox-cell {
  width: 40px;
}

/* Pills and badges */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 18px;
  line-height: 1;
}

.pill--green {
  background: #16a34a;
  color: #fff;
}

.pill--blue {
  background: #0ea5e9;
  color: #06263a;
}

.pill--orange {
  background: #f59e0b;
  color: #111827;
}

.pill--red {
  background: #ef4444;
  color: #fff;
}

.pill--gray {
  background: #e5e7eb;
  color: #111827;
}

.pill--black {
  background: #000000;
  color: #fff;
}

.number-pill {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
  background: #0f1b3d;
  color: #fff;
}

/* Filter bar polish */
.filter-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.filter-container input[type="text"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--surface-muted);
}

.filter-container label {
  color: var(--muted);
}

.filter-container .primary {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
}

.filter-container .primary:hover {
  background: #0c1633;
}

#clearFilterBtn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: var(--surface-alt);
  color: #334155;
}

#clearFilterBtn:hover {
  background: #e2e8f0;
}

/* Make tables scrollable on small screens */
.tables-wrap {
  overflow-x: auto;
}

table.machines {
  min-width: 980px;
}

button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icons {
  width: 32px;
  height: 32px;
  vertical-align: middle;
  margin-left: 4px;
}

/* Subtle selection checkbox */
.machine-checkbox {
  width: 14px;
  height: 14px;
  opacity: .4;
  transition: opacity .15s;
}

tr:hover .machine-checkbox,
.machine-checkbox:focus {
  opacity: 1;
}

/* Limit pointer cursor to headers to indicate sorting */
table.machines thead th {
  cursor: pointer;
}

.name-column {
  display: inline-block;
  /* allows text-align */
  text-align: left;
}

.alert {
  position: fixed;
  top: 0;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  z-index: 9999;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 400;
  text-align: center;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  padding: 1.6rem 15rem;
  -webkit-box-shadow: 0 2rem 4rem rgba(0, 0, 0, 0.25);
  box-shadow: 0 2rem 4rem rgba(0, 0, 0, 0.25);
}

.alert--success {
  background-color: #20bf6b;
}

.alert--error {
  background-color: #eb4d4b;
}

/* Style the tab */
.tab {
  overflow: hidden;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
}

/* Style the buttons inside the tab */
.tab button {
  background-color: inherit;
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
  font-size: 17px;
}

/* Change background color of buttons on hover */
.tab button:hover {
  background-color: #ddd;
}

/* Create an active/current tablink class */
.tab button.active {
  background-color: #ccc;
}

/* Style the tab content */
.tabcontent {
  display: none;
  padding: 6px 12px;
  border: none;
}

/* Responsive tweaks */
@media (max-width: 900px) {
  .menu-btn {
    display: inline-block;
    color: var(--text);
    border-color: var(--border);
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 56px;
    width: 220px;
    height: calc(100vh - 56px);
    z-index: 1000;
    transition: left .2s ease;
  }

  .sidebar-open .sidebar {
    left: 8px;
  }

  .content {
    padding-bottom: 16px;
  }
}

@media (max-width: 600px) {
  .sidebar-btn {
    padding: 12px;
  }

  table.machines {
    min-width: 860px;
  }
}

input[type=radio]:hover {
  cursor: pointer;
}

label:hover {
  cursor: pointer;
}

.pw_prompt {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  width: 580px;
  background-color: #f9f9f9;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  font-family: Arial, sans-serif;
  z-index: 1000;
}

.pw_prompt label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  font-size: 14px;
  color: #333;
}

.pw_prompt input {
  width: calc(100% - 16px);
  padding: 8px;
  margin-bottom: 15px;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-sizing: border-box;
  font-size: 14px;
}

.pw_prompt input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 4px rgba(0, 123, 255, 0.4);
}

.pw_prompt button {
  width: 100%;
  padding: 10px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.pw_prompt button:hover {
  background-color: #0056b3;
}

.pw_prompt button:active {
  background-color: #00408d;
}

@media (max-width: 400px) {
  .pw_prompt {
    width: 90%;
    padding: 15px;
  }
}

.filter-container {
  position: relative;
  display: inline-block;
}

#main_filter {
  padding-right: 25px;
  /* Space for the clear button */
}

.clear-btn:hover {
  cursor: pointer;
}

#machine-search-container {
  width: 300px;
  position: relative;
  margin-bottom: 20px;
}

#machine-search {
  width: 100%;
  padding: 6px;
  box-sizing: border-box;
}

#machine-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #ccc;
  border-top: none;
  position: absolute;
  width: 100%;
  background: white;
  z-index: 1000;
  display: none;
  /* 🔽 initially hidden */
}

#machine-list label {
  display: block;
  padding: 4px 8px;
  cursor: pointer;
}

#machine-list label:hover {
  background-color: #f0f0f0;
}

.custom-tooltip {
  position: absolute;
  background: #333;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1.4;
  white-space: pre;
  /* preserves spaces and line breaks */
  font-family: "Courier New", Courier, monospace;
  /* monospace font */
  pointer-events: none;
  z-index: 1000;
  display: none;
}

/* Footer */
.footer {
  background: var(--brand-primary);
  color: var(--brand-primary-foreground);
  padding: 12px 16px;
  text-align: center;
  font-size: 12px;
  width: 100%;
  margin-top: auto;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
}

/* Icon buttons for actions */
.icon-btn,
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0px;
  padding: 15px 15px;
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

.icon-btn:hover,
.icon-link:hover {
  background: #eef2f7;
  border-color: #cbd5e1;
}

.icon-btn svg,
.icon-link svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Keep anchor buttons within tables neutral */
table.machines td .icon-link {
  background: var(--surface-muted);
}

/* Color map utilities */
.row-critical {
  background: #fee2e2 !important;
}

.row-critical td {
  background: #fee2e2 !important;
}

.row-warn {
  background: #fff7ed !important;
}

.row-warn td {
  background: #fff7ed !important;
}

.cell-critical {
  background: #fecaca !important;
  font-weight: 700;
}

.cell-warn {
  background: #fde68a !important;
  font-weight: 600;
}

/* .cell-alert {
  background: #fef9c3 !important;
} */

/* Generic cards for inner tabs (logs/interventions/exceptions) */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  margin: 10px 0;
}

.card-title {
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-body {
  padding: 12px 16px;
}

/* Uniform filter rows */
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-row input[type="text"],
.filter-row input[type="date"],
.filter-row select {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 8px;
  padding: 6px 8px;
}

.filter-row .btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
}

.filter-row .btn.primary {
  background: var(--brand-primary);
  color: var(--brand-primary-foreground);
  border-color: var(--brand-primary);
}

.filter-row .btn:hover {
  background: #eef2f7;
}

.logs-box {
  min-height: 140px;
  max-height: 73vh;
  overflow: auto;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}

/* Toasts */
#toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 260px;
  max-width: 360px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  animation: toastIn .18s ease-out;
}

.toast--leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .18s, transform .18s;
}

.toast__icon {
  font-size: 16px;
  line-height: 1;
  margin-top: 2px;
}

.toast__title {
  font-weight: 700;
  margin-bottom: 2px;
}

.toast__message {
  font-size: 13px;
  color: var(--muted);
}

.toast__close {
  background: transparent;
  border: none;
  color: #64748b;
  margin-left: auto;
  cursor: pointer;
  font-size: 16px;
}

.toast--success {
  border-color: #86efac;
  background: #f0fdf4;
}

.toast--error {
  border-color: #fecaca;
  background: #fef2f2;
}

.toast--info {
  border-color: #bae6fd;
  background: #eff6ff;
}

.toast--warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.summary-content {
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  font-size: 14px;
}

.summary-table th,
.summary-table td {
  padding: 6px 8px;
  border: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.summary-table th:first-child,
.summary-table td:first-child {
  text-align: left;
}

.summary-table tbody tr.summary-total {
  font-weight: 600;
  background: var(--surface-muted);
}

#KPI_filters table {
  border-collapse: collapse;
  width: 100%;
}

#KPI_filters th {
  position: sticky;
  top: 0;
  background: #f8f8f8;
  z-index: 2;
}

#KPI_filters td,
#KPI_filters th {
  padding: 6px 10px;
  border: 1px solid #ccc;
  text-align: center;
}