.login-box {
  max-width: 420px;
  margin: 1.5rem auto;
  padding: 1.25rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.login-box form { display:flex; flex-direction:column; gap:0.5rem; }
.login-box input[type="text"], .login-box input[type="password"] { padding:0.6rem; border:1px solid #d0d7de; border-radius:6px; width:100%; box-sizing:border-box; }
.login-box button { width:100%; }

/* Global box sizing for predictable sizing */
* { box-sizing: border-box; }

body {
    font-family: Arial, sans-serif;
    margin: 2em;
    background: #f4f4f4;
  }
  
  h1, h2 {
    margin-bottom: 0.5em;
  }

/* Header and logout button — also used by admin dashboard */
.client-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
button {
  padding: 0.6em 1.2em;
  border: none;
  background: #0077cc;
  color: white;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
}
.container {
  max-width: 700px;
  width: 100%;
  margin: auto;
  background: white;
  padding: 2em;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
  box-sizing: border-box;
}
.btn-logout {
  font-size: 0.9em;
  text-decoration: none;
  color: #c00;
}
.btn-logout:hover { text-decoration: underline; }
.admin-link-container { text-align: center; margin-top: 1em; }
.admin-link-container a { font-size: 0.9em; text-decoration: none; color: #007bff; }
.admin-link-container a:hover { text-decoration: underline; }
  
  .global-status {
    font-size: 1.2em;
    margin-bottom: 1em;
  }
  
  form {
    margin-bottom: 2em;
    background: white;
    padding: 1em;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  
  form input[type="text"] {
    padding: 0.5em;
    margin-right: 1em;
  }
  
  form label {
    margin-right: 1em;
  }
  
  form button {
    padding: 0.5em 1em;
    background-color: #0077cc;
    color: white;
    border: none;
    cursor: pointer;
  }
  
  form button:hover {
    background-color: #005fa3;
  }
  
  table {
    width: 100%;
    border-collapse: collapse;
    background: white;
  }

/* Make wide tables scrollable on small screens */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Ensure media scale */
img, video, iframe { max-width: 100%; height: auto; display: block; }
  
  th, td {
    padding: 0.75em;
    border: 1px solid #ccc;
    text-align: left;
  }
  
  .status-ok {
    color: green;
    font-weight: bold;
  }
  
  .status-warning {
    color: orange;
    font-weight: bold;
  }
  
  .status-error {
    color: red;
    font-weight: bold;
  }
  
  .instance-type {
    text-transform: uppercase;
    font-size: 0.9em;
  }

  /* Loading overlay styles */
  .loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }
  .loading-overlay.hidden {
    display: none;
  }
  .spinner {
    width: 50px; height: 50px;
    border: 5px solid #ccc;
    border-top: 5px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  /* ---- modal override de port ---- */
.modal {
  display: none;
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center; align-items: center;
}
.modal-content {
  background: #fff;
  padding: 1.5em;
  border-radius: 8px;
  /* Allow modals to expand more naturally on larger screens while staying responsive */
  box-sizing: border-box;
  width: min(95vw, 1100px);
  max-width: 1100px;
}
.modal-close {
  float: right;
  font-size: 1.2em;
  cursor: pointer;
}
#newPort {
  width: 100%;
  padding: 0.5em;
  margin: 0.5em 0;
}

/* Settings button */
.settings-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}
.settings-btn:hover { transform: scale(1.05); }

/* Settings modal inner content scroll */
#settingsInner { max-height: 60vh; overflow: auto; }
/* Boxed page container */
.page-box { max-width: 100vw; margin: 0 auto; padding: 1.25rem; box-sizing: border-box; }

/* Dashboard 2-column layout: instances on left, stacked widgets on right */
.dashboard-container { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.main-column { flex: 2; min-width: 280px; padding: 1rem;}
.main-column .widget { width: 100%; padding: 1rem; box-shadow: #33333350 0 3px 12px;}
.side-column { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 1rem; align-items: stretch; }
.side-column .widget { width: 100%; max-width: 480px; padding: 1rem; background-color: #fff; box-shadow: #33333350 0 3px 12px; }

/* Side column overlay/menu button for small screens */
.side-menu-button {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  margin-left: 0.5rem;
}

/* Hide side-column and show burger under 1920px to avoid overlaps */
@media (max-width: 1919px) {
  .side-menu-button { display: inline-flex; align-items: center; }
  .side-column { display: none !important; }
  /* Make burger clearly visible and reachable (fixed top-right) */
  .side-menu-button {
    position: fixed;
    top: 0.9rem;
    right: 1rem;
    z-index: 1301;
    color: #000;
    background: rgba(255,255,255,0.95);
    border: 1px solid #e6e6e6;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  }
  body.side-open .side-column {
    display: flex !important;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 85%;
    max-width: 420px;
    background: #fff;
    z-index: 1200;
    box-shadow: -8px 0 24px rgba(0,0,0,0.18);
    overflow: auto;
    padding: 1rem;
  }
  body.side-open::before {
    content: '';
    position: fixed;
    left: 0; top: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1100;
  }
}

/* Instances widget styles (left) */
.instances-widget table { width: 100%; border-collapse: collapse; }
.instances-widget th, .instances-widget td { padding: 0.5rem; border-bottom: 1px solid #eee; }

/* Jobs widget: limit height and allow scrolling for long lists */
.jobs-list {
  max-height: 18rem; /* ~288px, adjust as needed */
  overflow: auto;
}
.alerts-list {
  max-height: 14rem; /* ~224px */
  overflow: auto;
}
.jobs-list table { width: 100%; border-collapse: collapse; }
.jobs-list td, .jobs-list th { padding: 0.5rem; border-bottom: 1px solid #eee; }

/* Responsive: stack columns on narrow screens */
@media (max-width: 900px) {
  .dashboard-container { flex-direction: column; }
  .side-column { align-items: stretch; }
  .side-column .widget { max-width: none; }
}

/* Modal form layout - responsive grid */
.modal-content form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  align-items: start;
}

/* Add option form */
.modal-content .form-options-add {
  display: flex;
  flex-flow: column;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

@media (min-width: 900px) {
  .modal-content .form-options-add { width: 30%; }
}

/* On larger screens, allow three-column rows inside modals */
@media (min-width: 720px) {
  .modal-content form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.6rem;
  }
}

/* For wider modals use two-column grid for related fields */
.modal-content form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.modal-content label {
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 0.25rem;
}

.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="password"],
.modal-content input[type="number"],
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fbfbfb;
  box-sizing: border-box;
}

.modal-content textarea { min-height: 6rem; }

.modal-content .form-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 0.4rem;
}

.btn-primary {
  background: #0077cc;
  color: #fff;
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
}
.btn-primary:hover { background: #005fa3; }

.btn-secondary {
  background: #f0f0f0;
  color: #222;
  border: 1px solid #ddd;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}

.modal .success, .modal .error {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.modal .success { background: #e6ffed; color: #056f2a; border: 1px solid #b7f2c9; }
.modal .error { background: #ffecec; color: #a10f0f; border: 1px solid #ffbdbd; }

/* Ensure fragment lists are readable inside modal */
.widget-fragment ul { list-style: none; padding: 0; margin: 0.4rem 0 0 0; }
.widget-fragment li { padding: 0.25rem 0; border-bottom: 1px dashed #eee; }

/* Make forms inside widget fragments fit modal width */
.widget-fragment form { margin: 0; }

/* Item actions (edit/delete) in lists and tables */
.item-actions { display: inline-flex; gap: 0.25rem; align-items: center; }
.item-actions button:hover { background: #f0f4f8; }
.item-actions .item-edit { color: #0b6bff; }
.item-actions .item-delete { color: #c53030; }

/* Make list rows layout nicer */
.widget-list ul li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.45rem 0; }
.widget-list .item-label { flex: 1 1 auto; }

/* Meta/icon for items (status) */
.item-meta { margin: 0 0.5rem; display: inline-flex; align-items: center; gap: 0.35rem; }

/* Toggle icons should show pointer and a subtle hover feedback */
.toggle-active { cursor: pointer; display: inline-flex; align-items: center; }
.toggle-active:hover { transform: scale(1.08); }

/* Table actions column */
.instances-widget td.item-actions, .instances-widget th.item-actions {
  width: 90px;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  min-width: 0; /* allow shrinking inside table cell */
  overflow: auto; /* enable scroll if content is too wide */
  padding: 0.25rem;
}
.instances-widget td.item-actions button {
  margin: 0;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  flex: 0 0 auto; /* don't stretch buttons */
}
.instances-widget td.item-actions .item-edit { background: #eef6ff; border: 1px solid #cfe3ff; }
.instances-widget td.item-actions .item-delete { background: #fff5f5; border: 1px solid #ffd2d2; }

/* On narrower screens, stack action buttons vertically to avoid overlap */
@media (max-width: 1080px) {
  .instances-widget td.item-actions, .instances-widget th.item-actions {
    width: auto;
    flex-direction: column;
    align-items: stretch;
  }
  .instances-widget td.item-actions button { width: 100%; }
  .item-actions button { background: transparent; border: none; padding: 0.25rem 0.5rem; border-radius: 6px; cursor: pointer; font-size: 0.95rem; }
}

/* Tooltip for special lines (e.g. class 'none') */
.tooltip { position: relative; cursor: help; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 6px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.tooltip:hover::after { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.tooltip::before {
  content: '';
  position: absolute;
  bottom: 115%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0,0,0,0.85) transparent transparent transparent;
  opacity: 0;
  transition: opacity 160ms ease;
}
.tooltip:hover::before { opacity: 1; }

/* Modal open/close animation */
.modal { opacity: 0; transition: opacity 200ms ease; }
.modal.open { opacity: 1; }
.modal-content { transform: scale(.98); transition: transform 180ms ease, opacity 200ms ease; opacity: 0; }
.modal.open .modal-content { transform: scale(1); opacity: 1; }

/* Reduce body padding on very small screens */
@media (max-width: 480px) {
  body { padding: 1em; margin: 0.5em; }
  .page-box { padding: 0.6rem; }
  .modal-content { padding: 1rem; }
}

/* Ensure tables inside containers can scroll when needed */
.instances-widget, .jobs-list { width: 100%; }
.instances-widget table, .jobs-list table { width: 100%; }



/* Ensure container list action buttons remain visible on narrow screens.
   Some global rules make .item-actions buttons transparent; override for
   container-specific action buttons (class .container-action). */
.item-actions .container-action,
.item-actions a.container-action,
.item-actions .container-action:visited {
  background: #0077cc;
  color: #fff;
  border: none;
}
.item-actions .container-action:hover,
.item-actions a.container-action:hover {
  background: #005fa3;
  color: #fff;
}

/* Keep specific semantic variants (edit/delete) intact on small screens */
.instances-widget td.item-actions .item-edit { background: #eef6ff; border: 1px solid #cfe3ff; }
.instances-widget td.item-actions .item-delete { background: #fff5f5; border: 1px solid #ffd2d2; }




