/* App styles for the security portal. Everything here uses Crystal tokens;
   the shell and the components come from crystal/1.7.0/ and are not restyled. */

body { margin: 0; }
[hidden] { display: none !important; }

/* Sign-in page (Crystal template 8, from crystal-signin.html) */
.crystal-signin { min-height: 100vh; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px); background: var(--bg-canvas); color: var(--text-primary); font-family: var(--font-ui); font-size: 13px; line-height: 20px; }
.crystal-signin-brand { text-align: center; }
.crystal-signin-brand img { height: 24px; width: auto; display: block; margin: 0 auto; }
.crystal-signin-brand .crystal-brand-app { margin-top: 8px; font-size: 13.5px; line-height: 20px; color: var(--text-secondary); }
.crystal-signin-card { width: 100%; max-width: 400px; box-sizing: border-box; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 14px; padding: 28px; }
.crystal-signin-card .crystal-title { margin: 0; }
.crystal-signin-card .crystal-btn.primary { width: 100%; height: 44px; margin-top: 20px; border-radius: 12px; font-size: 13.5px; }
.crystal-signin-card .crystal-error-text { margin-top: 12px; }
.crystal-signin-foot { font-size: 11.5px; line-height: 16px; color: var(--text-tertiary); text-align: center; }
@media (max-width: 768px) {
  .crystal-signin { justify-content: flex-start; padding-top: calc(env(safe-area-inset-top, 0px) + 56px); }
  .crystal-signin-card { padding: 22px 18px; }
}

/* Small helpers */
.sec-center { text-align: center; margin-top: 14px; }
.sec-w-60 { width: 60%; }
.sec-list-head { padding: 0 2px; }
.sec-empty { color: var(--text-secondary); }
.sec-empty b { color: var(--text-primary); }

/* Status tones for pills (Crystal status tokens; the mapping is in app.js) */
.crystal-pill.tone-not-started { --tone: var(--status-not-started); }
.crystal-pill.tone-planned     { --tone: var(--status-planned); }
.crystal-pill.tone-in-progress { --tone: var(--status-in-progress); }
.crystal-pill.tone-in-review   { --tone: var(--status-in-review); }
.crystal-pill.tone-ready       { --tone: var(--status-ready); }
.crystal-pill.tone-done        { --tone: var(--status-done); }

/* Forms in drawers */
.sec-form { display: flex; flex-direction: column; gap: 16px; }
.sec-flush { margin: 0; }
.sec-check { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 16px; color: var(--text-primary); }
.sec-check input { margin: 1px 0 0; accent-color: var(--accent-default); }
.sec-foot-hint { margin: 0 auto 0 0; align-self: center; }
.sec-result-list { margin: 8px 0 0; padding-left: 18px; color: var(--text-secondary); }
.sec-result-list li { margin: 4px 0; }
.sec-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* Drawers sit outside the app root, so they set the base text style themselves. */
.crystal-drawer { font-family: var(--font-ui); font-size: 13px; line-height: 20px; color: var(--text-primary); }

/* Findings: search and filters. Selects size to their content on desktop and
   fold behind the Filters button on phones. */
.sec-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.sec-filter-top { display: flex; gap: 8px; flex: 1 1 220px; max-width: 320px; }
.sec-filter-search { flex: 1; min-width: 0; }
.sec-filter-search input { min-width: 0; width: 100%; }
.sec-field-icon { display: inline-flex; color: var(--text-tertiary); flex: none; }
.sec-filter-toggle, .sec-phone-only { display: none; }
.sec-filter-more { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 999 1 0; min-width: 0; }
.sec-filter-more .crystal-field.select { display: flex; }
.sec-filter-more .crystal-btn { flex-shrink: 0; }

/* Sortable column headers: the header text is a button. */
.sec-sort { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; border-radius: 7px; }
.sec-sort:hover { color: var(--text-primary); }
.sec-sort:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.sec-sort-mark { display: inline-block; width: 10px; color: var(--text-primary); }
.sec-findings tr[data-href] { cursor: pointer; }
.sec-findings tr[data-href]:hover td { background: var(--bg-inset); }
.sec-findings td a.crystal-id:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 6px; }
.sec-empty-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }

