* {
  box-sizing: border-box;
  
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "FKGroteskNeue", "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
input[type="text"] {
  color: #000;
  font-weight: 600;
}

.top-fields input.empty {
  border-color: #ff7d7d !important;
  background: #fff0f0 !important;
}

.main-offset {
  margin: 15px 0 0 15px;
  display: flex;
  gap: 15px;
  height: calc(100vh - 30px);
  overflow: hidden;
}
.left-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  flex-shrink: 0;
  width: fit-content;
}
.top-fields {
  width: 450px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  background: #fafafa;
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 3px;
  gap: 8px;
  font-size: 15px;
  flex-shrink: 0;
}
.top-fields label {
  margin-right: 0;
  color: #00881d;
  font-weight: bold;
}
.top-fields input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #bbb;
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.top-fields input:not(:last-of-type) {
  margin-right: 10px;
}
.top-fields input:focus {
  outline: 1px solid #fff5f5;
  background: #e8ffea;
}
.top-fields input.invalid {
  border-color: #ff0000;
  background: #fff5f5;
}

.header-info-text {
  font-weight: normal;
  font-size: 0.9em;
  margin-left: 165px;
  word-spacing: 15px; 
  color: #000000; 
}


/* ===== MENU CONTAINER + TOGGLE ===== */
.menu-container {
  width: 450px;
  font-family: inherit;
  border: 1px solid #ccc;
  border-radius: 3px;
  overflow: hidden;
  font-size: 15px;
  background: #fafafa;
  padding-top: 0;
  flex-shrink: 0;
}
.menu-header {
  display: flex;
  align-items: center;
  background: #ededed;
  padding: 8px 12px;
  font-weight: bold;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}
.menu-header:hover {
  background-color: #d5d5d5;
}
.menu-header span:first-child {
  flex: 1;
}
.arrow {
  font-size: 14px;
  transition: transform 0.3s ease;
  margin-left: 8px;
  display: inline-block;
}
.arrow.rotated {
  transform: rotate(90deg);
}

/* ================================================================================================ */
.menu-row.header-row {
  display: flex;
  gap: 2px;
  height: 24px;
  background-color: rgba(158, 158, 158, 0.12);
  border-bottom: 1px solid rgba(94, 82, 64, 0.2);
}

.menu-row.header-row > td {
  width: 25%;
  padding: 4px 2px;
  font-weight: 550;
  font-size: 11px;
  color: #000000;
  text-align: center;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1.2;
  box-sizing: border-box;
}

.menu-row.input-row {
  display: flex;
  gap: 1px;
  height: 25px;
  border: none;

}

