:root{--bg:#f5f7fa;--card:#fff;--ink:#17202a;--muted:#6b7280;--line:#dfe4ea;--blue:#2563eb;--blue2:#eff6ff;--danger:#b91c1c;--green:#15803d;--amber:#b45309}*{box-sizing:border-box}body{margin:0;background:var(--bg);font-family:Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;color:var(--ink)}button,input,select,textarea{font:inherit}button{cursor:pointer;border:0}.hidden{display:none!important}.muted{color:var(--muted)}.topbar{height:72px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;padding:0 24px;gap:22px;position:sticky;top:0;z-index:20}.brand{display:flex;align-items:center;gap:10px;min-width:250px}.brand h1{font-size:17px;margin:0}.brand p{font-size:12px;color:var(--muted);margin:2px 0 0}.brand-mark{width:42px;height:42px;border-radius:12px;background:#111827;color:#fff;display:grid;place-items:center;font-weight:800}.brand-mark.small{width:34px;height:34px;border-radius:9px;font-size:12px}nav{display:flex;gap:4px;flex:1}.nav,.ghost{background:transparent;color:#5b6470;padding:9px 12px;border-radius:8px}.nav:hover,.nav.active{background:#eef2f7;color:#111827}.ghost{margin-left:auto}.badge{font-size:10px;background:#dc2626;color:#fff;border-radius:10px;padding:2px 6px;margin-left:4px}.settings-only{display:none}.manager-only{display:none}main{max-width:1500px;margin:0 auto;padding:26px}.pagehead{display:flex;justify-content:space-between;gap:20px;align-items:flex-start;margin-bottom:20px}.pagehead h2{margin:0 0 5px;font-size:25px}.pagehead p{margin:0;color:var(--muted);font-size:14px}.monthnav{display:flex;align-items:center;gap:12px}.monthnav button{width:34px;height:34px;border:1px solid var(--line);background:#fff;border-radius:8px;font-size:20px}.monthnav strong{min-width:130px;text-align:center}.department-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}.card,.crew-card,.panel,.request-card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:18px}.dept-head{display:flex;justify-content:space-between;margin-bottom:12px}.mini-week,.mini-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}.mini-week{font-size:10px;color:var(--muted);margin-bottom:4px;text-align:center}.mini-day{min-height:42px;border:1px solid #edf0f3;border-radius:5px;padding:5px;font-size:11px;background:#fafbfc}.mini-day.away{background:#f8fafc}.mini-day.today{outline:2px solid #93c5fd}.person-dot,.colour-dot{width:9px;height:9px;border-radius:50%;display:inline-block;flex:none}.away-list{margin-top:14px;display:grid;gap:7px}.away-person{display:flex;align-items:center;gap:8px;font-size:12px}.away-person .dates{margin-left:auto;color:var(--muted)}.filters{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.filters select,.field select,.field input,.field textarea{border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 10px;width:100%}.legend{display:flex;gap:12px;flex-wrap:wrap;margin-bottom:12px;color:var(--muted);font-size:12px}.legend b{color:#111827}.summary{display:flex;gap:10px;margin-bottom:14px;flex-wrap:wrap}.stat{background:#fff;border:1px solid var(--line);border-radius:10px;padding:10px 14px;min-width:120px}.stat span{display:block;font-size:11px;color:var(--muted)}.stat strong{font-size:18px}.calendar-wrap{overflow:auto;border:1px solid var(--line);border-radius:12px;background:#fff}.calendar-table{border-collapse:separate;border-spacing:0;min-width:1200px;width:100%}.calendar-table th,.calendar-table td{border-right:1px solid var(--line);border-bottom:1px solid var(--line);padding:0}.calendar-table th{height:42px;background:#f8fafc;position:sticky;top:0;z-index:3;font-size:11px;color:#5f6875}.calendar-table th:first-child{left:0;z-index:5}.calendar-table .person-col{position:sticky;left:0;z-index:4;background:#fff;width:190px;min-width:190px}.person-cell{padding:10px}.person-name{display:flex;gap:8px;align-items:center;font-weight:650}.person-meta{font-size:10px;color:var(--muted);margin-top:3px}.status-cell{width:38px;min-width:38px;height:48px;text-align:center;font-size:10px;font-weight:750;position:relative}.status-cell button{width:100%;height:100%;background:transparent}.status-cell.W{background:#f0fdf4;color:#166534}.status-cell.L{background:#eff6ff;color:#1d4ed8}.status-cell.T{background:#fefce8;color:#a16207}.status-cell.O{background:#f3f4f6;color:#4b5563}.status-cell.UL{background:#fff7ed;color:#c2410c}.status-cell.CL{background:#fdf4ff;color:#a21caf}.status-cell.SL{background:#fef2f2;color:#b91c1c}.status-cell.NP{background:#e5e7eb;color:#374151}.more-btn{width:30px;height:30px;background:#f3f4f6;border-radius:7px}.more-wrap{position:relative;display:flex;justify-content:center}.more-menu{position:absolute;right:4px;top:32px;background:#fff;border:1px solid var(--line);box-shadow:0 8px 24px #0002;border-radius:8px;padding:5px;z-index:10;min-width:190px}.more-menu button{display:block;width:100%;text-align:left;padding:8px;border-radius:6px;background:#fff}.more-menu button:hover{background:#f3f4f6}.crew-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}.crew-title{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}.field{margin:10px 0}.field label{display:block;font-size:11px;color:var(--muted);margin-bottom:5px}.field-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.crew-balance{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin-top:12px}.balance-box{border:1px solid var(--line);border-radius:8px;padding:8px}.balance-box small{display:block;color:var(--muted);font-size:10px}.balance-box strong{font-size:17px}.danger{color:var(--danger)}.primary{background:var(--blue);color:#fff;padding:9px 14px;border-radius:8px;font-weight:650}.primary:hover{filter:brightness(.96)}.secondary{background:#fff;border:1px solid var(--line);padding:8px 12px;border-radius:8px}.wide{width:100%}.request-list{display:grid;gap:12px}.request-card{display:grid;grid-template-columns:1fr auto;gap:14px}.request-title{font-weight:700}.request-meta{font-size:12px;color:var(--muted);margin-top:5px}.request-status{font-size:11px;font-weight:700;padding:5px 8px;border-radius:999px;background:#f3f4f6;display:inline-block}.request-status.pending_hod{background:#fff7ed;color:#9a3412}.request-status.pending_admin{background:#fefce8;color:#854d0e}.request-status.approved{background:#f0fdf4;color:#166534}.request-status.rejected{background:#fef2f2;color:#991b1b}.request-actions{display:flex;gap:7px;align-items:center}.settings-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}.user-row{display:grid;grid-template-columns:1.2fr .8fr 1fr auto;gap:10px;align-items:center;border-top:1px solid var(--line);padding:11px 0;font-size:13px}.pill{font-size:10px;padding:4px 7px;border-radius:999px;background:#eef2ff;display:inline-block}.active-pill{background:#f0fdf4;color:#166534}.inactive-pill{background:#f3f4f6;color:#6b7280}.audit{max-height:420px;overflow:auto}.audit-row{border-top:1px solid var(--line);padding:9px 0;font-size:12px}.modal-back{position:fixed;inset:0;background:#11182766;display:grid;place-items:center;z-index:100;padding:20px}.modal{width:min(520px,100%);background:#fff;border-radius:14px;padding:22px;box-shadow:0 20px 60px #0003;max-height:90vh;overflow:auto}.modal h3{margin:0 0 5px}.modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}.error{color:var(--danger);font-size:12px;margin-top:8px}.toast{position:fixed;bottom:22px;right:22px;background:#111827;color:#fff;padding:10px 14px;border-radius:8px;opacity:0;transform:translateY(10px);transition:.2s;z-index:200;font-size:13px}.toast.show{opacity:1;transform:none}.login-view{min-height:100vh;display:grid;place-items:center;padding:20px;background:linear-gradient(135deg,#eef2f7,#f8fafc)}.login-card{width:min(390px,100%);background:#fff;border:1px solid var(--line);border-radius:16px;padding:30px;box-shadow:0 15px 50px #0001}.login-card h1{margin:16px 0 5px}.login-card label{display:block;font-size:12px;color:var(--muted);margin:16px 0}.login-card input{display:block;width:100%;padding:10px;border:1px solid var(--line);border-radius:8px;margin-top:6px}.login-help{font-size:11px;color:var(--muted);margin-top:16px;text-align:center}@media(max-width:1000px){.crew-grid,.settings-grid{grid-template-columns:1fr}.department-grid{grid-template-columns:1fr}.topbar{padding:0 12px;overflow:auto}.brand{min-width:210px}main{padding:16px}.nav{white-space:nowrap}.pagehead{flex-direction:column}.request-card{grid-template-columns:1fr}.user-row{grid-template-columns:1fr 1fr}}

.password-wrap{position:relative;margin-top:6px}.password-wrap input{margin-top:0!important;padding-right:62px!important}.password-toggle{position:absolute;right:7px;top:50%;transform:translateY(-50%);background:transparent;color:var(--blue);font-size:12px;font-weight:650;padding:5px 7px}.password-toggle:hover{text-decoration:underline}

/* v4 UI refinements */
.dept-dropdown{background:#fff;border:1px solid var(--line);border-radius:12px;margin-bottom:12px;overflow:hidden}.dept-dropdown summary{list-style:none;cursor:pointer;padding:14px 16px;display:flex;justify-content:space-between;align-items:center;font-weight:700;background:#f8fafc}.dept-dropdown summary::-webkit-details-marker{display:none}.dept-dropdown summary:after{content:"▾";color:var(--muted);font-size:12px}.dept-dropdown[open] summary:after{content:"▴"}.crew-dept-grid{padding:14px;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}.colour-editor{display:flex;align-items:center;gap:10px}.colour-preview{width:14px;height:14px;border:1px solid #9ca3af;box-shadow:0 0 0 2px #fff,0 0 0 3px #d1d5db}.home-balance{display:flex;gap:6px;margin:8px 0 0 22px;padding:7px 8px;background:#f8fafc;border:1px solid var(--line);border-radius:7px}.home-balance span{display:flex;flex-direction:column;min-width:62px}.home-balance small{font-size:9px;color:var(--muted)}.home-balance strong{font-size:13px}.away-person{cursor:pointer;padding:5px;border-radius:7px;display:grid;grid-template-columns:auto 1fr auto;align-items:center}.away-person:hover,.away-person.selected{background:#f8fafc}.away-person .home-balance{grid-column:1/-1}@media(max-width:1000px){.crew-dept-grid{grid-template-columns:1fr}}
.selectable-crew{cursor:pointer}.selectable-crew:hover{background:#f5f7fa}.selectable-crew .person-cell{border-radius:8px}.selectable-crew:has(+ td){}


/* v6 shared header image */
.site-header{width:100%;background-color:#17202a;background-position:center;background-size:cover;background-repeat:no-repeat;position:relative;overflow:hidden}.site-header:after{content:'';position:absolute;inset:0;background:linear-gradient(90deg,rgba(17,24,39,.42),rgba(17,24,39,.08));pointer-events:none}.app-header{height:145px}.login-shell{width:min(760px,100%);display:flex;flex-direction:column;align-items:stretch;gap:0}.login-header{height:150px;border-radius:16px 16px 0 0}.login-card{border-radius:0 0 16px 16px}.header-preview{height:130px;border:1px solid var(--line);border-radius:10px;background:#f8fafc center/cover no-repeat;margin:12px 0;position:relative;overflow:hidden}.header-preview.empty:after{content:'No header image selected';position:absolute;inset:0;display:grid;place-items:center;color:var(--muted);font-size:12px}.header-upload{max-width:760px}.app-header + .topbar{position:sticky;top:0}.login-view{align-content:center}

.mini-day{cursor:pointer;border:1px solid transparent;background:transparent;font:inherit;padding:5px;border-radius:8px}
.mini-day.selected{outline:2px solid var(--accent,#2563eb);outline-offset:-2px;font-weight:700}
.mini-day.empty{cursor:default;pointer-events:none}
.home-day-list{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:14px;padding-top:14px;border-top:1px solid var(--border,#e5e7eb)}
.home-day-list h4{margin:0 0 8px;font-size:13px}.home-day-list h4 span{font-weight:400;color:#6b7280;margin-left:4px}
.day-person{display:flex;align-items:center;gap:7px;padding:4px 0;font-size:13px}.day-person em{margin-left:auto;font-style:normal;color:#6b7280;font-size:12px}
@media(max-width:700px){.home-day-list{grid-template-columns:1fr}}

/* v9 layout hardening */
html, body { width:100%; min-width:0; min-height:100%; margin:0; padding:0; }
body { display:block !important; }
#loginView { width:100%; min-height:100vh; }
#app { display:block !important; visibility:visible !important; opacity:1 !important; width:100%; min-width:0; min-height:100vh; height:auto !important; position:relative; box-sizing:border-box; }
#app[hidden], #loginView[hidden] { display:none !important; }

/* v10: hidden app must remain hidden until authentication completes */
#app.hidden { display: none !important; }
#loginView.hidden { display: none !important; }

/* v11 layout and administration refinements */
.site-header{display:flex;justify-content:center;align-items:center}
.app-header{height:clamp(90px,16vw,180px)}
.app-header:not(.hidden){width:min(34vw,720px);min-width:280px;margin:0 auto;border-radius:0 0 12px 12px}
.login-shell .login-header{height:clamp(80px,12vw,150px);width:min(34vw,720px);min-width:280px;margin:0 auto}
.crew-grid{display:block;width:100%}
.dept-dropdown{width:100%;margin-bottom:18px}
.crew-dept-grid{width:100%;grid-template-columns:repeat(3,minmax(260px,1fr));gap:18px;align-items:start}
.crew-card{min-width:0;overflow:hidden}
.user-actions{display:flex;gap:7px;justify-content:flex-end;align-items:center;flex-wrap:wrap}
.danger-btn{background:#fff;border:1px solid #fecaca;color:#b91c1c;padding:8px 12px;border-radius:8px;font-weight:600}
.danger-btn:hover{background:#fef2f2}
@media(max-width:1200px){.crew-dept-grid{grid-template-columns:repeat(2,minmax(260px,1fr))}}
@media(max-width:700px){.app-header:not(.hidden),.login-shell .login-header{width:100%;min-width:0;border-radius:0}.crew-dept-grid{grid-template-columns:1fr}.user-row{grid-template-columns:1fr}.user-actions{justify-content:flex-start}}


/* v12 refinements */
.site-header{background-size:contain;background-position:center;background-repeat:no-repeat;background-color:#17202a}
.crew-order{display:flex;align-items:center;gap:8px;margin-left:auto}
.crew-order label{font-size:12px;color:var(--muted);font-weight:600}
.crew-order select{border:1px solid var(--line);background:#fff;border-radius:8px;padding:8px 10px;min-width:220px}
.more-menu{position:fixed;min-width:210px;max-width:280px;max-height:calc(100vh - 16px);overflow:auto;z-index:1000}
@media(max-width:700px){.crew-order{width:100%;margin-left:0}.crew-order select{width:100%;min-width:0}.site-header{background-size:contain}}


/* v13 visual refinements */
.site-header {
  background-color: #fff;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}
.site-header:after { display: none; }

/* Grey title banners for department and crew headings */
.dept-head {
  background: #f0f0f0;
  border-radius: 8px;
  padding: 9px 12px;
  margin: 0 0 12px;
  align-items: center;
}
.dept-head strong { font-weight: 700; }

.crew-title {
  background: #f0f0f0;
  border-radius: 8px;
  padding: 9px 12px;
  margin: -1px -1px 14px;
  min-height: 42px;
}
.crew-title strong {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.crew-title strong .colour-dot { flex: 0 0 auto; }
.crew-title .danger-btn { padding: 6px 10px; }

@media(max-width:700px){
  .dept-head { padding: 8px 10px; }
  .crew-title { margin: -1px -1px 12px; padding: 8px 10px; }
}

/* v14 start-date and home layout refinements */
.status-cell.PRE{background:#e5e7eb;color:#9ca3af}
.status-cell.PRE button{color:#9ca3af;cursor:default}
.home-day-list.has-not-started{grid-template-columns:repeat(3,minmax(0,1fr))}
.not-started-person{color:#6b7280}
.not-started-person em{font-style:normal;margin-left:auto;color:#9ca3af;font-size:11px}
@media(max-width:900px){.home-day-list.has-not-started{grid-template-columns:1fr 1fr}}
@media(max-width:700px){.home-day-list.has-not-started{grid-template-columns:1fr}}

/* v15 header and calendar crew ordering */
.app-header:not(.hidden){width:100%;min-width:0;height:88px;margin:0;border-radius:0;background-color:#fff;background-size:contain;background-position:center;background-repeat:no-repeat;}
.site-header{background-color:#fff;}
.topbar{height:62px;background:#fff;}
.order-buttons{display:flex;flex-direction:column;gap:3px;}
.order-btn{width:26px;height:22px;border:1px solid var(--line);background:#fff;border-radius:5px;color:#4b5563;font-size:10px;line-height:1;}
.order-btn:hover:not(:disabled){background:#f0f0f0;color:#111827;}
.order-btn:disabled{opacity:.28;cursor:default;}
.calendar-actions{display:flex;align-items:center;justify-content:center;gap:7px;position:relative;min-width:74px;}
.calendar-actions .more-wrap{flex:none;}
@media(max-width:700px){.app-header:not(.hidden){height:72px}.topbar{height:58px}.calendar-actions{min-width:70px;}}
.date-head{padding:0!important;background:#f8fafc!important}.date-head button{display:block;width:100%;height:42px;background:transparent;color:#5f6875;font-size:11px;font-weight:650;line-height:1.05}.date-head button:hover{background:#eef2f7}.date-head.selected-date{background:#e5e7eb!important;box-shadow:inset 0 -3px 0 #2563eb}.date-head.selected-date button{color:#111827}.date-head span{font-size:9px;font-weight:500;color:#7b8490}

/* v21 Crew Hive branding and login sizing */
.site-header{background-color:#fff!important;background-size:contain!important;background-position:center!important;background-repeat:no-repeat!important;}
.site-header:after{display:none!important;}
.login-view{background:#fff!important;display:grid;place-items:center;min-height:100vh;padding:20px;}
.login-shell{width:min(34vw,720px)!important;min-width:320px;max-width:720px;margin:0 auto;display:flex;flex-direction:column;align-items:stretch;}
.login-shell .login-header{width:100%!important;min-width:0!important;margin:0!important;border-radius:16px 16px 0 0;}
.login-shell .login-card{width:100%!important;border-radius:0 0 16px 16px;padding:30px;}
@media(max-width:700px){.login-shell{width:100%!important;min-width:0!important;}.login-shell .login-header{border-radius:0;}.login-shell .login-card{border-radius:0;}}
