/* Field Log — direction: ruled ledger, one stamp accent, monospace data.
   See templates/base.html for the direction contract. */

:root {
  --bg: #eeece5;
  --surface: #fbfaf6;
  --surface-raised: #ffffff;
  --rule: #d9d5c9;
  --rule-strong: #c7c2b3;
  --ink: #1c1a15;
  --ink-secondary: #6b6558;
  --ink-faint: #6f6a5c;

  --accent: #b73f0f;
  --accent-strong: #96350c;
  --accent-ink: #fff7f2;
  --accent-tint: #f7e4d8;

  --ok: #3f6b4a;
  --ok-tint: #e3ede2;
  --err: #9c2b20;
  --err-tint: #f4e0dc;

  --source-webhook: #2f6f62;
  --source-cli: #47536b;
  --source-admin: var(--accent);

  --focus-ring: #96350c;

  --shadow-card: 0 1px 2px rgba(28, 26, 21, 0.05), 0 10px 24px -12px rgba(28, 26, 21, 0.18);
  --radius: 10px;
  --radius-sm: 6px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #1f1c16;
    --surface-raised: #251f18;
    --rule: #35301f;
    --rule-strong: #45402c;
    --ink: #f1efe6;
    --ink-secondary: #a89f8c;
    --ink-faint: #9a927e;

    --accent: #e0682f;
    --accent-strong: #f0824f;
    --accent-ink: #180c05;
    --accent-tint: #3a2013;

    --ok: #7fae87;
    --ok-tint: #223026;
    --err: #d97a6c;
    --err-tint: #3a2019;

    --source-webhook: #5fa494;
    --source-cli: #8891ab;
    --source-admin: var(--accent);

    --focus-ring: #f0824f;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 8px;
  border: 3px solid var(--bg);
}
* {
  scrollbar-color: var(--rule-strong) var(--bg);
  scrollbar-width: thin;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand:hover {
  color: var(--ink);
}
.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--accent);
  position: relative;
  flex: none;
}
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  background: var(--accent-ink);
  border-radius: 1px;
}
.brand-mark::before { top: 7px; }
.brand-mark::after { top: 12px; right: 8px; }

.primary-nav {
  display: flex;
  gap: 1.5rem;
}
.primary-nav a {
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  transition: color 150ms ease, border-color 150ms ease;
}
.primary-nav a:hover {
  color: var(--ink);
}
.primary-nav a.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0 0 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.375rem 1.5rem;
  margin-bottom: 2rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0 0 1rem;
  letter-spacing: -0.005em;
}

/* Config card reads as the logbook's cover page: a stamped top edge and a
   tracked, small-caps title, set apart from the ruled entries below it. */
.config-card {
  border-top: 3px solid var(--accent);
  padding-top: calc(1.25rem - 2px);
}
.config-card .card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-secondary);
}

.card-lede {
  margin: 0 0 1.25rem;
  color: var(--ink-secondary);
  font-size: 0.95rem;
}

.field {
  margin-bottom: 1rem;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.field input[type="text"],
.field input[type="search"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.field input[type="text"]:hover,
.field input[type="search"]:hover {
  border-color: var(--ink-faint);
}
.field input[type="text"]:focus,
.field input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.field input::placeholder {
  color: var(--ink-faint);
}
.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-strong);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.flash-stack {
  margin-bottom: 1.5rem;
  display: grid;
  gap: 0.6rem;
}
.flash {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  animation: flash-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.flash-success {
  background: var(--ok-tint);
  color: var(--ok);
}
.flash-error {
  background: var(--err-tint);
  color: var(--err);
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; }
}

.ledger-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.ledger-count {
  color: var(--ink-faint);
  font-weight: 400;
  margin-left: 0.5rem;
}
.ledger-search {
  min-width: 220px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.ledger-search:hover {
  border-color: var(--ink-faint);
}
.ledger-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.ledger-search::placeholder {
  color: var(--ink-faint);
}
.ledger-search::-webkit-search-cancel-button {
  filter: grayscale(1) opacity(0.7);
}

.legend {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  margin: 0 0 0.85rem;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--ink-secondary);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.dot-webhook { background: var(--source-webhook); }
.dot-cli { background: var(--source-cli); }
.dot-admin { background: var(--source-admin); }
.dot-replied { background: var(--ink-faint); }
.dot-pending { background: var(--accent); }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
.ledger-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
.ledger-table td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.88rem;
  vertical-align: middle;
  white-space: nowrap;
}
.ledger-table tbody tr {
  transition: background 120ms ease, box-shadow 120ms ease;
}
.ledger-table tbody tr:last-child td {
  border-bottom: none;
}
.ledger-table tbody tr:hover {
  background: var(--accent-tint);
  box-shadow: inset 0 0 0 1px var(--accent-tint), inset 0 1px 0 var(--rule-strong);
}
.ledger-table tbody tr.is-filtered-out {
  display: none;
}
.empty-row td {
  color: var(--ink-faint);
  font-style: normal;
  padding: 1.25rem 0.9rem;
}

.cell-truncate {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
@media (max-width: 720px) {
  .cell-truncate {
    max-width: 140px;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.6;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-webhook { color: var(--source-webhook); }
.badge-cli { color: var(--source-cli); }
.badge-admin { color: var(--source-admin); }
.badge-replied { color: var(--ink-faint); }
.badge-pending { color: var(--accent); }

.ledger-empty-filtered {
  padding: 1.25rem 0.9rem;
  color: var(--ink-faint);
  font-size: 0.88rem;
}

.back-link {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}
.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.icon-arrow-back {
  flex: none;
}

.results-summary .media-id {
  margin: 0 0 0.4rem;
  color: var(--ink-secondary);
  font-size: 0.85rem;
}
.results-summary .ledger-tally {
  margin: 0;
  font-size: 0.95rem;
}

.send-form {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
.send-preview {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}
.send-preview strong {
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 560px) {
  .page {
    padding: 1.1rem 1rem 3rem;
  }
  .page-header {
    gap: 0.75rem;
  }
  .ledger-search {
    width: 100%;
  }
}
