/* Action history — the panel under the Activity Log text log. */
#action-history, #ah-import-overlay { --ok: #2f9c8a; --bad: #e0573f; --skip: #6a7f96; }
#action-history .ah-title { font-size: 0.8rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.07em; margin: 0 0 10px; }
#action-history .ah-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
#action-history .ah-top label { color: var(--muted); font-size: 12px; width: auto; flex: 0 0 auto; margin: 0; }
#action-history .ah-top select { width: auto; min-width: 280px; max-width: 100%; }
#action-history .ah-subtabs { margin: 2px 0 10px; }
#action-history .ah-subtabs .tab-btn { font-size: 0.72rem; }
#s-log .ah-panel-hidden { display: none; }

/* Result pills in the table */
#ah-dt .pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; color: #fff; border: none; }
#ah-dt .pill.success { background: var(--ok); }
#ah-dt .pill.fail { background: var(--bad); }
#ah-dt .pill.skip, #ah-dt .pill.error { background: var(--skip); }
#ah-dt td.ah-msg { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
#ah-dt td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Character history summary (built from the action log) */
#ah-summary .ch-table td.ch-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
#ah-summary .ch-table td.ah-rate { width: 1%; white-space: nowrap; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
#ah-summary .ch-table td.ah-rate.good { color: var(--ok); }
#ah-summary .ch-table td.ah-rate.poor { color: var(--bad); }
#ah-summary tr.ah-total td { font-weight: 600; color: var(--text); }
#ah-summary tr.ah-exp { cursor: pointer; }
#ah-summary tr.ah-exp:hover td { background: rgba(200,168,75,.06); }
#ah-summary tr.ah-exp .ah-caret { display: inline-block; width: 12px; color: var(--accent); transition: transform .15s; }
#ah-summary tr.ah-exp.open .ah-caret { transform: rotate(90deg); }
#ah-summary tr.ah-sub td { background: var(--surface); font-size: .78rem; }
#ah-summary tr.ah-sub td.ch-key { padding-left: 28px; }
#action-history .ah-sec-note { padding: 4px 10px; font-size: .72rem; color: var(--muted); border-top: 1px solid var(--border); }
#action-history .ah-empty { color: var(--muted); padding: 20px; text-align: center; font-size: 0.85rem; }

/* Import logs */
#ah-import-overlay .ah-note, #action-history .ah-note { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
#ah-import-overlay .ah-import-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
#ah-import-overlay .ah-import-bar label { color: var(--muted); font-size: 12px; width: auto; min-width: 0; margin: 0; flex: 0 0 auto; }
#ah-import-overlay .ah-import-bar input[type=text] { width: 240px; font-size: 12px; padding: 4px 6px; }
#ah-import-overlay .ah-import-bar .ah-note { margin: 0; }
#ah-import-overlay .imp-err { color: var(--bad); }
#ah-import-overlay .ah-box { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 12px; }
#ah-import-overlay table.ah-table { width: 100%; border-collapse: collapse; font-size: 12px; }
#ah-import-overlay table.ah-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
#ah-import-overlay table.ah-table td { padding: 5px 6px; border-bottom: 1px solid rgba(46,64,96,.35); vertical-align: top; }
#ah-import-overlay table.ah-table .num { text-align: right; font-variant-numeric: tabular-nums; }
#imp-logs input[type=checkbox], #imp-all { width: auto; }

/* Phone cards: let the message wrap instead of cutting it off */
@media (max-width: 640px) {
  #ah-dt .dt-cards td.ah-msg { grid-column: 1 / -1; max-width: none; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  #ah-dt .dt-cards td.num { text-align: left; align-items: flex-start; }
  #ah-dt .dt-cards td > .pill { align-self: flex-start; }
}

/* Character picker and tabs stay in view while scrolling (below the main menu) */
#action-history .ah-sticky { position: sticky; top: var(--ah-sticky-top, 0px); z-index: 20; background: var(--surface); padding-top: 6px; margin-top: -6px; }

/* Headline totals */
#action-history .ah-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
#action-history .ah-tile { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; min-width: 0; }
#action-history .ah-tile .v { font-size: 1.05rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#action-history .ah-tile .l { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
@media (max-width: 640px) { #action-history .ah-totals { grid-template-columns: repeat(2, 1fr); } }

/* Collapsible summary cards: title and total, tap to open */
#ah-summary .ah-sec-head { cursor: pointer; user-select: none; }
#ah-summary .ah-sec-head .ah-caret { display: inline-block; width: 12px; color: var(--accent); transition: transform .15s; transform: rotate(90deg); }
#ah-summary .ah-sec.ah-collapsed .ah-sec-head .ah-caret { transform: none; }
#ah-summary .ah-sec.ah-collapsed .ah-sec-head { border-bottom: none; }
#ah-summary .ah-sec.ah-collapsed .ah-sec-body { display: none; }
#ah-summary .ah-sec-total { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; font-size: 0.82rem; }
#ah-summary .ah-sec.ah-collapsed { flex: 0 0 auto; }
#ah-dt .dt-compact.dt-cards td.ah-msg { flex-basis: 100%; }
/* .card clips overflow on phones; "clip" keeps that without making the card a
   scroll container, so the sticky picker can still stick to the page. */
#s-log { overflow: clip; }

/* Activity Log top tabs: Text Log | Database */
#s-log .log-tabs { margin-bottom: 12px; }

/* Quick category filters above the table */
#action-history .ah-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
#action-history .ah-chip { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; width: auto; }
#action-history .ah-chip:hover { color: var(--text); border-color: var(--accent); }
#action-history .ah-chip.on { background: rgba(200,168,75,.15); color: var(--accent); border-color: var(--accent); }

/* Import logs: button at the bottom, form in an overlay */
#action-history .ah-import-foot { display: flex; justify-content: flex-end; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
#ah-import-overlay .ah-import-box { max-width: 720px; max-height: 90vh; overflow-y: auto; }
#ah-import-overlay .ah-import-box > div.ah-import-head { display: flex; justify-content: space-between; align-items: center; }
#ah-import-overlay .ah-import-box > div.ah-import-bar { justify-content: flex-start; }
#ah-import-overlay .ah-range { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; justify-content: flex-start; }
#ah-import-overlay .ah-range label { flex: 0 0 auto; min-width: 0; }
#ah-import-overlay .ah-range input[type=date] { width: 160px; }
#ah-import-overlay .ah-range .ah-note { margin: 0 0 6px; }
#ah-import-overlay .ah-log-list { max-height: 40vh; overflow-y: auto; margin-bottom: 0; }
#ah-import-overlay #imp-status:empty, #ah-import-overlay #imp-result:empty { display: none; }
body.ah-modal-open { overflow: hidden; }
@media (max-width: 640px) {
  #ah-import-overlay .ah-import-box { width: 96%; padding: 16px; }
  #ah-import-overlay .ah-range label { flex: 1 1 140px; }
  #ah-import-overlay .ah-range input[type=date] { width: 100%; }
}
#ah-import-overlay .ah-import-box > div.ah-log-list, #ah-import-overlay .ah-import-box > #imp-result, #ah-import-overlay .ah-import-box > #imp-status { display: block; }
@media (max-width: 640px) { #ah-import-overlay .ah-import-bar input[type=text] { width: 100%; } }
#imp-logs td:nth-child(2), #imp-logs td.num { white-space: nowrap; }
@media (max-width: 640px) { #ah-import-overlay table.ah-table th:last-child, #imp-logs td:last-child { white-space: normal; } }
#ah-import-overlay .ah-import-box > #imp-status:empty, #ah-import-overlay .ah-import-box > #imp-result:empty { display: none; }
