/* Unified stylesheet of the web UI (issues #28, #39, #41).

The shared base applies to every page. The page blocks are scoped to a
page type, so a page keeps its own layout without leaking onto the
others. Page types:

- page-auth    the centered sign in and register cards (login, register)
- page-center  the centered confirmation (success)
- page-list    the list and dashboard pages (home, admin, admin/user,
               admin/group, group members, data source)
- page-form    the entity forms (user, group, data source)
- page-delete  the entity delete confirmations (user, group, data source)
- page-detail  the read-only user view

The signed-in pages use the layout of issue #41: a header row, a left
sidebar with the menu, and a client area with the breadcrumb bar and
the page content. The content fills the client area. The widths are
percent-based; no fixed pixel width caps the content. The page-auth
and page-center cards stay small and centered. On a narrow screen the
sidebar stacks above the client area.

The theme (issue #28) is applied by the head script of every page.
The script adds the theme name (light or dark) as a class of the html
element. The colors live in CSS variables: the light values sit on
:root, and the html.dark class overrides them. The color-scheme value
lets the native form controls follow the theme.
*/

/* Theme palettes (issue #28). The light values are the defaults. */
:root {
  color-scheme: light;
  --bg: #f4f4f7;
  --text: #1f2430;
  --card: #ffffff;
  --header-bg: #2563eb;
  --header-text: #ffffff;
  --sidebar-bg: #374151;
  --sidebar-text: #ffffff;
  --sidebar-item: rgba(255, 255, 255, 0.16);
  --sidebar-item-hover: rgba(255, 255, 255, 0.3);
  --crumb-bg: #e3e6ec;
  --border: #e3e6ec;
  --input-border: #c7ccd6;
  --muted: #5a6172;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-disabled: #9db8ec;
  --link: #2563eb;
  --accent-soft: #dbeafe;
  --accent-soft-2: #eff6ff;
  --field-bg: #ffffff;
  --field-disabled-bg: #eef0f4;
  --btn-secondary-bg: #e3e6ec;
  --danger-bg: #fee2e2;
  --danger-text: #dc2626;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-card: rgba(0, 0, 0, 0.12);
  --spinner-track: #c7ccd6;
  --on-accent: #ffffff;
  /* The dashboard chart marks (issue #100). */
  --chart-success: #16a34a;
  --chart-error: #dc2626;
  --chart-input: #2563eb;
  --chart-output: #d97706;
  --chart-cost: #9333ea;
}

/* The dark palette (issue #28). The head script adds the class. */
html.dark {
  color-scheme: dark;
  --bg: #0f172a;
  --text: #e2e8f0;
  --card: #1e293b;
  --header-bg: #1e3a8a;
  --header-text: #ffffff;
  --sidebar-bg: #111827;
  --sidebar-text: #ffffff;
  --sidebar-item: rgba(255, 255, 255, 0.16);
  --sidebar-item-hover: rgba(255, 255, 255, 0.3);
  --crumb-bg: #1e293b;
  --border: #334155;
  --input-border: #475569;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-disabled: #475569;
  --link: #93c5fd;
  --accent-soft: rgba(147, 197, 253, 0.18);
  --accent-soft-2: rgba(147, 197, 253, 0.08);
  --field-bg: #0f172a;
  --field-disabled-bg: #293548;
  --btn-secondary-bg: #334155;
  --danger-bg: rgba(248, 113, 113, 0.18);
  --danger-text: #f87171;
  --shadow: rgba(0, 0, 0, 0.5);
  --shadow-card: rgba(0, 0, 0, 0.5);
  /* The spinner track is white in the dark theme and gray in the
     light theme, per doc/spinner-options.html (issue #45). */
  --spinner-track: #ffffff;
  --on-accent: #ffffff;
  --chart-success: #4ade80;
  --chart-error: #f87171;
  --chart-input: #93c5fd;
  --chart-output: #fbbf24;
  --chart-cost: #c084fc;
}

* {
  box-sizing: border-box;
}

/* Base */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text);
}

