/* ITFlow Billing
 *
 * A technician's instrument, not a landing page: cool blueprint paper, hairline
 * rules, and every figure set in tabular monospace so columns of hours line up
 * and can be scanned down.
 *
 * No webfonts, no CDN -- this runs on an internal box that may have no egress.
 */

:root {
  --paper:      #EDF1F3;
  --card:       #FFFFFF;
  --ink:        #14232E;
  --ink-soft:   #5B7182;
  --ink-faint:  #8FA3AF;
  --rule:       #CBD8DF;
  --rule-soft:  #E1E9ED;

  --covered:    #0F6E62;  /* hours inside the block */
  --over:       #B07D18;  /* hours past it */
  --accent:     #1D5E8C;
  --bad:        #9B2C3F;

  --font-ui:   system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --r: 3px;
  --gap: 1.25rem;
}

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

body {
  margin: 0;
  font: 15px/1.55 var(--font-ui);
  color: var(--ink);
  background-color: var(--paper);
  /* Faint engineering grid. Two hairlines, 24px pitch. */
  background-image:
    linear-gradient(to right,  rgba(20,35,46,.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20,35,46,.035) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
}

.shell--center { display: grid; place-items: center; min-height: 100vh; padding: 2rem 1rem; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { text-align: right; }
.nowrap { white-space: nowrap; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}
.topbar__brand { display: flex; align-items: center; gap: .6rem; letter-spacing: -.01em; }
/* Half teal, half amber: the covered/overage split the whole app turns on. */
.topbar__mark {
  width: 12px; height: 12px; border-radius: 2px;
  background: linear-gradient(105deg, var(--covered) 0 50%, var(--over) 50% 100%);
}
.topbar__nav { display: flex; align-items: center; gap: 1.1rem; font-size: .875rem; }
.topbar__link { color: var(--ink-soft); text-decoration: none; }
.topbar__link:hover { color: var(--ink); }
.topbar__link.is-active { color: var(--ink); font-weight: 600; }
.topbar__user {
  color: var(--ink-faint); font-family: var(--font-mono); font-size: .8125rem;
  padding-left: 1.1rem; border-left: 1px solid var(--rule);
}

.page { max-width: 78rem; margin: 0 auto; padding: var(--gap) 1.5rem 4rem; }

/* ---------- type ---------- */
.eyebrow {
  margin: 0 0 .35rem; font-family: var(--font-mono); font-size: .6875rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint);
}
h1 { margin: 0 0 .4rem; font-size: 1.55rem; letter-spacing: -.02em; font-weight: 620; }
.lede { margin: 0; color: var(--ink-soft); font-size: .9375rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 1.25rem;
  margin-bottom: var(--gap);
}
.panel__title {
  margin: 0 0 .9rem; font-size: .8125rem; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-soft);
  display: flex; align-items: center; gap: .5rem;
}
.panel__count {
  font-family: var(--font-mono); font-size: .75rem; letter-spacing: 0;
  color: var(--ink-faint); background: var(--paper);
  border: 1px solid var(--rule-soft); border-radius: 99px; padding: 0 .45rem;
}
.panel__lede { margin: -.4rem 0 1rem; color: var(--ink-soft); font-size: .8125rem; max-width: 60ch; }

/* ---------- readout: the headline numbers ---------- */
.readout {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r);
  margin-bottom: var(--gap);
}
.readout__cell { padding: 1rem 1.25rem; border-left: 1px solid var(--rule-soft); }
.readout__cell:first-child { border-left: 0; }
.readout__cell--accent { background: linear-gradient(to bottom, rgba(15,110,98,.05), transparent); }
.readout__label {
  display: block; font-family: var(--font-mono); font-size: .6875rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .3rem;
}
.readout__value {
  display: block; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em;
}
.readout__value small { font-size: .875rem; font-weight: 400; color: var(--ink-faint); }
.readout__value--none { color: var(--ink-faint); font-weight: 400; }
.readout__sub {
  display: block; margin-top: .2rem; font-size: .6875rem; color: var(--ink-faint);
  line-height: 1.35;
}
.readout__cell--accent .readout__value { color: var(--covered); }
/* Money out, mirroring the overage amber used everywhere else for cost. */
.readout__cell--cost { background: linear-gradient(to bottom, rgba(176,125,24,.06), transparent); }
.readout__cell--cost .readout__value { color: var(--over); }
.neg { color: var(--bad); }
tfoot td {
  border-top: 1px solid var(--rule); padding-top: .6rem;
  font-weight: 600; color: var(--ink);
}

