/* ====== K7UNI Ham Radio Logger - Dark Theme Stylesheet ======
 * 
 * Complete responsive dark theme implementation for the K7UNI Logger
 * 
 * Major Features:
 * - Dynamic 3/4-column CSS Grid layout with responsive form column (573px-720px)
 * - NCS Script integration with toggleable 4th column and embedded viewer
 * - Comprehensive dark theme (#2c3e50 backgrounds, #34495e borders, #3498db accents)
 * - Mini RST input system with inline editing and save functionality
 * - Themed chat interface with custom scrollbars and proper input styling
 * - Role-based UI elements with proper permission handling
 * - Responsive design with media queries for various screen sizes
 * - Floating clock with dynamic positioning based on layout state
 * 
 * Layout Structure:
 * 3-column: Log (300px) | K7UNI Logger (1fr) | Operators (170px)
 * 4-column: Log (300px) | K7UNI Logger (573px-720px) | NCS Script (1fr) | Operators (170px)
 * 
 * Color Scheme:
 * - Primary Background: #2c3e50 (dark blue-gray)
 * - Secondary Background: #34495e (lighter blue-gray)  
 * - Accent Blue: #3498db (bright blue for buttons/links)
 * - Text Colors: #fff (primary), #e6eefb (secondary), #bdc3c7 (muted)
 * 
 * Last Updated: October 2025
 * ===================================================================== */

/* ====== Base ====== */
:root {
  --bg: #0b0f14;
  --fg: #e6eefb;
  --panel: #0e141b;
  --card: #141a22;
  --line: #223;
  --border: var(--line);
  --muted: #a9b3c3;
  --gap: 32px;
}

* { box-sizing: border-box; }
html, body { 
  height: 100%; 
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  color: #111;
  background: var(--bg);
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
}

/* ====== Header ====== */
header {
  margin: 0 0 20px 0;
  background: #141a22 !important;
  border: 1px solid #4da3ff !important;
  border-radius: 8px !important;
  color: #e6eefb !important;
  padding: 10px 20px;
  flex-shrink: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  contain: layout style !important;
  min-height: 60px !important;
  box-sizing: border-box !important;
}
header > div {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap; /* Never wrap - keep everything on one line */
  min-height: 40px; /* Ensure consistent height */
  overflow: hidden; /* Hide overflow instead of wrapping */
}
.header-left {
  display: flex;
  align-items: center;
  flex-wrap: nowrap; /* Prevent wrapping within left section */
  gap: 4px; /* Small gap between buttons */
  flex-shrink: 1; /* Allow shrinking if needed */
  min-width: 0; /* Allow flex shrinking */
}
.header-right {
  display: flex;
  align-items: center;
  white-space: nowrap; /* Prevent text wrapping */
  flex-shrink: 0; /* Never shrink the user info */
  margin-left: auto; /* Push to right */
}
header a { text-decoration: none; }
header h1,
header .brand,
header a,
nav a {
  color: #e6eefb !important;
}
header a,
header button,
header .header-btn {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  transition: background 0.2s !important;
  text-decoration: none !important;
  display: inline-block; /* NO !important - allow inline styles to override for permission-based visibility */
  margin: 0 2px; /* Small consistent margin instead of &nbsp; */
  white-space: nowrap; /* Prevent text wrapping inside buttons */
  height: 40px; /* Fixed height for consistency */
  line-height: 24px; /* Center text vertically */
  box-sizing: border-box; /* Include padding in height calculation */
}

/* Header responsive adjustments - make more compact instead of wrapping */
@media (max-width: 1200px) {
  header a,
  header button,
  header .header-btn,
  .toggle-btn {
    padding: 6px 10px !important; /* Smaller buttons */
    font-size: 13px !important;
    margin: 0 1px; /* Tighter spacing */
    height: 34px !important; /* Slightly smaller but consistent */
    line-height: 22px !important;
    white-space: nowrap !important; /* Maintain no-wrap */
  }
  .header-right span {
    font-size: 13px;
    margin: 0 4px !important;
  }
}

@media (max-width: 900px) {
  header > div {
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 6px;
  }
  .header-left {
    flex: 1 1 100%; /* Take full width */
    order: 2; /* Move below header-right */
    justify-content: flex-start;
    margin-top: 6px;
  }
  .header-right {
    flex: 1 1 100%; /* Take full width */
    order: 1; /* Show first */
    justify-content: space-between;
  }
}

@media (max-width: 768px) {
  header {
    padding: 8px 10px; /* Reduce padding on mobile */
    min-height: auto !important;
  }
  header a,
  header button,
  header .header-btn,
  .toggle-btn {
    padding: 5px 8px !important; /* Even smaller buttons on mobile */
    font-size: 12px !important;
    margin: 0 1px;
    height: 30px !important; /* Smaller but consistent */
    line-height: 20px !important;
    white-space: nowrap !important; /* Maintain no-wrap */
  }
  .header-right span {
    font-size: 12px; /* Smaller text */
    margin: 0 3px !important;
  }
  .header-left {
    gap: 3px; /* Tighter gap */
  }
}

@media (max-width: 480px) {
  header a,
  header button,
  header .header-btn,
  .toggle-btn {
    padding: 4px 6px !important;
    font-size: 11px !important;
    height: 28px !important;
    line-height: 20px !important;
  }
  .header-right span {
    font-size: 11px;
    margin: 0 2px !important;
  }
  /* Hide "Logged in as" text on very small screens, keep username */
  .header-right span strong::before {
    content: '';
  }
}

/* ====== Mobile Sidebar Toggles ====== */
.sidebar-toggle-btn {
  display: none; /* Hidden by default (desktop) */
  background: transparent !important;
  border: 1px solid #4da3ff !important;
  cursor: pointer;
  padding: 8px !important;
  border-radius: 6px;
  color: #4da3ff;
  position: relative;
  transition: all 0.2s;
}
.sidebar-toggle-btn:hover {
  background: rgba(77, 163, 255, 0.1) !important;
}
.sidebar-toggle-btn.active {
  background: rgba(77, 163, 255, 0.2) !important;
}

.operators-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #4da3ff;
  color: #0a0f16;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ====== Hamburger Menu (Mobile Only) ====== */
.hamburger-btn {
  display: none; /* Hidden by default (desktop) */
  background: transparent !important;
  border: none !important;
  cursor: pointer;
  padding: 8px !important;
  flex-direction: column;
  gap: 4px;
  z-index: 1001;
}
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 3px;
  background: #e6eefb;
  transition: all 0.3s;
  border-radius: 2px;
}
.hamburger-btn.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.hamburger-btn.active span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile sidebar panels */
.mobile-sidebar {
  display: none; /* Hidden by default */
  position: fixed;
  top: 60px;
  bottom: 0;
  width: 280px;
  background: #141a22;
  border: 1px solid #4da3ff;
  box-shadow: 2px 0 8px rgba(0,0,0,0.3);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 999;
  overflow-y: auto;
}
.mobile-sidebar.active {
  transform: translateX(0);
}
.mobile-sidebar.right {
  left: auto;
  right: 0;
  transform: translateX(100%);
  box-shadow: -2px 0 8px rgba(0,0,0,0.3);
}
.mobile-sidebar.right.active {
  transform: translateX(0);
}

.mobile-sidebar-header {
  background: #1e293b;
  padding: 16px;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mobile-sidebar-header h3 {
  margin: 0;
  color: #e6eefb;
  font-size: 18px;
}
.mobile-sidebar-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-sidebar-content {
  padding: 16px;
}

.mobile-menu {
  display: none; /* Hidden by default */
  position: fixed;
  top: 60px;
  right: 0;
  width: auto;
  min-width: 250px;
  max-width: 90vw;
  background: #141a22;
  border: 1px solid #4da3ff;
  border-top: none;
  border-right: none;
  border-radius: 0 0 0 8px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  z-index: 1000;
}
.mobile-menu.active {
  max-height: 80vh;
  overflow-y: auto;
}

.mobile-menu-section {
  border-bottom: 1px solid #334155;
  padding-bottom: 8px;
}
.mobile-menu-section:first-child {
  padding-top: 0;
}
.mobile-menu-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.mobile-menu-header {
  width: 100%;
  background: #1e293b !important;
  color: #94a3b8 !important;
  border: none !important;
  padding: 14px 20px 10px 20px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-align: left !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  pointer-events: none;
  margin-top: 8px;
}
.mobile-menu-section:first-child .mobile-menu-header {
  margin-top: 0;
}

.mobile-menu-item {
  display: block;
  width: 100%;
  background: transparent !important;
  color: #e6eefb !important;
  border: none !important;
  padding: 18px 20px !important;
  font-size: 16px !important;
  text-align: left !important;
  text-decoration: none !important;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid #1e293b;
}
.mobile-menu-item:hover {
  background: #1e293b !important;
}
.mobile-menu-section .mobile-menu-item:last-child {
  border-bottom: none;
}

.mobile-menu-user {
  padding: 12px 20px;
  color: #94a3b8;
  font-size: 13px;
  text-align: center;
  border-top: 1px solid #334155;
}

/* Show hamburger and hide desktop menu on mobile */
/* New operator toast notification */
.operator-toast {
  position: fixed;
  top: 70px;
  right: 20px;
  background: #1e293b;
  border: 1px solid #4da3ff;
  border-radius: 8px;
  padding: 14px 18px;
  color: #e6eefb;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  pointer-events: none;
}
.operator-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.operator-toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
}
.operator-toast-icon {
  font-size: 20px;
}
.operator-toast-text strong {
  color: #4da3ff;
  font-weight: 600;
}