h1 {
  font-size: 22px;
  margin: 0 0 16px;
}

/* Page content. It fills the client area of the signed-in pages
   (issue #41) and the body of the centered pages. */
main {
  width: 100%;
  margin: 16px 0 24px;
}

/* Header row */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 24px;
  font-size: 14px;
}

.site-name {
  color: inherit;
  text-decoration: none;
}

.role {
  margin-left: 8px;
  background: var(--accent-strong);
  border-radius: 10px;
  font-size: 12px;
  padding: 2px 10px;
}

.user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.user a {
  color: inherit;
  text-decoration: none;
}

.user a:hover {
  text-decoration: underline;
}

/* The logout button keeps its white face on the header in both
   themes (issue #28). */
.logout button {
  padding: 4px 12px;
  font-size: 13px;
  border: 1px solid #ffffff;
  border-radius: 4px;
  background: #ffffff;
  color: var(--accent-strong);
  cursor: pointer;
}

/* Shell of the signed-in pages (issue #41): the sidebar and the
   client area side by side, below the header. */
.shell {
  display: flex;
  flex: 1;
  align-items: stretch;
}

/* Left sidebar with the menu buttons. The background is a dark gray,
   darker than the client area (issue #41). */
.sidebar {
  flex: 0 0 14%;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 16px;
}

.sidebar .menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar .menu a {
  display: block;
  padding: 8px 12px;
  background: var(--sidebar-item);
  border-radius: 4px;
  color: var(--sidebar-text);
  font-size: 14px;
  text-decoration: none;
}

.sidebar .menu a:hover {
  background: var(--sidebar-item-hover);
}

/* The client area to the right of the sidebar. It holds the
   breadcrumb bar and the page content. */
.client {
  flex: 1;
  min-width: 0;
  padding: 16px 3% 32px;
}

/* Breadcrumb bar of the client area. It always shows, even without
   steps (issue #41). The min-height matches the height of one text
   line with the padding, so the bar keeps the same height when it is
   empty and the content below does not shift. */
.breadcrumb {
  min-height: 33px;
  line-height: 17px;
  padding: 8px 16px;
  background: var(--crumb-bg);
  font-size: 13px;
  border-radius: 4px;
}

.breadcrumb a {
  color: var(--link);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  color: var(--muted);
  margin: 0 8px;
}

/* Page head (list pages) */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-head h1 {
  margin: 0;
}

.page-head-actions {
  display: flex;
  gap: 8px;
}

.add {
  display: inline-block;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 4px;
  font-size: 14px;
  text-decoration: none;
}

/* The tags add form of the /data/tags page (issue #107) */
.add-form {
  display: flex;
  gap: 8px;
}

.add-form input[type="text"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
}

/* Table (list pages) */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 6px;
  box-shadow: 0 1px 4px var(--shadow);
  font-size: 14px;
  margin-top: 16px;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: none;
}

.actions {
  white-space: nowrap;
}

