/* The stylesheet of the shell, the only one: a module carries no CSS of its own.
   Palette and rhythm come from the mail prototype of 2026-09-05; the fonts are the
   system ones, because the portal runs on the office network, with or without the
   internet. The dark theme follows the operating system. */

:root {
  --ground: #F1F4F3;
  --surface: #FBFCFC;
  --surface2: #E7EDEB;
  --raised: #FFFFFF;
  --ink: #131A19;
  --ink2: #4B5957;
  --ink3: #798785;
  --line: #D8E0DE;
  --line2: #C0CAC7;
  --accent: #1E5C58;
  --accent-ink: #12403D;
  --accent-soft: #DBEAE7;
  --on-accent: #FFFFFF;
  --certain: #1E5C58;
  --uncertain: #8A5E12;
  --new: #3B4E86;
  --neutral: #6C7775;
  --notice: #9A3131;
  --radius: 5px;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0E1312;
    --surface: #151B1A;
    --surface2: #1D2523;
    --raised: #1A2120;
    --ink: #E6EDEB;
    --ink2: #A2AFAC;
    --ink3: #7A8785;
    --line: #27302E;
    --line2: #38443F;
    --accent: #66B7AE;
    --accent-ink: #8FD0C8;
    --accent-soft: #15302D;
    --on-accent: #0E1312;
    --certain: #66B7AE;
    --uncertain: #CFA054;
    --new: #8FA0DC;
    --neutral: #8A9491;
    --notice: #E08A8A;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.sheet {
  max-width: 58rem;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

h1 { font-family: var(--serif); font-size: 1.6rem; font-weight: 500; letter-spacing: -.01em; margin: 0 0 1.5rem; }
h2 { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; }

a { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.warning { border: 1px solid var(--notice); border-radius: var(--radius); color: var(--notice); margin: 0 0 1.5rem; padding: .6rem .9rem; }

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

.login { display: grid; gap: .6rem; max-width: 20rem; }

label { font-size: .9rem; }

input, button, select {
  font: inherit;
  color: inherit;
  padding: .4rem .7rem;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
}

input[type=text], input[type=password] { min-width: 0; max-width: 100%; }

button { cursor: pointer; font-size: .9rem; white-space: nowrap; }
button:hover { border-color: var(--ink3); }
button[disabled] { opacity: .45; cursor: default; }

/* The main gesture of a form: the login, the confirmation of a proposal, the
   application of the approved ones. */
.login button,
form[data-action="ok"] button,
form[data-action="apply"] button,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.notice { color: var(--notice); margin: .5rem 0 0; }

.context { color: var(--ink2); font-size: .9rem; margin: 0 0 .75rem; }
.empty { color: var(--ink3); font-size: .9rem; padding: .75rem 0; }
.muted { color: var(--ink3); font-size: .85rem; }

[data-outcome] { color: var(--ink2); font-size: .85rem; margin-left: .5rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); font-weight: 600; }

/* A list of rows, the shape of every read-only module (mail-done, cases). */
table.list { border-top: 1px solid var(--line); }
table.list td { background: var(--surface); }

/* A pill: a short word of state, in capitals, with its own color. */
.pill {
  display: inline-block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 600;
  padding: .1rem .5rem;
  border-radius: 11px;
  border: 1px solid var(--line2);
  color: var(--ink2);
  white-space: nowrap;
}
.pill.state-certain { color: var(--certain); border-color: var(--certain); }
.pill.state-uncertain { color: var(--uncertain); border-color: var(--uncertain); }
.pill.state-new { color: var(--new); border-color: var(--new); }
.pill.state-active { color: var(--certain); border-color: var(--certain); }
.pill.state-dormant { color: var(--ink3); }
.pill.state-decided { color: var(--neutral); }
.pill.state-unrelated { color: var(--neutral); border-color: var(--neutral); }
.pill.kind-home { color: var(--certain); border-color: var(--certain); }
.pill.kind-reference { color: var(--neutral); border-color: var(--neutral); }

/* --- the top of the page and the tabs -------------------------------------- */

.masthead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: 0 0 1.25rem; }
.masthead h1 { margin: 0; }
.masthead .today { color: var(--ink3); font-size: .9rem; margin: .2rem 0 0; }
.brand { font-family: var(--serif); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: .85rem; color: var(--accent-ink); }
.page-title { margin: 0 0 1rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 0 0 1.5rem; overflow-x: auto; }
.tabs [role="tab"] {
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--ink2); font-size: .95rem; padding: .6rem .9rem; margin-bottom: -1px;
  text-decoration: none;
}
.tabs [role="tab"]:hover { color: var(--ink); border-color: transparent; }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
/* What waits for the person in a tab (card 238): «Da vedere 15». */
.tabs .count { display: inline-block; min-width: 1.4em; margin-left: .35rem; padding: 0 .4em; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: .78rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }

.screen-title { font-size: 1.25rem; margin: 0 0 .9rem; }
.part { margin: 0 0 1.5rem; }

