:root{--green:#24765e;--dark:#185441;--line:#dce8e2}
body{background:#f4f8f6;color:#203b32;font-family:Tahoma,Arial,sans-serif;line-height:1.7}
.panel,.chart-panel,.kpi-card{border:1px solid var(--line);border-radius:18px;box-shadow:0 5px 20px rgba(25,70,50,.06)}
button{background:var(--green);border-radius:10px;cursor:pointer;transition:background .2s}
button:hover:not(:disabled){background:var(--dark)}
input,select,textarea{border-radius:10px;max-width:100%}
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:3px solid #9bcdb7;outline-offset:2px}
th{background:#eaf3ee;color:#204f3d}
tbody tr:hover{background:#f3f9f5}
#stats .total{background:#e5f2ec;color:#173f32}
@media(max-width:700px){.panel{padding:16px}.kpi-card{padding:16px}h1{font-size:24px}}
@media print{.panel,.chart-panel,.kpi-card{box-shadow:none}}

/* UI refinement - scoped to activities */
html{scroll-behavior:smooth;scroll-padding-top:95px}
body{background:#f3f8f5}
.content{max-width:1440px;margin:auto}
#workspace{min-width:0}
#workspace>.panel{margin:20px 0;padding:clamp(16px,2vw,28px)}
#workspace>.panel h2{margin-top:0}
.quick-nav{position:sticky;top:0;z-index:15;display:flex;gap:8px;flex-wrap:wrap;padding:12px;margin:18px 0 12px;background:rgba(245,250,247,.97);border:1px solid #d8e8df;border-radius:15px;box-shadow:0 8px 24px rgba(25,70,50,.08)}
.quick-nav a{display:inline-flex;align-items:center;justify-content:center;min-height:42px;padding:8px 14px;text-decoration:none;color:#195b46;border:1px solid transparent;border-radius:10px;font-weight:600;font-size:14px}
.quick-nav a:hover,.quick-nav a:focus-visible{background:#e0f0e7;border-color:#bddbca;outline-offset:2px}
.quick-nav a[aria-current="location"]{background:#24765e;color:#fff}
#logout{background:#fff;color:#185441;border:1px solid #bad3c6}
#logout:hover{background:#e7f2ec;color:#185441}
#workspace input,#workspace select,#workspace textarea{background:#fff;min-width:0;box-sizing:border-box}
#workspace .grid>*{min-width:0}
#workspace button{min-height:42px}
#workspace .kpi-card{min-height:135px;padding:18px;gap:8px}
#workspace .kpi-card.total{background:#e5f2ec;color:#173f32;border-color:#b7d9c9}
#workspace .kpi-value{font-size:clamp(26px,2.6vw,38px)}
#workspace .chart-panel{padding:18px;min-width:0}
#workspace .chart-panel h3{margin-bottom:10px}
#workspace .dash-grid{align-items:start}
#workspace .scroll{border:1px solid #e0ebe4;border-radius:12px;overflow-x:auto}
#workspace table{min-width:720px}
#workspace th{position:relative;background:#e8f2ed;color:#184d3b;font-weight:700}
#workspace td{vertical-align:top;line-height:1.7}
#workspace tbody tr:nth-child(even){background:#fafcfb}
#workspace tbody tr:hover{background:#eef7f1}
#workspace .table-title{display:flex;align-items:end;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:22px}
#workspace .table-search{min-width:min(100%,280px);font-size:13px}
#workspace .table-search input{padding:9px 12px}
#workspace .actions{gap:10px}
#workspace .actions button{white-space:normal}
#users form{margin-bottom:20px}
#historyControls{align-items:end}
#historyControls>*{min-width:130px;flex:1}
#historyControls button{flex:0 1 auto}
@media(max-width:850px){.quick-nav{position:static}.quick-nav a{flex:1 1 42%}.grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:600px){.quick-nav a{flex:1 1 100%;justify-content:flex-start}.grid{grid-template-columns:1fr}#workspace>.panel{padding:14px}#workspace .kpi-grid{grid-template-columns:1fr 1fr;gap:10px}#workspace .kpi-card{min-height:110px;padding:12px}#workspace .kpi-value{font-size:27px}#workspace .dash-grid{grid-template-columns:1fr}}
@media(max-width:380px){#workspace .kpi-grid{grid-template-columns:1fr}}
@media print{.quick-nav,#logout,.table-search,#historyControls{display:none!important}html{scroll-behavior:auto}#workspace .scroll{border:0;overflow:visible}#workspace table{min-width:0}#workspace .chart-panel{break-inside:avoid}}

/* Final responsive polish: visual changes only */
body{overflow-x:hidden}
.content{width:min(100% - 32px,1440px);box-sizing:border-box}
.content>h1{margin:22px 0 8px;font-size:clamp(24px,2.3vw,34px);line-height:1.35}
.content>h1+p{margin:0 0 12px}
#message{min-height:0;margin:8px 0}
#workspace{width:100%;box-sizing:border-box}
#workspace>.panel{margin:14px 0;padding:clamp(14px,1.7vw,24px)}
#workspace>.panel h2{font-size:clamp(20px,2vw,27px)}
.quick-nav{margin:10px 0;gap:6px;padding:8px;scroll-margin-top:12px}
.quick-nav a{min-height:38px;padding:7px 12px}
#logout{margin:0 0 4px;padding:8px 14px;min-height:38px}
#workspace .grid{gap:12px}
#workspace .grid label{min-width:0}
#workspace .type-controls{display:flex;align-items:stretch;flex-wrap:wrap;gap:8px;min-width:0}
#workspace .type-controls select{flex:1 1 180px;width:auto;min-width:0}
#workspace .type-controls button{flex:0 1 auto;max-width:100%;white-space:normal;overflow-wrap:anywhere}
#workspace .kpi-grid{gap:12px}
#workspace .kpi-card{min-height:112px;padding:15px}
#workspace .dash-heading{margin-bottom:14px}
#workspace .chart-panel{padding:16px}
#workspace .donut-wrap{padding:10px 0}
#workspace .legend{gap:10px}
#workspace .bar-row{margin:10px 0}
#workspace .followup-panel{padding:16px;margin:14px 0}
#workspace .scroll{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
#workspace table{width:100%;min-width:720px}
#workspace th,#workspace td{padding:10px;min-width:75px;overflow-wrap:anywhere}
#workspace td button{padding:8px 10px;font-size:13px}
#workspace .table-title{margin-top:16px}
@media(max-width:850px){.content{width:min(100% - 20px,1440px)}#workspace .grid{grid-template-columns:repeat(2,minmax(0,1fr))}#workspace .grid .wide{grid-column:1/-1}}
@media(max-width:600px){.content{width:calc(100% - 16px)}#workspace .grid{grid-template-columns:minmax(0,1fr)}#workspace .grid .wide{grid-column:auto}.quick-nav{position:static}#workspace .type-controls button{flex:1 1 100%}#workspace .kpi-card{min-height:105px}#workspace th,#workspace td{padding:8px}}
@media print{.content{width:100%;max-width:none}#workspace>.panel{margin:0;padding:0}#workspace .scroll{overflow:visible}#workspace table{min-width:0}#workspace .kpi-card{min-height:0}body{overflow:visible}}


/* UAT EXECUTIVE PRINT V1 */
@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  html, body {
    background: #fff !important;
    color: #172b25 !important;
    width: 100%;
    overflow: visible !important;
  }

  .content {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
  }

  #reports {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  #reports .kpi-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6mm !important;
  }

  #reports .kpi-card {
    padding: 10px !important;
    margin: 0 !important;
    break-inside: avoid;
  }

  #reports .kpi-value {
    font-size: 24px !important;
  }

  #reports .dash-grid {
    gap: 8mm !important;
  }

  #reports .chart-panel {
    padding: 10px !important;
    break-inside: avoid;
  }

  #reports table {
    width: 100% !important;
    font-size: 10px !important;
    table-layout: auto;
  }

  #reports th,
  #reports td {
    padding: 5px !important;
    min-width: 0 !important;
    overflow-wrap: anywhere;
  }

  #reports thead {
    display: table-header-group;
  }

  #reports tr {
    break-inside: avoid;
  }

  #reports .scroll {
    overflow: visible !important;
  }

  .quick-nav,
  #csv,
  #print,
  #refresh,
  #logout,
  #historyControls {
    display: none !important;
  }
}

/* UAT EXECUTIVE PRINT V2 */
@media print {
  @page {
    size: A4 landscape;
    margin: 9mm;
  }

  header,
  #login,
  #dailyEntry,
  #typeEditor,
  #users,
  #statusHistoryPanel,
  #showStatusHistory,
  #quickNav,
  #logout,
  #message,
  #reports .filters,
  #reports .actions,
  #reports .table-search {
    display: none !important;
  }

  #workspace,
  #reports {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .content {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .content > h1 {
    font-size: 19px !important;
    margin: 0 0 4px !important;
  }

  .content > h1 + p {
    font-size: 10px !important;
    margin: 0 0 8px !important;
  }

  #reports .dash-heading {
    margin-bottom: 7px !important;
  }

  #reports .kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 5px !important;
  }

  #reports .kpi-card {
    min-height: 0 !important;
    padding: 7px !important;
    break-inside: avoid;
  }

  #reports .kpi-value {
    font-size: 18px !important;
  }

  #reports .metric-note {
    font-size: 9px !important;
    margin: 6px 0 !important;
  }

  #reports .dash-grid {
    display: none !important;
  }

  #reports .followup-panel {
    padding: 7px !important;
    margin: 7px 0 !important;
    break-inside: avoid;
  }

  #reports h3 {
    font-size: 12px !important;
    margin: 7px 0 !important;
  }

  #reports .scroll {
    overflow: visible !important;
    border: 0 !important;
  }

  #reports table {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 9px !important;
  }

  #reports th,
  #reports td {
    padding: 4px !important;
    min-width: 0 !important;
  }

  #reports thead {
    display: table-header-group;
  }

  #reports tr {
    break-inside: avoid;
  }

  #reports button,
  #reports input,
  #reports select {
    display: none !important;
  }
}


