/* Utilities site styles. Plain CSS, no frameworks, no outside files.
   The statement sheet at the bottom keeps the old PDF's look and is what prints. */

:root {
  --ink: #1f2933;
  --muted: #52606d;
  --line: #d9dee3;
  --paper: #ffffff;
  --page-bg: #f4f6f8;
  --head-bg: #f0f3f6;
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --accent-pale: #eef2ff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page-bg);
}

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

h1 { font-size: 1.6rem; margin: 0 0 16px; line-height: 1.25; }
h2 { font-size: 1.3rem; margin: 28px 0 12px; line-height: 1.3; }
h3 { font-size: 1.1rem; margin: 20px 0 8px; }
p { margin: 0 0 12px; }

/* Header and navigation */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}
.site-name { font-weight: 700; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.site-property { color: var(--muted); }
/* The links wrap to a second line on a narrow screen instead of running off its edge. */
.site-nav { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.site-nav a { white-space: nowrap; }
.site-nav form { display: inline; margin: 0; }
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.page { max-width: 960px; margin: 0 auto; padding: 20px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card h1, .card h2 { margin-top: 0; }

/* Buttons: links and buttons look the same */
.button {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button-secondary { background: var(--paper); color: var(--accent); }
.button-secondary:hover { background: var(--accent-pale); color: var(--accent-dark); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 20px; }
.actions form { margin: 0; }

/* Tables that scroll sideways on narrow screens */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 16px; }
table.list { border-collapse: collapse; width: 100%; min-width: 480px; }
table.list th, table.list td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
table.list th { background: var(--head-bg); font-weight: 600; }
table.list td.number, table.list th.number { text-align: right; white-space: nowrap; }

.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.card-head h1 { margin: 0; }
.card-head .actions { margin: 0; justify-content: flex-end; }
.checklist .detail { display: inline; }
.mark { display: inline-block; min-width: 1.1em; font-weight: 700; }
.mark-yes { color: var(--ok); }
.mark-partial { color: var(--warn); }
.mark-no { color: var(--bad); }
.mark-none { color: var(--muted); }
.mark-link { color: var(--ink); text-decoration: none; }
.mark-link:hover { text-decoration: underline; }
.state { font-weight: 600; white-space: nowrap; }
.state-yes { color: var(--ok); }
.state-partial { color: var(--warn); }
.state-no { color: var(--bad); }
.state-none { color: var(--muted); }
.detail { color: var(--muted); font-size: 0.9rem; }
.status-line { margin-bottom: 4px; }
.warning { color: var(--bad); }

/* Messages after an action */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.message { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; border: 1px solid; }
.message-success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.message-error { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.message-warning, .message-info { background: #fffbeb; border-color: #fcd34d; color: #92400e; }

/* Forms */
select, input[type="text"], input[type="password"], input[type="date"], input[type="month"] {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid #9aa5b1;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  max-width: 100%;
}
select { min-width: 160px; }
.form-error { color: var(--bad); }

/* Upload page: one short row per kind of file; the details sit in tooltips (title attributes) */
.upload-table th, .upload-table td { white-space: nowrap; vertical-align: middle; padding: 6px 12px; }
.upload-table tr.highlighted td { background: var(--accent-pale); }
.upload-table .file-name {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.row-form { display: flex; flex-wrap: nowrap; gap: 6px 10px; align-items: center; margin: 0; }
.row-form input[type="file"] { font: inherit; width: 240px; }
.row-form input[type="text"], .row-form input[type="date"] { padding: 4px 8px; }
.row-form input[type="text"] { width: 11em; }
.tip { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.hidden-file { display: none; }
.delete-link { color: var(--bad); text-decoration: none; font-weight: 700; margin-left: 6px; }
.delete-link:hover { text-decoration: underline; }
.email-summary th { width: 9em; }
details { margin: 0 0 10px; }
details summary { cursor: pointer; }
details .row-form { flex-wrap: wrap; margin-top: 8px; }
table.list.price-list { min-width: 0; max-width: 480px; }
table.list.price-list td { padding: 4px 12px; }
.checklist a.state { text-decoration: underline; }

/* Documents page: the kept files and the form that adds one (labels left, fields right) */
.document-table td { vertical-align: top; }
.document-table td.document-note { white-space: normal; max-width: 28em; }
.form-grid { display: grid; grid-template-columns: max-content minmax(0, 32em); gap: 8px 12px; align-items: center; }
.form-grid label { font-weight: 600; }
.form-grid input[type="text"], .form-grid input[type="month"], .form-grid select, .form-grid textarea { width: 100%; padding: 4px 8px; font: inherit; }
.form-grid input[type="file"] { font: inherit; }

/* Reports page: one row per statement or report added by hand; its Open and PDF links sit side by side, an
   out-of-date statement ends its row with an orange warning sign (its tooltip says why), and a report added
   by hand with its delete link. The status is an icon whose tooltip says when and by whom (2026-11-20). */
.report-table td { white-space: nowrap; }
/* Every second month's rows on a very faint blue, the others white (Daniel, 2026-11-20) */
.report-table tr.report-month-band td { background: #f3f7fd; }
.report-table td.report-name { white-space: normal; min-width: 7em; max-width: 22em; }
/* A report's comments: a dark tooltip-like popup under its name, which has a dotted line under it (Daniel,
   2026-11-21). The page's script places it; position fixed keeps the table's scroll box from cutting it off. */
.report-name-text[aria-describedby] { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.report-comments-popup { position: fixed; z-index: 20; max-width: min(26em, calc(100vw - 16px)); padding: 6px 10px;
                         border-radius: 6px; background: var(--ink); color: #ffffff; font-size: 0.85rem; line-height: 1.4;
                         white-space: pre-line; box-shadow: 0 2px 8px rgba(31, 41, 51, 0.25); pointer-events: none; }
.report-comments-popup[hidden] { display: none; }
.report-table th.report-status, .report-table td.report-status { text-align: center; }
.status-icon { display: inline-flex; vertical-align: middle; cursor: help; }
.status-icon svg { display: block; }
.status-waiting_for_review { color: var(--warn); }
.status-reviewed { color: var(--accent); }
.status-sent, .status-emailed { color: var(--ok); }
.status-added, .status-building { color: var(--muted); }
.report-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.report-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.report-legend .status-icon { cursor: default; }
/* A built statement's status icon is also a list of statuses (Daniel, 2026-11-21): the list lies unseen over the
   icon and its small arrow, so a click or tap on the icon opens it. */
.status-form { display: inline; margin: 0; }
.status-picker { position: relative; display: inline-flex; align-items: center; gap: 1px; padding: 2px 3px;
                 border-radius: 4px; vertical-align: middle; }
.status-picker:hover { background: var(--accent-pale); }
.status-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.status-caret { display: block; color: var(--muted); }
.status-select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0;
                 cursor: pointer; font: inherit; }
/* A report added by hand ends its row with a pencil that opens the Edit dialog, then its delete cross (2026-11-21). */
.report-edit { display: inline-flex; vertical-align: middle; margin: 0; padding: 0; border: 0; background: none;
               color: var(--accent); cursor: pointer; }
.report-edit svg { display: block; }
.form-grid .form-grid-label { font-weight: 600; }
.status-confirm-list { margin: 0 0 14px; padding-left: 20px; }
.status-confirm-list li + li { margin-top: 4px; }
.report-dialog { border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; color: var(--ink);
                 width: min(44em, calc(100vw - 32px)); box-sizing: border-box; }
.report-dialog::backdrop { background: rgba(31, 41, 51, 0.45); }
.report-dialog h2 { margin: 0 0 14px; }
.report-dialog .actions { margin: 4px 0 0; }
.report-links a + a { margin-left: 14px; }
.report-table td.report-warning-cell { width: 1.5em; padding-left: 0; padding-right: 0; text-align: center; }
.report-warning { color: var(--warn); font-size: 1.25rem; line-height: 1; text-decoration: none; cursor: help; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Details report (statement_details_body.html): plain bordered tables inside the printable sheet */
.details-sheet h1.details-title { font-size: 1.3em; margin: 0 0 6px; }
.details-sheet h2 { font-size: 1.15em; margin: 20px 0 6px; }
.details-sheet h3 { font-size: 1em; margin: 14px 0 4px; }
.details-sheet p { margin: 4px 0; }
.details-sheet .details-warning { color: #b00020; font-weight: bold; }
table.details { border-collapse: collapse; width: 100%; margin: 6px 0 14px; }
table.details td.cell, table.details th.cell { border: 1px solid #999; padding: 2px 6px; text-align: left; vertical-align: top; }
table.details th.cell { background: #eee; }
table.details td.number, table.details th.number { text-align: right; white-space: nowrap; }
table.details td.total { font-weight: bold; }
table.details td.day-start { border-top: 2px solid #444; }

/* Sign-in page */
.login-card { max-width: 400px; margin: 40px auto; }
.login-card label { display: block; font-weight: 600; margin: 12px 0 4px; }
.login-card input[type="text"], .login-card input[type="password"] { width: 100%; }

@media (max-width: 640px) {
  .page { padding: 14px; }
  .card { padding: 14px; }
  .site-nav { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}

/* The statement sheet: laid out like the old PDFs. These rules are unchanged
   from the first version of the site, so the printed statement stays the same. */
.statement-sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 24px;
  overflow-x: auto;
  font-family: Calibri, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.2;
  color: #000;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.statement-sheet .address-block { margin-bottom: 18px; line-height: 1.35; }
table.statement { border-collapse: collapse; width: 100%; min-width: 560px; margin-bottom: 26px; }
table.statement th, table.statement td { border: 1px solid #000; padding: 2px 5px; }
table.statement td.number, table.statement th.number { text-align: right; }
table.statement td.middle { text-align: center; }
table.statement tr.heading td { background: #f2f2f2; }
table.statement tr.subtotal td { font-weight: bold; }
table.statement td.indent { padding-left: 22px; }
table.statement .not-in-total { color: #777; }
table.statement caption { font-weight: normal; border: 1px solid #000; border-bottom: none; padding: 2px; }
table.statement caption.usage { background: #4472c4; color: #fff; }
table.statement caption.gas { background: #f4b183; }
table.statement caption.electricity { background: #ffc000; }

/* Printing: only the statement sheet, on white, at the old size */
@page { margin: 15mm; }
@media print {
  body { background: #fff; }
  .site-header, .messages, .actions, .no-print { display: none !important; }
  .page { max-width: none; margin: 0; padding: 0; }
  .statement-sheet { border: none; padding: 0; overflow: visible; }
  table.statement { min-width: 0; }
}

/* Small buttons and the statement's editable correction lines */
.button-small { padding: 3px 10px; font-size: 0.85rem; }
.line-actions { font-size: 12px; margin-left: 8px; white-space: nowrap; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.line-actions form, .line-notes form { display: inline; margin: 0; }
.line-actions .link-button, .line-notes .link-button { font-size: inherit; }
.line-notes { margin: -16px 0 20px; font-size: 0.9rem; }
.line-notes .detail { margin-left: 14px; }
.edit-row input { font: inherit; font-size: 13px; padding: 2px 4px; border: 1px solid #9aa5b1; border-radius: 4px; max-width: 100%; }

/* General settings group on /settings/: the same table as the Advanced page's group, in the site's colours */
.general-settings-module { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.general-settings-module table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.general-settings-module col.setting-name-col { width: 45%; }
.general-settings-module caption {
  text-align: left;
  padding: 8px 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.general-settings-module th, .general-settings-module td {
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.95rem;
}
.general-settings-module th[scope="row"] { font-weight: 500; }
.general-settings-module tr.setting-topic th {
  padding: 6px 12px;
  background: var(--head-bg);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.general-settings-module .setting-links { margin-left: 10px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.general-settings-module .setting-name { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.general-settings-module .setting-control { display: inline; margin-right: 14px; white-space: nowrap; }
.general-settings-module .setting-unit { display: inline-block; min-width: 2.6em; font-weight: 600; color: var(--muted); }
.general-settings-module select, .general-settings-module input[type="text"] { padding: 2px 6px; min-width: 0; max-width: 100%; }
.general-settings-module .submit-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; background: var(--head-bg); }
.general-settings-module input[type="submit"] {
  padding: 6px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.general-settings-module .setting-hint { color: var(--muted); font-size: 0.85rem; }
