/* Kallias
   A bill is a document, so narrative text is set in a serif; interface chrome
   is sans; every figure is monospaced with tabular numerals so columns of
   hours and money line up and a running clock does not jitter. */

:root {
  /* Cloud Dancer, Pantone 11-4201, as the page.  One palette declared
     deliberately, so every browser shows the same thing instead of inventing
     a dark version of its own. */
  --paper:   #f0eee9;  /* Cloud Dancer: the page behind the cards */
  --surface: #fbfaf7;  /* cards, a half step lighter so they lift off it */
  --ink:     #191714;  /* warm near-black, never pure black */
  --muted:   #6e6862;
  --rule:    #dcd8d0;

  /* On an off-white ground a signal has to be darker than the text around it
     or it glows.  Bronze and oxblood both sit below the ink in value, so a
     running clock reads as emphasis rather than as a light switch, and both
     are colours you would find on a letterhead. */
  --running: #6f5a23;  /* live clock, Start */
  --flag:    #8f3322;  /* pending, blocked, needs review */

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  /* The wordmark only.  Times, letterspaced wide, for the epigraphic look. */
  --display: "Times New Roman", Times, serif;
}

/* Declared, so a browser stops guessing and stops inverting. */
:root { color-scheme: light; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}

.wrap { max-width: 860px; margin: 0 auto; padding: 24px 20px 64px; }

header.bar {
  display: flex; align-items: baseline; gap: 20px;
  border-bottom: 1px solid var(--rule); padding-bottom: 12px; margin-bottom: 28px;
}
header.bar h1 {
  font: 600 15px/1 var(--sans); letter-spacing: .08em;
  text-transform: uppercase; margin: 0;
}
header.bar nav { display: flex; gap: 16px; margin-left: auto; }
header.bar a { color: var(--muted); text-decoration: none; }
header.bar a:hover, header.bar a.on { color: var(--ink); }

.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 3px; padding: 24px; margin-bottom: 20px;
}

/* The clock, and what it is worth. The billable figure steps up every six
   minutes; showing the step honestly is the point of putting them together. */