/* Explicitly hide mobile controls on desktop */
.sidebar-toggle-btn,
.hamburger-btn,
.mobile-sidebar,
.mobile-menu {
  display: none !important;
}

@media (max-width: 900px) {
  .sidebar-toggle-btn {
    display: flex !important;
  }
  .mobile-sidebar {
    display: block !important;
  }
  .hamburger-btn {
    display: flex !important;
  }
  .mobile-menu {
    display: block !important;
  }
  .desktop-only {
    display: none !important;
  }
  
  /* Hide log and operators sections on mobile - shown in sidebars */
  .logwrap,
  aside {
    display: none !important;
  }
}

header .header-btn {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  transition: background 0.2s !important;
  text-decoration: none !important;
  display: inline-block !important;
}
header a:hover,
header button:hover,
header .header-btn:hover {
  background: #3578c6 !important;
}

/* ====== Toggle Button for NCS Script ====== */
.toggle-btn {
  background: #4a5568 !important;
  color: #ccc !important;
  border: none !important;
  border-radius: 8px !important; /* Match header button radius */
  padding: 8px 18px !important; /* Match header button padding */
  font-size: 15px !important; /* Match header button font size */
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important; /* Match header button shadow */
  transition: background 0.2s !important; /* Match header button transition */
  text-decoration: none !important;
  display: inline-flex; /* Use inline-flex for better centering - NO !important so inline styles can override */
  align-items: center !important; /* Center content vertically */
  justify-content: center !important; /* Center content horizontally */
  margin: 0 2px; /* Match header button margin */
  white-space: nowrap; /* Prevent text wrapping inside buttons */
  height: 40px; /* Fixed height for consistency */
  box-sizing: border-box; /* Include padding in height calculation */
  vertical-align: top; /* Align with other buttons */
}

.toggle-btn:hover {
  background: #2d3748 !important;
}

.toggle-btn[data-active="true"] {
  background: #4da3ff !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important; /* Match header button shadow */
}

.toggle-btn[data-active="true"]:hover {
  background: #3578c6 !important; /* Match header button hover */
}

/* ====== Section Headers (consistent blue lines) ====== */
.logwrap h2,
.formcol h2,
.ncs-script-column h2,
.history-report-column h2,
aside h2 {
  color: #fff;
  font-size: 18px;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #4a90e2;
  height: 26px; /* Fixed height to align all blue lines */
  display: flex;
  align-items: center;
  justify-content: center; /* Center text horizontally */
  text-align: center; /* Fallback centering */
}

/* Log wrapper with font controls - similar to NCS script */
.log-wrapper {
  background: #141a22;
  border: 1px solid #4da3ff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%; /* Take full available height */
  position: relative; /* For positioning font controls */
  /* Hide scrollbar while keeping functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.log-wrapper::-webkit-scrollbar {
  display: none;
}

/* Log font size controls - floating at top like NCS script */
.log-font-controls {
  position: sticky;
  top: -12px; /* Account for wrapper padding */
  right: -12px;
  z-index: 10;
  background: rgba(20, 26, 34, 0.95);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid #4da3ff;
  padding: 8px 12px;
  margin: -12px -12px 8px -12px; /* Extend to wrapper edges */
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
  border-radius: 8px 8px 0 0;
}

.log-font-btn {
  background: #2c3e50;
  border: 1px solid #4da3ff;
  border-radius: 4px;
  color: #e6eefb;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s ease;
  line-height: 1;
}

.log-font-btn:hover {
  background: #34495e;
  border-color: #3498db;
  transform: scale(1.05);
}

.log-font-size {
  color: #e6eefb;
  font-size: 11px;
  font-weight: 500;
  min-width: 35px;
  text-align: center;
}

/* NCS Script header with inline button */
.ncs-script-column h2 {
  justify-content: center; /* Center the content */
  flex-shrink: 0; /* Prevent header from shrinking */
  margin: 0 0 8px 0; /* Match logwrap h2 margin */
  position: relative; /* For absolute positioning of button */
}

/* Position the popout button absolutely */
.ncs-script-popout-btn {
  position: absolute !important;
  right: 0 !important;
  top: 40% !important;
  transform: translateY(-50%) !important;
}

/* History Report header with inline button */
.history-report-column h2 {
  justify-content: center; /* Center the content */
  flex-shrink: 0; /* Prevent header from shrinking */
  margin: 0 0 8px 0; /* Match logwrap h2 margin */
  position: relative; /* For absolute positioning of button */
}

/* Position the popout button absolutely */
.history-report-popout-btn {
  position: absolute !important;
  right: 0 !important;
  top: 40% !important;
  transform: translateY(-50%) !important;
}
.ncs-script-controls {
  border-top: 1px solid #333;
  padding-top: 10px;
  margin-top: 10px;
}

.ncs-script-controls label {
  color: #ccc;
  font-size: 14px;
  cursor: pointer;
}

.ncs-script-controls input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.ncs-script-controls button {
  background: #4da3ff;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.ncs-script-controls button:hover {
  background: #3578c6;
}

/* ====== NCS Script Column ====== */
.ncs-script-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%; /* Match parent height */
  max-height: 100%; /* Ensure it doesn't exceed container */
}

.ncs-script-header-actions {
  /* Remove margin since button is now inline with header */
  display: none; /* Hide the separate header actions container */
}

.ncs-script-popout-btn {
  background: #4da3ff;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px; /* Reduced padding to fit in standardized header height */
  font-size: 11px; /* Slightly smaller font */
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap; /* Prevent text wrapping */
  height: 24px; /* Fixed height to fit within header */
  display: flex;
  align-items: center;
}

.ncs-script-popout-btn:hover {
  background: #3578c6;
}

