:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-strong: #edf2f5;
  --text: #182026;
  --muted: #65717a;
  --line: #dce4e8;
  --primary: #0f6f68;
  --primary-dark: #0a504b;
  --success: #177245;
  --warning: #b86b00;
  --danger: #b33131;
  --shadow: 0 14px 30px rgba(25, 42, 54, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #13272f;
  color: #f3f8f8;
  padding: 28px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: #0f6f68;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #b9c8cc;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  color: #dce8eb;
  background: transparent;
  padding: 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.content {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
}

.primary-action,
.secondary-action,
.danger-action,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  background: var(--primary);
}

.primary-action:hover {
  background: var(--primary-dark);
}

.secondary-action {
  color: var(--text);
  background: var(--surface-strong);
}

.danger-action {
  color: #ffffff;
  background: var(--danger);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.4rem;
  background: var(--surface-strong);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric-card {
  padding: 20px;
  border-top: 5px solid var(--primary);
}

.metric-card.success {
  border-top-color: var(--success);
}

.metric-card.warning {
  border-top-color: var(--warning);
}

.metric-card.danger {
  border-top-color: var(--danger);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 2.2rem;
}

.panel {
  padding: 20px;
}

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

.panel-header h2,
.section-title h3 {
  margin-bottom: 4px;
}

.panel-header p,
.section-title p {
  margin-bottom: 0;
  color: var(--muted);
}

.alert-list {
  display: grid;
  gap: 10px;
}

.alert-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--warning);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.alert-item.expired {
  border-left-color: var(--danger);
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.report-filters {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(160px, 0.8fr) minmax(150px, 0.7fr) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
  margin-bottom: 16px;
}

.jotform-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 0.45fr) minmax(150px, 0.45fr) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
  margin-bottom: 16px;
}

.table-viewer-panel {
  display: grid;
  min-height: calc(100vh - 120px);
  grid-template-rows: auto auto minmax(520px, 1fr);
}

.jotform-frame-wrap {
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.jotform-frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 0;
}

.search-field {
  flex: 1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  padding: 0 12px;
}

.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.employee-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.employee-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.employee-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.employee-avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-strong);
  flex: 0 0 auto;
}

.employee-avatar.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.employee-card h3 {
  margin-bottom: 4px;
}

.employee-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.status-pill {
  align-self: flex-start;
  border-radius: 999px;
  padding: 5px 10px;
  color: #ffffff;
  background: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.valid {
  background: var(--success);
}

.status-pill.warning {
  background: var(--warning);
}

.status-pill.expired {
  background: var(--danger);
}

.doc-summary {
  display: grid;
  gap: 7px;
}

.doc-summary span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.modal {
  width: min(980px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.26);
}

.modal::backdrop {
  background: rgba(10, 22, 28, 0.55);
}

.modal form {
  padding: 24px;
}

.modal-header,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.modal-header {
  margin-bottom: 18px;
}

.modal-actions {
  margin-top: 22px;
  align-items: center;
}

.modal-actions > div {
  display: flex;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.photo-field {
  grid-row: span 2;
}

.photo-field input {
  padding: 9px;
}

#employee-photo-preview {
  display: none;
  width: 112px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-strong);
}

#employee-photo-preview.has-photo {
  display: block;
}

.documents-editor {
  margin-top: 24px;
}

.add-document-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.document-type-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 0.7fr) minmax(180px, 0.8fr) auto;
  align-items: end;
  gap: 14px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  color: var(--text);
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  margin: 0 8px 0 0;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.document-type-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.document-type-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.document-type-card h3 {
  margin-bottom: 4px;
}

.document-type-card p,
.document-required {
  margin: 0;
  color: var(--muted);
}

.section-title {
  margin-bottom: 14px;
}

.document-list {
  display: grid;
  gap: 10px;
}

