/* Shared components. The markup for each comes from js/ui/*.js; views may also use these classes directly. */

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
       padding: 0 18px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: var(--bg);
       color: var(--text); font-weight: 600; font-size: var(--text-sm); line-height: 1.2; cursor: pointer;
       text-decoration: none; white-space: nowrap; transition: background .12s ease, border-color .12s ease; }
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary); opacity: .9; }
.btn-danger { background: var(--loss); border-color: var(--loss); color: #FFFFFF; }
:root[data-theme="dark"] .btn-danger { color: #0D1117; }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--surface); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--text-sm); }
.btn-link { border: 0; background: none; padding: 0; min-height: var(--tap); color: var(--info); font-weight: 600;
            cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .5; cursor: default; }
.btn[aria-busy="true"]::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent;
                                border-radius: 50%; animation: spin .8s linear infinite; }
@media (max-width: 719px) { .btn-sm { min-height: var(--tap); } }

/* ---------- cards and panels ---------- */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-4); }
.card + .card { margin-top: var(--space-4); }
.card-quiet { background: var(--surface); border-color: transparent; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
.card-head h2 { font-size: var(--text-md); }
.help { font-size: var(--text-sm); color: var(--muted); }

/* ---------- list rows (one line each, the whole row clickable) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-row { display: flex; align-items: center; gap: var(--space-3); padding: 12px 0; min-height: var(--tap);
            color: inherit; text-decoration: none; }
a.list-row:hover .list-title, a.list-row:focus-visible .list-title { text-decoration: underline; text-underline-offset: 2px; }
.list-title { font-weight: 600; }
.list-sub { font-size: var(--text-sm); color: var(--muted); }
.list-end { margin-left: auto; text-align: right; flex: none; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; line-height: 1;
        padding: 5px 9px; border-radius: var(--radius-pill); background: var(--surface); color: var(--text); white-space: nowrap; }
.chip-buy, .chip-gain, .chip-hold { background: var(--gain-bg); color: var(--gain); }
.chip-avoid, .chip-sell, .chip-loss { background: var(--loss-bg); color: var(--loss); }
.chip-watch, .chip-trim, .chip-warn { background: var(--watch-bg); color: var(--watch); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-muted { background: var(--surface); color: var(--muted); }
.chip-outline { background: none; border: 1px solid var(--border-strong); color: var(--muted); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
/* "Claude BUY · ChatGPT WATCH — they disagree" (analyst.js consensusLine) */
.cons { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: var(--text-sm); }
.cons-one { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.cons-word { color: var(--muted); }
.cons-split .cons-word { color: var(--watch); font-weight: 600; }

/* conviction: five dots, the number is in the label */
.dots { display: inline-flex; gap: 3px; align-items: center; vertical-align: middle; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); display: block; }
.dots i.on { background: var(--text); }

/* ---------- alerts and notices ---------- */
.banner { display: flex; gap: var(--space-3); align-items: flex-start; padding: 12px 14px; border-radius: var(--radius);
          background: var(--surface); margin-bottom: var(--space-4); font-size: var(--text-sm); }
.banner .icon { margin-top: 2px; }
.banner-warn { background: var(--watch-bg); color: var(--text); }
.banner-warn .icon { color: var(--watch); }
.banner-bad { background: var(--loss-bg); }
.banner-bad .icon { color: var(--loss); }
.banner-info { background: var(--info-bg); }
.banner-info .icon { color: var(--info); }

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 var(--space-3); }
.field-label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: 6px; }
.field-hint { display: block; font-size: var(--text-xs); color: var(--muted); margin-top: 4px; }
.input, .select, .textarea { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--control-border);
                             border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: var(--text-md); }
.textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: var(--text-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); flex: none; }
.form-error { color: var(--loss); font-size: var(--text-sm); min-height: 1.4em; margin: var(--space-2) 0 0; }
.form-note { color: var(--muted); font-size: var(--text-sm); margin: var(--space-2) 0 0; }

/* ---------- segmented control ---------- */
.seg { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); background: var(--surface); gap: 2px; }
.seg button, .seg a { border: 0; background: none; color: var(--muted); font-weight: 600; font-size: var(--text-sm);
                      min-height: 36px; padding: 0 14px; border-radius: var(--radius-pill); cursor: pointer; text-decoration: none;
                      display: inline-flex; align-items: center; }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(11, 18, 32, .12); }
@media (max-width: 719px) { .seg button, .seg a { min-height: var(--tap); } }   /* 44px to tap on a phone (the chart's range too) */

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { width: 100%; font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 600; font-size: var(--text-xs); color: var(--muted); padding: 8px 10px;
            border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- empty state and skeleton ---------- */
.empty { text-align: center; padding: var(--space-6) var(--space-4); color: var(--muted); }
.empty .icon { margin: 0 auto var(--space-3); color: var(--muted); }
.empty h3 { color: var(--text); font-size: var(--text-md); margin-bottom: 4px; }
.empty h1 { color: var(--text); margin-bottom: var(--space-2); }   /* a page that is only this (offline.html) */
.empty p { max-width: 46ch; margin: 0 auto var(--space-3); font-size: var(--text-sm); }
.empty-inline { text-align: left; padding: var(--space-3) 0; }
.empty-inline .icon { display: none; }
.empty-inline p { margin-left: 0; }

.skel { display: block; border-radius: 6px; background: var(--surface-2); height: 14px; margin: 10px 0;
        animation: pulse 1.4s ease-in-out infinite; }
.skel-lg { height: 32px; width: 40%; }
.skel-card { height: 120px; border-radius: var(--radius); }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--text);
        border-radius: 50%; animation: spin .8s linear infinite; flex: none; }