.ncs-script-wrapper {
  background: #141a22; /* Match other containers */
  border: 1px solid #4da3ff; /* Add border like log column */
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow-y: scroll; /* Ensure scrolling works */
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  height: calc(100% - 34px); /* Subtract header height (26px) + margin (8px) to match log column */
  position: relative; /* For positioning font controls */
  /* Hide scrollbar while keeping functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

/* Font size controls - floating at top */
.ncs-font-controls {
  position: sticky;
  top: -12px; /* Account for wrapper padding */
  right: -12px;
  z-index: 10;
  background: rgba(20, 26, 34, 0.95);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid #4da3ff;
  padding: 8px 12px;
  margin: -12px -12px 8px -12px; /* Extend to wrapper edges */
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
  border-radius: 8px 8px 0 0;
}

.ncs-font-btn {
  background: #2c3e50;
  border: 1px solid #4da3ff;
  border-radius: 4px;
  color: #e6eefb;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s ease;
  line-height: 1;
}

.ncs-font-btn:hover {
  background: #34495e;
  border-color: #3498db;
  transform: scale(1.05);
}

.ncs-font-size {
  color: #e6eefb;
  font-size: 11px;
  font-weight: 500;
  min-width: 35px;
  text-align: center;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.ncs-script-wrapper::-webkit-scrollbar {
  display: none;
}

.ncs-script-content {
  color: #ccc;
  font-size: 14px;
  line-height: 1.4;
}

/* NCS Script content styling (matching page theme) */
.ncs-script-content .block {
  background: #141a22; /* Match page containers */
  border: 1px solid #4da3ff;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}

.ncs-script-content h2 {
  margin: 0 0 8px 0 !important;
  font-size: 16px !important;
  color: #fff !important;
  border-bottom: 1px solid #444 !important;
  padding-bottom: 4px !important;
}

.ncs-script-content p,
.ncs-script-content li {
  font-size: 13px;
  line-height: 1.5;
  margin: 6px 0;
  color: #ccc;
}

.ncs-script-content ul,
.ncs-script-content ol {
  margin: 0 0 0 16px;
}

.ncs-script-content .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0;
  font-size: 12px;
  color: #999;
}

.ncs-script-content .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

.ncs-script-content .ncs {
  color: #ff8ec3;
}

.ncs-script-content .op {
  color: #8ad1ff;
}

.ncs-script-content .stage {
  color: #ff7a7a;
}

.ncs-script-content .swatch.ncs {
  background: #ff8ec3;
}

.ncs-script-content .swatch.op {
  background: #8ad1ff;
}

.ncs-script-content .swatch.stage {
  background: #ff7a7a;
}

.ncs-script-content .note {
  font-size: 12px;
  color: #888;
}

.ncs-script-content .note.ncs {
  color: #ff8ec3;
}

.ncs-script-content a {
  color: #4da3ff;
  text-decoration: none;
}

.ncs-script-content a:hover {
  text-decoration: underline;
}

/* ====== History Report Column ====== */
.history-report-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%; /* Match parent height */
  max-height: 100%; /* Ensure it doesn't exceed container */
}



.history-report-wrapper {
  background: #141a22;
  border: 1px solid #4da3ff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  height: calc(100% - 34px);
  position: relative;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.history-report-wrapper::-webkit-scrollbar {
  display: none;
}

/* Font size controls - floating at top */
.history-font-controls {
  position: sticky;
  top: -12px; /* Account for wrapper padding */
  right: -12px;
  z-index: 10;
  background: rgba(20, 26, 34, 0.95);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid #4da3ff;
  padding: 8px 12px;
  margin: -12px -12px 8px -12px; /* Extend to wrapper edges */
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
  border-radius: 8px 8px 0 0;
}

.history-font-btn {
  background: #2c3e50;
  border: 1px solid #4da3ff;
  border-radius: 4px;
  color: #e6eefb;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s ease;
  line-height: 1;
}

.history-font-btn:hover {
  background: #34495e;
  border-color: #3498db;
  transform: scale(1.05);
}

.history-font-size {
  color: #e6eefb;
  font-size: 11px;
  font-weight: 500;
  min-width: 35px;
  text-align: center;
}

.history-report-content {
  height: 100%;
  width: 100%;
  max-width: 100%;
  border: none;
  border-radius: 4px;
  background: #141a22;
  overflow: hidden;
  box-sizing: border-box;
}

/* History report cards - override default card styling when embedded */
.history-report-content .card {
  border: 1px solid #4da3ff !important; /* Blue border to match theme */
  background: #141a22 !important; /* Match other containers */
}

/* Override history.php embedded styles for both inline and popout views */
.history-report-content .card,
.history-report-wrapper .card,
iframe .card,
.card {
  border: 1px solid #4da3ff !important;
  background: #141a22 !important;
}

/* Ensure body background matches when embedded */
.history-report-content body,
.history-report-wrapper body {
  background: var(--bg) !important;
}

/* Click-to-darken functionality for embedded script */
.ncs-script-content .block {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.ncs-script-content .block.dimmed {
  opacity: 0.4;
  border: 1px solid #333; /* Use original border color when dimmed */
}

.ncs-script-content .block:hover {
  background: #1a2028;
}

/* ====== User Admin Column ====== */
.user-admin-column {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

.user-admin-column h2 {
  justify-content: center; /* Center the content */
  flex-shrink: 0; /* Prevent header from shrinking */
  margin: 0 0 12px 0; /* Match working headers */
  position: relative; /* For absolute positioning of button */
  font-size: 18px; /* Match other headers */
  color: #fff !important; /* Match other headers */
  border-bottom: 2px solid #4a90e2 !important; /* Match main headers thickness */
  padding-bottom: 8px !important; /* Match working headers */
  text-align: center; /* Center the text */
  height: 26px; /* Fixed height to match working headers */
  display: flex;
  align-items: center;
}



.user-admin-wrapper {
  background: #141a22; /* Match other containers */
  border: 1px solid #4da3ff; /* Add border like other columns */
  border-radius: 8px;
  padding: 0; /* Remove padding to prevent overflow */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden; /* Prevent any overflow */
  flex: 1;
  min-height: 0;
  height: calc(100% - 38px); /* Subtract header (26px height + 8px padding-bottom + 2px border + 12px margin) */
  position: relative;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.user-admin-wrapper::-webkit-scrollbar {
  display: none;
}

.user-admin-content {
  height: 100%;
  width: 100%;
  max-width: 100%;
  border: none;
  border-radius: 4px;
  background: #141a22;
  display: block;
  overflow-x: hidden;
  box-sizing: border-box;
}

.user-admin-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ====== NET Admin Column ====== */
.net-admin-column {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

.net-admin-column h2 {
  justify-content: center; /* Center the content */
  flex-shrink: 0; /* Prevent header from shrinking */
  margin: 0 0 12px 0; /* Match working headers */
  position: relative; /* For absolute positioning of button */
  font-size: 18px; /* Match other headers */
  color: #fff !important; /* Match other headers */
  border-bottom: 2px solid #4a90e2 !important; /* Match main headers thickness */
  padding-bottom: 8px !important; /* Match working headers */
  text-align: center; /* Center the text */
  height: 26px; /* Fixed height to match working headers */
  display: flex;
  align-items: center;
}



.net-admin-wrapper {
  background: #141a22; /* Match other containers */
  border: 1px solid #4da3ff; /* Add border like other columns */
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  height: calc(100% - 38px);
  position: relative;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.net-admin-wrapper::-webkit-scrollbar {
  display: none;
}

.net-admin-content {
  height: 100%;
  width: 100%;
  max-width: 100%;
  border: none;
  border-radius: 4px;
  background: #141a22;
  display: block;
  overflow-x: hidden;
  box-sizing: border-box;
  padding: 12px;
}

.net-admin-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Hide scrollbar for Chrome, Safari and Opera on iframe */
#netAdminIframe::-webkit-scrollbar {
  display: none;
}

/* ====== Change Password Column ====== */
.change-password-column {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
}

.change-password-column h2 {
  justify-content: center; /* Center the content */
  flex-shrink: 0; /* Prevent header from shrinking */
  margin: 0 0 8px 0; /* Match other headers */
  font-size: 18px; /* Match other headers */
  color: #fff !important; /* Match other headers */
  border-bottom: 2px solid #4a90e2 !important; /* Match main headers thickness */
  padding-bottom: 4px !important; /* Space for the border */
  text-align: center; /* Center the text */
  height: 26px; /* Fixed height to align all blue lines */
  display: flex;
  align-items: center;
  justify-content: center; /* Center text horizontally */
}

.change-password-wrapper {
  background: #141a22; /* Match other containers */
  border: 1px solid #4da3ff; /* Add border like other columns */
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow-y: auto; /* Enable scrolling but hide scrollbar */
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  height: calc(100% - 34px); /* Subtract header height + margin */
  position: relative;
  /* Hide scrollbar while keeping functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.change-password-wrapper::-webkit-scrollbar {
  display: none;
}

.change-password-content {
  height: 100%;
  width: 100%;
  border: none;
  border-radius: 4px;
  background: #141a22; /* Match container background */
}

/* Iframe specific styling to prevent scrollbars */
#changePasswordIframe {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

/* Hide scrollbar for Chrome, Safari and Opera on iframe */
#changePasswordIframe::-webkit-scrollbar {
  display: none;
}

/* ====== Schedule Column ====== */
.schedule-column {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
}

.schedule-column h2 {
  justify-content: center;
  flex-shrink: 0;
  margin: 0 0 8px 0;
  font-size: 18px;
  color: #fff !important;
  border-bottom: 2px solid #4a90e2 !important;
  padding-bottom: 4px !important;
  text-align: center;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.schedule-wrapper {
  background: #141a22;
  border: 1px solid #4da3ff;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  height: calc(100% - 34px);
  position: relative;
}

.schedule-wrapper::-webkit-scrollbar {
  display: none;
}

.schedule-content {
  height: 100%;
  width: 100%;
  max-width: 100%;
  border: none;
  border-radius: 4px;
  background: #141a22;
  overflow: hidden;
  box-sizing: border-box;
}

#scheduleIframe {
  scrollbar-width: none;
  -ms-overflow-style: none;
  overflow: hidden;
}

#scheduleIframe::-webkit-scrollbar {
  display: none;
  width: 0 !important;
  height: 0 !important;
}

/* Ensure all iframes fit within their containers */
.schedule-content iframe,
.history-report-content iframe,
.user-admin-content iframe,
.net-admin-content iframe,
.ncs-script-content iframe,
.change-password-content iframe {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

/* ====== Layout: Dynamic 3/4 columns ====== */
.layout {
  display: grid !important;
  grid-template-columns: 300px 1fr 170px !important;
  column-gap: 12px !important;
  row-gap: 32px;
  min-height: 0 !important;
  position: fixed;
  top: 82px; /* Header height + margin */
  left: 0;
  right: 0;
  bottom: 8px; /* Small bottom padding */
  padding: 0 8px;
  transition: none !important;
  align-items: stretch;
  overflow: visible !important;
  transform: translateZ(0) !important;
  isolation: isolate !important;
  grid-template-rows: minmax(0, 1fr) !important;
}

/* 4-column layout when NCS script is active */
.layout.ncs-script-active {
  grid-template-columns: 300px minmax(573px, 720px) 1fr 170px !important; /* 4-column: increased log from 260px to 300px for scrollbar accommodation */
  column-gap: 12px !important; /* Standard gap for better spacing between columns */
  /* Remove transition to prevent layout shifts */
  transition: none !important;
}

/* 4-column layout when History Report is active */
.layout.history-report-active {
  grid-template-columns: 300px minmax(573px, 720px) 1fr 170px !important; /* 4-column layout */
  column-gap: 12px !important;
  /* Remove transition to prevent layout shifts */
  transition: none !important;
}

/* 4-column layout when User Admin is active */
.layout.user-admin-active {
  grid-template-columns: 300px minmax(573px, 720px) 1fr 170px !important; /* 4-column layout */
  column-gap: 12px !important;
  /* Remove transition to prevent layout shifts */
  transition: none !important;
}

/* 4-column layout when NET Admin is active */
.layout.net-admin-active {
  grid-template-columns: 300px minmax(573px, 720px) 1fr 170px !important; /* 4-column layout */
  column-gap: 12px !important;
  /* Remove transition to prevent layout shifts */
  transition: none !important;
}

/* 4-column layout when Change Password is active */
.layout.change-password-active {
  grid-template-columns: 300px minmax(573px, 720px) 1fr 170px !important; /* 4-column layout */
  column-gap: 12px !important;
  /* Remove transition to prevent layout shifts */
  transition: none !important;
}

/* 4-column layout when Schedule is active */
.layout.schedule-active {
  grid-template-columns: 300px minmax(573px, 720px) 1fr 170px !important;
  column-gap: 12px !important;
  transition: none !important;
}
.layout > * { 
  min-height: 0 !important; 
  height: 100%; /* Ensure all grid items take full height */
  /* Add containment to prevent layout shifts */
  contain: layout style !important;
  /* Prevent overflows */
  overflow: hidden !important;
}

/* ====== Clock Positioning ====== */
#pstClockContainer {
  position: absolute !important;
  top: 100% !important;
  margin-top: 20px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 1000 !important;
  pointer-events: none !important;
  transition: none !important;
  contain: layout !important;
}

/* Clock stays in same position regardless of layout state */
body.ncs-active #pstClockContainer,
body.ncs-script-active #pstClockContainer,
body.history-report-active #pstClockContainer,
body.user-admin-active #pstClockContainer,
body.net-admin-active #pstClockContainer,
body.change-password-active #pstClockContainer,
body.schedule-active #pstClockContainer {
  position: absolute !important;
  top: 100% !important;
  margin-top: 20px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
}

/* Remove responsive clock positioning that can cause layout shifts */
/* Keep clock consistently centered for all screen sizes */

/* Left column */
.logwrap {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
  min-width: 270px;
  max-width: 340px;
  height: 100%; /* Take full height of grid cell */
  /* Add containment to prevent layout shifts */
  contain: layout style !important;
  overflow: visible !important;
}
.logwrap h2 { margin: 0 0 8px 0; }
#log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible; /* Let the wrapper handle scrolling */
  height: auto;
  background: transparent; /* Let wrapper provide background */
  border: none; /* Remove border since wrapper has it */
  border-radius: 0;
  padding: 0; /* Remove padding since wrapper has it */
}
.rowlog {
  padding: 10px 12px;
  margin: 3px 0;
  border: 1px solid #4da3ff;
  border-radius: 4px;
  background: #223;
  color: #e6eefb;
  cursor: pointer;
  width: 100%;
  word-wrap: break-word;
  transition: all 0.2s ease;
}

.rowlog:hover { 
  background: #334;
  border-color: #4da3ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Log entry update flash animation */
@keyframes logEntryFlash {
  0% { 
    background: #c00;
    border-color: #ff4444;
    transform: scale(1.02);
  }
  50% { 
    background: #d44;
    border-color: #ff6666;
  }
  100% { 
    background: #223;
    border-color: #2a4f5a;
    transform: scale(1);
  }
}

.rowlog.flash-update {
  animation: logEntryFlash 0.8s ease-out;
}

.meta { font-size: 0.8em; color: #666; }

/* Center column */
.formcol {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow: hidden; /* Clip content to viewport bounds */
  min-width: 0;
  max-width: 100%;
  padding: 0 8px;
  height: 100%;
  max-height: 100%;
  position: relative;
  box-sizing: border-box !important;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.formcol::-webkit-scrollbar {
  display: none;
}

/* When NCS script is active, constrain the form column width */
.layout.ncs-script-active .formcol {
  min-width: 573px;
  max-width: 720px;
  width: 100%;
}

/* Logger section wrapper */
.logger-wrap {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  flex: 1; /* Fill available space */
  min-height: 0; /* Allow shrinking */
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 1;
  position: relative !important;
  contain: layout style !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.logger-wrap::-webkit-scrollbar {
  display: none;
}
.logger-wrap h2 { 
  margin: 0 0 8px 0; 
  color: #fff !important;
}
#logForm {
  width: 100%;
  max-width: 720px;
  background: #141a22 !important;
  border: 1px solid #4da3ff !important;
  border-radius: 8px !important;
  padding: 20px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
}
#logForm .row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: nowrap;
}
#logForm label {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: #e6eefb !important;
}
#logForm input:not(#ncsMsg), #logForm textarea {
  padding: 8px;
  font-weight: bold !important;
  border: 1px solid #4da3ff !important;
  border-radius: 4px !important;
  background: #223 !important;
  color: #e6eefb !important;
  -webkit-text-fill-color: #e6eefb !important;
  caret-color: #fff !important;
  /* Remove transition that could cause layout shifts */
  transition: none !important;
  box-sizing: border-box !important; /* Ensure padding/border included in width */
  max-width: 100% !important; /* Prevent overflow */
  width: 100% !important; /* Fill available space */
  /* Add containment to prevent layout shifts */
  contain: layout style !important;
}
#logForm input:focus, #logForm textarea:focus {
  border-color: #3578c6 !important;
  background: #233041 !important;
  outline: none !important;
  /* Remove box-shadow that could cause layout shifts */
  box-shadow: none !important;
  caret-color: #fff !important;
  /* Ensure no dimension changes on focus */
  border-width: 1px !important;
  padding: 8px !important; /* Maintain same padding */
}
#logForm input::placeholder, #logForm textarea::placeholder {
  color: #7a8ca3 !important;
  -webkit-text-fill-color: #7a8ca3 !important;
}
label.op      { flex: 0 0 180px; } /* +2 characters wider */
label.rst     { flex: 0 0 140px; } /* +3 characters longer */
label.name    { flex: 1 0 260px; } /* -20px shorter */
label.qth     { flex: 1 0 245px; } /* -35px shorter total (originally -20px, now additional -15px) */
label.radio   { flex: 1 0 240px; } /* -20px shorter */
label.antenna { flex: 1 0 260px; } /* -20px shorter */
label.comments{ flex: 0 1 310px; min-width: 225px; align-items: stretch; } /* Extended by 10px (300px → 310px) */
label.power   { flex: 0 0 120px; } /* Wider label for better visibility */
label.laston  { flex: 0 0 152px; } /* Increased by ~7px (50% of the 15px reduction) */
#logForm input[type="datetime-local"],
#logForm input[type="date"] { width: 100%; }
label.comments textarea {
  width: 100%;
  min-height: 3.2em;
  resize: vertical;
  line-height: 1.3;
}
#power {
  width: 50px !important; /* Reduced by ~30px (about 4 characters) */
  min-width: 50px !important; /* Ensure minimum width */
  max-width: 50px !important; /* Prevent stretching */
  appearance: textfield;
  -moz-appearance: textfield;
}
#power::-webkit-outer-spin-button,
#power::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Form actions - Save Log and NCS note as part of form */
.form-actions {
  background: #141a22 !important;
  padding: 16px 0 0 0 !important;
  margin-top: 16px !important;
  margin-bottom: 20px !important; /* Add bottom margin to create space before chat */
  /* Add positioning context for absolutely positioned chat */
  position: relative !important;
  contain: layout style !important;
}

