:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-strong: #f9fbfb;
  --text: #172126;
  --muted: #65747c;
  --line: #dfe7ea;
  --line-strong: #c9d5da;
  --green: #15803d;
  --green-bg: #e8f6ee;
  --amber: #b7791f;
  --amber-bg: #fff5db;
  --red: #b42318;
  --red-bg: #ffeceb;
  --blue: #2563eb;
  --blue-bg: #eaf1ff;
  --shadow: 0 18px 48px rgba(20, 39, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #19252b;
  color: #ffffff;
  font-weight: 800;
}

.login-panel h1,
.topbar h1,
.panel-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  margin-top: 20px;
  font-size: 2rem;
  line-height: 1.1;
}

.login-panel p {
  margin: 8px 0 28px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  font-size: 0.86rem;
  font-weight: 700;
}

.pin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.pin-row input,
.search-field,
select {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.pin-row input {
  width: 100%;
  padding: 0 12px;
}

.pin-row button {
  min-width: 96px;
  border: 0;
  border-radius: 8px;
  background: #172126;
  color: #ffffff;
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  color: var(--red);
  font-size: 0.88rem;
}

.dashboard {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 22px;
}

.topbar h1 {
  font-size: 1.8rem;
  line-height: 1.1;
}

.topbar p,
.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.connection-pill,
.sync-text,
.status-strip span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.connection-pill.is-live {
  color: var(--green);
  background: var(--green-bg);
  border-color: #bde7cb;
}

.connection-pill.is-offline {
  color: var(--red);
  background: var(--red-bg);
  border-color: #ffc6c2;
}

.connection-pill.is-connecting {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: #c9d8ff;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.connection-pill.is-live .pulse {
  animation: pulse 1.4s ease-in-out infinite;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.icon-button svg,
.search-field svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(20, 39, 48, 0.04);
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 14px;
  font-size: 2.5rem;
  line-height: 1;
  letter-spacing: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.employee-panel,
.event-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(20, 39, 48, 0.04);
}

.panel-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header.compact {
  min-height: 76px;
}

.panel-header h2 {
  font-size: 1.08rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-field {
  width: 240px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

select {
  padding: 0 36px 0 12px;
  color: var(--text);
}

.table-wrap {
  position: relative;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.94rem;
}

th {
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.person-cell strong,
.person-cell span {
  display: block;
}

.person-cell strong {
  font-size: 0.98rem;
}

.person-cell span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
}

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid !important;
  place-items: center;
  border-radius: 8px;
  background: #ecf0f2;
  color: #35444c !important;
  font-size: 0.82rem !important;
  font-weight: 800;
}

.status-badge {
  min-width: 116px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 800;
}

.status-badge span,
.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.status-in {
  color: var(--green);
  background: var(--green-bg);
}

.status-out {
  color: var(--red);
  background: var(--red-bg);
}

.status-break {
  color: var(--amber);
  background: var(--amber-bg);
}

.status-unknown {
  color: var(--blue);
  background: var(--blue-bg);
}

.empty-state {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.event-list {
  max-height: 600px;
  margin: 0;
  padding: 6px 18px 18px;
  list-style: none;
  overflow: auto;
}

.event-list li {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.event-list li:last-child {
  border-bottom: 0;
}

.event-dot {
  margin-top: 6px;
}

.event-list strong,
.event-list span,
.event-list small {
  display: block;
}

.event-list strong {
  font-size: 0.94rem;
}

.event-list span {
  margin-top: 3px;
  color: var(--text);
  font-size: 0.9rem;
}

.event-list small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.status-strip {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

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

  .event-panel {
    order: 2;
  }
}

@media (max-width: 760px) {
  .dashboard {
    padding: 14px;
  }

  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .controls {
    justify-content: flex-start;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-card {
    min-height: 96px;
    padding: 14px;
  }

  .summary-card strong {
    font-size: 2rem;
  }

  .search-field,
  select {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  tbody tr:last-child td {
    border-bottom: 1px solid var(--line);
  }

  tbody tr td:last-child {
    border-bottom: 0;
  }

  td {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
  }

  td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  td[data-label="Name"] {
    display: block;
  }

  td[data-label="Name"]::before {
    display: none;
  }

  .person-cell {
    width: 100%;
  }

  .pin-row {
    grid-template-columns: 1fr;
  }

  .pin-row button {
    min-height: 42px;
  }
}
