body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
  margin: 0;
  height: 100%;
  color: #2c3e50;
  line-height: 1.6;
}

h1 {
  font-size: 28px;
  border-bottom: 2px solid #10b981;
  font-weight: 600;
  margin: 0 0 0.8em 0;
  padding: 0 0 0.5em 0;
  overflow: hidden;
  color: #2c3e50;
}

p {
  line-height: 1.7em;
  margin: 0.5em 0 0.8em;
}

div#top {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-bottom: none;
  padding: 20px 30px;
  height: 70px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

div#logo { float: left; }

div#title {
  float: left;
  margin-left: 25px;
  padding: 0;
  border: none;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 48px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

div#side_panel {
  float: left;
  margin: 20px;
  font-size: 14px;
  line-height: 1.8em;
  overflow: hidden;
}

div#side_panel h1 {
  border: none;
  font-size: 18px;
  text-decoration: none;
  color: #334155;
  font-weight: 600;
  border-bottom: 2px solid #334155;
  padding-bottom: 0.3em;
}

div#side_panel h1 a {
  font-weight: 700;
}

div#side_panel hr {
  background-color: #e0e0e0;
  border: 0 none;
  color: #e0e0e0;
  height: 1px;
  margin: 1em 0;
}

div#side_panel a {
  color: #334155;
  font-weight: 500;
}

div#side_panel a.active {
  text-decoration: underline;
}

div#side_panel a::after {
  background-color: #334155;
}

div#side_panel a:hover {
  color: #1e293b;
}

div.side_panel_device_list {
  margin-top: 4px;
}

a.side_panel_device_link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}

a.side_panel_device_link::after {
  bottom: 0;
}

a.side_panel_device_link.side_panel_device_active {
  font-weight: 700;
  color: #059669;
  text-decoration: underline;
}

span.side_panel_device_name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

span.device_marker {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

span.device_marker_on {
  background-color: #2e7d32;
}

span.device_marker_off {
  background-color: #b0b8c1;
}

span.device_marker_warning {
  background-color: #f9a825;
}

span.device_marker_fault {
  background-color: #c62828;
}

div#content {
  background-color: white;
  padding: 30px 40px;
  border-left: none;
  border-bottom: none;
  overflow: hidden;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  margin-right: 20px;
  margin-bottom: 20px;
}

div#content_header {
  margin: 0 0 1em 0;
  padding: 0 0 0.5em 0;
}

div#page_title {
  font-size: 28px;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 0.4em;
  color: #2c3e50;
  font-weight: 600;
}

div#page_info {
  font-size: 13px;
  float: right;
  color: #7f8c8d;
}

div#content_related {
  clear: right;
}

div#footer {
  margin: 20px 0 20px 245px;
  font-size: 13px;
  line-height: 1.8em;
  color: #7f8c8d;
}

div.login_box {
  margin: 80px auto 0 auto;
  padding: 40px;
  width: 400px;
  border: none;
  background-color: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

div.login_fields label {
  float: left;
  margin: 0 15px 0 30px;
  padding: 8px 0;
  text-align: right;
  width: 100px;
  font-weight: 500;
  color: #34495e;
}

div.login_fields input {
  display: block;
  margin: 0 0 15px;
  padding: 10px 12px;
  width: 160px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-size: 14px;
}

div.login_fields input:hover {
  border: 2px solid #10b981;
}

div.login_fields input:focus {
  border: 2px solid #10b981;
  background-color: #f8f9fa;
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

div#login_button_d { text-align: right; }

.action_button {
  width: 80px;
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  text-align: center;
  display: inline-block;
}

.action_button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.action_button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

input {
  padding: 6px 10px;
  border-radius: 4px;
}

input.param_val {
  border: 2px solid #e0e0e0;
  border-radius: 4px;
  transition: border 0.3s ease;
}

input.param_val:focus {
  border: 2px solid #10b981;
  outline: none;
}

div#right_links {
  float: right;
  text-align: right;
}

div#right_links a {
  color: white;
  font-weight: 500;
}