/* Chat wrapper - provides stable container for chat */
.chat-wrapper {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: 720px !important;
  margin-top: 8px !important;
  overflow: visible !important;
  contain: layout !important;
  transform: translate3d(0, 0, 0) !important;
  isolation: isolate !important;
  box-sizing: border-box !important;
  will-change: auto !important;
  display: block !important;
  z-index: 1 !important;
  padding: 0 !important;
}

/* Chat container - in center column, below form */
.chat-container {
  background: #0e141b !important;
  border: 1px solid #4da3ff !important;
  border-radius: 6px !important;
  padding: 12px !important;
  margin: 0 !important; /* Remove margin since wrapper handles spacing */
  width: 100% !important;
  max-width: 720px !important;
  position: relative !important;
  z-index: 1 !important;
  clear: both !important; /* Ensure it clears any floated elements */
  /* Auto height to fit content */
  height: auto !important;
  display: flex !important; /* Use flexbox for internal layout */
  flex-direction: column !important; /* Stack children vertically */
  /* Prevent any dimension changes that could cause shifts */
  box-sizing: border-box !important;
  contain: layout style paint !important;
  /* Force GPU layer to prevent paint-related shifts */
  transform: translateZ(0) !important;
  will-change: auto !important;
  /* Completely isolate from document flow */
  isolation: isolate !important;
  min-width: 100% !important;
  max-width: 720px !important;
  overflow: visible !important;
}

