/* Agave stylesheet: hand-written, plain CSS, no framework.
   Looks the same as the previous Tailwind-CDN version (colours, spacing, type scale, responsive breakpoints). */

/* ---------- Base / reset ---------- */
*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: #e5e7eb; }
html {
  height: 100%;
  background-color: #f9fafb;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body { height: 100%; margin: 0; line-height: inherit; color: #1f2937; }
h1, h2, p, pre { margin: 0; }
h1, h2 { font-size: inherit; font-weight: inherit; }
a { color: inherit; text-decoration: inherit; }
table { text-indent: 0; border-color: inherit; border-collapse: collapse; }
th { text-align: inherit; }
button, input, textarea { font-family: inherit; font-size: 100%; font-weight: inherit; line-height: inherit; color: inherit; margin: 0; padding: 0; }
button { background-color: transparent; background-image: none; cursor: pointer; -webkit-appearance: button; appearance: button; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { opacity: 1; color: #9ca3af; }
svg, canvas { display: block; vertical-align: middle; }
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 1em; }
summary { display: list-item; }
:disabled { cursor: default; }

.is-hidden { display: none; }

/* ---------- App shell ---------- */
.app-shell { display: flex; height: 100%; min-height: 100vh; }
.sidebar {
  width: 14rem; flex-shrink: 0; display: flex; flex-direction: column;
  padding: 1.5rem 0.75rem; background-color: #fff; border-right: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.brand { padding: 0 1rem; margin-bottom: 2rem; }
.brand-name { font-size: 1.25rem; line-height: 1.75rem; font-weight: 700; color: #059669; }
.brand-user { margin-top: 0.25rem; font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }
.nav { display: flex; flex-direction: column; gap: 0.125rem; flex: 1 1 0%; }
.sidebar-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 1rem; border-radius: 0.5rem; color: #6b7280; font-size: 0.875rem; font-weight: 500; transition: background-color 0.15s, color 0.15s; white-space: nowrap; }
.sidebar-link:hover { background-color: #f3f4f6; color: #111827; }
.sidebar-link.active { background-color: #ecfdf5; color: #047857; font-weight: 600; }
.sidebar-link svg { flex-shrink: 0; width: 1rem; height: 1rem; }
.sidebar-foot { margin-top: auto; padding: 0 1rem; display: flex; align-items: center; justify-content: space-between; }
.signout-form { display: inline; }
.link-quiet { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1); }
.link-quiet:hover { color: #4b5563; }
.blur-toggle { color: #9ca3af; transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1); }
.blur-toggle:hover { color: #4b5563; }
.icon-sm { width: 1rem; height: 1rem; }
.main { flex: 1 1 0%; overflow: auto; background-color: #f9fafb; }
.main-inner { max-width: 80rem; margin-left: auto; margin-right: auto; padding: 2rem 1.5rem; }

/* ---------- Page headings ---------- */
.page-title { font-size: 1.5rem; line-height: 2rem; font-weight: 700; margin-bottom: 1.5rem; }
.page-title--tight { margin-bottom: 0.5rem; }
.page-subtitle { margin-top: 0.25rem; font-size: 0.875rem; line-height: 1.25rem; color: #6b7280; }
.page-subtitle--spaced { margin-top: 0; margin-bottom: 1.5rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; }
.page-header .page-title { margin-bottom: 0; }
.page-actions { display: flex; align-items: center; gap: 0.75rem; }

/* ---------- Cards ---------- */
/* Matches the previous rendering: the old @apply-based card background/border never took effect, so cards are
   transparent with only padding and a radius. */
.card { padding: 0.625rem 1rem; border-radius: 0.5rem; }
.card--spaced { margin-bottom: 2rem; }
.card--wide { grid-column: span 3 / span 3; }
.card--top { margin-top: 2rem; }
.card--inline { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; }
.card-title { font-weight: 600; margin-bottom: 1rem; }
.card-title--muted { font-size: 0.875rem; line-height: 1.25rem; color: #6b7280; }
.card-title--icon { display: flex; align-items: center; gap: 0.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-head .card-title { margin-bottom: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-label { font-size: 0.75rem; line-height: 1rem; color: #6b7280; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.5rem; line-height: 2rem; font-weight: 700; color: #111827; }
.stat-value--md { font-size: 1.25rem; line-height: 1.75rem; }
.stat-value--warn { color: #ca8a04; }
.stat-note { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }
.stat-time { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; color: #374151; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }

.timestamp { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }
.link-more { font-size: 0.75rem; line-height: 1rem; color: #059669; }
.link-more:hover { color: #047857; }
.empty-state { color: #6b7280; }
.empty-state--sm { font-size: 0.875rem; line-height: 1.25rem; }
.empty-state--dim { color: #9ca3af; }

.list-stack > * + * { margin-top: 0.75rem; }
.list-stack--sm > * + * { margin-top: 0.5rem; }
.list-stack--lg > * + * { margin-top: 1rem; }
.row-item { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid #f3f4f6; }
.row-item:last-child { border-bottom-width: 0; }
.row-ticker { margin-left: 0.5rem; font-weight: 500; }
.row-qty { font-size: 0.875rem; line-height: 1.25rem; color: #9ca3af; }
.run-time { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; }
.run-trigger { margin-left: 0.5rem; font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }
.run-status { font-size: 0.75rem; line-height: 1rem; color: #ca8a04; }
.run-status--ok { color: #16a34a; }
.run-status--fail { color: #dc2626; }

/* ---------- Buttons ---------- */
.btn { border-radius: 0.5rem; font-weight: 500; transition-property: color, background-color, border-color; transition-duration: 150ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }
.btn--sm { padding: 0.5rem 1rem; font-size: 0.875rem; line-height: 1.25rem; }
.btn--xs { padding: 0.375rem 1rem; font-size: 0.875rem; line-height: 1.25rem; }
.btn--lg { padding: 0.625rem 1.5rem; }
.btn--block { width: 100%; padding: 0.625rem 0; margin-top: 0.5rem; }
.btn-primary { background-color: #059669; color: #fff; }
.btn-primary:hover { background-color: #047857; }
.btn-secondary { background-color: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background-color: #e5e7eb; }
.btn-danger-soft { background-color: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger-soft:hover { background-color: #fee2e2; }

/* ---------- Forms ---------- */
.form-stack > * + * { margin-top: 1rem; }
.form-row { display: flex; align-items: center; gap: 1rem; }
.field-label { display: block; font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; color: #374151; margin-bottom: 0.375rem; }
.field-label--roomy { margin-bottom: 0.75rem; }
.input { background-color: #fff; border: 1px solid #d1d5db; border-radius: 0.5rem; color: #1f2937; }
.input:focus, .config-editor:focus { outline: 2px solid transparent; outline-offset: 2px; border-color: #10b981; box-shadow: 0 0 0 1px #10b981; }
.input--lg { width: 100%; padding: 0.625rem 1rem; }
.input--md { flex: 1 1 0%; padding: 0.625rem 1rem; font-size: 0.875rem; line-height: 1.25rem; }
.input--sm { flex: 1 1 0%; padding: 0.375rem 0.75rem; font-size: 0.875rem; line-height: 1.25rem; }
.config-editor { width: 100%; background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 0.5rem; padding: 0.75rem 1rem; font-size: 0.875rem; line-height: 1.25rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; color: #1f2937; resize: vertical; }

.alert { border-radius: 0.75rem; padding: 1rem 1.25rem; margin-bottom: 1.5rem; font-size: 0.875rem; line-height: 1.25rem; }
.alert--error { background-color: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; white-space: pre-wrap; }
.alert--success { background-color: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.status-row { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.status-label { font-size: 0.75rem; line-height: 1rem; color: #6b7280; }
.status-value { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; color: #1f2937; }
.history-item { border-bottom: 1px solid #f3f4f6; padding-bottom: 0.75rem; }
.history-item:last-child { border-bottom-width: 0; }
.history-head { display: flex; align-items: center; justify-content: space-between; }
.history-summary { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; color: #1f2937; }
.history-by { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }

/* ---------- Badges ---------- */
/* .badge-pending / -approved / -executed / -rejected / -expired / -skipped / -dry-run are intentionally unstyled:
   their old @apply rules never applied, and the look is unchanged. Only buy / sell / hold are styled. */
.badge-buy, .badge-sell, .badge-hold {
  display: inline-flex; padding: 0.25rem 0.75rem; border-radius: 0.5rem; font-size: 0.75rem; font-weight: 700;
  color: white; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.badge-buy { background-color: #16a34a; }
.badge-sell { background-color: #dc2626; }
.badge-hold { background-color: #6b7280; }
.badge-inline { margin-left: 0.25rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; font-size: 0.875rem; line-height: 1.25rem; }
.data-table thead tr { text-align: left; font-size: 0.75rem; line-height: 1rem; color: #6b7280; border-bottom: 1px solid #e5e7eb; }
.data-table th { padding: 0 1rem 0.75rem 0; }
.data-table th:last-child { padding-right: 0; }
.data-table tbody tr { border-bottom: 1px solid #f3f4f6; }
.data-table tbody tr:last-child { border-bottom-width: 0; }
.data-table td { padding: 0.75rem 1rem 0.75rem 0; }
.data-table td:last-child { padding-right: 0; }
.cell-ticker { font-weight: 700; color: #111827; }
.cell-soft { color: #4b5563; }
.cell-strong { font-weight: 500; color: #1f2937; }
.cell-body { color: #374151; }
.cell-sector { color: #6b7280; }
.cell-time { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }
.cell-id { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }
.cell-none { color: #9ca3af; }
.cell-none--faint { color: #d1d5db; }
.pl-pos { color: #16a34a; }
.pl-neg { color: #dc2626; }
.src-tag { font-size: 0.75rem; line-height: 1rem; font-weight: 400; color: #f97316; }
.trade-status { font-size: 0.75rem; line-height: 1rem; font-weight: 500; color: #9ca3af; }
.trade-status--filled { color: #16a34a; }
.trade-status--failed { color: #dc2626; }
.trade-status--dry { color: #9333ea; }
.trade-status--submitted { color: #2563eb; }
.meter { display: flex; align-items: center; gap: 0.5rem; }
.meter-track { width: 4rem; height: 0.375rem; background-color: #e5e7eb; border-radius: 9999px; }
.meter-fill { height: 0.375rem; background-color: #10b981; border-radius: 9999px; }
.meter-label { color: #6b7280; }

/* ---------- Portfolio charts ---------- */
.sector-layout { display: flex; flex-direction: column; align-items: center; gap: 2rem; }
.sector-chart { position: relative; width: 14rem; height: 14rem; flex-shrink: 0; }
.sector-legend { display: flex; flex-wrap: wrap; column-gap: 1.5rem; row-gap: 0.5rem; font-size: 0.875rem; line-height: 1.25rem; color: #4b5563; }
.legend-item { display: flex; align-items: center; gap: 0.375rem; }
.legend-swatch { display: inline-block; width: 0.625rem; height: 0.625rem; border-radius: 9999px; flex-shrink: 0; }
.legend-name { color: #374151; font-weight: 500; }
.legend-pct { color: #9ca3af; }

/* ---------- Report / logs ---------- */
.report-wrap { position: relative; }
.report-box { max-height: 24rem; overflow-y: auto; background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 0.5rem; padding: 1rem; font-size: 0.875rem; line-height: 1.25rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; color: #374151; }
.report-box pre { white-space: pre-wrap; }
.report-meta { margin-top: 0.5rem; font-size: 0.75rem; line-height: 1rem; color: #6b7280; }
.scroll-box { max-height: 24rem; overflow-y: auto; }
.log-entry { padding: 0.5rem 0; border-bottom: 1px solid #f3f4f6; }
.log-entry:last-child { border-bottom-width: 0; }
.log-entry-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.125rem; }
.log-type { font-size: 0.75rem; line-height: 1rem; font-weight: 500; color: #059669; }
.log-desc { font-size: 0.875rem; line-height: 1.25rem; color: #374151; }
.ws-status { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; }
.ws-status--live { color: #16a34a; }
.ws-status--bad { color: #dc2626; }
.log-output { height: 24rem; overflow-y: auto; background-color: #111827; border-radius: 0.5rem; padding: 0.75rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 0.75rem; line-height: 1.625; color: #d1d5db; }

/* ---------- Recommendations ---------- */
.rec-section { margin-bottom: 2rem; }
.group-heading { font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; margin-bottom: 1rem; color: #facc15; }
.count-pill { margin-left: 0.5rem; font-size: 0.875rem; line-height: 1.25rem; background-color: rgba(113, 63, 18, 0.5); color: #fde047; padding: 0.125rem 0.5rem; border-radius: 9999px; }
.rec-group { margin-bottom: 1.5rem; }
.rec-group > .list-stack { margin-top: 0.75rem; }
.rec-group-summary { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; margin-bottom: 0.75rem; font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; color: #6b7280; transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1); }
.rec-group-summary:hover { color: #d1d5db; }
.count-pill--dark { margin-left: 0; font-size: 0.75rem; line-height: 1rem; background-color: #1f2937; color: #9ca3af; }

.rec-card { border-width: 2px; border-color: #9ca3af; }
.rec-card--pending { border-color: rgba(250, 204, 21, 0.4); background-color: rgba(254, 252, 232, 0.4); }
.rec-card--inactive { border-color: #d1d5db; opacity: 0.6; }
.rec-card--executed { border-color: #22c55e; background-color: rgba(240, 253, 244, 0.4); }
.rec-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.rec-title { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.rec-ticker { font-size: 1.25rem; line-height: 1.75rem; font-weight: 700; color: #111827; }
.rec-qty { font-size: 0.875rem; line-height: 1.25rem; color: #6b7280; }
.rec-value { font-size: 0.875rem; line-height: 1.25rem; color: #9ca3af; }
.rec-badges { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; margin-left: 0.75rem; }
.rec-reasoning { font-size: 0.875rem; line-height: 1.625; color: #4b5563; margin-bottom: 1rem; }
.rec-meta { display: flex; align-items: center; gap: 1rem; font-size: 0.75rem; line-height: 1rem; color: #9ca3af; margin-bottom: 1rem; padding-top: 0.75rem; border-top: 1px solid #f3f4f6; }
.rec-meta-value { color: #374151; }
.rec-meta-value--bold { font-weight: 500; }
.rec-warning { color: #ea580c; }
.funding-hint { font-size: 0.75rem; line-height: 1rem; color: #b45309; background-color: #fffbeb; border: 1px solid #fde68a; border-radius: 0.5rem; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.rec-actions { display: flex; gap: 0.75rem; padding-top: 0.25rem; }
.rec-approve-form { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 0%; }
.rec-note { font-size: 0.75rem; line-height: 1rem; color: #9ca3af; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid #f3f4f6; }

/* ---------- Evaluation status (HTMX fragment) ---------- */
.eval-status { font-size: 0.875rem; line-height: 1.25rem; color: #ca8a04; }
.eval-status--busy { display: flex; align-items: center; gap: 0.5rem; }
.eval-status--done { color: #059669; }
.eval-status--failed { color: #dc2626; }
.spinner { width: 1rem; height: 1rem; animation: agave-spin 1s linear infinite; }
.spinner-track { opacity: 0.25; }
.spinner-arc { opacity: 0.75; }
@keyframes agave-spin { to { transform: rotate(360deg); } }

/* ---------- Sensitive value blur ---------- */
.sensitive-value { transition: filter 0.2s ease; }
.sensitive-value.blurred { filter: blur(5px); user-select: none; padding: 2px 4px; margin: -2px -4px; }

/* ---------- Login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; }
.login-box { width: 100%; max-width: 24rem; }
.login-head { text-align: center; margin-bottom: 2rem; }
.login-title { font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; color: #059669; }
.login-sub { margin-top: 0.25rem; font-size: 0.875rem; line-height: 1.25rem; color: #6b7280; }
.login-card { background-color: #fff; border: 1px solid #e5e7eb; border-radius: 0.75rem; padding: 2rem; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.login-error { background-color: #fef2f2; border: 1px solid #fecaca; border-radius: 0.5rem; padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.875rem; line-height: 1.25rem; color: #b91c1c; }

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  .sector-layout { flex-direction: row; }
}
@media (min-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
