/* MYDIN Facilities & ESG Platform — single stylesheet, no build step. */
:root {
  --brand: #0b5e3b;        /* MYDIN green */
  --brand-dark: #063d26;
  --accent: #f2a900;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2b24;
  --muted: #64766d;
  --line: #dde5e0;
  --ok: #1e8e4e;
  --warn: #d98e00;
  --danger: #c62828;
  --info: #0d6e8c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 12px; background: var(--brand-dark); color: #fff; padding: 8px 16px; position: sticky; top: 0; z-index: 50; }
.brand { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.brand span { color: var(--accent); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar a { color: #e8f0ec; }
.user-chip { font-size: 13px; opacity: .9; }
.bell { position: relative; font-size: 17px; }
.bell-count { position: absolute; top: -6px; right: -10px; background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 5px; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; }

/* Shell */
.shell { display: flex; min-height: calc(100vh - 44px); }
.sidenav { width: 220px; background: #fff; border-right: 1px solid var(--line); padding: 12px 0 40px; flex-shrink: 0; }
.nav-group { padding: 14px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.nav-link { display: block; padding: 7px 16px; color: var(--text); font-size: 14px; border-left: 3px solid transparent; }
.nav-link:hover { background: #eef4f0; text-decoration: none; }
.nav-link.active { border-left-color: var(--brand); background: #e7f2ec; font-weight: 600; }
.content { flex: 1; padding: 20px; max-width: 1400px; }
.content-guest { max-width: 460px; margin: 8vh auto; }

/* Cards, grids, KPIs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); }
.kpi.k-ok .kpi-value { color: var(--ok); }
.kpi.k-warn .kpi-value { color: var(--warn); }
.kpi.k-danger .kpi-value { color: var(--danger); }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: #eef4f0; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); white-space: nowrap; }
table.data tr:hover td { background: #f7faf8; }
table.data td.num, table.data th.num { text-align: right; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #fff; text-transform: capitalize; white-space: nowrap; }
.bg-ok { background: var(--ok); } .bg-warn { background: var(--warn); }
.bg-danger { background: var(--danger); } .bg-info { background: var(--info); }
.bg-info2 { background: #4a5fc1; } .bg-muted { background: #8a978f; }

/* Health score bar */
.health { display: inline-flex; align-items: center; gap: 6px; }
.health-bar { width: 70px; height: 8px; background: #e3e9e5; border-radius: 4px; overflow: hidden; }
.health-fill { height: 100%; border-radius: 4px; }

/* Forms */
form.std label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
form.std input[type=text], form.std input[type=email], form.std input[type=password],
form.std input[type=number], form.std input[type=date], form.std input[type=datetime-local],
form.std input[type=file], form.std select, form.std textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff;
}
form.std textarea { min-height: 90px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-outline { background: #fff; color: var(--brand); }
.btn-outline:hover { background: #eef4f0; color: var(--brand); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.inline-form { display: inline; }

/* Alerts / flash */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: #e7f5ec; border-color: #bfe3cd; color: #14532d; }
.alert-danger { background: #fdecea; border-color: #f5c6c2; color: #7f1d1d; }
.alert-warning { background: #fdf3e0; border-color: #f3ddb0; color: #7c4a03; }
.alert-info { background: #e6f2f7; border-color: #bcdde9; color: #0c4a5e; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: end; }
.filters label { font-size: 12px; color: var(--muted); display: block; }
.filters input, .filters select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }

/* Pagination */
.pagination { margin: 14px 0; display: flex; gap: 6px; align-items: center; }
.pagination a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pagination a.current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pg-info { font-size: 13px; color: var(--muted); margin-left: 8px; }

/* Checklist (technician mobile) */
.check-item { display: flex; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.check-item .ci-desc { flex: 1; }
.check-item select, .check-item input { padding: 6px; border: 1px solid var(--line); border-radius: 6px; }

/* Signature pad */
canvas.sigpad { border: 1px dashed #9db3a7; border-radius: 8px; background: #fff; width: 100%; height: 140px; touch-action: none; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .cal-head { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px; }
.cal .cal-day { min-height: 92px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.cal .cal-day.other { opacity: .45; }
.cal .cal-day.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.cal .day-num { font-weight: 700; }
.cal .cal-ev { display: block; margin-top: 3px; padding: 1px 5px; border-radius: 4px; background: #e7f2ec; color: var(--brand-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .cal-ev.ev-warn { background: #fdf3e0; color: #7c4a03; }
.cal .cal-ev.ev-danger { background: #fdecea; color: #7f1d1d; }

/* Photos */
.photo-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-grid a { display: block; }
.photo-grid img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* Login */
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; color: var(--brand-dark); }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

/* Management dashboard — client reference design (Chiller Energy Performance) */
.sectlabel { font-size: 13px; font-weight: 700; margin: 18px 0 10px; color: var(--text); }
.kpi .kpi-unit { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi.kpi-hero { background: linear-gradient(180deg, #fffdf4, #fff); border-color: #f0dfa6; }
.kpi.kpi-hero .kpi-value { color: var(--brand); }

/* Thin ACTUAL vs BASELINE bar: dark green fill over a soft cream track */
.gapbar { margin-top: 10px; }
.gapbar .track { height: 12px; border-radius: 3px; background: #fdf0c9; overflow: hidden; display: flex; }
.gapbar .fill { background: var(--brand); height: 100%; }
.gapbar .legend { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 5px; letter-spacing: .04em; }

/* Site tiles */
.tilegrid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
        display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden;
        transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: 0; transition: opacity .12s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(11, 94, 59, .10); border-color: #c9d9d0; }
.tile:hover::before { opacity: 1; }
.t-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.t-name { font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.t-name a { color: var(--brand-dark); }
.t-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.t-big { font-size: 30px; font-weight: 700; letter-spacing: -.03em; color: var(--ok); line-height: 1; }
.t-big .lbl { display: block; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }

/* Contract KPI pills */
.pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; letter-spacing: .04em; white-space: nowrap; }
.pill-ok { background: #e4f0ea; color: var(--ok); }
.pill-warn { background: #fdf0d6; color: var(--warn); }
.pill-muted { background: #f1f3f2; color: var(--muted); }

/* Target band */
.targetbar { margin-top: 9px; }
.tb-track { position: relative; height: 6px; border-radius: 3px; background: #edf1ee; }
.tb-zone { position: absolute; top: 0; bottom: 0; background: #cfe6da; border-radius: 3px; }
.tb-mark { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--brand-dark); border-radius: 1px; }
.tb-lbl { font-size: 10px; color: var(--muted); margin-top: 5px; letter-spacing: .02em; }

/* Tile mini stats + footer */
.t-stats { display: flex; gap: 14px; border-top: 1px solid #f0f4f1; padding-top: 10px; }
.t-stat { flex: 1; min-width: 0; }
.t-stat .v { font-size: 13px; font-weight: 700; }
.t-stat .l { font-size: 9.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-top: 1px; }
.t-foot { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.t-open { color: var(--brand); font-weight: 700; }

@media (max-width: 1100px) { .tilegrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .tilegrid { grid-template-columns: 1fr; } }

/* Print (digital service report / PDF via browser) */
@media print {
  .topbar, .sidenav, .no-print, .alert { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: none; page-break-inside: avoid; }
  .tilegrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; }
  .tile:hover { transform: none; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .kpi { border: 1px solid #ccc; }
  .kpi.kpi-hero { background: #fffdf4; }
  .page-head .filters button { display: none; }
}

/* Mobile (technician portal) */
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .sidenav { position: fixed; left: -240px; top: 44px; bottom: 0; z-index: 40; transition: left .2s; overflow-y: auto; box-shadow: 2px 0 10px rgba(0,0,0,.15); }
  .sidenav.open { left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .content { padding: 12px; }
  .user-chip { display: none; }
  .kpi .kpi-value { font-size: 20px; }
}
@media (max-width: 520px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Calendar: public holiday + staff leave chips */
.cal .cal-ev.ev-holiday { background: #ece3f7; color: #4a2c7a; }
.cal .cal-ev.ev-leave { background: #e0ecf7; color: #144a7a; }

/* Site view — monthly chiller performance report */
.card-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.card-head-row h3 { margin-bottom: 8px; }
.perf-summary { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-width: 640px; }
.perf-line { display: flex; justify-content: space-between; align-items: center; gap: 12px;
             padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.perf-line strong { white-space: nowrap; }
.perf-line.pl-blue   { background: #e8f2fa; border: 1px solid #c8dff0; color: #0d4f75; }
.perf-line.pl-orange { background: #fdf1e0; border: 1px solid #f2ddb8; color: #8a5a00; }
.perf-line.pl-green  { background: #e9f5ec; border: 1px solid #c9e6d2; color: #14602f; }
.agstar-list { margin: 0; padding-left: 20px; }
.agstar-list li { margin: 4px 0; }
