:root {
  --green: #1a7f37;
  --yellow: #9a6700;
  --red: #cf222e;
  --gray: #6e7781;
  --border: #d0d7de;
  --bg: #f6f8fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: #1f2328;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}

.title { display: flex; align-items: baseline; gap: 12px; }
.title h1 { font-size: 20px; margin: 0; }
.badge {
  background: #eaeef2;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--gray);
}

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  color: inherit;
  display: inline-block;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: #1f6feb; color: #fff; border-color: #1f6feb; }
.btn.primary:hover { background: #1a5fc4; }

.upload-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.upload-btn:hover { background: #f3f4f6; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 24px 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  color: var(--gray);
}
.tab:hover { background: #f3f4f6; }
.tab.active {
  background: var(--bg);
  border-color: var(--border);
  color: #1f2328;
  font-weight: 600;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 24px;
}

.filters input, .filters select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.filters input { flex: 1; min-width: 220px; }

main { padding: 0 24px 24px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}

th {
  background: #f6f8fa;
  font-weight: 600;
  position: sticky;
  top: 0;
}

tbody tr:hover { background: #f6f8fa; cursor: pointer; }

.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.status-green { background: var(--green); }
.status-yellow { background: var(--yellow); }
.status-red { background: var(--red); }
.status-unknown { background: var(--gray); }

.notify-btn {
  border: 1px solid #1f6feb;
  color: #1f6feb;
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.notify-btn:hover { background: #eaf1fe; }

.empty-state { text-align: center; color: var(--gray); padding: 30px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
}
.modal[hidden] {
  display: none !important;
}

.modal-content {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  max-width: 720px;
  width: 100%;
  position: relative;
  max-height: 85vh;
  overflow: auto;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.detail-row { border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.detail-label { font-size: 12px; color: var(--gray); font-weight: 600; text-transform: uppercase; }
.detail-value { font-size: 13px; white-space: pre-wrap; margin-top: 2px; }

.hint { font-size: 12px; color: var(--gray); margin-top: -8px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.project-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.project-form .field-group.full { grid-column: 1 / -1; }
.project-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.project-form input, .project-form select, .project-form textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.project-form textarea { resize: vertical; min-height: 50px; }

.sheet-view { padding: 0 24px 24px; }
.sheet-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
}
.sheet-toolbar input {
  flex: 1;
  min-width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.sheet-grid {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 12px;
}
.sheet-grid td, .sheet-grid th {
  border: 1px solid var(--border);
  padding: 6px 8px;
  white-space: pre-wrap;
  max-width: 320px;
  text-align: left;
}
.sheet-grid thead th {
  background: #eaeef2;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}
.sheet-grid tbody tr:nth-child(even) { background: #fafbfc; }
.sheet-grid tbody tr:hover { background: #eef4ff; }
.sheet-grid td:first-child, .sheet-grid th:first-child {
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 1;
  box-shadow: 2px 0 0 var(--border);
}
.sheet-grid thead th:first-child { z-index: 3; background: #eaeef2; }
.sheet-scroll { overflow: auto; max-height: 75vh; border-radius: 8px; border: 1px solid var(--border); }

.gdm-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.gdm-row label { flex: 0 0 220px; font-size: 13px; }
.gdm-row input { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2328;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 999;
}

/* ---------------- Role-based access (admin vs. viewer) ---------------- */

.admin-only.role-hidden { display: none !important; }

.badge.admin { background: #ddf4e2; color: var(--green); font-weight: 600; }

.lock-hint { font-size: 10px; font-weight: 500; text-transform: none; color: var(--gray); }

.project-form .field-group.locked select,
.project-form .field-group.locked input,
.project-form .field-group.locked textarea {
  background: #f0f2f4;
  color: var(--gray);
  cursor: not-allowed;
}

/* ---------------- Biweekly compliance & reminders ---------------- */

.compliance-content { max-width: 900px; }

.compliance-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}

.compliance-gdm-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.compliance-gdm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.compliance-gdm-header .btn { margin-left: auto; }

.compliance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.compliance-table th, .compliance-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}
