:root {
  --ink: #17212f;
  --muted: #667085;
  --line: #d9e2e5;
  --panel: #ffffff;
  --bg: #eef4f2;
  --green: #278066;
  --green-dark: #10241f;
  --gold: #bb7a11;
  --red: #b43d3d;
  --blue: #315f9f;
  --shadow: 0 16px 44px rgba(32, 45, 57, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.1; }
p, small, span, .muted { color: var(--muted); }

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(39, 128, 102, .12), rgba(49, 95, 159, .09)),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.brand-row b, .brand b {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #5bc097;
  color: #092118;
  font-size: 15px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

aside {
  min-height: 100vh;
  background: var(--green-dark);
  color: #eaf4ef;
  padding: 22px 16px;
  display: grid;
  align-content: start;
  gap: 9px;
}

.brand {
  margin-bottom: 20px;
  font-size: 20px;
}

aside button {
  border: 0;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  background: transparent;
  color: #deeee8;
}

aside button.active, aside button:hover { background: rgba(255,255,255,.12); }
aside small { margin-top: 28px; color: #aac0b8; line-height: 1.5; }
.logout { margin-top: 18px; color: #ffd7d7; }
.install {
  margin-top: 12px;
  background: #5bc097;
  color: #092118;
  font-weight: 900;
}

main {
  padding: 28px;
  min-width: 0;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.header-actions, .button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

select, input, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 11px;
  width: 100%;
}

textarea { resize: vertical; }

.view { display: none; }
.active-view { display: block; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card, .panel, .two article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 16px;
  text-align: left;
  transition: transform .16s ease, border-color .16s ease;
}

.metric-card:hover {
  transform: translateY(-1px);
  border-color: rgba(39, 128, 102, .45);
}

.metric-card b { display: block; font-size: 34px; margin-top: 5px; color: var(--ink); }
.metric-card span, .metric-card small { display: block; }

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, .85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.panel { padding: 16px; }
.panel-top, .section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-top input { width: 122px; }

.employee-list, .table-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.employee-card, .record-row {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 9px;
  text-align: left;
}

.employee-card.active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.record-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.employee-card b, .employee-card span, .record-row b, .record-row span { display: block; }
.risk-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.mini, .bar { height: 8px; border-radius: 99px; background: #e8eeee; overflow: hidden; }
.mini { flex: 1; }
.mini i, .bar i { display: block; height: 100%; background: var(--green); }

.pill, .chip, .event-type {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.low { color: #17604e; background: #dff2eb; }
.medium { color: #7a5208; background: #fff0cc; }
.high { color: var(--red); background: #ffe1df; }

.profile {
  border-radius: 8px;
  border: 1px solid #cce5da;
  background: linear-gradient(135deg, #e7f6ef, #f8fbfb);
  padding: 18px;
  display: grid;
  grid-template-columns: auto 1fr minmax(170px, 220px);
  gap: 14px;
  align-items: center;
}

.avatar {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #123931;
  color: #fff;
  font-weight: 900;
}

.score span { display: block; font-size: 12px; font-weight: 800; }
.score b { font-size: 34px; }

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}

.two article {
  padding: 15px;
  box-shadow: none;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { color: var(--blue); background: #e9eef7; }

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.event {
  display: grid;
  grid-template-columns: 106px 1fr auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.event-date { color: var(--muted); font-weight: 800; font-size: 13px; }
.event p { margin-top: 3px; }
.event-type { background: #eef1f4; }
.event-type.Late { color: #7a5208; background: #fff0cc; }
.event-type.Call-off, .event-type.No-call { color: var(--red); background: #ffe1df; }

.form-panel, #incidentForm {
  display: grid;
  gap: 12px;
}

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

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary, .secondary, .compact, .section-title button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-weight: 800;
  padding: 0 14px;
}

.primary { background: var(--green); color: #fff; border: 0; }
.secondary { background: #f7faf9; color: var(--ink); }
.compact { width: auto; white-space: nowrap; }

dialog {
  width: min(680px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(16, 36, 31, .45); }
#incidentForm, .drilldown-panel { padding: 18px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}
#closeIncident, #closeDrilldown {
  min-width: 68px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.drilldown-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  max-height: min(62vh, 560px);
  overflow: auto;
}

.drilldown-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.drilldown-item button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 80px);
  opacity: 0;
  background: #10221e;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  transition: .18s ease;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .app-shell, .grid, .metrics, .two, .split { grid-template-columns: 1fr; }
  aside {
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 3;
    grid-auto-flow: column;
    overflow-x: auto;
    align-items: center;
  }
  aside small { display: none; }
  header, .profile {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media (max-width: 560px) {
  main { padding: 16px; }
  h1 { font-size: 24px; }
  .row, .event, header, .header-actions, .record-row {
    grid-template-columns: 1fr;
    display: grid;
  }
  .panel-top { display: grid; }
  .panel-top input { width: 100%; }
}