/* Chat header integrated with divider */
.chat-header-divider {
  border-top: 1px solid #4da3ff !important;
  position: relative !important;
  margin: 0 0 6px 0 !important;
  text-align: center !important;
  /* Fixed height to prevent layout shifts */
  height: 14px !important;
  flex-shrink: 0 !important;
  contain: layout style !important;
}

.chat-header-text {
  background: #0e141b !important;
  color: #e6eefb !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 0 12px !important;
  position: relative !important;
  top: -7px !important;
  display: inline-block !important;
  /* Fixed dimensions to prevent shifts */
  height: 14px !important;
  line-height: 14px !important;
  contain: layout style !important;
}

/* Remove the old h3 styling since we're not using it */
#formActionArea h3 {
  display: none !important;
}

/* NCS note input styling - part of log action zone */
#ncsMsg {
  background: #223 !important;
  color: #e6eefb !important;
  -webkit-text-fill-color: #e6eefb !important; /* Ensure white text on webkit browsers */
  caret-color: #fff !important; /* White cursor */
  border: 1px solid #4da3ff !important;
  border-radius: 4px !important;
  padding: 6px 10px !important;
  margin-left: 80px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s !important;
  box-shadow: 0 1px 3px rgba(77, 163, 255, 0.1) !important;
  width: 200px !important;
}
#ncsMsg:focus {
  border-color: #3578c6 !important;
  background: #233041 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(61, 163, 255, 0.2), 0 2px 6px rgba(77, 163, 255, 0.15) !important;
  caret-color: #fff !important; /* Ensure white cursor on focus */
}

/* Right column */
aside {
  flex: 0 0 170px; /* Reduced from 280px to 170px (60% of original) */
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 0 !important;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Add containment to prevent layout shifts */
  contain: layout style !important;
}

/* Online operators section */
.operators-wrap {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
}
.operators-wrap h2 { 
  margin: 0 0 8px 0; 
  color: #fff !important;
}
#onlineList {
  border: 1px solid #4da3ff;
  border-radius: 8px;
  padding: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #141a22;
}

/* NCS messages section */
.ncs-wrap {
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
  margin-top: 16px;
  /* Prevent layout shifts during visibility changes */
  contain: layout style !important;
  /* Start completely hidden to prevent initial flash */
  opacity: 0 !important;
  visibility: hidden !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  /* Transition only when needed */
  transition: none !important;
}

/* Only show when explicitly enabled via JavaScript */
.ncs-wrap.ncs-visible {
  opacity: 1 !important;
  visibility: visible !important;
  position: static !important;
}
.ncs-wrap h2 { 
  margin: 0 0 8px 0; 
  color: #fff !important;
}
#ncsNotes {
  border: 1px solid #4da3ff;
  border-radius: 8px;
  padding: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #141a22;
}
.side-title { margin: 0 0 8px 0; font-size: 16px; }
.user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  margin: 2px 0;
  border: 1px solid #4da3ff;
  border-radius: 4px;
  background: #223;
  color: #e6eefb;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user:hover {
  background: #334;
  border-color: #4da3ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.user:last-child { 
  border: 1px solid #4da3ff; 
}
.muted { color: var(--muted); font-size: 12px; }
.user .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 0 3px rgba(0,0,0,0.3);
  background-color: #2ecc71 !important; /* Default to green for OP */
}
.user.ncs .dot { 
  background-color: #4da3ff !important; 
  border-color: #3578c6 !important;
  box-shadow: 0 0 4px rgba(77, 163, 255, 0.4) !important;
}
.user.op .dot { 
  background-color: #2ecc71 !important;
  border-color: #27ae60 !important;
  box-shadow: 0 0 4px rgba(46, 204, 113, 0.4) !important;
}

/* Context menu */
#contextMenu {
  position: absolute;
  display: none;
  background: #fff;
  border: 1px solid #ccc;
  z-index: 1000;
}
#contextMenu ul { list-style: none; margin: 0; padding: 0; }
#contextMenu li { padding: 8px 12px; cursor: pointer; }
#contextMenu li:hover { background: #eee; }