/* A small word of state next to a proposal: in capitals, spaced, discreet. */
.tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink3); margin-left: .35rem; font-weight: 500; white-space: nowrap; }

button.quiet { background: none; border-color: transparent; color: var(--ink2); }
button.quiet:hover { border-color: var(--line2); }
summary.button { list-style: none; display: inline-block; cursor: pointer; font-size: .9rem; padding: .4rem .7rem; border: 1px solid var(--line2); border-radius: var(--radius); background: var(--surface); white-space: nowrap; }
summary.button::-webkit-details-marker { display: none; }

/* --- the mail: the queue, the new case, the done ----------------------------- */

.news { margin: 0 0 .25rem; color: var(--ink2); }
.summary { color: var(--ink2); font-size: .9rem; margin: 0 0 1rem; text-align: right; }
.group-heading { font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink3); font-weight: 600; margin: 1.5rem 0 .5rem; }

.queue, .done, .members { list-style: none; margin: 0; padding: 0; }
.queue { border-top: 1px solid var(--line); }
.queue > li, .done > li {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .9rem 1rem .9rem 1.25rem; box-shadow: inset 3px 0 0 var(--neutral);
}
.queue > li { display: flex; gap: 1rem; justify-content: space-between; align-items: center; }
.queue > li .body { min-width: 0; flex: 1 1 auto; }
.queue > li.state-certain { box-shadow: inset 3px 0 0 var(--certain); }
.queue > li.state-uncertain { box-shadow: inset 3px 0 0 var(--uncertain); }
.queue > li.state-new { box-shadow: inset 3px 0 0 var(--new); }
.queue > li.state-decided { opacity: .75; }

.subject { font-weight: 600; letter-spacing: -.005em; }
.meta { color: var(--ink3); font-size: .85rem; margin-top: .1rem; }
.proposal { margin: .45rem 0 0; }
.proposal strong { color: var(--accent-ink); font-weight: 600; border-bottom: 1px dotted var(--line2); }
/* The confidence of a proposal, a dot before it (card 249): green no doubt, yellow some
   doubt, red not recognised. Its words are in the `aria-label`, the colour is not alone. */
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .4rem; vertical-align: .05em; }
.dot-green { background: var(--certain); }
.dot-yellow { background: var(--uncertain); }
.dot-red { background: var(--notice); }
/* The type of a proposed entity — a `pratica`, a `fornitore` — next to its name (card 223). */
.entity-type { font-size: .82rem; color: var(--ink3); margin-left: .3rem; }
.why-line { color: var(--ink2); font-size: .88rem; margin: .25rem 0 0; }
.why-line details { display: inline; }
.why-line summary { display: inline; cursor: pointer; color: var(--ink3); text-decoration: underline dotted; margin-left: .4rem; }
.why-line ul { margin: .3rem 0; padding-left: 1.1rem; }

.gestures { display: flex; flex-wrap: wrap; gap: .4rem; align-items: flex-start; justify-content: flex-end; flex: 0 0 auto; max-width: 55%; }
.gestures form.first { order: -1; }
.gestures form { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.gestures [data-outcome] { flex-basis: 100%; margin: 0; text-align: right; }
/* «Altrove…» holds two forms (card 245): the cases that exist, and a new case below them. */
.elsewhere:has(> details[open]) { flex-basis: 100%; }
.gestures .elsewhere form { display: block; }
.new-case-choice { padding: 0 .75rem; text-align: left; }
.new-case-choice > details > summary { cursor: pointer; color: var(--accent-ink); margin: .2rem 0 .4rem; }
.new-case-choice .folder-field summary { cursor: pointer; color: var(--ink3); font-size: .85rem; margin: 0 0 .4rem; }
.choices { list-style: none; padding: .6rem .75rem; margin: .4rem 0; background: var(--surface2); border-radius: var(--radius); text-align: left; }
.choices-heading { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); font-weight: 600; margin-top: .4rem; }
.choice .why { font-size: .82rem; color: var(--ink3); margin: .1rem 0 .3rem; padding-left: 1.4rem; }

.new-case {
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--new), 0 1px 3px rgba(0,0,0,.05);
  padding: 1rem 1.25rem; margin: 0 0 1.25rem;
}
.new-case h3 { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; margin: 0 0 .3rem; }
.new-case form { margin: .8rem 0; }
.new-case .field, .new-case-choice .field { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin: 0 0 .5rem; }
.new-case .field > span, .new-case-choice .field > span { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); font-weight: 600; }
.new-case .field input[type=text], .new-case-choice .field input[type=text] { flex: 1 1 18rem; }
.new-case .folder-field summary { cursor: pointer; color: var(--ink3); font-size: .85rem; margin: 0 0 .4rem; }
.new-case .gestures { justify-content: flex-start; max-width: none; }
.members { border-top: 1px solid var(--line); }
.members li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.members li:last-child { border-bottom: 0; }
.members .meta { display: block; }

