:root{
  --bg:#e6e9e9;
  --card:#ffffff;
  --text:#1f2937;
  --muted:#6b7280;
  --border:#e8e8e8;
  --red-bg:#fbdede;
  --red-text:#c0392b;
  --green-bg:#d7f2e3;
  --green-text:#1f8a4c;
  --yellow:#f0c24b;
  --red:#ee6161;
  --gray:#c7cdd1;
  --blue:#4f90d9;
  --greenbar:#69c23a;
  --black:#141414;
  --blue-link:#2563eb;
}

*{ box-sizing:border-box; }

html,body{ margin:0; padding:0; }

body{
  font-family:"Open Sans","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}

/* ================= App Header ================= */
#app-header{
  background:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:18px 40px;
  border-bottom:1px solid var(--border);
}

.header-nav{
  display:flex;
  align-items:center;
  gap:8px;
}

.header-nav-link{
  font-size:14px;
  font-weight:600;
  color:var(--text);
  text-decoration:none;
  padding:9px 16px;
  border-radius:999px;
  border:1px solid transparent;
  cursor:pointer;
}

.header-nav-link:hover{
  background:#f2f3f3;
}

.header-nav-link.active{
  background:var(--black);
  color:#fff;
}

.header-nav-link.active:hover{
  background:var(--black);
}

.header-right{
  display:flex;
  align-items:center;
  gap:16px;
}

.user-info{
  display:flex;
  align-items:center;
  gap:10px;
}

.avatar{
  width:34px;
  height:34px;
  flex:0 0 auto;
  border-radius:50%;
  background:var(--black);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
  font-weight:700;
  letter-spacing:.02em;
}

.user-meta{
  display:flex;
  flex-direction:column;
  line-height:1.3;
}

.username{
  font-size:14px;
  font-weight:600;
  color:var(--text);
}

.header-email{
  font-size:12px;
  color:var(--muted);
}

.header-divider{
  width:1px;
  height:20px;
  background:var(--border);
}

.header-logout{
  font-size:14px;
  font-weight:600;
  color:var(--text);
  text-decoration:none;
  cursor:pointer;
  padding:0;
}

.header-logout:hover{
  color:var(--red-text);
  text-decoration:underline;
}

.header-cta{
  background:#2fa84f;
  color:#fff;
  border:none;
  border-radius:999px;
  height:36px;
  padding:0 18px;
  font-family:inherit;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
}

.header-cta:hover{
  background:#268f42;
}

/* ================= Page container ================= */
.page{
  max-width:1320px;
  margin:0 auto;
  padding:20px 40px 60px;
}

/* ================= Pills (shared) ================= */
.pill{
  border:1px solid #d7dadb;
  background:#fff;
  color:#000;
  height:40px;
  padding:0 20px;
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  font-family:"Open Sans","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,Helvetica,Arial,sans-serif;
  font-size:16px;
  font-weight:500;
  cursor:pointer;
  white-space:nowrap;
}

.pill.active{
  background:var(--black);
  color:#fff;
  border-color:var(--black);
}

.tabs-row{
  display:flex;
  flex-wrap:wrap;
  gap:15px;
  margin-bottom:20px;
}

/* ================= Cards ================= */
.card{
  background:var(--card);
  border-radius:16px;
  padding:24px;
  margin-bottom:20px;
  box-shadow:0 1px 2px rgba(0,0,0,0.03);
}

.card h2{
  margin:0 0 2px;
  font-size:24px;
  font-weight:400;
}

.card .target{
  margin:0 0 18px;
  font-size:16px;
  color:var(--muted);
}

/* ================= Trend chart layout ================= */
.trend-layout{
  display:flex;
  gap:24px;
  align-items:stretch;
}

.trend-chart{
  flex:1 1 60%;
  min-width:0;
}

.apex-chart{
  width:100%;
}

.apex-chart .apexcharts-canvas{
  margin:0 auto;
}

.trend-list{
  flex:0 0 230px;
  position:relative;
}