/* ====== Auth & account pages ====== */
.center-page .card {
  background: #141a22;
  border: 1px solid #4da3ff;
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 4px 16px rgba(77, 163, 255, 0.15);
}
.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  margin: 0;
}
.card h1 { margin-top: 0; }
.card label { display: block; margin-top: 12px; }
.card input { 
  width: 100%; 
  padding: 10px; 
  margin-top: 6px; 
  background: #223 !important;
  color: #e6eefb !important;
  border: 1px solid #4da3ff !important;
  border-radius: 4px !important;
  -webkit-text-fill-color: #e6eefb !important;
  caret-color: #fff !important;
  transition: border-color 0.2s, background-color 0.2s !important;
  text-shadow: none !important;
}
.card input:focus {
  border-color: #3578c6 !important;
  background: #233041 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(61, 163, 255, 0.2) !important;
  caret-color: #fff !important;
}
.card input::placeholder {
  color: #7a8ca3 !important;
  -webkit-text-fill-color: #7a8ca3 !important;
}
.card button { margin-top: 16px; padding: 10px 14px; cursor: pointer; }
.error { color: #b00020; margin-top: 10px; }
.ok { color: #0b7a0b; margin-top: 10px; }
.meta-note { color: #666; font-size: 12px; margin-top: 10px; }
.backbar {
  display: flex; justify-content: space-between; align-items: center; margin: 24px;
}

/* Auth & account page button/link styling */
.card button,
.card a.header-btn,
.card a[href="/auth/register.php"],
.card a[href="/auth/login.php"],
.card a[href="/auth/forgot_password.php"],
.back-btn {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  transition: background 0.2s !important;
  text-decoration: none !important;
  display: inline-block !important;
  margin-bottom: 8px !important;
}
.card button:hover,
.card a.header-btn:hover,
.card a[href="/auth/register.php"]:hover,
.card a[href="/auth/login.php"]:hover,
.back-btn:hover {
  background: #3578c6 !important;
}

/* Responsive niceties */
@media (max-height: 560px) {
  :root {
    --bg: #0b0f14;
    --fg: #e6eefb;
    --panel: #0e141b;
    --card: #141a22;
    --line: #223;
    --border: var(--line);
    --muted: #a9b3c3;
    --gap: 32px;
  }
}

/* Log row status dot */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 1px #0001 inset;
}
.status-ok   { background: #1aa31a; }
.status-warn { background: #ff9800; }
.status-bad  { background: #e53935; }
.status-earlyout { background: #2196f3;}

/* Operator box: 8 chars wide */
#op { width: 10ch; }

/* RST inputs: 5 chars wide */
#rst_sent,
#rst_rcvd {
  width: 8ch;
  background-color: grey;
}

/* Last On: shorten date input */
#last_on { width: 12ch; }

/* Admin page overrides */
.admin-page {
  display: block !important;
  height: auto !important;
  overflow: auto !important;
  padding: 20px 10%;
  grid-template-rows: unset !important;
}
.admin-page .section {
  max-width: 980px;
  margin: 0 auto 24px;
}
.admin-page .backbar {
  margin: 24px auto;
  max-width: 980px;
}
.admin-page .backbar a,
.admin-page .backbar .logout-btn {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  transition: background 0.2s !important;
  text-decoration: none !important;
  display: inline-block !important;
  margin-bottom: 8px !important;
}
.admin-page .backbar a:hover,
.admin-page .backbar .logout-btn:hover {
  background: #3578c6 !important;
}
.admin-page .backbar,
.admin-page .backbar strong {
  color: #fff !important;
}

/* No permission message */
#noPermMsg {
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9em;
  color: #555;
}
.form-wrapper {
  margin-top: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  flex-shrink: 0; /* Prevent the form from shrinking */
  /* Enhanced stability to prevent layout shifts */
  contain: layout style !important;
  box-sizing: border-box !important;
  /* Create positioning context for absolutely positioned chat */
  position: relative !important;
  /* Add bottom margin to provide space for absolutely positioned chat */
  margin-bottom: 320px !important; /* Chat wrapper height + some padding */
}

/* NCS quick notes */
#ncsNotes {
  max-height: 40vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  font-weight: bold !important;
}
.ncs-note {
  background: #e53935 !important;
  color: #fff !important;
  border-radius: 6px;
  padding: 6px 8px;
  margin-top: 8px;
  font-size: 0.92em;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,.08) inset;
}
.ncs-note:hover { 
  filter: brightness(1.05); 
  background: #d32f2f !important;
}
#ncsNotesTitle {
  font-weight: bold !important;
}

/* Save button - styled to connect with log section */
#saveLogBtn {
  background: linear-gradient(135deg, #4da3ff 0%, #3578c6 100%) !important;
  color: #fff !important;
  border: 2px solid #4da3ff !important;
  border-radius: 6px !important;
  padding: 8px 16px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 6px rgba(77, 163, 255, 0.15) !important;
  transition: all 0.2s ease !important;
  text-shadow: none !important;
  letter-spacing: 0.3px !important;
}
#saveLogBtn:hover {
  background: linear-gradient(135deg, #3578c6 0%, #2056a3 100%) !important;
  box-shadow: 0 3px 8px rgba(77, 163, 255, 0.25) !important;
  transform: translateY(-1px) !important;
}

/* NCS note input */
#ncsMsg { margin-left: 150px; }

/* ====== Combined color overrides ====== */
.card, .card *,
.side-title,
.logwrap h2,
.logger-wrap h2,
.operators-wrap h2,
.ncs-wrap h2,
.admin-page h1, .admin-page h2,
.admin-page table td,
label,
#onlineList, #onlineList *, header * {
  color: #fff !important;
}

#log, #log * { color: #e6eefb !important; }
#log .meta, #log .muted { color: #a9b3c3 !important; }

#chatBox, #chatBox * { background: #fafafa !important; color: #000 !important; }
#chatBox .chat-edited,
#chatBox .chat-deleted { background: transparent !important; color: #9ba8b8 !important; }

input, textarea, select, #log input[data-mini] {
  color: #000 !important;
  background: #fff !important;
  border: 1px solid #cfd3d7 !important;
  -webkit-text-fill-color: #000 !important;
  text-shadow: none !important;
  caret-color: #000;
}
input::placeholder, textarea::placeholder, #log input[data-mini]::placeholder {
  color: #666 !important;
  -webkit-text-fill-color: #666 !important;
}
#logForm input:-webkit-autofill,
#logForm textarea:-webkit-autofill,
#logForm select:-webkit-autofill {
  -webkit-text-fill-color: #000 !important;
  transition: background-color 9999s ease-in-out 0s !important;
}

/* Card input dark theme override - must come after general input rules */
.card input,
.center-page .card input {
  background: #223 !important;
  color: #e6eefb !important;
  border: 1px solid #4da3ff !important;
  border-radius: 4px !important;
  -webkit-text-fill-color: #e6eefb !important;
  caret-color: #fff !important;
  text-shadow: none !important;
}

.card input:focus,
.center-page .card input:focus {
  border-color: #3578c6 !important;
  background: #233041 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(61, 163, 255, 0.2) !important;
  caret-color: #fff !important;
}

.card input::placeholder,
.center-page .card input::placeholder {
  color: #7a8ca3 !important;
  -webkit-text-fill-color: #7a8ca3 !important;
}

/* Autofill overrides for card inputs */
.card input:-webkit-autofill,
.card input:-webkit-autofill:hover,
.card input:-webkit-autofill:focus,
.card input:-webkit-autofill:active,
.center-page .card input:-webkit-autofill,
.center-page .card input:-webkit-autofill:hover,
.center-page .card input:-webkit-autofill:focus,
.center-page .card input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px #223 inset !important;
  -webkit-text-fill-color: #e6eefb !important;
  background: #223 !important;
  color: #e6eefb !important;
  border: 1px solid #4da3ff !important;
  transition: background-color 9999s ease-in-out 0s !important;
}

/* Autofill overrides for all form inputs */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active,
#logForm input:-webkit-autofill,
#logForm input:-webkit-autofill:hover,
#logForm input:-webkit-autofill:focus,
#logForm input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--card) inset !important;
  -webkit-text-fill-color: var(--fg) !important;
  background: var(--card) !important;
  color: var(--fg) !important;
  border: 1px solid #4da3ff !important;
  transition: background-color 9999s ease-in-out 0s !important;
}

/* Mini RST editor button */
#log button[data-mini="save"]:not(.flash-success),
html body #log button[data-mini="save"] {
  color: #000 !important;
  background: #eaeef3 !important;
  border: 1px solid #cfd3d7 !important;
  text-shadow: none !important;
  -webkit-text-fill-color: #000 !important;
}
#log button[data-mini="save"].is-busy {
  opacity: .75;
  pointer-events: none;
}
#log button[data-mini="save"].flash-success,
html body #log button[data-mini="save"].flash-success {
  background: #2ecc71 !important;
  color: #fff !important;
  border-color: #27ae60 !important;
  box-shadow: 0 0 0 2px rgba(46,204,113,.2) !important;
}

/* Dark theme override for mini save buttons */
#log button[data-mini="save"]:not(.flash-success),
html body #log button[data-mini="save"]:not(.flash-success) {
  background: #3498db !important;
  color: #fff !important;
  border: 1px solid #2980b9 !important;
  border-radius: 3px !important;
  padding: 4px 8px !important;
  cursor: pointer !important;
  font-size: 12px !important;
  font-weight: bold !important;
  -webkit-text-fill-color: #fff !important;
  text-shadow: none !important;
}

html body #log button[data-mini="save"]:not(.flash-success):hover {
  background: #2980b9 !important;
}

html body #log button[data-mini="save"]:not(.flash-success):disabled {
  background: #7f8c8d !important;
  border-color: #95a5a6 !important;
  cursor: not-allowed !important;
}

