:root {
  --brand: #2E8B57;
  --brand-600: #2A7C4E;
  --brand-light: #E7F3EC;
  --forest-900: #0F2A20;
  --forest-800: #14352A;
  --forest-700: #1B4433;
  --ok: #2E9E5B;
  --warn: #E0A72E;
  --late: #D64545;
  --info: #3E7BC0;
  --bg: #EEF1EC;
  --card: #FFFFFF;
  --line: #E6EBE7;
  --ink: #16221C;
  --ink2: #4B584F;
  --muted: #7C8A80;
  --text: #16221C;
  --border: #E6EBE7;
  --radius: 16px;
  --shadow: 0 2px 8px rgba(16,42,32,.05);

  /* compat aliases */
  --brand-strong: #2A7C4E;
  --tint-1: #E7F3EC;
  --tint-2: #D4ECDF;
  --focus: #78C49A;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ══════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════ */
.page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 20% 20%, var(--brand-light), var(--bg) 60%),
    radial-gradient(900px 600px at 90% 80%, #D4ECDF, var(--bg) 70%);
}

.card {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3.2vw, 34px);
}

.header { text-align: center; margin-bottom: 18px; }

.logo {
  height: 44px;
  width: auto;
  display: inline-block;
  margin-bottom: 14px;
}

.avatar {
  width: 74px; height: 74px;
  margin: 0 auto 10px;
  border-radius: 999px;
  display: grid; place-items: center;
  background: var(--brand-light);
  border: 1px solid var(--tint-2);
}

.avatar svg { fill: var(--brand); }

.title {
  margin: 6px 0 0;
  font-size: clamp(28px, 3.1vw, 36px);
  letter-spacing: .2px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.form { display: grid; gap: 14px; }

.field label {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.field label span { color: var(--brand); }

.field input {
  width: 100%; height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  outline: none;
  font-size: 14px;
  transition: box-shadow .2s, border-color .2s;
}

.field input::placeholder { color: var(--muted); }
.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46,139,87,.15);
}

.row {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px; margin-top: 2px;
}

.checkbox {
  display: inline-flex; align-items: center;
  gap: 10px; cursor: pointer; user-select: none;
  color: var(--ink2); font-size: 14px;
}

.checkbox input {
  width: 16px; height: 16px;
  accent-color: var(--brand);
}

.btn {
  height: 48px; border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}

.btn:hover { filter: brightness(.92); }
.btn:active { transform: translateY(1px); }

.footer {
  display: flex; justify-content: center;
  gap: 6px; font-size: 14px;
  color: var(--ink2); margin-top: 2px;
}

.link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

.link:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════
   SHARED LAYOUT — sidebar + main
   ══════════════════════════════════════════════════ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--forest-700);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand .logo-text {
  font-size: 16px;
  font-weight: 800;
  color: rgba(255,255,255,.9);
  letter-spacing: .2px;
}

.sidebar-brand .logo-text em {
  font-style: normal;
  color: #5EBB82;
}

.sidebar-brand small {
  display: block;
  font-size: 10.5px;
  color: rgba(255,255,255,.4);
  margin-top: 3px;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-section-label {
  padding: 16px 20px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.nav-link {
  display: block;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}

.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
}

.nav-link.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: #5EBB82;
  font-weight: 700;
}

/* ── Main content ── */
.main {
  flex: 1;
  padding: 28px 32px;
  overflow-x: auto;
  background: var(--bg);
}

.page-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.page-sub {
  margin: 0 0 24px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ── KPI strip ── */
.kpi-strip {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.kpi-item {
  flex: 1;
  padding: 18px 20px;
  text-align: center;
  border-right: 1px solid var(--line);
}

.kpi-item:last-child { border-right: none; }

.kpi-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.kpi-number.green { color: var(--ok); }

.kpi-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ── Section panel ── */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.panel-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--brand-light);
  border-radius: 999px;
  padding: 2px 10px;
}