.trend-list-scroll{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:216px;
  overflow-y:auto;
  padding-right:10px;
  scrollbar-width:thin;
  scrollbar-color:#c7cdd1 transparent;
}

.trend-list-scroll::-webkit-scrollbar{
  width:5px;
}

.trend-list-scroll::-webkit-scrollbar-track{
  background:transparent;
}

.trend-list-scroll::-webkit-scrollbar-thumb{
  background:#c7cdd1;
  border-radius:4px;
}

.trend-list-scroll::-webkit-scrollbar-thumb:hover{
  background:#9aa2a8;
}

.trend-row{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:8px;
  border-radius:999px;
  padding:8px 8px 8px 16px;
  font-size:16px;
  font-weight:400;
  letter-spacing:.02em;
  background:#fff;
  color:#000;
  border:none;
}

.trend-row.red .value{ background:var(--red-bg); color:var(--red-text); }
.trend-row.green .value{ background:var(--green-bg); color:var(--green-text); }

.trend-row .value{
  background:none;
  border-radius:999px;
  padding:4px 12px;
  font-size:13px;
  font-weight:700;
}

/* ================= Operations Panel (Date Filter + Overview + Actions) ================= */
/* One shared white box: spacing between its sub-widgets replaces the old */
/* per-widget card margins/shadows. */
.widget-section{
  margin-bottom:28px;
}

.widget-section:last-child{
  margin-bottom:0;
}

.bordered-box{
  border:1px solid var(--border);
  border-radius:12px;
  padding:24px;
}

/* ================= Date range pills ================= */
.date-pills{
  display:flex;
  flex-wrap:wrap;
  gap:15px;
}

.dropdown{
  position:relative;
  padding:0;
  background:#fff;
}

.dropdown.active{
  background:var(--black);
  border-color:var(--black);
}

.dropdown-toggle{
  border:none;
  background:none;
  height:40px;
  padding:0 20px;
  font-family:"Open Sans","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,Helvetica,Arial,sans-serif;
  font-size:16px;
  font-weight:500;
  color:#000;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:8px;
}

.dropdown.active .dropdown-toggle{
  color:#fff;
}

.chevron{
  font-size:12px;
  margin-top: -5px;
}

.dropdown-menu{
  position:absolute;
  top:calc(100% + 8px);
  left:0;
  background:#fff;
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px;
  margin:0;
  list-style:none;
  min-width:180px;
  box-shadow:0 8px 24px rgba(0,0,0,0.08);
  z-index:10;
}

.dropdown-menu.open{
  display:block;
}

.dropdown-menu li{
  padding:8px 12px;
  font-size:13px;
  font-weight:500;
  color:#000;
  border-radius:8px;
  cursor:pointer;
}

.dropdown-menu li:hover{
  background:#f2f3f3;
}

/* ================= Overview grid ================= */
.overview-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:20px;
  align-items:stretch;
}

.overview-card{
  display:flex;
  flex-direction:column;
  height:100%;
}

.overview-card h2{
  font-size:24px;
  font-weight:400;
  margin:0 0 14px;
}

.overview-card .apex-chart{
  cursor:pointer;
  flex:1;
  display:flex;
  align-items:center;
}

.overview-card .apex-chart > div{
  width:100%;
}

/* ================= Actions table ================= */
.actions-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin:0 0 16px;
  padding:0 4px;
}

.chart-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:16px;
}

.chart-header h2{
  margin:0;
}

.series-filter{
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  margin:0 0 18px;
}

.series-filter-item{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:14px;
  color:var(--text);
  cursor:pointer;
  user-select:none;
}

.series-filter-item input[type="checkbox"]{
  cursor:pointer;
}

.series-swatch{
  width:10px;
  height:10px;
  border-radius:50%;
  flex:0 0 auto;
}

.top10-period-filter{
  margin:0;
}

.top10-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:20px;
}

.top10-grid h3{
  font-size:16px;
  font-weight:600;
  margin:0 0 12px;
}

.top10-list{
  list-style:none;
  margin:0;
  padding:0;
}

.top10-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 0;
  border-bottom:1px solid var(--border);
  font-size:14px;
}

