@font-face {
  font-family: "Helvetica Now";
  src: url("/static/fonts/HelveticaNowDisplay-Regular.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Helvetica Now";
  src: url("/static/fonts/HelveticaNowDisplay-Medium.otf") format("opentype");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Helvetica Now";
  src: url("/static/fonts/HelveticaNowDisplay-Bold.otf") format("opentype");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #f7f7f7;
  --panel: #ffffff;
  --ink: #2e2e2e;
  --dim: #595959;
  --line: #e7e7e7;
  --line-strong: rgba(23,23,23,.2);
  --dark: #171717;
  --gold: #d4a537;
  --green: #3f9a5c;
  --amber: #c98a2c;
  --red: #c0554a;
  --gray: #b3b3b3;
  --ease: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; }
body {
  font-family: "Helvetica Now", Arial, sans-serif;
  background: var(--bg); color: var(--ink); margin: 0;
  -webkit-font-smoothing: antialiased;
}

header.site { display: flex; align-items: center; gap: 12px; padding: 24px 28px 8px; }
header.site .logo { height: 24px; width: auto; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px 60px; }
.wrap-narrow { max-width: 560px; margin: 0 auto; padding: 0 28px 60px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
h1 { font-size: 20px; font-weight: 500; margin: 8px 0 2px; }
p.sub { color: var(--dim); margin: 0; font-size: 14px; }

.btn {
  display: inline-block; padding: 11px 18px; font-size: 14px; font-weight: 500;
  background: var(--dark); color: #fff; border: none; border-radius: 9px;
  text-decoration: none; cursor: pointer; font-family: inherit;
  transition: background .2s var(--ease);
}
.btn:hover { background: #2a2a2a; }
.btn.secondary { background: transparent; color: var(--dim); border: 1px solid var(--line-strong); }
.btn.secondary:hover { color: var(--ink); background: #fff; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--line-strong); }
.btn.danger:hover { background: #fbebe9; }
.btn.danger-solid { background: var(--red); color: #fff; }
.btn.danger-solid:hover { background: #a8493f; }
.confirm-message { font-size: 14px; color: var(--ink); line-height: 1.5; margin: 0 0 20px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--dim); margin-bottom: 14px; }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; }

.gantt {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 24px 8px; overflow-x: auto;
}
.gantt-inner { min-width: 720px; }

/* CSS Grid, not percentages matched by hand across sibling elements - the
   label column and the chart column are defined ONCE here and every row
   (including the month-axis header) shares the exact same column widths,
   so a bar's left/width percentage always means the same pixel position
   as the today-line and month ticks above it. Two independently-computed
   percentage bases (one for the full row, one for just the track div)
   is what caused bars to render offset from where the axis said they were. */
.gantt-grid { display: grid; grid-template-columns: 220px 1fr; }

.month-axis-label { border-bottom: 1px solid var(--line); }
.month-axis { position: relative; height: 22px; border-bottom: 1px solid var(--line); }
.month-axis .tick { position: absolute; top: 0; font-size: 11px; color: #a0a0a0; border-left: 1px solid var(--line); padding-left: 5px; height: 100%; }

.today-line {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--gold); z-index: 2;
}
.today-line.with-label::before {
  content: "Today"; position: absolute; top: -18px; left: 4px; font-size: 10.5px;
  color: var(--gold); font-weight: 500; white-space: nowrap;
}

.row-label {
  padding: 14px 14px 14px 0; border-bottom: 1px solid var(--line);
  min-height: 92px; display: flex; flex-direction: column; justify-content: center;
  align-items: flex-start;
}
.row-label-top { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px; }
.row-label .pname { font-size: 13.5px; font-weight: 500; }
.row-label .ptags { font-size: 11px; color: var(--dim); margin-top: 2px; }

/* Deliberate gap + divider between edit and delete, not just a couple of
   px apart - that's what made a mis-tap on delete easy in the first place.
   Delete also stays visually muted (plain gray) until actually pressed,
   so only the deliberate act of clicking it turns it red. */
.row-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.row-actions .divider { width: 1px; height: 16px; background: var(--line); }
.row-actions form { margin: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; color: var(--dim);
  background: none; border: none; cursor: pointer; padding: 0; text-decoration: none;
}
.icon-btn:hover { background: #f0f0ee; color: var(--ink); }
.icon-btn.delete:active, .icon-btn.delete:focus-visible { background: #fbebe9; color: var(--red); }

/* no fixed height: grid stretches this to match row-label's height, so
   bar/marker top:50% centers against whatever that turns out to be -
   keeps label and bar visually one row regardless of label content length */
.track { position: relative; border-bottom: 1px solid var(--line); }
.gantt-grid > *:nth-last-child(-n+2) { border-bottom: none; }
.bar {
  position: absolute; top: calc(50% - 5px); height: 10px; border-radius: 6px; background: var(--gray); opacity: .85;
}
.bar.urgency-on_track { background: var(--green); }
.bar.urgency-soon { background: var(--amber); }
.bar.urgency-order_urgent { background: var(--red); }
.bar.urgency-overdue { background: var(--red); opacity: .5; }
.bar.urgency-done { background: var(--gray); }

.marker {
  position: absolute; top: calc(50% - 5px); width: 10px; height: 10px; transform: translateX(-50%) rotate(45deg);
  border: 2px solid var(--panel); z-index: 1;
}
.marker.design { background: #171717; }
.marker.order { background: var(--gold); }

/* Always-visible date labels, not just hover tooltips (tooltips don't
   exist on touch devices at all, and were the whole complaint) - staggered
   above/below the bar so they never collide even when design-by and
   order-by land close together in pixel terms on a zoomed-out chart. */
.marker-date {
  position: absolute; transform: translateX(-50%); font-size: 9.5px; font-weight: 500;
  white-space: nowrap; letter-spacing: .01em;
}
.marker-date.design-date { top: calc(50% - 24px); color: #171717; }
.marker-date.order-date { top: calc(50% + 12px); color: var(--gold); }

.pills { display: flex; gap: 5px; margin-top: 4px; }
.status-pill {
  display: inline-block; font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  background: #f0f0ee; color: var(--dim); white-space: nowrap;
}
.stock-flag { color: var(--red); font-weight: 500; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 100px 20px; color: var(--dim);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.empty .empty-icon { opacity: .55; margin-bottom: 18px; }
.empty h2 { font-size: 16px; font-weight: 500; color: var(--ink); margin: 0 0 6px; }
.empty p { font-size: 13.5px; margin: 0 0 20px; max-width: 320px; }

/* form page */
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; max-width: 480px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field input[type=text], .field input[type=date], .field textarea, .field select {
  width: 100%; padding: 11px 12px; font-size: 14px; font-family: inherit;
  border: 1.5px solid var(--line-strong); border-radius: 8px; color: var(--ink);
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--gold); outline: none; }
.checkgroup { display: flex; gap: 16px; }
.checkgroup label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 400; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
a.back { display: inline-block; margin-top: 20px; color: var(--dim); text-decoration: none; font-size: 14px; }
a.back:hover { color: var(--ink); }

/* ---- modal (native <dialog>, gives backdrop + Esc-to-close for free) ---- */
dialog {
  border: none; border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 40px));
  background: var(--panel); box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
dialog::backdrop { background: rgba(23,23,23,.4); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 0; }
.modal-header h2 { font-size: 16.5px; font-weight: 500; margin: 0; }
.modal-close {
  width: 28px; height: 28px; border-radius: 7px; border: none; background: none;
  color: var(--dim); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #f0f0ee; color: var(--ink); }
.modal-body { padding: 18px 24px 24px; }
.modal-error { background: #fbebe9; color: var(--red); font-size: 13px; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; display: none; }

/* floating label - CSS-only via :placeholder-shown, ported from the
   Quill Project Work pattern (dark theme there, adapted to this app's
   light one). placeholder=" " (a single space) is required: it's what
   makes :placeholder-shown/:not(:placeholder-shown) fire without any JS. */
.field-float { position: relative; margin-bottom: 20px; }
.field-float input[type=text], .field-float input[type=password] {
  width: 100%; height: 50px; box-sizing: border-box; border: 1px solid var(--line-strong);
  border-radius: 8px; background: transparent; color: var(--ink); padding: 18px 14px 4px;
  font-size: 14.5px; font-family: inherit; transition: border-color .2s var(--ease); outline: none;
}
.field-float textarea {
  width: 100%; min-height: 84px; box-sizing: border-box; border: 1px solid var(--line-strong);
  border-radius: 8px; background: transparent; color: var(--ink); padding: 22px 14px 8px;
  font-size: 14.5px; font-family: inherit; transition: border-color .2s var(--ease); outline: none; resize: vertical;
}
.field-float input:focus, .field-float textarea:focus { border-color: var(--gold); }
.field-float label {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 13.5px; color: var(--dim); pointer-events: none; background: var(--panel);
  padding: 0 5px; transition: top .15s ease, font-size .15s ease, color .15s ease;
}
.field-float textarea ~ label { top: 14px; transform: none; }
.field-float input:focus ~ label, .field-float input:not(:placeholder-shown) ~ label,
.field-float textarea:focus ~ label, .field-float textarea:not(:placeholder-shown) ~ label {
  top: 0; transform: translateY(-50%); font-size: 11px; letter-spacing: .02em; color: var(--gold);
}
.field-float input:not(:focus):not(:placeholder-shown) ~ label,
.field-float textarea:not(:focus):not(:placeholder-shown) ~ label { color: var(--dim); }

/* static-label fields (date/select don't suit the floating trick well) */
.field-static { margin-bottom: 20px; }
.field-static > label { display: block; font-size: 12px; font-weight: 500; color: var(--dim); margin-bottom: 6px; }
.field-static input[type=date], .field-static select {
  width: 100%; height: 44px; box-sizing: border-box; padding: 0 12px; font-size: 14.5px;
  font-family: inherit; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink);
}
.field-static input:focus, .field-static select:focus { border-color: var(--gold); outline: none; }

/* ---- login page ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 36px 32px; text-align: center;
}
.login-card h1 { font-size: 19px; font-weight: 500; margin: 0 0 2px; }
.login-card .sub { margin: 0 0 24px; }
.login-card form { text-align: left; }
.login-card .btn { margin-top: 4px; }

/* user menu in header */
.header-user {
  margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13.5px; color: var(--dim);
}
.header-user form { margin: 0; }
.header-user button {
  background: none; border: none; color: var(--dim); font-size: 13px; cursor: pointer;
  padding: 0; font-family: inherit; text-decoration: underline;
}
.header-user button:hover { color: var(--ink); }