/* UAT EXECUTIVE PRINT V3 */
@media print {
  #reports .table-title {
    margin-top: 4px !important;
    margin-bottom: 2px !important;
  }

  #reports .table-title h3 {
    margin: 2px 0 !important;
  }

  #reports > h3 {
    margin: 5px 0 2px !important;
  }

  #reports .scroll {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    break-before: auto !important;
    page-break-before: auto !important;
  }

  #reports table {
    margin: 0 !important;
    border-spacing: 0 !important;
    line-height: 1.2 !important;
  }

  #reports thead {
    display: table-header-group !important;
  }

  #reports tbody {
    break-before: auto !important;
    page-break-before: auto !important;
  }

  #reports tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  #reports th,
  #reports td {
    padding: 3px 4px !important;
    line-height: 1.25 !important;
  }

  #reports .followup-panel {
    margin: 4px 0 !important;
  }

  #reports .empty-state {
    padding: 3px !important;
  }

  #reports .dash-heading {
    margin-bottom: 4px !important;
  }

  #reports .kpi-grid {
    gap: 4px !important;
  }

  #reports .kpi-card {
    padding: 5px !important;
  }

  #reports .metric-note {
    margin: 3px 0 !important;
  }
}


/* UAT EXECUTIVE PRINT V4 */
@media print {
  html,
  body {
    min-height: 0 !important;
    height: auto !important;
  }

  body {
    display: block !important;
  }

  main.content {
    display: block !important;
    flex: none !important;
    min-height: 0 !important;
    height: auto !important;
  }

  body > footer {
    display: block !important;
    position: static !important;
    clear: both !important;
    padding: 4px 0 0 !important;
    margin: 5px 0 0 !important;
    border-top: 1px solid #dce8e3 !important;
    background: white !important;
    font-size: 9px !important;
    line-height: 1.3 !important;
    break-before: avoid !important;
    page-break-before: avoid !important;
  }
}