/* ---------- signature: block-hour burn gauge ---------- */
.client { padding: .75rem 0; border-bottom: 1px solid var(--rule-soft); }
.client:last-child { border-bottom: 0; }
.client__row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.client__name { font-weight: 550; text-decoration: none; color: var(--ink); }
.client__name:hover { color: var(--accent); }
.client__amount { font-weight: 600; }
.client__meta { margin: .3rem 0 0; font-size: .75rem; color: var(--ink-faint); }

.gauge { margin-top: .5rem; }
.gauge__track {
  position: relative; display: flex; height: 9px;
  background: var(--rule-soft); border-radius: 2px; overflow: hidden;
}
.gauge__fill { background: var(--covered); }
.gauge__over {
  /* Hatched, so overage reads as exceptional even in grayscale or print. */
  background: repeating-linear-gradient(
    135deg, var(--over) 0 4px, color-mix(in srgb, var(--over) 72%, #fff) 4px 8px);
}
.gauge__fill, .gauge__over { transition: width .3s ease; }
/* The boundary of what was actually purchased. */
.gauge__mark {
  position: absolute; top: -2px; bottom: -2px; width: 1px;
  background: var(--ink); opacity: .55;
}
.gauge__legend {
  margin: .35rem 0 0; font-size: .75rem; color: var(--ink-soft);
  display: flex; align-items: center; gap: .5rem;
}

/* ---------- tags ---------- */
.tag {
  display: inline-block; font-family: var(--font-mono); font-size: .625rem;
  letter-spacing: .05em; text-transform: uppercase;
  padding: .1rem .35rem; border-radius: 2px; border: 1px solid;
  vertical-align: middle;
}
.tag--ok   { color: var(--covered); border-color: color-mix(in srgb, var(--covered) 35%, #fff); }
.tag--over { color: var(--over);    border-color: color-mix(in srgb, var(--over) 40%, #fff);
             background: color-mix(in srgb, var(--over) 8%, #fff); }
.tag--ah   { color: var(--over);    border-color: color-mix(in srgb, var(--over) 35%, #fff); }
.tag--os   { color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 30%, #fff); }

/* ---------- layout ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.cols > .panel { margin-bottom: 0; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  text-align: left; font-family: var(--font-mono); font-size: .6875rem; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint);
  padding: 0 .6rem .5rem; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { padding: .5rem .6rem; border-bottom: 1px solid var(--rule-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.table--dense td { padding: .35rem .6rem; font-size: .8125rem; }
.row--muted td { color: var(--ink-faint); }
.subject {
  display: inline-block; max-width: 24rem; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  margin-left: .4rem; color: var(--ink-soft);
}

/* Ticket deep link. Underline only on hover -- in a dense table, a column of
   permanently underlined refs turns into visual noise. */
.ticket-link {
  color: var(--accent); text-decoration: none; white-space: nowrap;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 35%, transparent);
}
.ticket-link:hover { border-bottom-style: solid; }
.ticket-link__out {
  display: inline-block; margin-left: .15em; font-size: .7em;
  opacity: .5; vertical-align: super;
}
.ticket-link:hover .ticket-link__out { opacity: 1; }

/* Visible to screen readers only. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.basis { font-size: .75rem; color: var(--ink-faint); }
.score {
  display: inline-block; min-width: 1.4rem; text-align: center;
  background: var(--paper); border: 1px solid var(--rule-soft);
  border-radius: 2px; font-size: .75rem;
}
.empty__cell { color: var(--ink-faint); font-size: .8125rem; padding: 1rem .6rem; }

/* ---------- forms ---------- */
.filters, .form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 1rem; margin-bottom: var(--gap);
}
.form { flex-direction: column; align-items: stretch; }
.form--inline { flex-direction: row; align-items: flex-end; margin-top: 1rem;
                padding-top: 1rem; border-top: 1px solid var(--rule); }
.form__row { display: flex; gap: .75rem; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field--grow   { flex: 1 1 12rem; }
.field--narrow { flex: 0 0 7.5rem; }
.field__label {
  font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft);
}
.field__hint { font-size: .75rem; color: var(--ink-faint); }

.input {
  width: 100%; padding: .45rem .6rem; font: inherit; font-size: .875rem;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--r);
}
.input:focus { border-color: var(--accent); outline: none;
               box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.input--code { letter-spacing: .3em; font-size: 1.1rem; }

.btn {
  padding: .5rem 1rem; font: inherit; font-size: .875rem; font-weight: 550;
  color: #fff; background: var(--ink); border: 1px solid var(--ink);
  border-radius: var(--r); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #1D3242; }
.btn--ghost { color: var(--ink-soft); background: transparent; border-color: var(--rule);
              text-decoration: none; display: inline-block; }
.btn--ghost:hover { background: var(--paper); color: var(--ink); }
.linkbtn {
  font: inherit; font-size: .75rem; color: var(--ink-faint);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
}
.linkbtn:hover { color: var(--bad); }

/* ---------- messages ---------- */
.alert {
  padding: .7rem .9rem; border-radius: var(--r); font-size: .875rem;
  border: 1px solid; margin-bottom: var(--gap);
}
.alert--bad  { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, #fff);
               background: color-mix(in srgb, var(--bad) 5%, #fff); }
.alert--good { color: var(--covered); border-color: color-mix(in srgb, var(--covered) 30%, #fff);
               background: color-mix(in srgb, var(--covered) 5%, #fff); }
/* Not a failure -- a consequence the admin should know about before it shows on an invoice. */
.alert--warn { color: var(--ink); border-color: color-mix(in srgb, var(--over) 40%, #fff);
               background: color-mix(in srgb, var(--over) 7%, #fff);
               margin-top: 1rem; margin-bottom: 0; line-height: 1.5; }
.alert--warn strong { color: var(--over); }

/* ---------- admin ---------- */
.form__actions { margin-top: 1rem; display: flex; gap: .75rem; }
.input.num { text-align: right; }

.daypick { border: 0; padding: 0; margin: 1rem 0 0; }
.daypick legend { padding: 0; margin-bottom: .4rem; }
.daypick__row { display: flex; flex-wrap: wrap; gap: .4rem; }
.daypick__day { position: relative; }
.daypick__day input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.daypick__day span {
  display: block; min-width: 3.2rem; text-align: center;
  padding: .35rem .5rem; font-family: var(--font-mono); font-size: .75rem;
  color: var(--ink-faint); background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--r);
  transition: background .12s ease, color .12s ease;
}
.daypick__day input:checked + span {
  color: #fff; background: var(--ink); border-color: var(--ink);
}
.daypick__day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-soft);
         background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); }
.empty__hint { font-size: .8125rem; color: var(--ink-faint); max-width: 40ch; margin: .4rem auto 0; }

/* ---------- setup / login ---------- */
.setup { max-width: 44rem; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
.setup__head { margin-bottom: var(--gap); }
.login { width: 100%; max-width: 24rem; }
.login__head { margin-bottom: var(--gap); }
.login__alt { margin: 1rem 0 0; text-align: center; font-size: .8125rem; }
.login__alt a { color: var(--ink-faint); }
.login__alt a:hover { color: var(--accent); }

.cmd {
  font-family: var(--font-mono); font-size: .8125rem; line-height: 1.5;
  background: var(--ink); color: #D9E4EA;
  padding: .75rem .9rem; border-radius: var(--r); overflow-x: auto;
  white-space: pre-wrap; word-break: break-all;
}
.note { margin-top: 1rem; font-size: .8125rem; color: var(--ink-soft);
        border-top: 1px solid var(--rule-soft); padding-top: .75rem; }
.note summary { cursor: pointer; color: var(--accent); }
.note > *:not(summary) { margin: .6rem 0; }
.note code { font-family: var(--font-mono); background: var(--paper);
             padding: .1em .3em; border-radius: 2px; }

.checks { list-style: none; margin: 0 0 var(--gap); padding: 0;
          border: 1px solid var(--rule); border-radius: var(--r); background: var(--card); }
.checks__item { padding: .55rem .9rem .55rem 2.1rem; font-size: .8125rem;
                border-bottom: 1px solid var(--rule-soft); position: relative; }
.checks__item:last-child { border-bottom: 0; }
.checks__item::before {
  position: absolute; left: .8rem; font-family: var(--font-mono); font-weight: 700;
}
.checks__item--ok::before   { content: "\2713"; color: var(--covered); }
.checks__item--warn::before { content: "!"; color: var(--over); }
.checks__item--warn { background: color-mix(in srgb, var(--over) 5%, #fff); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .readout { grid-template-columns: repeat(2, 1fr); }
  .readout__cell:nth-child(3) { border-left: 0; }
  .readout__cell:nth-child(n+3) { border-top: 1px solid var(--rule-soft); }
}
@media (max-width: 560px) {
  .readout { grid-template-columns: 1fr; }
  .readout__cell { border-left: 0; border-top: 1px solid var(--rule-soft); }
  .readout__cell:first-child { border-top: 0; }
  .field--narrow, .field--grow { flex: 1 1 100%; }
  .page { padding: 1rem .85rem 3rem; }
}

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