:root {
  --green: #47C820;
  --green-dark: #379018;
  --charcoal: #5B5D62;
  --charcoal-dark: #45474B;
  --ink: #26282b;
  --paper: #ffffff;
  --bg: #f4f5f4;
  --line: #e3e5e2;
  --red: #e5484d;
  --red-bg: #fdeceb;
  --yellow: #b8860b;
  --yellow-bg: #fff6da;
  --yellow-dot: #f5a524;
  --green-bg: #e9f9e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,20,20,0.05), 0 4px 16px rgba(20,20,20,0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }

.topbar { background: var(--charcoal-dark); color: #fff; }
.topbar-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-mark { font-size: 20px; font-weight: 700; letter-spacing: 0.12em; color: var(--green); }
.brand-sub { font-size: 11px; color: #c9cbce; letter-spacing: 0.03em; }
.topnav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.topnav a { color: #eef0ee; }
.topnav a:hover { color: var(--green); text-decoration: none; }
.who { color: #d6d8d6; display: flex; align-items: center; gap: 8px; }
.role-pill { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; background: rgba(71,200,32,0.18); color: var(--green); padding: 2px 8px; border-radius: 999px; }
.link-btn { background: none; border: none; color: #eef0ee; font: inherit; cursor: pointer; padding: 0; }
.link-btn:hover { color: var(--green); text-decoration: underline; }
.inline-form { display: inline; }

.page { flex: 1; max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; width: 100%; }
.pagefoot { text-align: center; color: #9aa; font-size: 12px; padding: 18px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: #7a7d80; font-size: 14px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: 17px; }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--green); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--green-dark); text-decoration: none; }
.btn.secondary { background: var(--paper); color: var(--charcoal-dark); border: 1px solid var(--line); }
.btn.secondary:hover { background: #f0f1f0; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #c93c40; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.proj-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.proj-card h3 { margin: 0; font-size: 16px; }
.proj-card h3 a { color: var(--ink); }
.proj-desc { color: #7a7d80; font-size: 13px; min-height: 18px; }

.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; display: flex; }
.progress > span { height: 100%; }
.progress .p-done { background: var(--green); }
.progress .p-ongoing { background: var(--yellow-dot); }
.progress-legend { display: flex; gap: 14px; font-size: 12px; color: #7a7d80; flex-wrap: wrap; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status-badge.status-not_started { background: var(--red-bg); color: var(--red); }
.status-badge.status-ongoing { background: var(--yellow-bg); color: var(--yellow); }
.status-badge.status-done { background: var(--green-bg); color: var(--green-dark); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.status-not_started { background: var(--red); }
.status-dot.status-ongoing { background: var(--yellow-dot); }
.status-dot.status-done { background: var(--green); }

select.status-select { border-radius: 999px; border: 1px solid var(--line); padding: 5px 10px; font-size: 12.5px; font-weight: 600; background: var(--paper); }
select.status-select.status-not_started { background: var(--red-bg); color: var(--red); border-color: #f3c9cb; }
select.status-select.status-ongoing { background: var(--yellow-bg); color: var(--yellow); border-color: #f0dfa8; }
select.status-select.status-done { background: var(--green-bg); color: var(--green-dark); border-color: #bfe8b0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #7a7d80; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
tr:last-child td { border-bottom: none; }
.section-block { margin-bottom: 22px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-title-row h3 { margin: 0; font-size: 15px; background: var(--charcoal-dark); color: #fff; display: inline-block; padding: 6px 12px; border-radius: 6px; }
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

textarea.remark-box { width: 100%; min-width: 160px; font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; resize: vertical; min-height: 36px; }
.assigned-name { font-weight: 600; }
.unassigned { color: #b7b9b7; font-style: italic; }

.photo-cell { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.photo-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-thumb { position: relative; width: 52px; height: 52px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); display: block; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.geo-tag { font-size: 10.5px; color: #7a7d80; }
.geo-tag a { color: #7a7d80; text-decoration: underline; }

form.form { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
form.form.wide { max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--charcoal-dark); }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field textarea, .field select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; background: #fff;
}
.field textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 12px; color: #9a9d9f; }
.error-box { background: var(--red-bg); color: var(--red); border: 1px solid #f3c9cb; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; }
.success-box { background: var(--green-bg); color: var(--green-dark); border: 1px solid #bfe8b0; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; }

.checklist { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.checklist label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 400; }

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: flex; align-items: center; gap: 8px; background: #f0f1f0; border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 13px; }
.pill button { background: none; border: none; color: #9a3d3d; cursor: pointer; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.pill button:hover { background: var(--red-bg); }

.modal-overlay { position: fixed; inset: 0; background: rgba(20,20,20,0.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.modal h2 { margin-top: 0; }
.modal-close-row { display: flex; justify-content: flex-end; }

.tabs-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.login-wrap { max-width: 380px; margin: 60px auto; }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo .brand-mark { color: var(--green); font-size: 26px; font-weight: 700; letter-spacing: 0.14em; }
.login-logo div.brand-sub { color: var(--charcoal); font-size: 12px; letter-spacing: 0.05em; margin-top: 4px; }

table.users-table td, table.users-table th { white-space: nowrap; }
.tag-inactive { color: var(--red); font-size: 12px; font-weight: 600; }
.tag-active { color: var(--green-dark); font-size: 12px; font-weight: 600; }

@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .page-head { flex-direction: column; }
  table, thead, tbody, th, td, tr { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border-bottom: 8px solid var(--bg); padding: 8px 0; }
  .table-wrap td { border-bottom: none; padding: 6px 12px; }
  .table-wrap td:before { content: attr(data-label); display: block; font-size: 11px; color: #9a9d9f; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }
}