/* PM drag/title bar: force dark & readable */
.pm-win > div:first-child {
  background: grey !important;
  color: white !important;
}
.pm-win > div:first-child .pm-btn { color: #fff !important; }

/* PM header */
.pm-win .pm-head,
.pmWindow .pm-head,
.pm-window .pm-head,
.pm-win .ui-dialog-titlebar {
  background: #0e141b !important;
  color: #e6eefb !important;
  border-bottom: 1px solid #233041 !important;
  font-weight: 600 !important;
}
.pm-win .pm-head .pm-title,
.pm-win .pm-head .title,
.pm-win .pm-head > :not(button),
.pm-win .pm-head button {
  color: #e6eefb !important;
  -webkit-text-fill-color: #e6eefb !important;
  fill: #e6eefb !important;
  background: transparent !important;
  border: 0 !important;
}

/* PM layer */
#pmLayer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

/* Window controls */
.window-controls { -webkit-app-region: no-drag; }
.control-btn {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 0 8px;
}
.control-btn:hover { background-color: rgba(255, 255, 255, 0.2); }
.window-content { pointer-events: auto; }

/* --- Private Message Window: Dark Theme --- */
.pm-win,
.pmWindow,
.pm-window {
  background: #141a22 !important;
  color: #e6eefb !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1.5px 0 #223 inset;
  border: 1px solid #223 !important;
}

.pm-win > div:first-child,
.pm-win .pm-head,
.pmWindow .pm-head,
.pm-window .pm-head,
.pm-win .ui-dialog-titlebar {
  background: linear-gradient(90deg, #223 0%, #233041 100%) !important;
  color: #e6eefb !important;
  border-bottom: 1px solid #233041 !important;
  font-weight: 600 !important;
  padding: 10px 18px !important;
  border-top-left-radius: 12px !important;
  border-top-right-radius: 12px !important;
}

.pm-win .pm-head .pm-title,
.pm-win .pm-head .title,
.pm-win .pm-head > :not(button),
.pm-win .pm-head button {
  color: #e6eefb !important;
  -webkit-text-fill-color: #e6eefb !important;
  fill: #e6eefb !important;
  background: transparent !important;
  border: 0 !important;
}

.pm-win .pm-btn,
.pm-win .ui-dialog-titlebar-close {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 6px !important;
  padding: 6px 14px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  transition: background 0.2s !important;
}
.pm-win .pm-btn:hover,
.pm-win .ui-dialog-titlebar-close:hover {
  background: #3578c6 !important;
}

.pm-win input[type="text"],
.pm-win textarea {
  color: #e6eefb !important;
  -webkit-text-fill-color: #e6eefb !important;
  background: #223 !important;
  border: 1px solid #4da3ff !important;
  border-radius: 6px !important;
  padding: 7px 12px !important;
  font-size: 15px !important;
}

.pm-win input[type="text"]::placeholder,
.pm-win textarea::placeholder {
  color: #7a8ca3 !important;
}

.pm-win .pm-body,
.pmWindow .pm-body,
.pm-window .pm-body {
  background: #141a22 !important;
  color: #e6eefb !important;
  padding: 16px !important;
  border-bottom-left-radius: 12px !important;
  border-bottom-right-radius: 12px !important;
}

.pm-win .pm-message,
.pmWindow .pm-message,
.pm-window .pm-message {
  background: #223 !important;
  color: #e6eefb !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  margin-bottom: 8px !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.08) inset;
}

.pm-win .pm-message.me {
  background: #4da3ff !important;
  color: #fff !important;
}

.pm-win .pm-message .meta {
  color: #a9b3c3 !important;
  font-size: 12px !important;
}

/* Chat box styles */
#chatBox {
  background: #141a22 !important;
  color: #e6eefb !important;
  border: 1px solid #4da3ff !important;
  border-radius: 4px !important;
  padding: 8px 14px 8px 8px !important;
  font-size: 14px !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  /* Resizable height */
  height: 180px !important; /* Default height */
  min-height: 100px !important; /* Minimum height for usability */
  max-height: 500px !important; /* Maximum height to prevent excessive expansion */
  overflow: auto !important; /* Required for resize to work */
  scrollbar-width: none !important; /* Hide scrollbar for Firefox */
  margin-bottom: 8px !important; /* Space between chat and input */
  box-sizing: border-box !important;
  /* Force GPU layer to isolate repaints */
  transform: translateZ(0) !important;
  will-change: auto !important;
  /* Prevent content from affecting layout */
  overflow-anchor: none !important; /* Disable scroll anchoring */
  /* Isolate from document flow changes */
  isolation: isolate !important;
  /* Enable vertical resizing */
  resize: vertical !important;
  /* Prevent font loading shifts */
  font-display: block !important;
}
/* Hide scrollbar for Chrome, Safari and Opera */
#chatBox::-webkit-scrollbar {
  display: none !important;
}
#chatBox::-webkit-scrollbar-track {
  display: none !important;
}
#chatBox::-webkit-scrollbar-thumb {
  display: none !important;
}
#chatBox::-webkit-scrollbar-thumb:hover {
  display: none !important;
}
#chatBox::-webkit-scrollbar-corner {
  display: none !important;
}

/* Chat date breaks */
#chatBox .chat-date-break {
  color: #fff !important;
  background: transparent !important;
  text-align: center;
  font-weight: bold;
  margin: 10px 0 4px 0;
  font-size: 15px;
  letter-spacing: 1px;
  border: none !important;
  box-shadow: none !important;
  /* Prevent line from causing layout shifts */
  height: 20px !important;
  line-height: 20px !important;
  flex-shrink: 0 !important;
  contain: layout style !important;
}

/* Chat timestamps */
#chatBox .chat-timestamp {
  color: #fff !important;
  background: transparent !important;
  font-weight: bold;
  margin-right: 8px;
  /* Fixed width to prevent layout shifts */
  display: inline-block !important;
  width: 50px !important;
  flex-shrink: 0 !important;
}

/* Chat line styling */
#chatBox .chat-line {
  background: #223 !important;
  color: #e6eefb !important;
  padding: 6px 10px !important;
  margin-bottom: 6px !important;
  font-size: 15px !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.08) inset;
  /* Prevent chat lines from causing layout shifts */
  min-height: 30px !important;
  line-height: 18px !important;
  contain: layout style !important;
  /* Prevent text overflow from affecting layout */
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

#chatBox .chat-line strong {
  color: #3da3ff !important;
  background: transparent !important;
  font-weight: 600;
}

/* Chat edited/deleted indicators */
.chat-edited {
  color: #9ba8b8 !important;
  font-size: 11px !important;
  font-style: italic !important;
  margin-left: 4px !important;
  background: transparent !important;
}

.chat-deleted {
  color: #9ba8b8 !important;
  font-style: italic !important;
  font-size: 11px !important;
  background: transparent !important;
}

/* Chat context menu */
.chat-context-menu {
  background: #1a2332 !important;
  border: 1px solid #4da3ff !important;
  border-radius: 4px !important;
  padding: 4px 0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
  z-index: 10000 !important;
}

.context-menu-item {
  padding: 8px 16px !important;
  cursor: pointer !important;
  transition: background-color 0.15s !important;
  user-select: none !important;
  white-space: nowrap !important;
}

.context-menu-item:hover {
  background: #2a3a4f !important;
}

#chatInput {
  background: #223 !important;
  color: #e6eefb !important;
  border: 1px solid #4da3ff !important;
  border-radius: 4px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s !important;
  caret-color: #fff !important;
  flex-shrink: 0 !important; /* Don't shrink the input */
  /* Fixed height to prevent layout shifts */
  height: 36px !important; /* Fixed height */
  line-height: 20px !important; /* Consistent line height */
  /* Prevent any dimension changes that could cause shifts */
  contain: layout style !important; /* CSS containment */
  /* Prevent focus state from changing dimensions */
  border-width: 1px !important; /* Maintain consistent border width */
}
#chatInput:focus {
  border-color: #3578c6 !important;
  background: #233041 !important;
  /* Remove box-shadow that could cause layout shifts */
  box-shadow: none !important; 
  caret-color: #fff !important;
  /* Ensure no dimension changes on focus */
  border-width: 1px !important;
  padding: 8px 12px !important; /* Maintain same padding */
}
#chatInput::placeholder {
  color: #7a8ca3 !important;
}

#log button[data-mini="save"] {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.08) !important;
  padding: 2px 8px !important;
  text-shadow: none !important;
  transition: background 0.2s !important;
  display: inline-block !important;
  min-width: 0 !important;
  width: auto !important;
  line-height: 1.2 !important;
}
#log button[data-mini="save"]:hover {
  background: #3578c6 !important;
}

/* Back button and logout button in backbar */
.backbar .back-btn,
.backbar .logout-btn {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  transition: background 0.2s !important;
  text-decoration: none !important;
  display: inline-block !important;
  margin-bottom: 8px !important;
}
.backbar .back-btn:hover,
.backbar .logout-btn:hover {
  background: #3578c6 !important;
}

.backbar .logged-in-as,
.backbar .logged-in-as strong {
  color: #fff !important;
}

#chatInput {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

a.back-btn {
  background: #4da3ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.08) !important;
  transition: background 0.2s !important;
  text-decoration: none !important;
  display: inline-block !important;
  margin-bottom: 8px !important;
}
a.back-btn:hover {
  background: #3578c6 !important;
}

#logForm input[type="text"][name="rst_sent"],
#logForm input[type="text"][name="rst_rcvd"],
input[data-mini="sent"],
input[data-mini="rcvd"] {
  font-weight: bold !important;
}

#logForm textarea {
  font-weight: bold !important;
}

#chatInput,
.pm-win input[type="text"] {
  caret-color: #fff !important;
}