div#right_links a::after {
  background-color: white;
}

div#right_links a:hover {
  color: #f0f0f0;
  background-color: rgba(255, 255, 255, 0.1);
}

select.lang_switch_select {
  margin-right: 20px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
}

select.lang_switch_select option {
  color: #2c3e50;
  background-color: white;
}

div.table_wrapper {
  overflow: auto;
}
div#chart {
  overflow: hidden;
  min-height: 400px;
  height: calc(100vh - 440px);
  width: 100%;
}

table.cont_table {
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-collapse: collapse;
  color: #2c3e50;
  margin: 1em 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  border-radius: 6px;
  overflow: hidden;
}

th.cont_table {
  border: 1px solid #e0e0e0;
  padding: 12px 16px;
  background: linear-gradient(180deg, #e8ecf0 0%, #d9dfe5 100%);
  font-weight: 600;
  color: #34495e;
}

td.cont_table {
  border: 1px solid #e0e0e0;
  padding: 10px 16px;
  background-color: #fafafa;
}

td.c_right, th.c_right { text-align: right; }
td.c_left, th.c_left { text-align: left; }
td.c_center { text-align: center; }

svg.edit_icon { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; margin-left: 6px; }

div#page_title svg.edit_icon { width: 20px; height: 20px; margin-left: 10px; }

div.modal_overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.45);
  z-index: 1000;
}

div.modal_overlay div.login_box {
  margin-top: 120px;
  width: 360px;
}

p.modal_subtitle {
  color: #7f8c8d;
  font-size: 13px;
  margin: -0.5em 0 1.2em 0;
}

div#add_device_row {
  margin-top: 15px;
}

a.remove_device_link {
  color: red;
}

svg.signal_level { width: 24px; height: 24px; }

span.volt_bad { color: red; }
span.volt_good { color: green; }
span.volt_usb { color: green; }

span.status_online { color: green; }
span.status_offline { color: red; }
span.status_registered { color: blue; }

span.fault_ok { color: #2e7d32; font-weight: 600; }
span.fault_warning { color: #e65100; font-weight: 600; }
span.fault_alarm { color: #c62828; font-weight: 700; }

span.bridges_bad { color: red; }

span.version_upgrade { color: blue; }

a {
  white-space: nowrap;
  color: #059669;
  text-decoration: none;
  transition: all 0.2s ease;
  font-weight: 500;
  position: relative;
}

a::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: #10b981;
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.3s ease;
}

a:link, a:visited { text-decoration: none; }

a:hover {
  background-color: #f8f9fa;
  text-decoration: none;
  color: #047857;
}

a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.copy-icon {
  width: 1em;
  height: 1em;
  cursor: pointer;
  color: #666;
  transition: color 0.2s;
}

.copy-icon:hover {
  color: #007bff;
}

.copy-icon.copied {
  color: #28a745;
}

.hidden {
  display: none !important;
}

#loading {
  text-align: center;
  padding: 40px 20px;
  font-size: 20px;
  color: #7f8c8d;
  font-weight: 500;
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

#data-controls {
  display: none;
  margin: 0 0 20px 0;
  padding: 20px;
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#data-controls label {
  margin-right: 10px;
  font-weight: 600;
  color: #34495e;
  font-size: 14px;
}

#data-controls input[type="datetime-local"] {
  margin-right: 20px;
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 4px;
  transition: border 0.3s ease;
  font-size: 14px;
}

#data-controls input[type="datetime-local"]:focus {
  border: 2px solid #10b981;
  outline: none;
  background-color: #f8f9fa;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

#data-controls button {
  padding: 10px 20px;
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

#data-controls button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

#data-controls button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

#data-controls button:disabled {
  background: #7f8c8d;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.col_date {
  width: 11em;
}
.col_deviceid {
  width: 14.5em;
}
.col_account {
  width: 8em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#devices_table tbody tr {
  cursor: pointer;
}

#device_detail_body {
  margin-top: 10px;
}

div.device_row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