.apply-bar {
  position: sticky; bottom: 0; z-index: 1; margin: 1rem 0 0; padding: .75rem 0;
  background: linear-gradient(to bottom, transparent, var(--ground) 30%);
}
.apply-bar form { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }

.done { border-top: 1px solid var(--line); }
.done > li { box-shadow: inset 3px 0 0 var(--certain); }
.done > li.by-external { box-shadow: inset 3px 0 0 var(--neutral); }
/* A home the person corrected (card 238): before and after, and what was learned. */
.done > li.corrected { box-shadow: inset 3px 0 0 var(--uncertain); }
.correction { margin: .45rem 0 0; font-size: .9rem; color: var(--ink2); }
.correction .before { text-decoration: line-through; color: var(--ink3); }
.learned { margin: .5rem 0 0; padding: .5rem .75rem; background: var(--accent-soft); border-radius: var(--radius); font-size: .85rem; color: var(--accent-ink); }
.learned strong { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; margin-right: .4rem; }

table.cases { border-top: 0; }
table.cases td { background: var(--surface); padding: .7rem .75rem; vertical-align: middle; }
table.cases td.name { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
table.cases td.name .muted { font-family: var(--sans); font-weight: 400; margin-left: .4rem; }
table.cases .number { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 40rem) {
  .queue > li { flex-direction: column; align-items: stretch; }
  .gestures { justify-content: flex-start; max-width: none; }
  .gestures [data-outcome] { text-align: left; }
  .summary { text-align: left; }
  table.cases th:nth-child(4), table.cases td:nth-child(4) { display: none; }
}

/* --- the search of the mail page (card 189) --------------------------------- */

.mail-search { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .4rem; }
.mail-search input[type=text] { flex: 1 1 16rem; }
.mail-search-heading { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink3); font-weight: 600; margin: 1rem 0 .4rem; }

/* --- the credentials page -------------------------------------------------- */

.credentials td { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; }
.credentials form { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.credentials tr.state-missing td { box-shadow: inset 3px 0 0 var(--uncertain); }

/* --- the panes of a page (card 225) ------------------------------------------
   Generic: a module marks the root of its template with data-pane="side|main|detail"
   and the page that holds one is laid out in a grid — the side on the left, main and
   detail on the right, one under the other; a panel without a pane takes the whole
   width. No name of a module here, no key in the manifest of the page. Below 52rem,
   one column: the panels in the written order. */

.sheet:has([data-pane]) { max-width: 90rem; }

@media (min-width: 52rem) {
  .panes:has(> * > [data-pane]) {
    display: grid;
    grid-template-columns: minmax(13rem, 18rem) minmax(0, 1fr);
    column-gap: 1.25rem;
    align-items: start;
  }
  .panes:has(> * > [data-pane]) > * { grid-column: 1 / -1; min-width: 0; }
  .panes > :has(> [data-pane="side"]) {
    grid-column: 1; grid-row: span 2;
    position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto;
  }
  .panes > :has(> [data-pane="main"]),
  .panes > :has(> [data-pane="detail"]) { grid-column: 2; }
}

.tree { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.tree ul { list-style: none; margin: 0; padding-left: 1rem; }
.tree a { display: block; padding: .2rem .4rem; border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.tree a[aria-current="true"] { background: var(--accent-soft); font-weight: 600; }
.tree .branch { display: block; padding: .2rem .4rem; color: var(--ink3); }

.messages { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.messages li a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem 1rem; padding: .55rem .8rem;
                 border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.messages li a[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.messages .subject { font-weight: 500; overflow-wrap: anywhere; }
.messages .unseen .subject { font-weight: 700; }
.messages .when { color: var(--ink3); font-size: .85rem; white-space: nowrap; }
.messages .meta { color: var(--ink2); font-size: .85rem; grid-column: 1 / -1; }
.unknown { font-size: .8rem; color: var(--new); }
.messages .unknown { grid-column: 1 / -1; }
.pager { margin: .6rem 0 0; font-size: .9rem; }

.letter header { border-bottom: 1px solid var(--line); margin-bottom: .8rem; padding-bottom: .6rem; }
.letter .subject { font-family: var(--serif); font-size: 1.1rem; margin: 0 0 .3rem; }
.letter .meta { color: var(--ink2); font-size: .9rem; margin: 0; overflow-wrap: anywhere; }
.letter .body { white-space: pre-wrap; font-family: var(--sans); margin: 0; overflow-wrap: anywhere; }
.letter .attachments { font-size: .9rem; color: var(--ink2); }

/* The window (card 247): one module over the page, in a `<dialog>`. Closing it leaves the
   page under it as it was — the same tab, the same point of the list. */
dialog.window {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  max-height: 85vh;
  max-width: 52rem;
  overflow: auto;
  padding: 1.25rem;
  width: calc(100% - 2rem);
}
dialog.window::backdrop { background: rgb(0 0 0 / .35); }
dialog.window .window-close { float: right; }
a.read { font-size: .9rem; margin-left: .4rem; }