/* A finding as a list row: pills on the right, under the text on phones. */
.sec-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sec-row .sec-pills { flex: none; justify-content: flex-end; max-width: 50%; }
a.sec-row:hover .crystal-row-title { color: var(--accent-default); }

/* The finding drawer */
.sec-detail { display: flex; flex-direction: column; gap: 16px; }
.sec-detail > .crystal-skeleton { display: block; }
.sec-finding-title { margin: 0 0 8px; font-size: 14px; line-height: 20px; font-weight: 600; overflow-wrap: anywhere; }
.sec-next { display: flex; flex-direction: column; gap: 10px; }
.sec-next .crystal-hint, .sec-next .crystal-error-text { margin-top: 0; }
#finding-reasons { display: flex; flex-direction: column; gap: 4px; }
#finding-reasons:empty { display: none; }
#finding-reasons p { margin: 0; }
.sec-props { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.sec-props dt { color: var(--text-tertiary); font-size: 12px; line-height: 20px; }
.sec-props dd { margin: 0; overflow-wrap: anywhere; }
.sec-block { margin: 0; }
.sec-h { margin: 0 0 6px; font-size: 12.5px; line-height: 16px; font-weight: 600; color: var(--text-primary); }
.sec-prose { margin: 0; color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
.sec-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sec-items li { overflow-wrap: anywhere; }
.sec-accepted { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; overflow-wrap: anywhere; }
.sec-readonly { color: var(--text-secondary); overflow-wrap: anywhere; }
#drawer-finding .crystal-drawer-foot { align-items: center; }
#drawer-finding .crystal-drawer-foot:empty { display: none; }
#drawer-finding .crystal-panel-title:focus { outline: none; }

/* Multi-line field. Crystal 1.7.0 has no textarea, so this one is built from the field tokens. */
.crystal-field.sec-area { height: auto; padding: 8px 10px; align-items: stretch; }
.crystal-field.sec-area textarea { all: unset; flex: 1; min-height: 60px; font: inherit; color: inherit; white-space: pre-wrap; overflow-wrap: anywhere; resize: vertical; overflow: auto; }
.crystal-field input[type="date"] { min-height: 20px; }

@media (pointer: coarse) {
  .crystal-field.sec-area textarea { font-size: max(16px, 1em); }
}

@media (max-width: 768px) {
  /* Crystal 1.7.0 hides the last item of a KPI tile's header on phones to drop the target label. That also
     hides the verdict pill of a tile in the bad state, leaving a colored number with no word. Keep the pill. */
  .crystal-grid.kpi-strip .crystal-kpi-head > .crystal-pill:last-child { display: inline-flex; }
  .sec-list-head .crystal-panel-title { white-space: nowrap; }
  .sec-filters { display: block; }
  .sec-filter-top { max-width: none; }
  .sec-filter-toggle { display: inline-flex; }
  .sec-phone-only { display: block; }
  .sec-filter-more { display: none; margin-top: 8px; }
  .sec-filter-more.open { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; }
  .sec-filter-more > div { min-width: 0; }
  .sec-filter-more select { min-width: 0; width: 100%; box-sizing: border-box; text-overflow: ellipsis; }
  .sec-filter-more.open > .sec-phone-only { grid-column: 1 / -1; }
  .sec-filter-more .crystal-chip { justify-self: start; }
  .sec-filter-more .crystal-btn { justify-self: end; }
  .sec-row { flex-wrap: wrap; }
  .sec-row .sec-pills { flex: 1 1 100%; max-width: none; justify-content: flex-start; }
  .sec-finding-title { font-size: 15px; line-height: 22px; }
  .sec-h { font-size: 15px; line-height: 22px; }
  .sec-props dt { font-size: 13px; line-height: 22px; }
  .sec-next .sec-row-actions .crystal-btn { flex: 1 1 auto; }
}

/* An item with one action on its right (an evidence file and its Download button). */
.sec-items li.sec-item-action { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sec-items li.sec-item-action > div { min-width: 0; }