.top10-item:last-child{
  border-bottom:none;
}

.top10-rank{
  flex:0 0 auto;
  width:20px;
  color:var(--muted);
  font-weight:600;
}

.top10-name{
  flex:1 1 auto;
  color:var(--text);
  min-width:0;
}

.top10-value{
  flex:0 0 auto;
  color:var(--text);
  font-weight:600;
}

.installations-period-filter{
  margin:0;
}

.installations-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:20px;
}

.installations-grid .bordered-box{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.actions-card h2{
  font-size:20px;
  margin:0;
  padding:0;
}

.actions-filter{
  margin:0;
  padding:0;
}

.table-scroll{
  width:100%;
  overflow-x:auto;
}

.actions-table-scroll{
  max-height:640px;
  overflow-y:auto;
}

.actions-table-scroll thead th{
  position:sticky;
  top:0;
  z-index:1;
}

table.actions{
  width:100%;
  border-collapse:collapse;
  min-width:860px;
  font-size:15px;
}

table.actions thead th{
  background:#E0E6E6;
  text-align:left;
  font-size:15px;
  color:#000;
  height:50px;
  padding:12px 14px;
  font-weight:600;
  vertical-align:middle;
}

table.actions thead th:first-child{ border-radius:18px 0 0 0; }
table.actions thead th:last-child{ border-radius:0 18px 0 0; }

table.actions tbody td{
  padding:16px 14px;
  border-bottom:1px solid var(--border);
  font-size:15px;
  vertical-align:top;
}

table.actions tbody td a {
  color: #0064A2;
  text-decoration: none;
}

.badge{
  display:inline-flex;
  align-items:center;
  height:30px;
  padding:0 10px;
  border-radius:4px;
  font-size:11px;
  font-weight:500;
  letter-spacing:.06em;
  white-space:nowrap;
  margin-bottom:6px;
}

.badge.high-risk{ background:#ee5b5b; color:#fff; }
.badge.attention{ background:var(--yellow); color:#5a4300; }
.badge.cancelled{ background:var(--gray); color:#3a4247; }
.badge.recovered{ background:var(--greenbar); color:#fff; }
.badge.healthy{ background:var(--greenbar); color:#fff; }

.timestamp{
  display:block;
  font-size:13px;
  color:var(--muted);
}

.cell-text{
  display:block;
  font-size:15px;
  color:var(--text);
}

.customer-name{
  color:#0064A2;
  font-weight:500;
  text-decoration:none;
  display:block;
  font-size:18px;
}

.customer-since{
  font-size:13px;
  color:var(--muted);
  display:block;
}

.customer-since .tenure{
  color:var(--muted);
}

.signal-text{
  display:block;
  font-size:15px;
  color:var(--text);
}

.meeting-status{
  display:flex;
  align-items:center;
  gap:6px;
  font-weight:400;
  font-size:13px;
}

.dot{
  width:15px;
  height:15px;
  border-radius:50%;
  flex:0 0 auto;
}

.dot.blue{ background:var(--blue); }
.dot.green{ background:var(--greenbar); }
.dot.gray{ background:#9aa2a8; }
.dot.yellow{ background:var(--yellow); }

/* Plain text now — only the customer name is clickable in this table. */
.notes-link{
  color:var(--text);
  font-weight:400;
  display:block;
  margin-bottom:4px;
}

/* ================= Bar Detail Popup (modal) ================= */
.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(20,20,20,0.5);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
  z-index:100;
}

.modal-overlay[hidden]{
  display:none;
}

.modal-box{
  background:#fff;
  border-radius:16px;
  width:100%;
  max-width:680px;
  max-height:80vh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  box-shadow:0 20px 60px rgba(0,0,0,0.25);
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:20px 24px;
  border-bottom:1px solid var(--border);
}

.modal-header h3{
  margin:0;
  font-size:18px;
  font-weight:600;
}

.modal-close{
  border:none;
  background:none;
  font-size:22px;
  line-height:1;
  color:var(--muted);
  cursor:pointer;
  padding:4px;
}

.modal-close:hover{
  color:var(--text);
}

.modal-body{
  padding:16px 24px 24px;
  overflow-y:auto;
}

#modal-table{
  min-width:0;
}

.modal-reasons-heading{
  margin:0 0 8px;
  font-size:15px;
  font-weight:600;
  color:var(--text);
}

.modal-reasons-list{
  list-style:none;
  margin:0;
  padding:0;
}

.modal-reasons-list li{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 4px;
  border-bottom:1px solid var(--border);
}

.modal-reasons-list li:last-child{
  border-bottom:none;
}

.reason-text{
  font-size:15px;
  color:var(--text);
}

.reason-count{
  flex:0 0 auto;
  min-width:28px;
  text-align:center;
  padding:2px 10px;
  border-radius:999px;
  background:#eef0f1;
  color:var(--text);
  font-size:13px;
  font-weight:600;
}

/* ================= Customer Detail Popup ================= */
.customer-modal-box{
  width:100%;
  max-width:1400px;
  max-height:92vh;
}

#customer-detail-modal .modal-header{
  align-items:flex-start;
}

.customer-modal-heading{
  min-width:0;
}

.customer-modal-name-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.customer-modal-name-row h3{
  margin:0;
}

.customer-modal-name-row h3 a{
  color: #0064A2;
  text-decoration: none;
}

.customer-modal-subline{
  margin:6px 0 0;
  font-size:14px;
  font-weight:500;
  color:var(--muted);
}

.stat-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));
  gap:10px;
  margin-bottom:20px;
  margin-top:20px;
}

.stat-card{
  background:none;
  border:0px solid var(--border);
  border-radius:10px;
  padding:10px 12px;
}

.stat-card .stat-label{
  display:block;
  font-size:11px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.04em;
  margin-bottom:4px;
}

.stat-card .stat-value{
  display:block;
  font-size:20px;
  color:var(--text);
  font-weight:bold;
}

.customer-modal-actions{
  display:flex;
  justify-content:flex-end;
  margin-bottom:16px;
}

.cta-button{
  background:#2fa84f;
  color:#fff;
  border:none;
  cursor:pointer;
}

.cta-button:hover{
  background:#268f42;
}

/* ================= Create Note Popup ================= */
.note-modal-box{
  width:100%;
  max-width:640px;
}

.form-label{
  display:block;
  font-size:13px;
  font-weight:600;
  color:var(--text);
  margin:14px 0 6px;
}

.form-label:first-of-type{
  margin-top:0;
}

.form-field{
  margin:0;
}

.form-textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius:8px;
  padding:10px 12px;
  font-family:inherit;
  font-size:14px;
  color:var(--text);
  resize:vertical;
  box-sizing:border-box;
}