/* ---------- the running-job pill in the top bar ---------- */
/* It may shrink (the label ends in an ellipsis), the bar's icon buttons never do. Below 1024px the bar has no room
   for the label beside the sections and the buttons, so only the spinner shows; the label is still read out and is
   the pill's tooltip. */
#jobpill { display: flex; min-width: 0; }
.jobpill { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 260px; padding: 6px 12px; border-radius: var(--radius-pill);
           background: var(--surface); color: var(--text); font-size: var(--text-xs); font-weight: 600; cursor: default; }
.jobpill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 1023px) {
  #jobpill { flex: none; }
  .jobpill { width: var(--tap); height: var(--tap); padding: 0; justify-content: center; }
  .jobpill-text { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
                  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px;
          width: min(420px, calc(100vw - 32px)); pointer-events: none; }
@media (max-width: 719px) { .toasts { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); right: 16px; } }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px;
         background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
         box-shadow: var(--shadow-pop); font-size: var(--text-sm); animation: toast-in .18s ease-out; }
.toast > .icon { margin-top: 2px; }
.toast-good > .icon { color: var(--gain); }
.toast-bad > .icon { color: var(--loss); }
.toast-warn > .icon { color: var(--watch); }
.toast-info > .icon { color: var(--info); }
.toast-text { flex: 1; min-width: 0; padding-top: 1px; }
.toast-close { flex: none; width: 32px; height: 32px; margin: -6px -4px -6px 0; border: 0; background: none; color: var(--muted);
               border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.toast-close:hover { background: var(--surface); color: var(--text); }
.toast .btn { min-height: 32px; padding: 0 12px; margin-top: -4px; }
@media (max-width: 719px) {   /* 44px to tap on a phone */
  .toast .btn { min-height: var(--tap); margin-top: -8px; margin-bottom: -6px; }
  .toast-close { width: var(--tap); height: var(--tap); margin: -10px -8px -10px 0; }
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- dialogs ---------- */
dialog.dialog { border: 0; padding: 0; border-radius: 16px; background: var(--bg); color: var(--text);
                width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-pop); }
dialog.dialog::backdrop { background: var(--overlay); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog-head { padding: 20px 22px 4px; font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; }
.dialog-body { padding: 6px 22px 4px; color: var(--muted); font-size: var(--text-sm); overflow-y: auto; }
.dialog-body p:last-child { margin-bottom: 0; }
.dialog-fields { padding: 8px 22px 0; overflow: visible; }
.dialog-preview { margin: 4px 22px 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); font-size: var(--text-sm); }
.dialog-preview:empty { display: none; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; flex-wrap: wrap; }

/* ---------- the AI permission's screen and the legal links (js/legal.js) ---------- */
.consent-providers { margin: 0 0 var(--space-3); }
.consent-sent { margin: 0 0 var(--space-3); }
.consent-sent li + li { margin-top: var(--space-2); }
.consent-sent b, .consent-never b { color: var(--text); font-weight: 600; }
.consent-policy a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; }
.legal-links { display: flex; flex-wrap: wrap; gap: 0 var(--space-4); font-size: var(--text-sm); }
.legal-links a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--muted); }
.legal-links a:hover { color: var(--text); }

/* ---------- tooltips (hover, focus or tap anything with data-tip) ---------- */
.tip { border-bottom: 1px dotted currentColor; cursor: help; }
.tipbox { position: fixed; z-index: 70; max-width: 320px; padding: 8px 10px; border-radius: var(--radius-sm);
          background: var(--tip-bg); color: var(--tip-text); font-size: var(--text-sm); line-height: 1.45;
          pointer-events: none; box-shadow: var(--shadow-pop); }

/* ---------- ticker search ---------- */
.search { position: relative; }
.search-list { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; width: max(100%, 320px); max-width: calc(100vw - 32px);
               margin: 0; padding: 4px; list-style: none; background: var(--bg); border: 1px solid var(--border-strong);
               border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.search-list li { display: grid; grid-template-columns: 72px 1fr; gap: 0 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.search-list li[aria-selected="true"], .search-list li:hover { background: var(--surface); }
.search-list b { font-weight: 600; }
.search-list small { grid-column: 2; color: var(--muted); font-size: var(--text-xs); }

/* ---------- sparkline and price chart ---------- */
.spark { display: inline-block; vertical-align: middle; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: 6px; }
.chart-tip { position: absolute; top: 6px; pointer-events: none; background: var(--bg); border: 1px solid var(--border-strong);
             border-radius: var(--radius-sm); padding: 6px 9px; font-size: var(--text-xs); white-space: nowrap; box-shadow: var(--shadow-pop); }
.chart-tip b { font-size: var(--text-sm); display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px dashed currentColor; }

/* ---------- key figures ---------- */
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv dt, .kv .k { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.kv dd, .kv .v { margin: 0; font-size: var(--text-md); font-weight: var(--weight-num); }
.big-num { font-size: var(--text-2xl); font-weight: var(--weight-num); letter-spacing: -0.03em; line-height: 1.1; }
