/* ENP Incentive Calculator — design system (monday.com style) */

:root {
  --primary: #6161FF;
  --primary-hover: #5151D5;
  --done: #00C875;
  --working: #FDAB3D;
  --stuck: #E2445C;
  --bg: #F6F7FB;
  --card: #FFFFFF;
  --text: #323338;
  --text-secondary: #676879;
  --border: #E6E9EF;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Figtree', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }

/* ---------------------------------------------------------------- */
/* App bar */
/* ---------------------------------------------------------------- */

.appbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.appbar .brand {
  font-weight: 800;
  font-size: 17px;
  color: var(--primary);
  white-space: nowrap;
}

.appbar .spacer { flex: 1; }

.appbar select {
  min-width: 140px;
}

.fx-chip {
  background: #EFEFFE;
  color: var(--primary);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.save-indicator {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 90px;
  text-align: right;
  white-space: nowrap;
}
.save-indicator.saving { color: var(--working); }
.save-indicator.saved { color: var(--done); }

/* ---------------------------------------------------------------- */
/* Tab nav */
/* ---------------------------------------------------------------- */

.tabnav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 4px;
  padding: 0 24px;
  overflow-x: auto;
}

.tabnav a {
  display: inline-block;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabnav a:hover { color: var(--text); text-decoration: none; }

.tabnav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------------------------------------------------------------- */
/* Layout */
/* ---------------------------------------------------------------- */

.content {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

.final-banner {
  background: #FFF4E5;
  border: 1px solid var(--working);
  color: #8a5a00;
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 13px;
}

/* ---------------------------------------------------------------- */
/* Cards */
/* ---------------------------------------------------------------- */

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

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

.card-header h2, .card-header h3 { margin: 0; flex: 1; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.kpi-card .kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---------------------------------------------------------------- */
/* Buttons */
/* ---------------------------------------------------------------- */

button, .btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}

.btn-primary, button.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary, button.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger, button.btn-danger {
  background: #fff;
  color: var(--stuck);
  border-color: #F4C4CC;
}
.btn-danger:hover { background: #FFF1F3; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 8px;
  font-size: 14px;
}
.icon-btn:hover { color: var(--stuck); }

/* ---------------------------------------------------------------- */
/* Tables */
/* ---------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  /* separate (not collapse): collapsed borders break opaque background
     painting on position:sticky cells in Chrome/WebKit, causing scrolled
     content to bleed through the pinned column */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--card);
}

thead th {
  position: sticky;
  top: 0;
  background: #FAFBFD;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 5;
}

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: #F0F1FF; }

tbody tr:last-child td { border-bottom: none; }

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

tfoot td {
  padding: 10px 12px;
  font-weight: 700;
  border-top: 2px solid var(--border);
  background: #FAFBFD;
}

.sticky-col {
  position: sticky;
  left: 0;
  /* must be opaque (not "inherit"/transparent) or horizontally-scrolled
     columns show through the pinned column instead of being covered by it */
  background: var(--card, #fff);
  z-index: 4;
}

thead th.sticky-col { z-index: 6; background: #FAFBFD; }

tbody tr:hover td.sticky-col { background: #F0F1FF; }

/* ---------------------------------------------------------------- */
/* Forms */
/* ---------------------------------------------------------------- */

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(97, 97, 255, 0.15);
}

input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
  background: #F6F7FB;
  color: var(--text-secondary);
  cursor: not-allowed;
}

input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
  width: 100px;
}

input.cell-input {
  width: 90px;
  padding: 5px 8px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}

.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 140px; }

/* ---------------------------------------------------------------- */
/* Status pills */
/* ---------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill-done, .pill-a { background: rgba(0, 200, 117, 0.15); color: #00814A; }
.pill-working, .pill-b { background: rgba(253, 171, 61, 0.18); color: #92600A; }
.pill-stuck, .pill-c { background: rgba(226, 68, 92, 0.15); color: #B0203A; }
.pill-neutral { background: #EEF0F5; color: var(--text-secondary); }
.pill-primary { background: rgba(97, 97, 255, 0.14); color: var(--primary); }

/* ---------------------------------------------------------------- */
/* Access key gate */
/* ---------------------------------------------------------------- */

.gate-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.gate-card {
  width: 360px;
  text-align: center;
}

.gate-card input {
  width: 100%;
  margin: 12px 0;
  text-align: left;
}

.gate-card button { width: 100%; }

/* ---------------------------------------------------------------- */
/* Misc utility */
/* ---------------------------------------------------------------- */

.muted { color: var(--text-secondary); }
.bold { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; }
.flex-gap { display: flex; align-items: center; gap: 8px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

/* Bar list (dashboard) */
.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 90px;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.bar-track {
  background: #EEF0F5;
  border-radius: 4px;
  height: 16px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8f8fff);
  border-radius: 4px;
}

/* Flags */
.flag {
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12.5px;
  margin-bottom: 6px;
  font-weight: 600;
}
.flag-error { background: #FDEBED; color: #B0203A; border: 1px solid #F4C4CC; }
.flag-warn { background: #FFF4E5; color: #8a5a00; border: 1px solid #FBD9A8; }

/* Calc card (results expand) */
.calc-block {
  background: #FAFBFD;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.calc-block .section-title {
  font-family: 'Figtree', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-header h2 { flex: 1; margin: 0; }

/* Section spacing */
.section { margin-bottom: 24px; }

.tag-badge {
  display: inline-block;
  background: #EEF0F5;
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---------------------------------------------------------------- */
/* Print (Payroll Brief) */
/* ---------------------------------------------------------------- */

@media print {
  .appbar, .tabnav, .final-banner, button, input, select, .icon-btn {
    display: none !important;
  }
  .content {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  .card {
    box-shadow: none;
    border: none;
    page-break-inside: avoid;
  }
}