.menu-row.input-row > td {
  width: 100%;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.variable-name-input,
.variable-desc-input,
.variable-value-input {
  width: 100%;
  padding: 4px 5px;
  font-size: 13px;
  box-sizing: border-box;
  color: #134252;
  background-color: none;
  border: 0.1px solid rgba(94, 82, 64, 0.2);
  border-radius: 1px;
  font-family: "FKGroteskNeue", "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

}

.variable-result-input {
  width: 100%;
  padding: 5px 5px;
  font-size: 13px;
  box-sizing: border-box;
  color: #134252;
  background-color: #f0f0f0;
  cursor: default;
  border: 0.1px solid rgba(167, 125, 62, 0.2);
  border-radius: 2px;
  font-family: "FKGroteskNeue", "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

}

.variable-result-input:focus {
  outline: none;
}

.variable-result-input[style*="color: red"] {
  border-color: #ff4444 !important;
  background-color: #fff0f0 !important;
}

/* ================================================================================================ */

/* Menu content collapse/expand */
.menu-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.menu-content.expanded {
  max-height: 1500px;
}

/* Specific menu header backgrounds */
.variables-header { background: #fff6f6; } /* pilka SPINDLE */
.spindle-header { background: #e6e6e6; } /* pilka SPINDLE */
.drill-header { background: #e8f5e8; }    /* zalia DRILL */
.mill-header { background: #e8f4ff; }     /* melyna MILL */

/* ===== TABLE STYLES ===== */
.menu-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}
.menu-row {
  border-bottom: 1px solid #f0f0f0;
  height: 27px;
}
.menu-label {
  padding-left: 12px;
  width: 200px;
  vertical-align: middle;
  border-right: 1px solid #ccc;
}
.menu-input-td {
  padding: 0 0;
  text-align: center;
}
.menu-input-td input {
  width: 100%;
  padding: 1px 7px 1px 5px;
  border: none;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 400 !important;
  font-family: inherit;
  margin-left: 0;
  text-align: right;
}
.menu-input-td input:focus {
  outline: 1px solid #999;
}
.menu-input-td input.invalid {
  border: 1px solid #ff0000;
  background: #fff5f5;
}
.menu-unit {
  color: #666;
  padding-right: 16px;
  text-align: right;
  width: 60px;
  vertical-align: middle;
}
.menu-checkbox {
  display: flex;
  align-items: center;
  justify-content: left;
  font-size: 13px;
  height: 100%;
  padding: 3px 8px;
  vertical-align: middle;
  gap: 5px;
}
#toolDiameter {
  width: 60px;
  font-weight: 600;
  color: #000;
  margin-left: 100px;
  min-width: 0;
}
.menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  margin-left: 62px;
  font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
  font-size: 12px;
  font-weight: bold;
  border: 1px solid #999;
  border-radius: 3px;
  background: #ededed;
  cursor: pointer;
  transition: background 0.2s ease;
  color: #333;
  white-space: nowrap;
  width: 130px;
  height: 20px;
}
.menu-button:hover {
  background: #d1d1d1;
  border-radius: 10px;
}
.menu-button:active {
  background: #898a8a;
}
.menu-button:focus {
  outline: none;
}

/* ===== COMPENSATION & DIRECTION ===== */
.compensation-label,
.direction-label {
  vertical-align: top;
  padding: 5px 0 0 12px;
}
.radio-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  padding: 6px 15px 7px 0;
  width: 100%;
  flex: 1;
  justify-content: flex-start;
}
.radio-group label {
  font-size: 13px;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 12px;
  color: #111;
  font-weight: 350;
  letter-spacing: 1px;
  justify-content: flex-start;
  cursor: pointer;
  margin: 0;
}
.radio-group input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

/* Mill compensation radio states (classes added on the millCompensation td in B3b). */
/* comp-missing: compensation required but absent → bold bright-red labels + red radios. */
.radio-group.comp-missing label {
  color: #e53935;
  font-weight: 700;
}
.radio-group.comp-missing input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #e53935;            /* red ring */
  background-color: #fff;               /* white gap */
  background-image: radial-gradient(circle, #e53935 0 4px, transparent 4px); /* red center dot */
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  margin: 0;
  box-sizing: border-box;
}
/* comp-disabled: compensation not allowed on this line → dimmed, not-allowed cursor. */
.radio-group.comp-disabled label {
  color: #999;
  cursor: not-allowed;
}
.radio-group.comp-disabled input[type="radio"] {
  cursor: not-allowed;
}

/* ===== DRILL & MILL INPUT COLORS ====== */
#drillX, #millX { color: #000000; font-weight: bold; }
#drillZ, #millZ { color: green; font-weight: bold; }
#drillY, #millY { color: #ff0000; font-weight: bold; }
#drillFSpeed, #millFSpeed { color: #d100b5; font-weight: bold; }
#millRadius { color: #ff8b3d; font-weight: bold; }
#millCorrection { color: #d100b5; font-weight: bold; }

/* VALUE spalvos = INPUT spalvos */
#drillXResult, #millXResult { color: #000000 !important; font-weight: bold; }     /* X juoda */
#drillZResult, #millZResult { color: green !important; font-weight: bold; }       /* Z žalia */
#drillYResult, #millYResult { color: #ff0000 !important; font-weight: bold; }     /* Y raudona */
/* Drill F neturi result - OK */
#millRResult { color: #ff6600 !important; font-weight: bold; }                    /* R oranžinė */
#millCResult { color: #d100b5 !important; font-weight: bold; }                    /* C violetinė */

/* Y MINUS - raudona → tamsiai raudona */
#drillY:invalid, #millY:invalid,
#drillYResult:contains("-"), #millYResult:contains("-") {
  color: #cc0000 !important;  /* tamsesnė raudona minusui */
  font-weight: bold !important;
}