.clock { display: flex; align-items: flex-end; gap: 32px; flex-wrap: wrap; }
.clock .elapsed {
  font: 300 54px/1 var(--mono); font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.clock.live .elapsed { color: var(--running); }
.worth { display: flex; gap: 28px; padding-bottom: 6px; }
.worth div { display: flex; flex-direction: column; gap: 3px; }
.worth .figure {
  font: 500 21px/1 var(--mono); font-variant-numeric: tabular-nums;
}
.label {
  font: 500 10px/1 var(--sans); letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.provenance { font: italic 13px/1.4 var(--serif); color: var(--muted); }

label { display: block; margin: 16px 0 5px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; font: 15px var(--sans);
  border: 1px solid var(--rule); border-radius: 2px; background: var(--surface);
  color: var(--ink);
}
textarea { font-family: var(--serif); min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--running); outline-offset: 1px; border-color: transparent;
}

.row { display: flex; gap: 16px; }
.row > * { flex: 1; }

.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
button {
  font: 500 14px var(--sans); padding: 9px 18px; cursor: pointer;
  border: 1px solid var(--ink); border-radius: 2px;
  background: var(--ink); color: var(--surface);
}
button.secondary { background: transparent; color: var(--ink); }
button.go { background: var(--running); border-color: var(--running); }
button:focus-visible { outline: 2px solid var(--running); outline-offset: 2px; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th {
  font: 500 10px var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); text-align: left; padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--rule);
}
td {
  padding: 11px 10px 11px 0; border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
td.narrative { font-family: var(--serif); }
td.num {
  font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right;
  white-space: nowrap;
}
/* A heading sits over its figures, not at the far side of the column. */
th.num { text-align: right; }
/* An identifier, a client or matter number: monospace, but a name, not a
   quantity, so it reads from the left like the text beside it. */
td.id { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.tag {
  font: 500 10px var(--sans); letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 7px; border: 1px solid currentColor; border-radius: 2px;
}
.tag.pending { color: var(--flag); }
.tag.forced  { color: var(--flag); }

.notice { padding: 12px 16px; border-left: 3px solid var(--flag);
          background: var(--surface); margin-bottom: 20px; }
.notice.ok { border-left-color: var(--running); }

.empty { color: var(--muted); font-family: var(--serif); font-style: italic;
         padding: 20px 0; }

@media (max-width: 640px) {
  .row { flex-direction: column; }
  .clock { gap: 18px; }
  .clock .elapsed { font-size: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------------
   The front page shell
   Navigation runs across the top.  The wordmark sits alone in a column of
   deliberate emptiness on the left, so nothing competes with the clock,
   which is the only thing on this screen that changes while you watch it.
   --------------------------------------------------------------------- */

.topbar {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.topbar nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  gap: 20px;
  align-items: center;
}
.topbar a { color: var(--muted); text-decoration: none; }
.topbar a:hover, .topbar a.on { color: var(--ink); }
.topbar form { margin-left: auto; }

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 32px;
}
.mark {
  font: 400 27px/1 var(--display);
  letter-spacing: 0.34em;
  color: var(--ink);
  padding-top: 2px;
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; gap: 16px; }
}

/* The clock sits at the top right of its card and is given the room. */
.clockcard { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.clockcard .onmatter { max-width: 420px; }
.clockcard .face { margin-left: auto; text-align: right; }
.clockcard .face .elapsed { font: 600 42px/1 var(--mono); font-variant-numeric: tabular-nums; }
.clockcard.live .face .elapsed { color: var(--running); }
.clockcard .worth { justify-content: flex-end; margin-top: 8px; }

/* Discard is reachable, not convenient.  Recorded time that disappears is
   what every other rule here exists to prevent. */
.lastresort { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 12px; }
.lastresort summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.lastresort p { color: var(--muted); font: italic 13px/1.4 var(--serif); }

/* The ledger.  Narrative edits in place, so the box has to look like text
   until you touch it. */
.ledger td.narrative { width: 55%; }
.ledger textarea.inline {
  width: 100%;
  min-height: 0;
  height: 3.1em;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
}
.ledger textarea.inline:hover { border-color: var(--rule); }
.ledger textarea.inline:focus { border-color: var(--running); background: var(--surface); }
.ledger .rowtools { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.ledger .rowtools a, .ledger .rowtools button { font-size: 12px; }
.ledger .rowtools button {
  padding: 3px 9px; background: transparent; color: var(--muted);
  border: 1px solid var(--rule);
}
.unwritten { color: var(--flag); font-weight: 600; }

/* Narrative history */
.version { border-left: 2px solid var(--rule); padding: 8px 0 8px 14px; margin: 14px 0; }
.version.current { border-left-color: var(--running); }
.version.gone { opacity: 0.55; }
.version .meta { font-size: 12px; color: var(--muted); }
.version .body { font-family: var(--serif); margin: 4px 0 8px; }

/* ---------------------------------------------------------------------
   The page, after the left column went away
   The wordmark floats in the empty space beside the clock rather than
   sitting in a bar of its own, and the ledger runs the full width.
   --------------------------------------------------------------------- */

.page { max-width: 1100px; margin: 0 auto; padding: 26px 20px 64px; }

.topline { display: flex; align-items: flex-start; gap: 24px; }
/* The same wordmark as the sign-in page, smaller: Times, letterspaced wide.
   Rob asked for Times New Roman on KALLIAS everywhere. */
.topline .mark {
  font: 400 22px/1 var(--display);
  letter-spacing: 0.34em;
  color: var(--muted);
  padding-top: 10px;
}

/* The clock is about a third of the width and holds nothing but the clock:
   time, what it is worth, the matter it is on, and Stop. */
.clockpanel { margin-left: auto; width: 34%; min-width: 270px; }
.clockpanel .elapsed {
  font: 600 38px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.clockpanel.live .elapsed { color: var(--running); }
.clockpanel .reading {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted); margin-top: 8px;
}
.clockpanel .reading .figure { font-family: var(--mono); color: var(--ink); }
.clockpanel .on {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule);
}
.clockpanel .on a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.clockpanel .on a:hover { border-bottom-color: var(--ink); }
.clockpanel button { width: 100%; margin-top: 16px; }
.clockpanel .lastresort { margin-top: 14px; }

@media (max-width: 820px) {
  .topline { flex-direction: column; }
  .clockpanel { width: 100%; margin-left: 0; }
}

td.when a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
td.when a:hover { border-bottom-color: var(--ink); }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.crumbs a { color: var(--muted); }

/* ---------------------------------------------------------------------
   Pass E: the firm above the wordmark, the play control, the popup
   --------------------------------------------------------------------- */

.firm {
  font: 600 12px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 4px;
}

/* A play glyph, not a button with a border round it. */
button.play {
  background: transparent;
  border: none;
  color: var(--running);
  font-size: 15px;
  padding: 2px 4px;
  line-height: 1;
}
button.play:disabled { color: var(--rule); }

/* Row controls read as text, because a row of buttons reads as a toolbar. */
button.rowlink {
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}
button.rowlink:hover { color: var(--flag); }

/* Descriptions are clamped to two lines; the popup is where they are read
   and written in full. */
.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

/* The running clock in the top bar of every other page. */
.topclock {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--running);
  text-decoration: none;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.topclock .matter {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.topbar nav .topclock + form { margin-left: 16px; }

dialog {
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  padding: 20px 22px;
  width: min(560px, 92vw);
  box-shadow: 0 16px 38px rgba(25, 23, 20, 0.18);
}
dialog::backdrop { background: rgba(25, 23, 20, 0.32); }
dialog textarea { min-height: 96px; }
.dialoghead {
  display: flex; align-items: baseline; gap: 12px;
  border-bottom: 1px solid var(--rule); padding-bottom: 8px; margin-bottom: 4px;
}
.dialoghead .label { margin-right: auto; }

/* The stop square. Same weight as the play glyph so a row does not jump when
   the clock moves to it. */
button.stopsquare {
  background: transparent;
  border: none;
  color: var(--flag);
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
}
.topclock .matter, .topclock .ticking { text-decoration: none; }
.topclock .ticking { border-bottom: 1px dotted var(--running); cursor: pointer; }
.topclock form { display: inline; }

/* Both cells are ways into the same popup, so both look touchable. */
.openpopup { cursor: pointer; }
.openpopup.hours { border-bottom: 1px dotted var(--rule); }
.openpopup.hours:hover { border-bottom-color: var(--ink); }

/* The clock flashing when it moves to another entry.  Without it a switch
   looks like a clock that was always running there, which is the one thing a
   timekeeper must never be unsure about. */
@keyframes clockswitch {
  0%   { background: #ece2c9; border-color: var(--running); }
  70%  { background: #ece2c9; border-color: var(--running); }
  100% { background: var(--surface); border-color: var(--rule); }
}
.clockpanel.switched { animation: clockswitch 1.6s ease-out 1; }

a#popupRef { text-decoration: none; border-bottom: 1px dotted var(--rule); }
a#popupRef:hover { border-bottom-color: var(--ink); }
a#openSegment { border-bottom: 1px dotted var(--rule); }

/* Add is a control, so it looks like one even though it is a link: it goes
   somewhere rather than doing something. */
a.addbtn {
  font: 500 13px var(--sans);
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  color: var(--surface);
  background: var(--ink);
  text-decoration: none;
}
a.addbtn:hover { background: var(--running); border-color: var(--running); }

/* The firm sits quietly above the wordmark. */
.firm { color: var(--muted); }

/* The way out to the manual tools: present, not advertised. */
.footnote { margin-top: 28px; font-size: 12px; }
.footnote a { color: var(--rule); text-decoration: none; border-bottom: 1px solid transparent; }
.footnote a:hover { color: var(--muted); border-bottom-color: var(--muted); }

/* Sign-in.  Kallias's own pages; the Klesterion mark sits bottom right,
   small and muted, never a link and never the heading. */
.signin .card { position: relative; padding-bottom: 40px; }
.signin .klesterion { position: absolute; right: 16px; bottom: 12px; height: 14px; color: var(--muted); opacity: .7; }
.signin .klesterion svg { height: 14px; width: auto; display: block; }
/* The key animation's stage (KLESTERION 58-A): the whole page, behind the
   card.  The kit paints its field into it; the key itself flies in the
   kit's own overlay above the page and comes down onto the mark. */
.wrap.signin { position: relative; z-index: 1; }
.key-stage { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 0; pointer-events: none; }
.signin .secret {
  font-family: var(--mono); font-size: 14px; letter-spacing: .08em; line-height: 1.6;
  user-select: all; -webkit-user-select: all; overflow-wrap: anywhere;
  background: #ffffff; color: #191714; border: 1px solid var(--rule);
  border-radius: 4px; padding: 8px 10px; margin: 4px 0 8px;
}
.signin .qr { margin: 14px 0; width: 220px; }
/* The QR is data read by a camera.  Opaque white field, black modules,
   and no dark-mode treatment of any kind may touch it. */
.signin .qr img {
  display: block; width: 220px; height: 220px; background: #ffffff; padding: 8px;
  border: 1px solid #dcd8d0; color-scheme: light only; forced-color-adjust: none;
  filter: none; mix-blend-mode: normal; opacity: 1; image-rendering: pixelated;
}
@media (prefers-color-scheme: dark) { .signin .qr img { filter: none; background: #ffffff; } }