.attendance-employees{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,16rem),1fr));gap:.75rem;margin-block:1rem}
.attendance-card{display:grid;gap:.5rem;padding:1rem;border:1px solid #d6e3de;border-radius:.65rem;background:#f5faf8}
#attendanceDialog{width:min(34rem,calc(100% - 2rem));max-height:calc(100dvh - 2rem);overflow:auto;box-sizing:border-box;border:1px solid #d6e3de;border-radius:.75rem;padding:1rem}
#attendanceDialog::backdrop{background:#12272199}
#attendance [hidden]{display:none}
#attendance button,#attendanceDialog button{min-height:44px}
#attendanceEvents{overflow-wrap:anywhere}
@media(max-width:600px){
 #attendanceDialog .grid{grid-template-columns:minmax(0,1fr)}
 #attendanceDialog input,#attendanceDialog select,#attendanceDialog textarea{width:100%;min-width:0;box-sizing:border-box;font-size:16px}
 #reports .actions button{flex:1 1 11rem;min-height:44px}
}

#referrals [hidden]{display:none}
#referrals button{min-height:44px}
#referralDialog{width:min(34rem,calc(100% - 2rem));max-height:calc(100dvh - 2rem);overflow:auto;box-sizing:border-box;border:1px solid #d6e3de;border-radius:.75rem;padding:1rem}
#referralDialog::backdrop{background:#12272199}
.referral-email,.referral-text{overflow-wrap:anywhere}
.referral-text{white-space:pre-wrap}
@media(max-width:600px){
 #referralForm.grid,#referralResponse.grid{grid-template-columns:minmax(0,1fr)}
 #referrals input,#referrals select,#referrals textarea{width:100%;min-width:0;box-sizing:border-box;font-size:16px}
}

#leaveRequests [hidden]{display:none}
#leaveRequests button{min-height:44px}
#leaveRequests textarea{width:100%;box-sizing:border-box}
@media(max-width:600px){
 #leaveForm.grid{grid-template-columns:minmax(0,1fr)}
 #leaveRequests input,#leaveRequests select,#leaveRequests textarea{width:100%;min-width:0;box-sizing:border-box;font-size:16px}
}

.nav-page-inactive { display: none !important; }
.quick-nav a[aria-current="page"] {
  background: #24765e;
  color: #fff;
}