/* ===== EDITOR & BUTTONS ===== */
.textbutton-container {
  font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  flex: 1;
  min-height: 100px;
}
#editor {
  flex: 1;
  width: 100%;
  height: 100%;
  border: 1px solid #bbb;
  border-radius: 2px;
  overflow: hidden;
}
#editor,
.CodeMirror {
  height: 100% !important;
  min-height: 0;
}
.button-group {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.button-group button {
  flex: 1;
  padding: 8px 16px;
  font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid #999;
  border-radius: 3px;
  background: #ededed;
  cursor: pointer;
  transition: background 0.2s ease;
}
.button-group button:hover {
  background: #e0e0e0;
}
.button-group button:active {
  background: #d5d5d5;
}

/* ===== CONFIRM CONTAINER ===== */
.confirm-container {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  left: 0;
  width: 450px;
  height: 55px;
  z-index: 20;
  background: #fafafadc;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #ccc;
  border-radius: 3px;
}
.confirm-clear-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  cursor: not-allowed;
  user-select: none;
  color: #aaa;
  flex-shrink: 0;
}
.confirm-container button {
  flex: 1 1 auto;
  padding: 8px 16px;
  font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
  font-size: 15px;
  font-weight: bold;
  border: 1px solid #999;
  border-radius: 3px;
  background: #ededed;
  cursor: pointer;
  transition: background 0.2s ease;
  text-align: center;
}
.confirm-container button:hover {
  background: #e0e0e0;
}
.confirm-container button:active {
  background: #d5d5d5;
}

.input-result {
  display: inline-block;
  min-width: 90px;
  max-width: 90px;
  text-align: left;
  color: #000000;
  border: none;
  margin-right: 80px;
  font-size: 14px;
  padding: 1px 1px;
  font-family: inherit !important;
  word-break: break-all;
}

.menu-table .input-result {
  font-size: 13px;
  font-weight: 500 !important;
}

/* ===== PLACEHOLDER & ERROR ===== */
input::placeholder {
  color: #a3a3a3; 
  opacity: 1;
  font-weight: normal;
}
.error-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ff4444;
  color: white;
  padding: 20px 30px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  animation: fadeInOut 3s ease-in-out;
}
@keyframes fadeInOut {
  0% { opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 840px) {
  body, html {
    min-width: 500px;
    height: auto;
    overflow: visible; 
  }
  .main-offset {
    flex-direction: column;
    height: auto;
    gap: 20px;
    overflow: visible;
  }
  .left-section {
    width: fit-content;
  }
  .top-fields,
  .menu-container,
  .confirm-container,
  .textbutton-container {
    width: 450px;
  }
  .textbutton-container {
    height: auto;
    min-height: 450px;
  }
}

/* ====== CODEMIRROR STYLING ====== */
.CodeMirror {
  height: 100% !important;
  font-family: 'Consolas', 'Courier New', monospace !important;
  font-size: 13px !important;
  background: white !important;
}

/* TIKSLUS background elementas */
.CodeMirror-linebackground.active-line-bg {
  background: rgba(165, 196, 231, 0.5) !important;
}

/* Line numeris */
.CodeMirror-linenumber.active-line-gutter {
  background: rgba(100, 149, 237, 0.5) !important;
  color: white !important;
}

.cm-comment {
  color: #868686 !important;
  font-weight: normal;
}
.cm-gcode-command {
  color: blue;
  font-weight: bold;
}
.cm-gcode-axis-x {
  color: #000000;
  font-weight: bold;
}
.cm-gcode-z {
  color: #00aa00;
  font-weight: bold;
  text-shadow: 0 0 1px rgba(0,0,0,0.5);
}
.cm-gcode-y-pos {
  color: #ff0000;
  font-weight: bold;
}
.cm-gcode-y-neg {
  color: #940000;
  font-weight: bold;
}
.cm-gcode-m {
  color: #000000;
  font-weight: bold;
}
.cm-gcode-t {
  color: rgb(0, 0, 0);
  font-weight: bold;
}
.cm-gcode-f {
  color: #d100b5;
  font-weight: bold;
}
.cm-gcode-number {
  color: #cecece;
}
.cm-gcode-r {
  color: #ff8b3d;
  font-weight: bold;
  text-shadow: 0 0 1px rgba(0,0,0,0.5);
}
.right-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  gap: 0;
  overflow: hidden;
  margin-right: 15px;
}

#viewer-container {
  flex-shrink: 0;
  width: 100%;
  min-height: 80px;
  border: 1px solid #ccc;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  position: relative;
}

.resize-divider {
  width: 100%;
  height: 6px;
  background: #ccc;
  cursor: ns-resize;
  flex-shrink: 0;
  transition: background 0.2s;
}

.resize-divider:hover {
  background: #999;
}