:root{
  --brand:#0077c8;
  --brand-dark:#003d6b;
  --accent:#ff7a00;
  --bg:#f5f8ff;
  --card:#ffffff;
  --muted:#6b7280;
  --border:#e5e7eb;
  --text:#1f2937;
}

*{
  box-sizing:border-box;
  font-family:Inter,system-ui,Arial,sans-serif;
}

body{
  margin:0;
  background:
    radial-gradient(1200px 600px at 20% -20%,#e6f3fb,transparent),
    radial-gradient(800px 500px at 100% 0,#f3f7ff,transparent),
    var(--bg);
  color:var(--text);
}

/* Utility */
.hidden{
  display:none !important;
}

/* Header */

/* 
.header{
  position: sticky;
  top: 0;
  z-index: 1000;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  background:rgba(255,255,255,.9);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--border);
}
*/

.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  background:rgba(255,255,255,.8);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--border);
}


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

.brand-icon{
  width:38px;
  height:38px;
  display:grid;
  place-items:center;
  background:var(--brand);
  color:#fff;
  border-radius:10px;
  font-size:18px;
}

.brand-title{
  font-weight:600;
  color:var(--brand-dark);
}

.brand-sub{
  font-size:12px;
  color:var(--muted);
}

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

/* Panels / layout */
.panel{
  max-width: 1600px;
  margin: 18px auto;
  padding: 20px 24px;
}

/* Forms / inputs / buttons */
.form{
  display:grid;
  gap:10px;
  max-width:440px;
}

/* Support button */
.support-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 12px;
  border-radius: 999px;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  z-index: 900;
}

/* Panel */
.support-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 320px;
  max-height: 420px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 900;
}

.support-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f3f4ff;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}

.support-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

.support-messages {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
  font-size: 12px;
}

.support-msg {
  margin-bottom: 6px;
  max-width: 90%;
  padding: 6px 8px;
  border-radius: 10px;
  line-height: 1.3;
}

.support-msg.me {
  margin-left: auto;
  background: #e0f2fe;
}

.support-msg.other {
  margin-right: auto;
  background: #f3f4ff;
}

.support-msg-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
}

.support-form {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
}

.support-form input {
  flex: 1;
  padding: 8px;
  border-radius: 999px;
}

.support-form button {
  padding: 8px 10px;
  border-radius: 999px;
  border: none;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.support-btn.has-unread::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: red;
  box-shadow: 0 0 0 2px #fff;
}

#support-conv-select option.unread {
  color: red;
  font-weight: 600;
}

.support-msg.unread-other {
  background: #fff8e1;   
  border-left: 3px solid #ff9800;
}

.support-msg.unread-other .support-msg-meta::after {
  content: "NEW";
  margin-left: 6px;
  font-size: 11px;
  color: #ff9800;
  font-weight: 600;
}


label{
  display:grid;
  gap:6px;
  font-size:12px;
  color:var(--muted);
}

input,
select,
textarea{
  padding:10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
}

.month-locked {
  background: #f9fafb;
  color: var(--muted);
  cursor: not-allowed;
}

.month-locked:read-only {
  cursor: not-allowed;
}

.btn{
  padding:10px 14px;
  border-radius:10px;
  border:1px solid var(--border);
  cursor:pointer;
}

.btn.primary{
  background:var(--brand);
  border-color:var(--brand);
  color:#fff;
}

.btn.outline{
  background:#fff;
}

/* Toolbar above table */
.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin:12px 0;
}

.switch{
  display:flex;
  gap:6px;
  align-items:center;
  font-size:14px;
}

/* KPIs */
.kpis{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:10px;
}

.kpi{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
}

.kpi-title{
  color:var(--muted);
  font-size:12px;
}

.kpi-value{
  font-size:22px;
  font-weight:600;
}

/* Charts */
.charts{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:10px;
  margin:10px 0;
}

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
}

.card-title{
  font-size:14px;
  font-weight:600;
  margin-bottom:8px;
}

/* fixed-height chart container */
.chart-box{
  position:relative;
  height:260px;
  width:100%;
}