.form-textarea:focus{
  outline:none;
  border-color:#0064A2;
  box-shadow:0 0 0 3px rgba(0,100,162,0.12);
}

.form-textarea-large{
  min-height:180px;
  padding:14px 16px;
  font-size:15px;
  line-height:1.5;
}

.form-select{
  width:100%;
  border:1px solid var(--border);
  border-radius:8px;
  padding:8px 12px;
  font-family:inherit;
  font-size:14px;
  color:var(--text);
  background:#fff;
  box-sizing:border-box;
}

.add-account-box{
  width:100%;
  max-width:420px;
}

/* ================= Process page ================= */
.process-panel h2{
  margin:0 0 12px;
}

.process-placeholder{
  font-size:15px;
  color:var(--muted);
  margin:0;
}

.process-doc-link{
  text-decoration:none;
}

.form-input{
  width:100%;
  border:1px solid var(--border);
  border-radius:8px;
  padding:8px 12px;
  font-family:inherit;
  font-size:14px;
  color:var(--text);
  box-sizing:border-box;
}

.form-input:focus{
  outline:none;
  border-color:#0064A2;
  box-shadow:0 0 0 3px rgba(0,100,162,0.12);
}

.account-lookup-row{
  display:flex;
  gap:10px;
  align-items:center;
}

.account-lookup-row .form-input{
  flex:1;
}

