:root{
  --awm-light:#A0D23B;
  --awm-dark:#297D53;
  --bg:#f4f7f4;
  --text:#0f1e17;
  --muted:#5b6b63;
  --card:#ffffff;
  --ring:rgba(41,125,83,0.25);
  --border:#dfe9e2;
}

/* Base */
*{box-sizing:border-box}
html,body{
  margin:0; padding:0; background:var(--bg); color:var(--text);
  font:17px/1.6 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,"Helvetica Neue",Arial,"Apple Color Emoji","Segoe UI Emoji";
}
@media (min-width:900px){ html,body{ font-size:18px; } }

/* Header */
.topbar{
  position:sticky; top:0; z-index:1000;
  background:var(--awm-dark); color:#fff; border-bottom:1px solid #225f42;
  padding:14px 18px; display:flex; gap:16px; align-items:center; justify-content:space-between;
}
.brand{ display:flex; align-items:center; gap:12px; }
.logo-wrap{ background:#fff; border-radius:10px; padding:6px 8px; box-shadow:0 4px 12px rgba(0,0,0,.12); display:flex; align-items:center; }
.logo{ height:28px; width:auto; display:block; }
.brand-text{ font-weight:900; letter-spacing:.2px; font-size:1.2rem; }

/* Search / Combobox */
.search-wrap{ display:flex; gap:10px; width:100%; max-width:980px; align-items:center; }
.combo{ position:relative; flex:1; }
.combo input{
  width:100%; height:48px; padding:0 14px; border:1px solid #e5efe8; border-radius:999px; background:#fff;
  outline:none; font-size:1rem; color:var(--text);
}
.combo input::placeholder{ color:#7aa08f; }
.combo input:focus{ box-shadow:0 0 0 4px var(--ring); border-color:#cfe5d8; }
.combo-list{
  position:absolute; left:0; right:0; top:52px; max-height:260px; overflow:auto;
  background:#fff; color:#0f1e17; border:1px solid var(--border); border-radius:12px; box-shadow:0 12px 24px rgba(0,0,0,.12);
}
.combo-item{ padding:10px 12px; cursor:pointer; font-size:.95rem; }
.combo-item:hover, .combo-item--active{ background:#f3fbf4; }

/* Buttons */
.actions{ display:flex; gap:8px; }
.btn{
  height:48px; padding:0 18px; border:none; border-radius:999px;
  background:#1f5f43; color:#fff; font-weight:700; cursor:pointer; font-size:1rem;
}
.btn:hover{ filter:brightness(1.06); }
.btn[disabled]{ opacity:.6; cursor:not-allowed; }
.btn--ghost{ background:#2a6b4b; border:1px solid #225f42; }

/* ===== Layout (STRICT 3 / 2 / 1) ===== */
/* Restore small side padding so cards don’t stick to the edges,
   but keep 3-up and the wider date columns intact. */
.container{
  max-width:1880px;
  margin:28px auto 96px;
  padding:0 clamp(8px, 1.2vw, 16px);   /* <-- restored responsive left/right padding */
}
.cards{ display:grid; gap:8px; }
@media (min-width:1200px){
  .cards{ grid-template-columns:repeat(3, minmax(480px, 1fr)); }  /* 3-up */
}
@media (min-width:760px) and (max-width:1199.98px){
  .cards{ grid-template-columns:repeat(2, minmax(480px, 1fr)); }
}
@media (max-width:759.98px){
  .cards{ grid-template-columns:1fr; }
}

.card{
  position:relative; background:var(--card); border:1px solid var(--border);
  border-radius:18px; overflow:hidden; box-shadow:0 10px 24px rgba(0,0,0,0.05);
}

/* Card Header */
.card__header{
  display:flex; flex-direction:column; gap:8px; padding:16px 18px 18px;
  background:linear-gradient(135deg, var(--awm-dark), #2f8b5c); color:#fff;
}
.card__toprow{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.card__title{ font-weight:800; display:flex; align-items:center; gap:10px; font-size:1.05rem; }
.pill{ display:inline-flex; align-items:center; gap:8px; background:#ffffff22; border:1px solid #ffffff33; border-radius:999px; padding:6px 12px; font-size:.8rem; }
.card__sub{ opacity:.95; font-size:.9rem; }
.badge{ display:inline-block; padding:6px 12px; border-radius:999px; font-size:.8rem; font-weight:800; background:#eef7f1; color:#1c5d3f; border:1px solid #d6edc2; white-space:nowrap; }

/* ===== Table ===== */
.table{
  width:100%; border-collapse:collapse; table-layout:fixed; font-size:.97rem;
}
.table th, .table td{
  padding:12px 16px;              /* keep visible inner padding, incl. date cols */
  border-top:1px solid var(--border);
  vertical-align:top;
}
.table th{
  text-align:left; background:#f3fbf4; color:#204b3a; position:sticky; top:0;
  line-height:1.25; white-space:normal; word-break:keep-all; overflow-wrap:normal;
}

/* Column widths:
   - Date columns use ch units sized around “Completion” to avoid squish.
   - Both date columns same width; other columns share the rest. */
.table th:nth-child(4), .table td:nth-child(4),
.table th:nth-child(5), .table td:nth-child(5){ width:12.5ch; }  /* Contract / Completion */

.table th:nth-child(1), .table td:nth-child(1){ width:26%; word-break:break-word; } /* Task Name */
.table th:nth-child(2), .table td:nth-child(2){ width:18%; }                        /* Tracking Link */
.table th:nth-child(3), .table td:nth-child(3){ width:22%; word-break:break-word; } /* Project Name */

/* Two-line headers for the Date columns (no mid-word wrap) */
.table .th-stack{ display:inline-block; }
.table .th-stack span{ display:block; }

/* Allow the link to wrap within its cell */
.table td:nth-child(2) a{ white-space:normal; }

/* Date cell two-line style */
.table td .date{ line-height:1.2; }
.table td .date .m{ white-space:nowrap; }    /* Month, */
.table td .date .dy{ white-space:nowrap; }   /* DD YYYY */

/* Right-edge breathing room on last column */
.table th:last-child,
.table td:last-child{ padding-right:24px; }

.table a{ color:#1e513a; text-decoration:none; font-weight:600; }
.table a:hover{ text-decoration:underline; }

/* Empty */
.empty{ margin:40px 0; text-align:center; color:#5b6b63; font-size:1rem; }

/* Footer */
.footer{
  position:fixed; bottom:0; left:0; right:0; background:var(--awm-dark); color:#eaf6ec;
  border-top:1px solid #225f42; padding:12px 18px; display:flex; justify-content:center;
}

/* =======================
   Right-side Drawer styles
   ======================= */

.drawer-overlay{
  position: fixed;
  inset: 0;
  background: rgba(16,30,23,0.28);
  backdrop-filter: blur(2px);
  z-index: 1100;
}

.drawer-panel{
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: clamp(380px, 28vw, 480px);
  background: #fff;
  box-shadow: -22px 0 40px rgba(0,0,0,0.18);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 220ms ease;
  z-index: 1110;
  display: flex;
  flex-direction: column;
}

.drawer-panel.open{ transform: translateX(0); }

.drawer-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 18px; background: #f7fbf8; border-bottom:1px solid var(--border);
}
.drawer-title{ margin:0; font-size:1.05rem; font-weight:800; color:#163a2b; }
.drawer-close{
  appearance:none; border:none; border-radius:10px; width:36px; height:36px;
  font-size:22px; line-height:1; background:#eaf4ee; color:#174a35; cursor:pointer;
}
.drawer-close:hover{ filter:brightness(0.98); }

.drawer-meta{ padding: 10px 18px 0 18px; color:#334d41; }
.drawer-meta-grid{ display:grid; grid-template-columns: 1fr; gap:6px; }

.drawer-body{
  padding: 12px 18px 18px 18px;
  overflow:auto;
}

.drawer-table{
  width:100%; border-collapse:collapse; table-layout:fixed;
  border:1px solid var(--border); border-radius:12px; overflow:hidden;
}
.drawer-table th, .drawer-table td{
  padding:10px 12px; border-top:1px solid var(--border); vertical-align:top;
}
.drawer-table thead th{
  background:#f3fbf4; color:#204b3a; text-align:left; border-top:none;
}
.drawer-table td:last-child{ text-align:right; }

.drawer-empty{
  margin:10px 0 0 0; color:#556a61;
}

.drawer-footer{
  margin-top:auto; padding:12px 18px; border-top:1px solid var(--border);
  display:flex; justify-content:flex-start; gap:10px;
}
.btn-link{
  display:inline-block; padding:8px 12px; border:1px solid #cfe5d8;
  border-radius:999px; color:#1c5d3f; text-decoration:none; font-weight:700;
}
.btn-link:hover{ background:#f3fbf4; }

/* clickable table row */
.row-click{ cursor:pointer; }
.row-click:focus{ outline: 2px solid var(--awm-dark); outline-offset: 2px; }

/* 1) Slightly narrower date columns */
.table th:nth-child(4), .table td:nth-child(4),
.table th:nth-child(5), .table td:nth-child(5){
  width: 10.5ch; /* was 12.5ch */
}

/* 2) Masonry flow on wide screens to remove tall-gap issue */
@media (min-width:1200px){
  .cards{
    /* override grid to masonry columns */
    display:block;
    column-count: 3;
    column-gap: 12px;
  }
  .card{
    display:inline-block;
    width:100%;
    break-inside: avoid;
    margin: 0 0 12px;
  }
}

/* ================================
   Customer-scoped (locked) layout
   ================================ */

/* IMPORTANT: prevent the masonry/columns layout from affecting the single locked view */
body.customer-view .cards{
  display:block !important;
  column-count: 1 !important;
  column-gap: 0 !important;
}

.project{
  max-width: 1180px;
  margin: 0 auto;
}

.project__overview{
  border:1px solid var(--border);
  background:var(--card);
  border-radius:18px;
  box-shadow:0 10px 30px rgba(15,30,23,0.08);
  padding:18px 18px;
}

.ov__title{ display:flex; align-items:flex-start; justify-content:space-between; gap:14px; flex-wrap:wrap; }
.ov__cust{ font-size:22px; font-weight:850; color:var(--text); }
.ov__badges{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.ov__addr{ margin-top:8px; color:var(--muted); font-weight:600; }

.project__layout{
  margin-top:14px;
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap:14px;
  align-items:start;
}
@media (max-width:980px){
  .project__layout{ grid-template-columns: 1fr; }
}

.project__panel{
  border:1px solid var(--border);
  background:var(--card);
  border-radius:18px;
  box-shadow:0 10px 30px rgba(15,30,23,0.08);
  overflow:hidden;
}

.panel__head{
  padding:14px 16px;
  background:#f7fbf8;
  border-bottom:1px solid var(--border);
}
.panel__title{ font-weight:850; color:#163a2b; font-size:1.05rem; }
.panel__hint{ margin-top:2px; color:var(--muted); font-size:.9rem; }

/* Compact table inside panels */
.table--compact{ font-size:.95rem; }
.table--compact th, .table--compact td{ padding:10px 14px; }

/* Selected row state */
.row-selected{ background:#f3fbf4; }

/* Details area */
.detail__body{ padding:12px 16px 10px; }
.detail__table{ width:100%; }
.detail__actions{ padding: 0 16px 16px; }
.detail__track{ width:100%; text-align:center; }

/* Restore wider date columns to avoid squish */
.table th:nth-child(4), .table td:nth-child(4),
.table th:nth-child(5), .table td:nth-child(5){
  width: 12ch;  /* back to comfy width */
}

/* Drawer header hierarchy + close button alignment */
.drawer-header{ align-items: flex-start; }
.drawer-title{ margin:0; font-weight:400; }
.drawer-title .drawer-customer{
  font-size: 1.25rem;
  font-weight: 800;
  color: #163a2b;
  margin-bottom: 2px;
}
.drawer-title .drawer-sub{
  font-size: .96rem;
  line-height: 1.2;
}
.drawer-title .sub-label{
  color: #4e6a5d;
  font-weight: 500;     /* label: medium */
}
.drawer-title .sub-val{
  color: #163a2b;
  font-weight: 800;     /* value: bold */
}
.drawer-close{
  margin-top: 2px;      /* visually top-align with title */
  line-height: 1;
}

/* center the lock pill without pushing layout */
/* keep centered and spaced properly above filters */
.lock-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 55px;           /* lowered so it floats below navbar, above cards */
  z-index: 2;
  background-color: #1b5e20;
  color: #fff;
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}



/* Access gate: larger, centered message */
.access-gate{
  text-align: center;
  max-width: 760px;
  margin: 12vh auto 0;
  padding: 0 16px;
}
.access-gate h2{
  font-size: 2.25rem;
  line-height: 1.2;
  margin: 0 0 14px;
}
.access-gate p{
  font-size: 1.125rem;
  line-height: 1.65;
  margin: 10px 0;
}

/* Hide controls when there is no ?c or ?admin=true */
body.no-controls #searchCustomer,
body.no-controls #comboCustomers,
body.no-controls #searchMilestone,
body.no-controls #comboMilestones,
body.no-controls #refreshBtn,
body.no-controls #clearFilters{
  display: none !important;
}


/* ================================
   Customer Access View (Project Scoped)
   ================================ */

body.customer-view .search-wrap{
  display:none !important;
}

/* ================================
   Single Project View (Customer)
   ================================ */

.project{
  margin-top: 18px;
}

.project__header{
  border:1px solid var(--border);
  background:var(--card);
  border-radius:14px;
  box-shadow:0 6px 18px rgba(15,30,23,0.06);
  padding: 16px;
}

.project__cust{
  font-weight: 900;
  font-size: 20px;
  line-height: 1.2;
}

.project__sub{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.project__addr{
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.project__layout{
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 12px;
  margin-top: 12px;
  align-items:start;
}

@media (max-width: 980px){
  .project__layout{ grid-template-columns: 1fr; }
}

.project__list,
.project__detail{
  border:1px solid var(--border);
  background:var(--card);
  border-radius:14px;
  box-shadow:0 6px 18px rgba(15,30,23,0.06);
  overflow: hidden;
}

.table--compact th,
.table--compact td{
  padding: 10px 12px;
}

.row-selected{
  background: rgba(160,210,59,0.12);
}

.project__detail{
  padding: 14px;
}

.detail__head{
  display:flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.detail__title{
  font-weight: 900;
  color: #163a2b;
}

.detail__meta{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.detail__items{
  margin-top: 12px;
}

.detail__actions{
  margin-top: 12px;
}

.detail__track{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
}

.context-bar{
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 16px;
  border:1px solid var(--border);
  background:var(--card);
  border-radius:14px;
  box-shadow:0 6px 18px rgba(15,30,23,0.06);
  margin:18px 0 10px;
}

/* IMPORTANT: honor the HTML `hidden` attribute.
   The UA stylesheet typically sets `[hidden]{display:none;}`,
   but our class rules can override it. We only display the
   context bar when it is NOT hidden.
*/
.context-bar:not([hidden]){ display:flex; }

.context-left{min-width:0}
.context-title{
  font-weight:700;
  letter-spacing:0.2px;
  font-size:14px;
  color:var(--muted);
  text-transform:uppercase;
}
.context-meta{
  margin-top:2px;
  font-weight:700;
  font-size:18px;
  line-height:1.2;
  color:var(--text);
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.context-meta .dot{color:var(--muted); font-weight:600}

/* Access card */
.access-card{
  margin:26px auto 12px;
  max-width:720px;
}
.access-card__inner{
  border:1px solid var(--border);
  background:var(--card);
  border-radius:18px;
  box-shadow:0 10px 30px rgba(15,30,23,0.08);
  padding:22px 20px;
}
.access-card h2{
  margin:0 0 6px 0;
  font-size:22px;
  letter-spacing:0.2px;
}
.access-sub{
  margin:0 0 18px 0;
  color:var(--muted);
}

.access-form{
  display:grid;
  gap:14px;
}
.field{display:grid; gap:6px}
.field__label{
  font-weight:650;
  font-size:13px;
  color:var(--muted);
  letter-spacing:0.2px;
  text-transform:uppercase;
}
.field input{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  outline:none;
  font-size:16px;
}
.field input:focus{
  border-color:var(--awm-dark);
  box-shadow:0 0 0 4px var(--ring);
}
.field__hint{
  color:var(--muted);
  font-size:13px;
}
.form-error{
  border:1px solid rgba(180, 30, 30, 0.25);
  background:rgba(180, 30, 30, 0.06);
  color:#7a1111;
  padding:10px 12px;
  border-radius:12px;
  font-weight:600;
}
.access-help{
  margin:4px 0 0 0;
  color:var(--muted);
  font-size:13px;
}

/* Buttons */
.btn{
  border-radius:12px;
}
.btn--primary{
  background:linear-gradient(180deg, var(--awm-dark), #1f6a47);
  color:#fff;
  border:1px solid rgba(0,0,0,0.08);
  font-weight:700;
  padding:12px 14px;
}
.btn--primary:hover{
  filter:brightness(1.03);
}
.btn--ghost{
  border:1px solid var(--border);
}

/* Lock pill refinement */
.lock-pill{
  margin-left:10px;
  max-width:38vw;
  overflow:hidden;
  text-overflow:ellipsis;
}
@media (max-width:720px){
  .lock-pill{display:none;}
  .context-meta{font-size:16px;}
}