.chart-box canvas{
  position:absolute;
  inset:0;
  width:100% !important;
  height:100% !important;
}

/* Main table */
.table-wrap{
  overflow-x:auto;
  overflow-y:hidden;
  background:rgba(255,255,255,.8);
  border:1px solid var(--border);
  border-radius:14px;
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  table-layout:auto;
}

th[data-month],
td.cell-actual,
td.cell-forecast{
  min-width:80px;
}

thead th{
  position:sticky;
  top:0;
  background:#fff;
  border-bottom:1px solid var(--border);
  padding:6px 4px;
  font-size:12px;
  text-align:left;
  white-space:nowrap;
}

/* NEW: specifically for month headers so JS can rename to "Forecast XXX" */
th[data-month]{
  white-space:nowrap;
}

/* NEW: visual style for actual vs forecast headers */
.actual-col-header{
  font-weight:600;
}

.forecast-col-header{
  font-size:11px;
  color:var(--muted);
}

/* Hide columns (used for "Hide past months" toggle) */
.col-hidden{
  display:none;
}

tbody td{
  border-top:1px solid var(--border);
  padding:6px 4px;
  vertical-align:top;
  font-size:12px;
}

td.num{
  text-align:center;
  font-variant-numeric: tabular-nums;
  padding: 4px 6px;
  white-space:nowrap;
}

/* actual / forecast cells */
td.cell-actual{
  font-weight:500;
}

td.cell-forecast{
  color:inherit;
  font-style:italic;
}

td.cell-forecast::after{
  font-size:10px;
  opacity:0.7;
}

.badge{
  display:inline-block;
  padding:4px 8px;
  border-radius:999px;
  background:#10b981;
  color:#fff;
  font-size:12px;
}

.badge.gray{
  background:#9ca3af;
}

.actions{
  white-space:nowrap;
  display:flex;
  gap:6px;
}

.actions .btn{
  padding:0 4px;
  font-size:11px;
  border:none;
  background:transparent;
  color:var(--brand);
}

.actions .btn:hover{
  text-decoration:underline;
  background:transparent;
}

.actions .btn.outline{
  background:#fff;
}

.actions .btn:not(.outline){
  background:#f3f4f6;
  border-color:#d1d5db;
}


/* Grids (forms, modal) */
.grid-3{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}

.grid-3 input[name="fNov"],
.grid-3 input[name="fDec"],
.grid-3 input[name="fNext"] {
  font-style: italic;
}

.grid-6{
  display:grid;
  grid-template-columns:repeat(6,1fr);
  gap:10px;
}

/* Modal */
.modal{
  max-width:960px;
  max-height:80vh;
  overflow:auto;
}

/* Misc */
.tips{
  margin:12px 0;
}

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

/* Login panel layout */
#login-panel{
  min-height:calc(100vh - 64px);
  display:grid;
  place-items:start center;
  padding-top:64px;
}

#login-panel h2{
  font-size:36px;
  margin:0 0 16px 0;
}

#login-panel .form{
  max-width:420px;
  margin:0 auto;
}

#login-panel .btn.primary{
  font-size:16px;
}

/* Custom fields admin UI */
#cf-admin {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

#sr-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#sr-modal .modal-close {
  position: absolute;
  top: 16px;     
  right: 24px;   
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}


#sr-modal form.modal {
  position: relative;
}


.cf-row-header,
.cf-row {
  display: grid;
  grid-template-columns: 2fr 90px 90px;
  column-gap: 8px;
  align-items: center;
  font-size: 13px;
}

.cf-row-header {
  font-weight: 600;
  color: var(--muted);
}

.cf-row input[type="text"] {
  width: 100%;
}

.cf-row .switch {
  justify-content: flex-start;
}

.cf-row .btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: #2563eb;
  cursor: pointer;
}

.toolbar.small {
  gap: 6px;
}


/* Slightly larger inputs on wide screens */
@media (min-width:900px){
  #login-panel .form input{
    font-size:16px;
    padding:12px 14px;
  }
}