#logForm input,
#logForm textarea,
#logForm select {
  caret-color: #000 !important;
}

/* ====== Card rows ====== */
.card-row {
  display: flex;
  gap: 24px;
  margin-top: 32px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.card-row .card {
  flex: 1 1 0;
  min-width: 260px;
  max-width: 340px;
}

/* ====== Admin grid layout ====== */
.admin-page .admin-grid { 
  display: grid !important; 
  grid-template-columns: 1fr 1fr 1fr !important;
  gap: 20px !important; 
  margin: 20px 0 !important; 
}
.admin-page .admin-grid .card { 
  flex: none !important;
  min-width: unset !important; 
  max-width: none !important;
  width: auto !important;
}
@media (max-width: 1200px) {
  .admin-page .admin-grid { 
    grid-template-columns: 1fr 1fr !important;
  }
  
  /* Keep NCS script on smaller screens, but make columns more compact */
  .layout.ncs-script-active {
    grid-template-columns: 250px minmax(400px, 500px) 1fr 150px !important;
    column-gap: 12px !important;
  }
  
  .layout.ncs-script-active .formcol {
    min-width: 400px;
    max-width: 500px;
  }
}

@media (max-width: 1400px) {
  /* Reduce minimum widths for tighter layout */
  .layout {
    grid-template-columns: 280px 1fr 170px !important;
    column-gap: 12px !important;
  }
  
  .layout.ncs-script-active {
    grid-template-columns: 280px minmax(500px, 600px) 1fr 170px !important;
    column-gap: 12px !important;
  }
  
  .layout.ncs-script-active .formcol {
    min-width: 500px;
    max-width: 600px;
  }
}

@media (max-width: 900px) {
  /* Only on very small screens, stack columns vertically */
  .layout,
  .layout.ncs-script-active {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto auto !important;
    column-gap: 12px !important;
  }
  
  .logwrap, .formcol, .ncs-script-column, aside {
    min-width: unset !important;
    max-width: unset !important;
    width: 100% !important;
  }
  
  /* Hide main content when admin columns are open on mobile */
  .layout.ncs-script-active .logwrap,
  .layout.ncs-script-active .formcol,
  .layout.ncs-script-active aside,
  .layout.history-report-active .logwrap,
  .layout.history-report-active .formcol,
  .layout.history-report-active aside,
  .layout.user-admin-active .logwrap,
  .layout.user-admin-active .formcol,
  .layout.user-admin-active aside,
  .layout.net-admin-active .logwrap,
  .layout.net-admin-active .formcol,
  .layout.net-admin-active aside,
  .layout.change-password-active .logwrap,
  .layout.change-password-active .formcol,
  .layout.change-password-active aside,
  .layout.schedule-active .logwrap,
  .layout.schedule-active .formcol,
  .layout.schedule-active aside {
    display: none !important;
  }
  
  /* Show only the active column on mobile - full width */
  .layout.ncs-script-active .ncs-script-column,
  .layout.history-report-active .history-report-column,
  .layout.user-admin-active .user-admin-column,
  .layout.net-admin-active .net-admin-column,
  .layout.change-password-active .change-password-column,
  .layout.schedule-active .schedule-column {
    display: flex !important;
    grid-column: 1 / -1 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  
  /* Hide clock on mobile when admin columns are open */
  .layout.ncs-script-active #pstClockContainer,
  .layout.history-report-active #pstClockContainer,
  .layout.user-admin-active #pstClockContainer,
  .layout.net-admin-active #pstClockContainer,
  .layout.change-password-active #pstClockContainer,
  .layout.schedule-active #pstClockContainer {
    display: none !important;
  }
  
  /* Ensure all admin column wrappers and content fit mobile viewport */
  .schedule-wrapper,
  .history-report-wrapper,
  .user-admin-wrapper,
  .net-admin-wrapper,
  .ncs-script-wrapper,
  .change-password-wrapper {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  
  .schedule-content,
  .history-report-content,
  .user-admin-content,
  .net-admin-content,
  .ncs-script-content,
  .change-password-content {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 800px) {
  .admin-page .admin-grid { 
    grid-template-columns: 1fr !important;
  }
  
  /* Stack columns on mobile */
  .layout,
  .layout.ncs-script-active {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto !important;
    column-gap: 12px !important;
  }
  
  .ncs-script-column {
    display: none !important;
  }
}

/* Mobile phones and very small screens */
@media (max-width: 480px) {
  .layout,
  .layout.ncs-script-active {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto !important;
    column-gap: 0px !important;
    row-gap: 12px !important;
  }
  
  .logwrap, .formcol, .ncs-script-column, aside {
    min-width: unset !important;
    max-width: unset !important;
    width: 100% !important;
    padding: 8px !important;
  }
  
  .formcol {
    padding: 8px !important;
  }
  
  .chat-container {
    margin-top: 12px !important;
    max-height: calc(100vh - 200px) !important; /* Adjust for mobile viewport */
  }
  
  .ncs-script-column {
    display: none !important;
  }
  
  /* Ensure form inputs stay within bounds on mobile */
  #logForm input:not(#ncsMsg), #logForm textarea {
    box-sizing: border-box !important;
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0 !important; /* Allow inputs to shrink */
    overflow: hidden !important; /* Prevent text overflow */
  }
  
  /* Ensure form grid layout is responsive */
  #logForm {
    overflow: hidden !important;
  }
  
  .form-row {
    flex-wrap: wrap !important;
  }
}

.rst-edited {
  background: #c00 !important;
  color: #fff !important;
}

input.rst-edited[data-mini] {
  background: #c00 !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  border: 1px solid #c00 !important;
}

#log input.rst-edited[data-mini] {
  background: #c00 !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  border: 1px solid #c00 !important;
}

/* Mini RST input styling */
#log input[data-mini] {
  background: #2c3e50 !important;
  color: #fff !important;
  border: 1px solid #34495e !important;
  border-radius: 3px !important;
  padding: 2px 4px !important;
  -webkit-text-fill-color: #fff !important;
  caret-color: #fff !important;
}

#log input[data-mini]:focus {
  border-color: #3498db !important;
  outline: none !important;
}

#log input[data-mini]::placeholder {
  color: #bdc3c7 !important;
  -webkit-text-fill-color: #bdc3c7 !important;
}

/* RST edited state (red highlight) */
#log input[data-mini].rst-edited {
  background: #e74c3c !important;
  border-color: #c0392b !important;
}

/* Button Layout Utilities */
.button-single {
  margin-top: 16px !important;
}

.button-grid {
  display: flex !important;
  gap: 8px !important;
  margin-top: 16px !important;
}

.button-grid button {
  flex: 1 !important;
}

/* Button Style Classes */
.big.success {
  background: #0b7a0b !important;
  color: white !important;
  border: 1px solid #065606 !important;
}

.big.primary {
  background: #1f4788 !important;
  color: white !important;
  border: 1px solid #0d2342 !important;
}

.big.warning {
  background: #8b4513 !important;
  color: white !important;
  border: 1px solid #5d2f0a !important;
}

.big.secondary {
  background: #4a5568 !important;
  color: white !important;
  border: 1px solid #2d3748 !important;
}

/* Warning text styling */
.warning-text {
  color: #b71c1b !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}

/* ====== Drag and Drop for Log Reordering ====== */
.rowlog[draggable="true"] {
  transition: opacity 0.2s ease;
  cursor: grab;
}

.rowlog[draggable="true"]:active {
  cursor: grabbing;
}

.rowlog.drag-over {
  border-top: 3px solid #4da3ff !important;
  background: rgba(77, 163, 255, 0.1) !important;
}

.rowlog:hover[draggable="true"] {
  background: rgba(77, 163, 255, 0.05) !important;
  cursor: grab;
}


@media (max-width: 1366px) {
  /* Scale everything to 75% for 1366x768 and smaller screens */
  html {
    zoom: 0.75 !important;
  }
}

/* Media query for medium screens like 1629x824 */
@media (max-width: 1700px) and (min-width: 1367px) {
  /* Slightly scale down to fit everything */
  html {
    zoom: 0.85 !important;
  }
  
  /* Reduce default chatBox height for better fit */
  #chatBox {
    height: 140px !important;
    min-height: 80px !important;
    max-height: 400px !important;
  }
  
  /* Ensure clock has proper spacing */
  #pstClockContainer {
    margin-top: 15px !important;
  }
}

/* ====== Clock Box Centering ====== */
#pstClockBox {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}

#pstClock {
  display: block !important;
  text-align: center !important;
  line-height: 1 !important;
}




