/* Nivtar brand: violet #2F1D80, neon cyan #3AE8F8, orange #F7931E (web
   buttons), Inter typeface — per "Nivtar brand elements v2". */
:root {
  --bg: #f5f5fa;
  --card: #ffffff;
  --ink: #221a44;
  --muted: #6b6685;
  --line: #e5e3f0;
  --violet: #2f1d80;
  --violet-dark: #241566;
  --cyan: #3ae8f8;
  --orange: #f7931e;
  --brand-ink: #ffffff;
  --ok: #1e7f4f;
  --warn-bg: #fff7e6;
  --warn: #b45f06;
  --danger: #b3261e;
  --locked: #eef1f6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
h1, h2, h3 { letter-spacing: -0.02em; }

nav {
  background: var(--violet);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  height: 56px;
}
nav .logo { display: flex; align-items: center; margin-right: .75rem; }
nav .logo img { height: 26px; display: block; }
nav a { color: #cfc8ee; text-decoration: none; padding: .35rem 0; font-weight: 500; }
nav a:hover, nav a.active { color: #fff; border-bottom: 2px solid var(--cyan); }
nav .spacer { flex: 1; }
nav .user { color: #a99fd6; font-size: .85rem; }
nav form { margin: 0; }
nav button {
  background: transparent; border: 1px solid #5a4aa8; color: #cfc8ee;
  border-radius: 6px; padding: .3rem .7rem; cursor: pointer; font: inherit; font-size: .85rem;
}
nav button:hover { border-color: var(--cyan); color: #fff; }

/* Fluid layout: tables get the full browser width (with a sane cap). */
main { max-width: 1920px; margin: 1.25rem auto; padding: 0 1.5rem; }

h1 { font-size: 1.35rem; margin: .25rem 0 1rem; }
h2 { font-size: 1.05rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: .55rem .9rem; border-radius: 8px; margin-bottom: .4rem;
  background: #e8f2ec; color: var(--ok); border: 1px solid #bfdccc;
}
.messages li.warning { background: var(--warn-bg); color: var(--warn); border-color: #ecd3a8; }
.messages li.error { background: #fdeceb; color: var(--danger); border-color: #f2c4c1; }
.messages li.info { background: #ebe8f8; color: var(--violet); border-color: #cfc8ee; }

table.grid { border-collapse: collapse; width: 100%; background: var(--card); }
table.grid th, table.grid td {
  border: 1px solid var(--line);
  padding: .4rem .55rem;
  text-align: right;
  white-space: nowrap;
}
table.grid th { background: #f0eef9; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.grid td.txt, table.grid th.txt { text-align: left; }
/* Row hover never repaints the state rows (section banners, totals,
   below-NMW): those colours carry meaning. Needed as :not() rather than
   source order because the frozen-column rule below is more specific. */
table.grid tbody tr:hover:not(.section):not(.totals):not(.below-nmw) td { background: #f8f7fc; }
table.grid input[type="number"], table.grid input[type="text"] {
  width: 5.5rem; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 6px;
  text-align: right; font: inherit;
}
table.grid input:focus {
  outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--violet);
}
table.grid input.note-input { width: 11rem; text-align: left; }
table.grid tr.below-nmw td { background: var(--warn-bg); }
table.grid tr.totals td { font-weight: 700; background: #f0eef9; }
table.grid tr.section td {
  background: var(--violet); color: #fff; font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .06em; text-align: left;
  border-color: var(--violet);
}
table.grid tr.section td .muted { color: #cfc8ee; text-transform: none; letter-spacing: 0; font-weight: 400; }
.grid-scroll { overflow-x: auto; }
/* Week grid: the table scrolls inside its card so the header row stays
   fixed. box-shadow draws the header's lines because collapsed borders
   don't travel with position:sticky cells. */
.grid-scroll.sticky-head {
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding: 0; /* table sits flush so rows can't peek above the sticky header */
}
.grid-scroll.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line);
  border-top: none;
  border-bottom: none;
}

/* Frozen W.NO + Name columns during horizontal scroll — only on screens
   wide enough that the remaining data area stays usable. */
@media (min-width: 900px) {
  #hours-grid th:nth-child(1), #hours-grid td:nth-child(1) {
    position: sticky; left: 0; z-index: 2;
    background: var(--card);
    min-width: 3.5rem; max-width: 3.5rem;
  }
  #hours-grid th:nth-child(2), #hours-grid td:nth-child(2) {
    position: sticky; left: 3.5rem; z-index: 2;
    background: var(--card);
    box-shadow: 1px 0 0 var(--line);
  }
  /* header corner cells stick both ways, above everything */
  #hours-grid thead th:nth-child(-n+2) { z-index: 4; background: #f0eef9; }
  /* keep row-state backgrounds on the frozen cells */
  #hours-grid tr.totals td:nth-child(-n+2) { background: #f0eef9; }
  #hours-grid tr.below-nmw td:nth-child(-n+2) { background: var(--warn-bg); }
  #hours-grid tbody tr:hover:not(.section):not(.totals):not(.below-nmw) td:nth-child(-n+2) { background: #f8f7fc; }
  /* section banners: pin the label so it stays readable while scrolling */
  #hours-grid tr.section td { position: sticky; left: 0; background: var(--violet); }
}

.badge {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge.draft { background: #ebe8f8; color: var(--violet); }
.badge.ready { background: var(--warn-bg); color: var(--warn); }
.badge.saved { background: #e8f2ec; color: var(--ok); }
.badge.review { background: #fdeceb; color: var(--danger); }
.badge.parttime { background: #ddfaff; color: #0d6a75; }

.btn {
  display: inline-block; background: var(--orange); color: #221a44; border: none;
  padding: .5rem 1rem; border-radius: 8px; cursor: pointer; font: inherit;
  font-weight: 600; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn.secondary { background: #fff; color: var(--violet); border: 1px solid var(--violet); font-weight: 500; }
.btn.secondary:hover { background: #ebe8f8; filter: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }

a { color: var(--violet); }

.toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }

.muted { color: var(--muted); font-size: .85rem; }
.neg { color: var(--danger); font-weight: 700; }
table.grid input.hol-warn {
  background: var(--warn-bg);
  border-color: var(--warn);
  outline-color: var(--warn);
}
.warn-text { color: var(--warn); font-weight: 600; }
.nmw-flag { color: var(--warn); font-weight: 700; cursor: help; }

.note-dot { cursor: help; text-decoration: none; }
.rate-link { text-decoration: none; border-bottom: 1px dotted var(--muted); }

.login-box { max-width: 380px; margin: 8vh auto; padding: 0; overflow: hidden; }
.login-head { background: var(--violet); padding: 1.4rem 1.5rem; }
.login-head img { height: 30px; display: block; }
.login-body { padding: 1.25rem 1.5rem 1.5rem; }
.login-box input { width: 100%; padding: .55rem .7rem; margin: .3rem 0 .9rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

form.inline { display: inline; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.field-row label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.field-row input { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; width: 9rem; }

textarea.weeknote {
  width: 100%; min-height: 60px; border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .7rem; font: inherit; resize: vertical;
}

kbd {
  background: #f0eef9; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 .35rem; font-size: .8rem; font-family: inherit;
}

td.saving { outline: 2px solid #cfc8ee; }
tr.htmx-swapping td { opacity: .4; }