.btn {
  display: inline-block;
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.edit {
  background: var(--btn-secondary-bg);
  color: var(--text);
}

.delete {
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* The task actions (issue #69): the toggle and the run now forms
   sit on one line in the action cell. */
.actions form {
  display: inline-block;
  margin-right: 4px;
}

/* The Enable button of the task list (issues #69, #106). The accent
   face marks the positive action, like the Add link. */
.btn.enable {
  background: var(--accent);
  color: var(--on-accent);
}

/* The Disable and the Run now buttons of the task list (issues #69,
   #106). The secondary face matches the Edit button. */
.btn.disable,
.btn.run {
  background: var(--btn-secondary-bg);
  color: var(--text);
}

/* The Stop button of the task list (issue #106). The danger face
   marks the interruptive action, like the Delete button. */
.btn.stop {
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* The Call link of the report task rows (issue #163). The secondary
   face matches the Edit button. */
.btn.call {
  background: var(--btn-secondary-bg);
  color: var(--text);
}

/* The Confirm button of the user email row (issue #136). The accent
   face marks the positive action, like the Add link. */
.btn.confirm {
  background: var(--accent);
  color: var(--on-accent);
}

/* The confirmation mark of a confirmed user email (issue #136).
   The success green matches the chart success color. */
.email-confirmed {
  color: var(--chart-success);
  font-weight: 700;
}

/* Info block (detail and delete pages) */
.info {
  margin: 0 0 16px;
}

.info div {
  display: flex;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 14px;
}

.info dt {
  width: 70px;
  color: var(--muted);
}

.info dd {
  margin: 0;
}

/* Shared form bits */
.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

.buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* The Cancel link of a form button row (issue #47). It shares the
   box of the button it stands next to. The gray face matches the
   secondary button. */
a.cancel {
  display: inline-block;
  flex: 1;
  padding: 8px 0;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  background: var(--btn-secondary-bg);
  color: var(--text);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.error {
  color: var(--danger-text);
  font-size: 13px;
  margin: 12px 0 0;
}

/* Spinner of the data source scan block */
/* The global spinner (issue #43): a ring with one colored arc that
   rotates. The top border carries the color. */
@keyframes scan-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* page-auth: the centered sign in and register cards */
body.page-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

body.page-auth h1 {
  text-align: center;
}

body.page-auth form {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow-card);
  padding: 24px;
}

body.page-auth label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

body.page-auth input {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 14px;
  background: var(--field-bg);
  color: var(--text);
}

body.page-auth button {
  flex: 1;
  padding: 8px 0;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

body.page-auth .signin {
  background: var(--accent);
  color: var(--on-accent);
}

body.page-auth .register {
  background: var(--btn-secondary-bg);
  color: var(--text);
}

body.page-auth a.register {
  display: inline-block;
  flex: 1;
  padding: 8px 0;
  font-size: 14px;
  border-radius: 4px;
  text-align: center;
  text-decoration: none;
}

body.page-auth .error {
  text-align: center;
}

/* page-center: the centered confirmation */
body.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

body.page-center main {
  width: auto;
  margin: 0;
  text-align: center;
}

body.page-center p {
  font-size: 14px;
}

body.page-center .generated-value {
  font-family: ui-monospace, monospace;
  font-size: 16px;
  background: var(--field-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 8px 12px;
}

body.page-center a.go {
  display: inline-block;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 4px;
  font-size: 14px;
  text-decoration: none;
}

/* page-list: the list and dashboard pages */
body.page-list .modules {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

body.page-list .modules li {
  margin: 0 0 8px;
}

body.page-list .modules a {
  display: block;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 6px;
  box-shadow: 0 1px 4px var(--shadow);
  color: var(--link);
  font-size: 14px;
  text-decoration: none;
}

body.page-list .search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

body.page-list .search label {
  font-size: 13px;
  color: var(--muted);
}

body.page-list .search input {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 14px;
  background: var(--field-bg);
  color: var(--text);
}

body.page-list .search button {
  padding: 8px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

body.page-list .results {
  background: var(--accent-soft-2);
}

body.page-list .results td {
  border-bottom-color: var(--accent-soft);
}

body.page-list .btn.add {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* page-form and page-delete: the shared form card and fields */
body.page-form main form,
body.page-delete main form {
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 1px 4px var(--shadow);
  padding: 24px;
}

body.page-form main label,
body.page-delete main label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

body.page-form main input[type="text"],
body.page-form main input[type="password"],
body.page-form main textarea,
body.page-form main select,
body.page-delete main input[type="text"] {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  background: var(--field-bg);
  color: var(--text);
}

/* The fixed height keeps every text field and the row buttons at
   one height, so the Add buttons align with their input (issue #45). */
body.page-form main input[type="text"],
body.page-form main input[type="password"],
body.page-delete main input[type="text"] {
  height: 38px;
}

body.page-form main button,
body.page-delete main button {
  flex: 1;
  padding: 8px 0;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* page-form specifics */
body.page-form main input:disabled,
body.page-form main select:disabled {
  background: var(--field-disabled-bg);
  color: var(--muted);
}

body.page-form fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 12px;
  padding: 12px;
}

body.page-form legend {
  font-size: 13px;
  padding: 0 6px;
}

body.page-form .check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

body.page-form .check input {
  margin: 0;
}

body.page-form .save {
  background: var(--accent);
  color: var(--on-accent);
}

/* The Send code button of the email confirmation page (issue #136).
   The gray face matches the secondary button of the Cancel link. */
body.page-form .send-code {
  background: var(--btn-secondary-bg);
  color: var(--text);
}

/* The derived fields are plain labels with their text value
   (issue #46), like the Site URLs block. An empty value collapses. */
body.page-form p.derived-text {
  margin: 0 0 12px;
  color: var(--muted);
}

/* Languages and Types share one line (issue #46): each half takes
   half of the row width. */
body.page-form .derived-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

body.page-form .derived-half {
  flex: 1;
  min-width: 0;
}

body.page-form .derived-half p.derived-text {
  margin-bottom: 0;
}

/* The Name field and the Type label share one line (issue #46):
   the name takes the free width, the type sits on the right. The
   label is present on the edit page only. */
body.page-form .name-type-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 12px;
}

body.page-form .name-group {
  flex: 1;
  min-width: 0;
}

body.page-form .name-group input[type="text"] {
  margin-bottom: 0;
}

body.page-form .type-group {
  flex: 0 0 auto;
}

body.page-form .type-group p.derived-text {
  margin-bottom: 0;
}

/* The shared height of the scan row controls and the spinner
   (issues #43, #44): the controls and the spinner keep one height,
   so the row never shifts on the spinner toggle. */
body.page-form {
  --scan-row-height: 38px;
}

body.page-form .scan-all-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

body.page-form #scan-all-button {
  /* The shared form button rule gives flex: 1 (issue #40). The Scan
     All button keeps its natural size (issue #44). */
  flex: 0 0 auto;
  height: var(--scan-row-height);
  padding: 8px 16px;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

body.page-form #scan-all-button:disabled {
  background: var(--accent-disabled);
  cursor: default;
}

/* The track and the arc colors follow the theme variables (issue
   #28), so the spinner keeps its contrast in both themes. */
body.page-form .scan-spinner {
  display: inline-block;
  align-self: center;
  width: var(--scan-row-height);
  height: var(--scan-row-height);
  border: 3px solid var(--spinner-track);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: scan-rotate 0.9s linear infinite;
}

/* The idle spinner keeps its box: the row and the panel elements
   must not move when the spinner appears (issue #43). */
body.page-form .scan-spinner.idle {
  visibility: hidden;
}

body.page-form .scan-message {
  font-size: 13px;
  margin: 8px 0 0;
  color: var(--muted);
}

body.page-form .scan-message.error {
  color: var(--danger-text);
}

/* The site URL list and the feed blocks (issue #43). */

body.page-form #site-urls .site-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

body.page-form .site-url-text {
  flex: 1;
  word-break: break-all;
}

body.page-form .site-url-row .scan-site-url {
  /* The shared form button rule gives flex: 1 (issue #40). The accent
     background keeps the text readable in both themes (issue #45). */
  flex: 0 0 auto;
  padding: 2px 10px;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

body.page-form .site-url-row .scan-site-url:disabled {
  opacity: 0.5;
  cursor: default;
}

body.page-form .site-url-row .delete {
  flex: 0 0 auto;
  padding: 4px 12px;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  background: var(--danger-bg);
  color: var(--danger-text);
  cursor: pointer;
}

body.page-form .add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

/* The selector keeps the base input rule specificity plus the row
   class and the type attribute, so the margin value wins over the
   base 12px bottom margin (issue #45). The row margin would shift
   the field against the Add button. */
body.page-form main .add-row input[type="text"] {
  flex: 1;
  margin-bottom: 0;
}

/* The kind select of the add row of the task edit form (issue #70)
   keeps its natural width in the flex row. */
body.page-form .add-row select {
  flex: 0 0 auto;
  width: auto;
  margin-bottom: 0;
}

body.page-form #add-schedule-button {
  /* The same style and size as the site URL Add button. */
  flex: 0 0 auto;
  height: var(--scan-row-height);
  padding: 8px 16px;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

/* The schedule rows of the task edit form (issue #70): one row per
   schedule, the fields sit inline with the row buttons. */
body.page-form #schedules .schedule-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

body.page-form .schedule-kind {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}

body.page-form main input.schedule-value {
  /* The base input rule sets width: 100% at the same specificity
     (body.page-form main input[type="text"]). This rule follows it
     in the sheet, so the fixed 80px width wins (issue #73). */
  flex: 0 0 auto;
  width: 80px;
  margin-bottom: 0;
}

body.page-form .schedule-unit,
body.page-form .schedule-from-select {
  flex: 0 0 auto;
  width: auto;
  margin-bottom: 0;
}

body.page-form .schedule-from {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}

/* The five cron fields of the task edit form (issue #73): a short
   label and a small fixed-width input for every field of the cron
   expression. The input selector keeps the base input rule
   specificity plus the field class, so the fixed width wins over
   the base 100% width (issue #73). */
body.page-form .schedule-cron-label {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
}

body.page-form main input.schedule-cron-field {
  flex: 0 0 auto;
  width: 56px;
  margin-bottom: 0;
}

body.page-form .schedule-row .delete {
  flex: 0 0 auto;
  padding: 4px 12px;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  background: var(--danger-bg);
  color: var(--danger-text);
  cursor: pointer;
}

body.page-form #add-site-url-button {
  /* The same style and size as the scan button (issue #44). */
  flex: 0 0 auto;
  height: var(--scan-row-height);
  padding: 8px 16px;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

body.page-form .feed-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  margin: 8px 0 12px;
  font-size: 14px;
}

body.page-form .feed-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

body.page-form main .feed-name[type="text"] {
  /* The base input rule margin would shift the field against the
     Delete feed button (issue #45). */
  flex: 1;
  margin-bottom: 0;
}

body.page-form .delete-feed {
  /* The shared form button rule gives flex: 1 (issue #40). The button
     keeps its natural width, aligns to the right, and matches the
     height of the name field (issue #45). */
  flex: 0 0 auto;
  margin-left: auto;
  height: var(--scan-row-height);
  padding: 4px 12px;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  background: var(--danger-bg);
  color: var(--danger-text);
  cursor: pointer;
}

body.page-form .feed-lang {
  width: auto;
  margin: 0 0 8px;
  padding: 2px 4px;
  font-size: 13px;
  /* The same height as the tags field of the meta row (issue #45). */
  height: var(--scan-row-height);
}

/* The tags field and the language drop-down share one line
   (issue #45): the tags take the free width, the language sits on
   the right. */
body.page-form .feed-meta-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}

body.page-form .feed-tags-group {
  flex: 1;
  min-width: 0;
}

body.page-form main .feed-tags-group input[type="text"] {
  margin-bottom: 0;
}

body.page-form .feed-lang-group {
  flex: 0 0 auto;
}

body.page-form .feed-lang-group .feed-lang {
  margin-bottom: 0;
}

body.page-form .feed-sources {
  margin: 4px 0 8px;
}

body.page-form .add-source-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

body.page-form main .add-source-row input[type="text"] {
  flex: 1;
  margin-bottom: 0;
}

body.page-form .add-source-row .add-source {
  /* The same style and size as the site URL Add button (issue #45). */
  flex: 0 0 auto;
  height: var(--scan-row-height);
  padding: 8px 16px;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

body.page-form .feed-error {
  color: var(--danger-text);
  font-size: 13px;
  margin: 4px 0 0;
}

body.page-form #add-feed-button {
  margin-bottom: 12px;
  padding: 6px 16px;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

body.page-form .source-row {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 14px;
}

body.page-form .source-url {
  flex: 1;
  word-break: break-all;
}

body.page-form .source-type,
body.page-form .feed-move {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

body.page-form .source-row select.feed-move {
  width: auto;
  margin: 0;
  padding: 2px 4px;
  font-size: 13px;
}

body.page-form .source-row .delete {
  /* The shared form button rule gives flex: 1 (issue #40). */
  flex: 0 0 auto;
  padding: 4px 12px;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  background: var(--danger-bg);
  color: var(--danger-text);
  cursor: pointer;
}

body.page-form .preview {
  /* The shared form button rule gives flex: 1 (issue #40). The accent
     background keeps the text readable in both themes (issue #45). */
  flex: 0 0 auto;
  padding: 2px 10px;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

/* Feed preview panel (issues #42, #43): the form and the panel
   share the client area as before, the panel takes the right half.
   The panel is sticky: the page and the form scroll, but the panel
   stays in place below the top of the viewport. The panel scrolls
   its items inside its own frame. A Close button hides the panel. */
#form-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

#form-side {
  flex: 1;
  min-width: 0;
}

#preview-panel {
  position: sticky;
  top: 16px;
  flex: 1;
  min-width: 0;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 14px;
}

#preview-panel .preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#preview-panel h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

#preview-panel .preview-close {
  margin: 0 0 8px;
  padding: 2px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}

#preview-panel .preview-url {
  margin: 0 0 4px;
  font-size: 13px;
  word-break: break-all;
}

#preview-panel .preview-count {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

#preview-panel .scan-spinner {
  margin: 0 0 8px;
}

.preview-message {
  font-size: 13px;
  margin: 8px 0;
  color: var(--muted);
}

.preview-message.error {
  color: var(--danger-text);
}

.preview-item {
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

.preview-item:first-child {
  border-top: none;
  padding-top: 0;
}

.preview-title {
  font-weight: 600;
  margin: 0 0 4px;
}

.preview-body {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 4px;
}

.preview-meta {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.preview-meta .preview-date {
  margin-right: 8px;
}

.preview-meta a {
  color: var(--link);
  text-decoration: none;
}

/* page-delete specifics */
body.page-delete .danger {
  background: var(--danger-text);
  color: var(--on-accent);
}

body.page-delete button:disabled {
  background: var(--btn-secondary-bg);
  color: var(--muted);
  cursor: not-allowed;
}

/* Narrow screens (issue #41): the sidebar stacks above the client
   area and the menu wraps to a row. */
@media (max-width: 640px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    flex: 0 0 auto;
  }

  .sidebar .menu {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .client {
    padding: 16px 16px 32px;
  }

  /* The preview panel stacks below the form without the sticky pin
     (issues #42, #43). */
  #form-layout {
    flex-direction: column;
  }

  #preview-panel {
    position: static;
    max-height: none;
  }
}

/* page-detail: the read-only user view */
body.page-detail .card {
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 1px 4px var(--shadow);
  padding: 24px;
}

/* Job detail page (issue #158): the type sections below the header
   card. The h3 holds one group of the report section, and the h4
   holds one report part of the group block. */
body.page-detail h2 {
  margin: 24px 0 8px;
  font-size: 18px;
}

body.page-detail h3 {
  margin: 16px 0 8px;
  font-size: 15px;
}

body.page-detail h4 {
  margin: 12px 0 4px;
  font-size: 13px;
}

/* The tag editor drop-down (issue #83). The widget is a one-line
   field for a comma-separated tag list. The drop-down floats below
   the field and lists the candidate tags. */
.tag-editor-dropdown {
  position: fixed;
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow-card);
}

.tag-editor-option {
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
}

.tag-editor-option.active {
  background: var(--accent-soft);
}

/* page-list: the dashboard (issue #100). The filter
   form, the counter row, and the inline SVG charts. */

body.page-list .filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

body.page-list .filters label {
  font-size: 14px;
  color: var(--muted);
}

body.page-list .filters select,
body.page-list .filters input {
  padding: 4px 8px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: var(--field-bg);
  color: var(--text);
}

body.page-list .counters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 24px;
}

body.page-list .counter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 4px var(--shadow);
}

body.page-list .counter-label {
  font-size: 13px;
  color: var(--muted);
}

body.page-list .counter-value {
  font-size: 20px;
  font-weight: 600;
}

body.page-list .counter-note {
  font-size: 13px;
  color: var(--muted);
}

body.page-list .chart {
  margin: 0 0 24px;
}

body.page-list .chart h2 {
  font-size: 16px;
  margin: 0 0 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--muted);
  font-size: 11px;
}

.chart-bar.bar-success,
.swatch.bar-success {
  fill: var(--chart-success);
  background: var(--chart-success);
}

.chart-bar.bar-error,
.swatch.bar-error {
  fill: var(--chart-error);
  background: var(--chart-error);
}

.chart-bar.bar-cost,
.swatch.bar-cost {
  fill: var(--chart-cost);
  background: var(--chart-cost);
}

.chart-line {
  fill: none;
  stroke-width: 2;
}

.chart-line.line-input,
.swatch.line-input {
  stroke: var(--chart-input);
  background: var(--chart-input);
}

.chart-line.line-output,
.swatch.line-output {
  stroke: var(--chart-output);
  background: var(--chart-output);
}

/* The data-flow diagram of the sender job detail page (issue #160).
   The svg scales to the page width, like the dashboard charts.
   The node border and the state text follow the job state; the
   colors match the chart marks. */
.flow-svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 16px;
}

.flow-edge {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
}

.flow-arrow {
  fill: var(--muted);
}

.flow-node rect {
  fill: var(--card);
  stroke-width: 1.5;
}

.flow-node.finished rect,
.flow-node.done rect {
  stroke: var(--chart-success);
}

.flow-node.running rect {
  stroke: var(--chart-input);
}

.flow-node.waiting rect {
  stroke: var(--chart-output);
}

.flow-node.error rect {
  stroke: var(--chart-error);
}

.flow-node.stopped rect,
.flow-node.none rect {
  stroke: var(--muted);
  stroke-dasharray: 4 3;
}

.flow-name {
  fill: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.flow-data {
  fill: var(--muted);
  font-size: 10px;
}

.flow-progress {
  fill: var(--text);
  font-size: 10px;
}

.flow-status {
  font-size: 10px;
}

.flow-status-detail {
  font-size: 9px;
  fill: var(--muted);
}

.flow-status.finished,
.flow-status.done {
  fill: var(--chart-success);
}

.flow-status.running {
  fill: var(--chart-input);
}

.flow-status.waiting {
  fill: var(--chart-output);
}

.flow-status.error {
  fill: var(--chart-error);
}

.flow-status.stopped,
.flow-status.none {
  fill: var(--muted);
}

/* The window diagrams of the flow page (issue #176). One section
   per report window: the header holds the kind and the window
   bounds. The section holds the window pipeline svg and the report
   generation block svg. */
.flow-window {
  margin-top: 24px;
}

.flow-window h2 {
  font-size: 16px;
  margin: 0 0 8px;
}

.flow-window .flow-svg {
  margin-top: 0;
}

/* The group label of one report chain row of the report generation
   block (issue #176). */
.flow-label-text {
  fill: var(--text);
  font-size: 12px;
  font-weight: 600;
}

/* The report generation placeholder of the window pipeline
   (issue #176): the dashed border marks the aggregate node. */
.flow-node.placeholder rect {
  stroke-dasharray: 5 3;
}

/* AI session dump (issue #101): the text dump of one session in a
   pre block. The block scrolls horizontally on a narrow screen. */
pre.session-dump {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 4px var(--shadow);
  padding: 16px;
  margin-top: 16px;
  overflow-x: auto;
  white-space: pre;
}

/* Report text of the job detail page (issue #170): a plain text
   block that wraps on the page width. Newlines of the text stay as
   line breaks. */
.report-text {
  font-size: 14px;
  line-height: 1.5;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 4px var(--shadow);
  padding: 16px;
  margin-top: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