.account-lookup-row .cta-button{
  flex-shrink:0;
}

.account-lookup-empty{
  font-size:14px;
  color:var(--muted);
  margin:16px 0 0;
}

.note-modal-buttons{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:20px;
}

.note-modal-buttons .pill{
  cursor:pointer;
}

/* ================= Login Page & Form ================= */
.page:has(.login) {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card.login {
  width: 100%;
  max-width: 440px;
  margin: 60px auto;
  padding: 36px 32px;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.login-header {
  margin-bottom: 24px;
}

.login-header h2 {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}

.login-header p {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form .form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.login-form .label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.login-form .forgot-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--blue-link);
  text-decoration: none;
}

.login-form .forgot-link:hover {
  text-decoration: underline;
}

.login-form input[type="email"],
.login-form input[type="password"],
.login-form input[type="text"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form input[type="email"]:focus,
.login-form input[type="password"]:focus,
.login-form input[type="text"]:focus {
  outline: none;
  border-color: #0064A2;
  box-shadow: 0 0 0 3px rgba(0, 100, 162, 0.12);
}

.login-form .checkbox-group {
  flex-direction: row;
  align-items: center;
  margin-top: -2px;
}

.login-form .checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.login-form .checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  accent-color: #2fa84f;
  cursor: pointer;
}

.login-form .field-error {
  font-size: 12px;
  color: var(--red-text);
  font-weight: 500;
  margin-top: 2px;
}

.login-form .form-actions {
  margin-top: 8px;
}

.login-form .btn-primary {
  width: 100%;
  height: 42px;
  background: #2fa84f;
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.login-form .btn-primary:hover {
  background: #268f42;
}

.login-form .btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.overview-outcomes-row {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.outcome-col:first-child {
  padding-left: 0;
}

.outcome-col {
  flex: 1 1 0;
  min-width: 150px;
  padding: 20px 24px 0;
    padding-left: 24px;
}

.outcome-col + .outcome-col {
  border-left: 1px solid var(--border);
}

.outcome-title {
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  margin: 0 0 14px;
}

.outcome-table-values {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 22px;
  font-weight: bold;
  color: var(--text);
}

.outcome-table-values.negative {
  color: var(--red-text);
}

.outcome-table-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

@media (max-width: 480px) {
  .card.login {
    padding: 24px 20px;
    margin: 20px auto;
  }
}

/* ================= Tablet (>=641px) ================= */
@media (min-width:641px){
  .overview-grid{
    grid-template-columns:1fr 1fr;
  }
  .top10-grid{
    grid-template-columns:1fr 1fr;
  }
  .installations-grid{
    grid-template-columns:repeat(3, 1fr);
  }
}

/* ================= Narrower desktop / tablet ================= */
@media (max-width:1024px){
  .page{ padding:20px 20px 60px; }
  #app-header{ padding:16px 20px; }
}

/* ================= Mobile-ish trend stacking ================= */
@media (max-width:900px){
  .trend-layout{
    flex-direction:column;
  }
  .trend-list{
    flex:1 1 auto;
  }
  .trend-list-scroll{
    max-height:200px;
    padding-right:8px;
  }
}

/* ================= Mobile ================= */
@media (max-width:640px){
  #app-header{
    flex-wrap:wrap;
    gap:10px;
    padding:14px 16px;
  }
  .header-nav{
    flex-wrap:wrap;
  }
  .header-nav-link{
    padding:7px 12px;
    font-size:13px;
  }
  .username{
    font-size:13px;
  }
  .page{ padding:14px 10px 40px; }
  .card{ padding:16px; border-radius:14px; }
  .bordered-box{ padding:16px; }
  .widget-section{ margin-bottom:20px; }
  .tabs-row .pill,
  .date-pills .pill{
    padding:8px 14px;
    font-size:13px;
  }
  .trend-row{ font-size:11.5px; }
  .overview-grid{
    grid-template-columns:1fr;
  }
  .modal-box{ max-height:88vh; }
  .modal-header{ padding:16px 18px; }
  .modal-body{ padding:12px 18px 18px; }
}
