/* Waterboard Design System */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --border: #e4e7ee;
  --border-light: #f0f1f5;
  --text: #111827;
  --text-secondary: #4b5563;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff4ff;
  --green: #059669;
  --green-bg: #ecfdf5;
  --green-border: #a7f3d0;
  --yellow: #b45309;
  --yellow-bg: #fffbeb;
  --yellow-border: #fde68a;
  --orange: #c2410c;
  --orange-bg: #fff7ed;
  --orange-border: #fed7aa;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --transition: 150ms ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ── Navigation ── */

.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.92);
}

.navbar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.4px;
}

.navbar-nav {
  display: flex;
  gap: 2px;
  align-items: center;
  height: 100%;
}

.nav-link {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { color: var(--accent); background: var(--accent-light); }

.navbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  font-size: 12px;
  color: var(--muted);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  transition: all var(--transition);
}
.btn-sm:hover { background: var(--bg); border-color: #d1d5db; }

/* ── Impersonation ── */

.impersonation-banner {
  background: var(--yellow-bg);
  border-bottom: 2px solid var(--yellow-border);
  padding: 6px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--yellow);
}

/* ── Layout ── */

.page-layout {
  display: flex;
  min-height: calc(100vh - 48px);
}

.page-layout .container {
  flex: 1;
  min-width: 0;
}

.container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ── Sidebar ── */

.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding-top: 20px;
}

.sidebar-header {
  padding: 0 16px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.sidebar-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition);
}
.sidebar-group-toggle:hover { background: var(--bg); color: var(--text); }
.sidebar-group-toggle.active { color: var(--text); font-weight: 600; }

.sidebar-chevron { transition: transform var(--transition); }
.sidebar-group.open .sidebar-chevron { transform: rotate(90deg); }

.sidebar-submenu { padding: 2px 0 6px; }

.sidebar-sublink {
  display: block;
  padding: 5px 16px 5px 28px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition);
}
.sidebar-sublink:hover { background: var(--bg); color: var(--text); }
.sidebar-sublink.active {
  color: var(--accent);
  background: var(--accent-light);
  border-right: 2px solid var(--accent);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}
header .meta {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Summary Cards ── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.summary-card:hover { box-shadow: var(--shadow); }
.summary-card .label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  margin-bottom: 4px;
}
.summary-card .value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.summary-card .sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Tabs ── */

.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}

.tab {
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--muted);
  border: none;
  background: none;
  transition: all var(--transition);
  text-decoration: none;
}
.tab.active { background: var(--accent); color: #fff; }
.tab:hover:not(.active) { background: var(--bg); color: var(--text); }

.panel { display: none; }
.panel.active { display: block; }

/* ── Cards ── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--card);
}

.card-body { padding: 16px; }

/* ── Controls ── */

.global-controls {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}

.ctrl {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.ctrl label {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.ctrl input, .ctrl select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: #fff;
  width: 64px;
  transition: border-color var(--transition);
}
.ctrl input:focus, .ctrl select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
.ctrl select { width: auto; }

/* ── Tables ── */

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

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

th {
  background: #fafbfc;
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
th:hover { color: var(--text); }

td {
  padding: 7px 10px;
  border-top: 1px solid var(--border-light);
  white-space: nowrap;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: #f9fafb; }
tbody tr:first-child td { border-top: none; }

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'IBM Plex Mono', 'SF Mono', monospace;
  font-size: 11.5px;
}

.name-col {
  font-weight: 500;
  min-width: 140px;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}
tr:hover .name-col { background: #f9fafb; }
th.name-col { background: #fafbfc; }

/* ── Badges ── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-100 { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-75 { background: var(--blue-bg); color: var(--accent); border: 1px solid var(--blue-border); }
.badge-50 { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.badge-25 { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.badge-0 { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-na { background: #f3f4f6; color: #9ca3af; border: 1px solid #e5e7eb; }
.badge-pass { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-fail { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-status { padding: 2px 10px; font-size: 11px; }
.badge-completed { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-failed { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-processing { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }

/* ── Inline Inputs ── */

.inline-input {
  width: 58px;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11.5px;
  font-family: 'IBM Plex Mono', monospace;
  text-align: right;
  background: #fff;
  font-variant-numeric: tabular-nums;
  transition: all var(--transition);
}
.inline-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}

/* ── Progress Bars ── */

.bar-wrap { display: flex; align-items: center; gap: 6px; min-width: 100px; }
.bar-track { flex: 1; height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }
.bar-label { font-size: 11px; font-weight: 600; min-width: 38px; text-align: right; font-family: 'IBM Plex Mono', monospace; }

/* ── Scheme Reference ── */

.scheme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 16px;
}

.scheme-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: #fafbfc;
}
.scheme-card h4 {
  font-size: 11px;
  margin-bottom: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.tier-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}
.tier-row:last-child { border-bottom: none; }

.param-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}
.param-label { color: var(--muted); }

.highlight-row td { background: #fffdf5 !important; }

/* ── QTD / Full / Est. cell annotations ── */

.cell-tag {
  font-size: 8px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
  font-family: 'IBM Plex Sans', sans-serif;
  margin-left: 2px;
  vertical-align: super;
}
sub.cell-tag {
  vertical-align: sub;
}
.cell-sub {
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 1px;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  line-height: 1.4;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--card); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #d1d5db; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: none; color: var(--accent); border: none; padding: 4px 8px; font-family: inherit; cursor: pointer; font-size: 12px; border-radius: 4px; }
.btn-ghost:hover { background: var(--accent-light); }

/* ── Forms ── */

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: all var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.form-input::placeholder { color: #c0c4cc; }
select.form-input { cursor: pointer; }

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ── Flash Messages ── */

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: flashIn 0.25s ease;
}
@keyframes flashIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.flash-warning { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
.flash-info { background: var(--blue-bg); color: var(--accent); border: 1px solid var(--blue-border); }

/* ── Auth / Login ── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  text-align: center;
  margin-bottom: 2px;
}
.auth-card .subtitle {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-bottom: 24px;
}

/* ── Pagination ── */

.pagination {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  justify-content: center;
}
.pagination a, .pagination span {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  transition: all var(--transition);
}
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination a:hover { background: var(--bg); }

/* ── Footer ── */

.footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2px;
}

/* ── Utilities ── */

.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-accent { color: var(--accent); }
.text-yellow { color: var(--yellow); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 600; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Working Days Popover ── */

.wd-trigger {
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
}
.wd-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06);
  padding: 12px 14px;
  z-index: 50;
  font-size: 12px;
}
.wd-popover::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.wd-trigger:hover .wd-popover,
.wd-trigger:focus .wd-popover {
  display: block;
  animation: wd-pop 0.15s ease;
}
@keyframes wd-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.wd-popover-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.wd-popover-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  color: var(--text-secondary);
}
.wd-popover-num {
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}
.wd-popover-holidays {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 0 4px 10px;
  margin-bottom: 2px;
  border-left: 2px solid var(--red-border);
  font-size: 11px;
  color: var(--muted);
}
.wd-popover-total {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 6px;
  color: var(--text);
  font-weight: 600;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .container { padding: 12px; }
  header h1 { font-size: 18px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .navbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .page-layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 12px 0; }
  .sidebar-header { padding-bottom: 8px; margin-bottom: 4px; }
  .sidebar-submenu { display: flex; flex-wrap: wrap; padding: 0 12px; }
  .sidebar-sublink { display: inline-block; padding: 5px 10px; }
  .sidebar-sublink.active { border-right: none; border-bottom: 2px solid var(--accent); }
}
