body {
    font-family: Arial;
    padding: 20px;
}

.zones {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 20px 8px;
    margin-bottom: 12px;
    padding: 16px;
    background: #f4f4f4;
    border-radius: 8px;
    box-sizing: border-box;
    width: 100%;
}

.zone-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.zone {
    width: 45px; /* Slightly larger for better visibility */
    height: 45px;
    border-radius: 50%;
    background: green;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16);
    margin-bottom: 8px;
}

.zone-label {
    font-size: 15px;
    text-align: center;
    color: #333;
    font-weight: bold;
    /* Limit width to prevent pushing grid cells */
    max-width: 85px; 
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Config Modal Styles */
.config-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.config-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
    margin-bottom: 20px;
}

.config-grid input {
    padding: 5px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    vertical-align: middle;
}

.setup-menu {
    display: inline-block;
    position: relative;
    float: right;
    vertical-align: middle;
    margin-right: 8px;
}

.user-menu {
    display: inline-block;
    position: relative;
    float: right;
    vertical-align: middle;
}

.user-menu-btn {
    background: none;
    border: 1px solid #aaa;
    border-radius: 20px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-menu-btn:hover {
    background: #eee;
}

.user-icon {
    font-size: 20px;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 500;
}

.user-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

.user-dropdown button:hover {
    background: #f0f0f0;
}

.bootstate {
    padding: 15px;
    background: green;
    font-weight: bold;
     color: white;

}

.zone.active {
    background: red;
}

.zone.siren-cleared {
    background: #007bff;  /* blue: was active at siren-on, now cleared */
}

.zone.siren-post-cleared {
    background: #ffc107;  /* yellow: activated after siren fired, now cleared */
}

.zone.disabled {
    background: #cccccc;  /* gray: zone disabled */
}

.temp-display {
    font-size: 13px;
    font-weight: bold;
    margin-left: 8px;
    color: #555;
}

.temp-alert-icon {
    font-size: 20px;
    margin-left: 4px;
    animation: temp-blink 0.8s infinite;
}

@keyframes temp-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

.controls button {
    margin-right: 10px;
    padding: 10px 20px;
}

.green {
    background: lightgreen;
}

.red {
    background: red;
    color: white;
}

#progressContainer {
    width: 100%;
    background: #ddd;
    height: 20px;
    margin-top: 20px;
}

#progressBar {
    height: 100%;
    width: 0%;
    background: blue;
}

.hidden {
    display: none !important;
}

#messageBox {
    margin-top: 20px;
    padding: 15px;
    background: #eee;
    border: 1px solid #aaa;
}

#main {
    background: transparent;
    padding: 0;
}

.controls {
    background: #e6e0e0;
    padding: 15px;
    display: inline-block;
}

.triggerbutton:active {
    background: red;
    /* color while pressed */
    color: white;
   
}

.flicker {
  animation: flicker 1s infinite;
   background: red;
     font-weight: bold;
     color: white;
      padding: 15px;
}

@keyframes flicker {
  0%   { opacity: 1; }
  50%  { opacity: 0; }
  100% { opacity: 1; }
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-box {
    background: white;
    padding: 28px;
    border-radius: 8px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-box h3 { margin: 0; }

.modal-box input {
    padding: 9px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions button {
    flex: 1;
    padding: 9px;
    cursor: pointer;
}

.error {
    color: red;
    font-size: 13px;
    margin: 0;
}

/* ---- Multi-device dashboard -------------------------------------------- */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(560px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.device-panel {
    border: 3px solid #ccc;
    border-radius: 10px;
    padding: 16px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.device-panel.panel-online  { border-color: #28a745; }
.device-panel.panel-offline { border-color: #dc3545; }
.device-panel.panel-siren   { border-color: #dc3545; animation: siren-flash 0.8s infinite; }

@keyframes siren-flash {
  0%, 100% { background: white; }
  50%       { background: #ffcccc; }
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-location {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.panel-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    color: white;
}

.badge-booted  { background: #6c757d; }
.badge-green   { background: #28a745; }
.badge-red     { background: #dc3545; }
.badge-armed   { background: #fd7e14; }
.badge-siren   { background: #dc3545; }

.device-panel .zones {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 16px 8px;
    margin-bottom: 12px;
    padding: 16px;
    background: #f4f4f4;
    border-radius: 8px;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
}

.device-panel .controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: #e6e0e0;
    padding: 10px;
    border-radius: 6px;
}

.device-panel .controls button,
.device-panel .controls .ctrl-alarm,
.device-panel .controls .ctrl-trigger {
    padding: 7px 14px;
    cursor: pointer;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #f8f8f8;
}

.ctrl-alarm.red { background: #dc3545; color: white; border-color: #dc3545; }

.upgrade-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-bar-wrap {
    width: 100%;
    background: #ddd;
    height: 14px;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #007bff;
    transition: width 0.3s;
}

.panel-message {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f0f0f0;
    border: 1px solid #aaa;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.panel-message button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #555;
}