.document-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(150px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.document-name {
  color: var(--text);
  font-weight: 800;
}

.remove-document-btn {
  align-self: center;
}

.file-name {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 400;
  min-height: 16px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  background: #fbfcfd;
  text-align: center;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 18px;
  }

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

  .metrics-grid,
  .form-grid,
  .document-type-form,
  .report-filters,
  .jotform-filters,
  .add-document-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .content {
    padding: 18px;
  }

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

  .nav,
  .metrics-grid,
  .form-grid,
  .document-type-form,
  .report-filters,
  .jotform-filters,
  .add-document-bar,
  .document-row {
    grid-template-columns: 1fr;
  }

  .table-viewer-panel {
    min-height: calc(100vh - 170px);
    grid-template-rows: auto auto minmax(460px, 1fr);
  }

  .jotform-frame-wrap,
  .jotform-frame-wrap iframe {
    min-height: 460px;
  }

  .modal-actions > div,
  .form-actions,
  .document-type-card {
    flex-direction: column;
    align-items: stretch;
  }
}
.cloud-status {
  margin-left: auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: #e8f5ee;
  color: #17643a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.cloud-status.error {
  background: #fdecec;
  color: #a4262c;
}

.file-name a {
  color: #1769aa;
  font-weight: 700;
}
.auth-page { min-height:100vh; display:grid; place-items:center; padding:24px; background:#eef4f7; }
.auth-card { width:min(440px,100%); background:#fff; border-radius:20px; padding:32px; box-shadow:0 20px 60px rgba(22,52,70,.14); }
.auth-card h1 { margin:18px 0 8px; }
.auth-card form { display:grid; gap:16px; margin-top:24px; }
.auth-card label,.admin-form label { display:grid; gap:7px; font-weight:700; }
.auth-card input,.admin-form input,.admin-form select { padding:12px; border:1px solid #c7d5dc; border-radius:8px; font:inherit; }
.auth-card .primary-action { justify-content:center; }
.form-error { min-height:20px; color:#a4262c; font-weight:700; }
.admin-page { background:#eef4f7; min-height:100vh; }
.admin-header { display:flex; align-items:center; justify-content:space-between; padding:24px clamp(20px,5vw,72px); background:#fff; }
.admin-header h1 { margin:4px 0 0; }
.admin-content { width:min(1180px,calc(100% - 32px)); margin:28px auto; display:grid; gap:22px; }
.admin-form { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); align-items:end; gap:14px; margin-top:18px; }
.admin-list { display:grid; gap:8px; margin-top:16px; }
.admin-list > div { display:grid; grid-template-columns:minmax(160px,1fr) minmax(220px,2fr) auto; align-items:center; gap:14px; padding:12px; border:1px solid #dce6eb; border-radius:10px; }
.admin-list button { border:1px solid #b8c9d2; background:#fff; padding:8px 12px; border-radius:7px; cursor:pointer; }
.auth-card [hidden] { display:none !important; }
.auth-card select { padding:12px; border:1px solid #c7d5dc; border-radius:8px; font:inherit; background:#fff; }
.manager-only[hidden] { display:none !important; }
.company-document-card small { display:block; margin-top:8px; color:#667985; }
.company-document-card .status-badge { display:inline-flex; margin-top:9px; padding:5px 9px; border-radius:999px; font-size:12px; font-weight:800; }
.status-badge.valid { background:#e4f5eb; color:#17643a; }
.status-badge.warning { background:#fff3cd; color:#7a5900; }
.status-badge.expired,.status-badge.missing { background:#fde5e5; color:#a4262c; }
.compact-list { margin-top:18px; }
.company-directory { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:14px; margin-top:16px; }
.company-directory-card { display:flex; justify-content:space-between; align-items:center; gap:18px; padding:18px; border:1px solid #d9e4e9; border-radius:12px; background:#fff; }
.company-directory-card.selected { border-color:#157d73; box-shadow:0 0 0 2px rgba(21,125,115,.1); }
.company-directory-card p { margin:5px 0; color:#526772; }
.company-directory-card small { color:#6c7e87; }
.company-directory-card > div:last-child { display:grid; justify-items:end; gap:8px; }