div.card_box {
  flex: 1 1 180px;
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

div.card_label {
  font-size: 12px;
  color: #7f8c8d;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

div.card_value {
  font-size: 24px;
  font-weight: 700;
  color: #2c3e50;
}

div.device_row_alarms {
  margin-bottom: 20px;
}

div.alarms_panel {
  flex: 1 1 100%;
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

div.alarms_panel_title {
  font-size: 12px;
  color: #7f8c8d;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

div.alarms_chip_list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

span.alarm_chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
}

span.alarm_chip_warning {
  background-color: #fff3e0;
  color: #e65100;
}

span.alarm_chip_alarm {
  background-color: #fdecea;
  color: #c62828;
}

div.gauge_group {
  flex: 1 1 220px;
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 12px 12px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

div.gauge_group_title {
  font-size: 13px;
  font-weight: 600;
  color: #34495e;
  text-align: center;
  margin-bottom: 4px;
}

div.gauge_group_body {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 6px;
}

div.gauge_item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

div.gauge_item_label {
  font-size: 11px;
  font-weight: 600;
  color: #7f8c8d;
  text-align: center;
  max-width: 104px;
}

div.gauge_box {
  width: 110px;
  height: 100px;
}

div.gauge_box_single {
  width: 180px;
  height: 140px;
}

div.device_row_range {
  align-items: center;
  margin-bottom: 10px;
}

span.range_label {
  font-size: 13px;
  font-weight: 600;
  color: #34495e;
  margin-right: 10px;
}

div.range_buttons a.range_btn {
  display: inline-block;
  padding: 5px 12px;
  margin-right: 6px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  color: #34495e;
  background-color: #fafafa;
}

div.range_buttons a.range_btn:hover {
  background-color: #f0f0f0;
}

div.range_buttons a.range_btn_active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-color: transparent;
}

div.chart_box {
  flex: 1 1 420px;
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

div.chart_title {
  font-size: 13px;
  font-weight: 600;
  color: #34495e;
  margin-bottom: 4px;
}

div.chart_canvas {
  width: 100%;
  height: 260px;
}

@media only screen and (max-width: 900px) {
  div#side_panel {
    column-count: 2;
    width: inherit;
    float: inherit;
    margin: 15px;
  }
  div#content {
    margin-left: inherit;
    margin-right: inherit;
    border-radius: 0;
    border-left: none;
    border-top: none;
    padding: 1em;
  }
  div#footer { margin: 1em; }
}

/* RTL support (Hebrew). Mirrors the two-column layout, form labels, and
   table alignment; brand elements (logo/title) stay physically put, and
   ECharts gauges/charts render left-to-right internally regardless of
   page direction, since that's outside CSS's reach. */
html[dir="rtl"] div#side_panel {
  float: right;
}

html[dir="rtl"] div#logo {
  float: right;
}

html[dir="rtl"] div#title {
  float: right;
  margin-left: 0;
  margin-right: 25px;
}

html[dir="rtl"] div#right_links {
  float: left;
  text-align: left;
}

html[dir="rtl"] select.lang_switch_select {
  margin-right: 0;
  margin-left: 20px;
}

html[dir="rtl"] div#content {
  margin-right: 0;
  margin-left: 20px;
}

html[dir="rtl"] div#footer {
  margin: 20px 245px 20px 0;
}

html[dir="rtl"] div.login_fields label {
  float: right;
  margin: 0 30px 0 15px;
}

html[dir="rtl"] div#login_button_d {
  text-align: left;
}

html[dir="rtl"] svg.edit_icon {
  margin-left: 0;
  margin-right: 6px;
}

html[dir="rtl"] div#page_title svg.edit_icon {
  margin-right: 10px;
}

html[dir="rtl"] td.c_left, html[dir="rtl"] th.c_left {
  text-align: right;
}

@media only screen and (max-width: 900px) {
  html[dir="rtl"] div#side_panel {
    float: inherit;
  }
  html[dir="rtl"] div#content {
    margin-left: inherit;
  }
}