.panel-action {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.panel-action:hover { text-decoration: underline; }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr { background: #F4F7F5; }

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
  font-size: 13px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F7FAF8; }

.td-bold { font-weight: 700; }
.td-muted { color: var(--muted); font-size: 12.5px; }

/* ── Badge (dot + label) ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.badge-ok { background: #E4F4EA; color: #1e7a44; }
.badge-ok::before { background: #2E9E5B; }

.badge-warn { background: #FCF3DE; color: #8a6410; }
.badge-warn::before { background: #E0A72E; }

.badge-late { background: #FBE4E4; color: #a52f2f; }
.badge-late::before { background: #D64545; }

.badge-info { background: #E6EFFA; color: #295d95; }
.badge-info::before { background: #3E7BC0; }

.badge-muted { background: #F0F2F1; color: var(--muted); }
.badge-muted::before { background: #B0BAB4; }

/* Compat aliases */
.badge-active { background: #E4F4EA; color: #1e7a44; }
.badge-active::before { background: #2E9E5B; }
.badge-inactive { background: #FBE4E4; color: #a52f2f; }
.badge-inactive::before { background: #D64545; }
.badge-pending { background: #FCF3DE; color: #8a6410; }
.badge-pending::before { background: #E0A72E; }
.badge-done { background: #E6EFFA; color: #295d95; }
.badge-done::before { background: #3E7BC0; }
.badge-open { background: #E7F3EC; color: #2A7C4E; }
.badge-open::before { background: #2E8B57; }

/* ── Action buttons (table row) ── */
.action-btns {
  display: flex;
  gap: 6px;
}

.btn-sm {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  transition: background .15s, border-color .15s;
}

.btn-sm:hover {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-600);
}

.btn-sm-danger {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #FBE4E4;
  background: #FBE4E4;
  color: #a52f2f;
  transition: background .15s;
}

.btn-sm-danger:hover {
  background: #F5CCCC;
}

/* ── Top bar button ── */
.btn-new {
  padding: 10px 20px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: var(--brand);
  color: #fff;
  transition: filter .15s;
}

.btn-new:hover { filter: brightness(.92); }

/* ── Empty state ── */
.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 13px;
}

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,42,32,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: min(520px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(15,42,32,.18);
}

.modal-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover { color: var(--ink); }

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 14px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Form fields (modal) ── */
.mfield {
  margin-bottom: 14px;
}

.mfield label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 6px;
}

.mfield input,
.mfield select,
.mfield textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s;
}

.mfield input:focus,
.mfield select:focus,
.mfield textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46,139,87,.12);
}

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

.mfield-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink2);
  cursor: pointer;
  margin-bottom: 14px;
}

.mfield-check input {
  width: 16px; height: 16px;
  accent-color: var(--brand);
}

/* ── Confirm overlay ── */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,42,32,.45);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}

.confirm-overlay.open {
  display: flex;
}

.confirm-box {
  background: var(--card);
  border-radius: var(--radius);
  width: min(400px, 90vw);
  box-shadow: 0 8px 40px rgba(15,42,32,.18);
  padding: 24px;
  text-align: center;
}

.confirm-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
}

.confirm-msg {
  font-size: 13px;
  color: var(--ink2);
  margin: 0 0 20px;
  line-height: 1.5;
}

.confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-cancel {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

.btn-cancel:hover { background: #F4F7F5; }

.btn-confirm-danger {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: var(--late);
  color: #fff;
}

.btn-confirm-danger:hover { filter: brightness(.92); }

.btn-save {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: var(--brand);
  color: #fff;
}

.btn-save:hover { filter: brightness(.92); }

/* ── DataTables overrides ── */
.dataTables_wrapper { padding: 12px 16px; }
.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  outline: none;
  margin-left: 6px;
}
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46,139,87,.12);
}
.dataTables_wrapper .dataTables_length select {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
}
.dataTables_wrapper .dataTables_info { font-size: 12px; color: var(--muted); }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 8px !important;
  font-size: 12px;
  padding: 4px 10px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--brand-light) !important;
  border-color: var(--brand) !important;
  color: var(--brand-600) !important;
}
table.dataTable thead th { border-bottom: 1px solid var(--line) !important; }
table.dataTable.no-footer { border-bottom: none !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px; }
  .kpi-strip { flex-wrap: wrap; }
  .kpi-item { min-width: 50%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
