/* RISEN IT Support — components. */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--gray-800); --btn-bd: var(--border-strong); --btn-bg-h: var(--gray-50);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 36px; padding: 0 var(--sp-4);
  font-size: var(--fs-14); font-weight: 560; line-height: 1; white-space: nowrap;
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd); border-radius: var(--r-sm);
  box-shadow: var(--sh-xs); cursor: pointer; text-decoration: none; user-select: none;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.btn:hover { background: var(--btn-bg-h); color: var(--btn-fg); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-bd: var(--primary); --btn-bg-h: var(--primary-hover); box-shadow: 0 1px 2px rgba(29, 78, 216, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { border-color: var(--primary-hover); }
.btn-secondary { --btn-bg: var(--surface); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-bg-h: var(--surface-hover); --btn-fg: var(--gray-700); box-shadow: none; }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-bd: var(--red-200); --btn-bg-h: var(--danger-soft); }
.btn-danger-solid { --btn-bg: var(--danger); --btn-fg: var(--white); --btn-bd: var(--danger); --btn-bg-h: var(--red-800); }
:root[data-theme="dark"] .btn-danger-solid { --btn-bg: #dc2626; --btn-bd: #dc2626; --btn-bg-h: #b91c1c; }
.btn-note { --btn-bg: var(--amber-50); --btn-fg: var(--amber-800); --btn-bd: var(--amber-300); --btn-bg-h: var(--amber-100); }
.btn-sm { min-height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-13); }
.btn-lg { min-height: 44px; padding: 0 var(--sp-5); font-size: var(--fs-15); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 36px; }
.btn-icon.btn-sm { width: 30px; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--btn-fg) transparent var(--btn-fg) transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
.form { display: block; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-5); min-width: 0; }
.field > span, .field-label { font-weight: 560; font-size: var(--fs-13); color: var(--gray-800); }
.field > span .muted, .field-label .muted { font-weight: 400; }
fieldset.field { border: 0; padding: 0; margin: 0 0 var(--sp-5); }
fieldset.field > legend { padding: 0; margin-bottom: var(--sp-2); font-weight: 560; font-size: var(--fs-13); color: var(--gray-800); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 12px;
  font-size: var(--fs-14); line-height: 1.4; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  box-shadow: var(--sh-xs);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--gray-400); }
input:hover, select:hover, textarea:hover { border-color: var(--gray-400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gray-500) 50%), linear-gradient(135deg, var(--gray-500) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
select[size], select[multiple] { background-image: none; padding: 4px; min-height: 0; }
select[size] option { padding: 6px 8px; border-radius: 4px; }
textarea { resize: vertical; min-height: 120px; line-height: var(--lh); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
input[type=file] { font-size: var(--fs-13); max-width: 100%; }
.hint { color: var(--text-muted); font-size: var(--fs-12); line-height: 1.45; }
.error { color: var(--danger); font-size: var(--fs-12); font-weight: 500; display: flex; gap: 4px; align-items: flex-start; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.has-error input:focus, .has-error select:focus, .has-error textarea:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .18); }
.check { display: flex; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-4); cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-5); }
.input-icon { position: relative; display: block; }
.input-icon > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.input-icon > input { padding-left: 36px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }
.password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 34px; display: inline-grid; place-items: center;
  border: 0; background: transparent; color: var(--gray-500); border-radius: var(--r-sm); cursor: pointer;
}
.password-toggle:hover { color: var(--gray-800); background: var(--surface-hover); }
.password-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.form-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; align-items: center; flex-wrap: wrap; padding-top: var(--sp-5); margin-top: var(--sp-2); border-top: 1px solid var(--border); }
.filter-input { margin-bottom: var(--sp-2); }

/* Choice cards (priority) and segmented options (issue type) — native radios, styled */
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice-body {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: var(--sp-3) var(--sp-3) var(--sp-3) 38px; position: relative;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--sh-xs); transition: border-color var(--t) var(--ease), background var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.choice-body::before {
  content: ""; position: absolute; left: 13px; top: 15px; width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--gray-400); background: var(--surface); transition: border var(--t) var(--ease);
}
.choice-title { font-weight: 600; font-size: var(--fs-14); color: var(--gray-900); }
.choice-sub { font-size: var(--fs-12); color: var(--text-muted); }
.choice:hover .choice-body { border-color: var(--gray-400); }
.choice input:checked + .choice-body { border-color: var(--primary); background: var(--primary-softer); box-shadow: 0 0 0 1px var(--primary); }
.choice input:checked + .choice-body::before { border: 4.5px solid var(--primary); }
.choice input:focus-visible + .choice-body { box-shadow: var(--focus-ring); }
.choice .prio-dot { position: absolute; right: 12px; top: 14px; width: 8px; height: 8px; border-radius: 50%; }
.segmented { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.segmented .seg { position: relative; }
.segmented .seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmented .seg span {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 38px; padding: 0 var(--sp-4);
  border: 1px solid var(--border-strong); border-radius: var(--r-full); background: var(--surface);
  font-weight: 540; font-size: var(--fs-13); color: var(--gray-700); box-shadow: var(--sh-xs); cursor: pointer;
  transition: all var(--t) var(--ease);
}
.segmented .seg span .icon { width: 16px; height: 16px; color: var(--gray-500); }
.segmented .seg:hover span { border-color: var(--gray-400); }
.segmented .seg input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--blue-800); box-shadow: 0 0 0 1px var(--primary); }
.segmented .seg input:checked + span .icon { color: var(--primary); }
.segmented .seg input:focus-visible + span { box-shadow: var(--focus-ring); }

/* File drop zone + chips */
.dropzone {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-sunken); color: var(--text-muted); transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-softer); }
.dropzone .dz-icon { width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--primary); flex: none; box-shadow: var(--sh-xs); }
.dropzone .dz-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dropzone .dz-text strong { color: var(--gray-800); font-weight: 560; font-size: var(--fs-13); }
.dropzone .dz-text strong u { color: var(--primary); text-decoration: none; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone input[type=file]:focus-visible ~ .dz-text strong { text-decoration: underline; }
.dropzone:focus-within { box-shadow: var(--focus-ring); border-color: var(--primary); }
.file-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); list-style: none; padding: 0; }
.file-chips:empty { display: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); padding: var(--sp-6); margin-bottom: var(--sp-5); min-width: 0;
}
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h2 { font-size: var(--fs-15); font-weight: 600; margin: 0; display: flex; align-items: center; gap: var(--sp-2); }
.card-flush { padding: 0; overflow: hidden; }
.section-title { font-size: var(--fs-12); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--text-muted); margin: 0 0 var(--sp-3); }

/* ---------- Page header + breadcrumbs ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head h1 { margin: 0; }
.page-head p { margin: var(--sp-1) 0 0; color: var(--text-muted); }
.page-head > div { min-width: 0; }
.page-head .actions { align-self: center; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-13); color: var(--text-muted); margin: 0; padding: 0; list-style: none; min-width: 0; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.breadcrumbs li + li::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--gray-400); border-top: 1.5px solid var(--gray-400); transform: rotate(45deg); margin-right: 4px; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs [aria-current] { color: var(--gray-900); font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.back { font-size: var(--fs-13); display: inline-flex; align-items: center; gap: 4px; margin-bottom: var(--sp-3); }

/* ---------- Alerts + toasts ---------- */
.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4);
  border: 1px solid transparent; font-size: var(--fs-14); line-height: 1.5;
}
.alert > .icon { margin-top: 2px; }
.alert ul { margin: var(--sp-2) 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--success-soft); border-color: var(--green-200); color: var(--green-700); }
.alert-error { background: var(--danger-soft); border-color: var(--red-200); color: var(--red-800); }
.alert-info { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-800); }
.alert-warning { background: var(--amber-50); border-color: var(--amber-200); color: var(--amber-800); }
.alert-body { flex: 1; min-width: 0; }
.toasts { position: fixed; z-index: 80; right: var(--sp-5); top: calc(var(--topbar-h) + var(--sp-3)); display: flex; flex-direction: column; gap: var(--sp-2); width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-3);
  background: var(--surface-raised); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--r-md); box-shadow: var(--sh-lg); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  animation: toast-in 220ms var(--ease);
}
.toast-success { border-left-color: var(--success); }
.toast-success > .icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error > .icon { color: var(--danger); }
.toast-info > .icon { color: var(--primary); }
.toast .alert-body { padding-top: 1px; color: var(--gray-800); }
.toast-live .toast-link { font-weight: 560; word-break: break-word; }
.toast-close { flex: none; width: 28px; height: 28px; border: 0; background: transparent; color: var(--gray-500); border-radius: var(--r-sm); cursor: pointer; display: grid; place-items: center; }
.toast-close:hover { background: var(--surface-hover); color: var(--gray-900); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: all 200ms var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Badges ---------- */
.badge {
  --b-bg: var(--slate-100); --b-fg: var(--slate-600); --b-dot: currentColor;
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  min-height: 22px; padding: 1px 9px; border-radius: var(--r-full);
  font-size: var(--fs-12); font-weight: 560; line-height: 1.35; white-space: nowrap; vertical-align: middle;
  background: var(--b-bg); color: var(--b-fg); border: 1px solid transparent;
}
.badge-dot::before, .badge[class*="status-"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--b-dot); flex: none; }
.status-open { --b-bg: var(--blue-100); --b-fg: var(--blue-700); --b-dot: var(--blue-600); }
.status-in_progress { --b-bg: var(--purple-50); --b-fg: var(--purple-700); }
.status-in_uat { --b-bg: var(--teal-50); --b-fg: var(--teal-700); }
.status-waiting_deploy { --b-bg: var(--orange-50); --b-fg: var(--orange-700); --b-dot: var(--orange-700); }
.status-awaiting_approval { --b-bg: var(--amber-75); --b-fg: var(--amber-800); --b-dot: var(--amber-700); }
.status-resolved { --b-bg: var(--green-50); --b-fg: var(--green-600); }
.status-closed { --b-bg: var(--slate-100); --b-fg: var(--slate-600); }
.status-correction_needed { --b-bg: var(--pink-50); --b-fg: var(--pink-700); }
.status-waiting { --b-bg: var(--gray-100); --b-fg: var(--gray-500); font-style: italic; }
.prio-low { --b-bg: var(--slate-100); --b-fg: var(--slate-600); }
.prio-medium { --b-bg: var(--sky-50); --b-fg: var(--sky-800); }
.prio-high { --b-bg: var(--orange-50); --b-fg: var(--orange-700); }
.prio-urgent { --b-bg: var(--red-50); --b-fg: var(--red-700); }
.prio-dot.prio-low { background: var(--gray-400); }
.prio-dot.prio-medium { background: var(--sky-800); }
.prio-dot.prio-high { background: var(--orange-700); }
.prio-dot.prio-urgent { background: var(--red-700); }
.badge[class*="prio-"] .icon { width: 12px; height: 12px; }
.source-web { --b-bg: var(--slate-100); --b-fg: var(--slate-600); }
.source-email { --b-bg: var(--teal-25); --b-fg: var(--teal-650); }
.source-chat { --b-bg: var(--purple-50); --b-fg: var(--purple-700); }
.badge-outline { background: var(--surface); border-color: var(--border-strong); color: var(--gray-700); }
.badge-muted { --b-bg: var(--slate-100); --b-fg: var(--slate-600); }
.badge-ok { --b-bg: var(--green-50); --b-fg: var(--green-600); }
.badge-warn { --b-bg: var(--amber-75); --b-fg: var(--amber-800); }
.badge-it { --b-bg: var(--blue-100); --b-fg: var(--blue-700); }
.badge-internal { --b-bg: var(--amber-100); --b-fg: var(--amber-800); }
.badge .icon { width: 12px; height: 12px; }
.badges { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.sla { display: block; font-size: var(--fs-12); color: var(--text-muted); margin-top: 3px; white-space: nowrap; }
.prio-stack { display: inline-flex; flex-direction: column; align-items: flex-start; }
.role-chip { display: inline-flex; align-items: center; padding: 0 7px; min-height: 18px; border-radius: var(--r-full); font-size: 11px; font-weight: 600; letter-spacing: .01em; background: var(--blue-100); color: var(--blue-700); white-space: nowrap; }
.role-chip.role-employee { background: var(--slate-100); color: var(--slate-600); }
.role-chip.role-it_admin { background: var(--purple-50); color: var(--purple-700); }

/* ---------- Avatars (deterministic palette tint per name) ---------- */
.avatar {
  --av-bg: var(--blue-100); --av-fg: var(--blue-700);
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--av-bg); color: var(--av-fg);
  font-size: 12px; font-weight: 650; letter-spacing: .02em; line-height: 1; user-select: none;
  box-shadow: inset 0 0 0 1px rgba(15, 27, 51, .06);
}
.avatar-xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.av-0 { --av-bg: var(--blue-100); --av-fg: var(--blue-700); }
.av-1 { --av-bg: var(--purple-50); --av-fg: var(--purple-700); }
.av-2 { --av-bg: var(--teal-50); --av-fg: var(--teal-700); }
.av-3 { --av-bg: var(--amber-75); --av-fg: var(--amber-800); }
.av-4 { --av-bg: var(--green-50); --av-fg: var(--green-600); }
.av-5 { --av-bg: var(--pink-50); --av-fg: var(--pink-700); }
.av-6 { --av-bg: var(--sky-50); --av-fg: var(--sky-800); }
.av-7 { --av-bg: var(--orange-50); --av-fg: var(--orange-700); }
.av-none { --av-bg: var(--gray-100); --av-fg: var(--gray-500); }
.person { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.person-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.person-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-name { font-weight: 560; color: var(--gray-900); }
.person-sub { font-size: var(--fs-12); color: var(--text-muted); }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); overflow-x: auto; margin-bottom: var(--sp-5); max-width: 100%;
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-14); }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-sunken); font-size: var(--fs-12); font-weight: 600; letter-spacing: .02em;
  color: var(--text-muted); white-space: nowrap; text-transform: none;
}
.table thead th:first-child { border-top-left-radius: var(--r-lg); }
.table thead th:last-child { border-top-right-radius: var(--r-lg); }
.table tbody tr { transition: background var(--t) var(--ease); }
.table tbody tr:hover { background: var(--gray-25); }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tr.inactive td { color: var(--text-muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.cell-subject { max-width: 0; width: 38%; }
.table .t-link { color: var(--gray-900); font-weight: 560; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .t-link:hover { color: var(--primary); text-decoration: none; }
.table .t-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; font-size: var(--fs-12); color: var(--text-muted); min-width: 0; overflow: hidden; white-space: nowrap; }
.table .t-meta .badge { min-height: 18px; font-size: 11px; padding: 0 7px; }
.table .ticket-no { font-family: var(--mono); font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin: 0 0 var(--sp-3); flex-wrap: wrap; }
.table-count { color: var(--text-muted); font-size: var(--fs-13); }

/* ---------- Pagination ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); margin: var(--sp-4) 0; flex-wrap: wrap; }
.pager .muted { font-size: var(--fs-13); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) 10px; color: var(--text-muted); font-weight: 560; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current], .tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.stat {
  position: relative; display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); color: var(--text); overflow: hidden;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
a.stat:hover { border-color: var(--blue-200); box-shadow: var(--sh-md); transform: translateY(-1px); text-decoration: none; color: var(--text); }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--blue-100); color: var(--blue-700); }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-text { display: flex; flex-direction: column; min-width: 0; }
.stat-n { font-size: var(--fs-28); font-weight: 680; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--gray-900); }
.stat-l { color: var(--text-muted); font-size: var(--fs-13); font-weight: 500; }
.stat-go { position: absolute; right: 14px; top: 14px; color: var(--gray-300); transition: color var(--t) var(--ease), transform var(--t) var(--ease); }
a.stat:hover .stat-go { color: var(--primary); transform: translateX(2px); }
.stat-unassigned .stat-icon { background: var(--amber-75); color: var(--amber-700); }
.stat-mine .stat-icon { background: var(--teal-50); color: var(--teal-700); }
.stat-urgent .stat-icon { background: var(--red-50); color: var(--red-700); }
.stat-urgent .stat-n { color: var(--red-700); }

/* ---------- Empty states + skeletons ---------- */
.empty { text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--text-muted); }
.empty-art { width: 120px; height: 90px; margin: 0 auto var(--sp-4); display: block; }
.empty h2, .empty h3 { font-size: var(--fs-16); color: var(--gray-900); margin-bottom: var(--sp-1); }
.empty p { max-width: 420px; margin: 0 auto var(--sp-4); }
.skeleton { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 37%, var(--gray-100) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; min-height: 12px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Tooltips (CSS, from data-tip) ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  background: var(--navy-900); color: var(--white); font-size: var(--fs-12); font-weight: 500; line-height: 1.3;
  padding: 5px 8px; border-radius: var(--r-sm); white-space: nowrap; box-shadow: var(--sh-md); z-index: 60; pointer-events: none;
}

/* ---------- Dialog (confirmations) ---------- */
dialog.modal {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); background: var(--surface); color: var(--text);
}
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: toast-in 180ms var(--ease); }
.modal-body { display: flex; gap: var(--sp-4); padding: var(--sp-6) var(--sp-6) var(--sp-4); }
.modal-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--danger-soft); color: var(--danger); }
.modal-body h2 { font-size: var(--fs-16); margin-bottom: var(--sp-1); }
.modal-body p { color: var(--text-muted); margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); background: var(--surface-sunken); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Definition list (properties) ---------- */
dl.meta { margin: 0; display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 12px var(--sp-4); align-items: center; }
dl.meta dt { font-size: var(--fs-13); color: var(--text-muted); font-weight: 500; }
dl.meta dd { margin: 0; min-width: 0; font-size: var(--fs-13); color: var(--gray-900); overflow-wrap: anywhere; }

/* ---------- Attachments ---------- */
.files { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.file-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2); max-width: 100%; min-height: 40px;
  padding: 5px var(--sp-3) 5px 6px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  color: var(--gray-800); box-shadow: var(--sh-xs); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
a.file-chip:hover, .file-chip a:hover { text-decoration: none; }
.file-chip:hover { border-color: var(--blue-200); box-shadow: var(--sh-sm); }
.file-chip .file-type { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; background: var(--blue-100); color: var(--blue-700); }
.file-chip .file-type.ft-image { background: var(--purple-50); color: var(--purple-700); }
.file-chip .file-type.ft-pdf { background: var(--red-50); color: var(--red-700); }
.file-chip .file-type.ft-sheet { background: var(--green-50); color: var(--green-600); }
.file-chip .file-type .icon { width: 15px; height: 15px; }
.file-chip .file-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.file-chip .file-name { font-size: var(--fs-13); font-weight: 540; color: var(--gray-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.file-chip .file-size { font-size: 11.5px; color: var(--text-muted); }
.file-chip .file-view { font-size: var(--fs-12); font-weight: 560; margin-left: var(--sp-1); }
.file-chip .chip-remove { border: 0; background: transparent; color: var(--gray-500); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; margin-left: 2px; }
.file-chip .chip-remove:hover { background: var(--surface-hover); color: var(--danger); }
.file-thumb { display: block; width: 168px; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface-sunken); box-shadow: var(--sh-xs); }
.file-thumb img { display: block; width: 100%; height: 104px; object-fit: cover; }
.file-thumb span { display: flex; justify-content: space-between; gap: var(--sp-2); padding: 6px var(--sp-2); font-size: 11.5px; color: var(--gray-700); background: var(--surface); border-top: 1px solid var(--border); }
.file-thumb span b { font-weight: 540; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-ext { font-size: 10.5px; font-weight: 700; background: var(--gray-100); color: var(--gray-700); border-radius: 4px; padding: 1px 5px; letter-spacing: .02em; }

/* ---------- Conversation timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.timeline > li { margin: 0; }
.tl-event { display: flex; justify-content: center; }
.tl-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; max-width: 100%;
  padding: 5px var(--sp-3); border-radius: var(--r-full); background: var(--gray-100); border: 1px solid var(--gray-150);
  font-size: var(--fs-12); color: var(--text-subtle); text-align: center; line-height: 1.45;
}
.tl-pill strong { color: var(--gray-800); font-weight: 600; }
.tl-pill .icon { width: 13px; height: 13px; color: var(--gray-500); }
.tl-pill time { color: var(--text-muted); }
.tl-pill .badge { min-height: 18px; font-size: 11px; padding: 0 7px; }
.comment { display: flex; gap: var(--sp-3); align-items: flex-start; }
.comment-card {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg);
  padding: var(--sp-3) var(--sp-4) var(--sp-4); box-shadow: var(--sh-xs);
}
.comment.from-it .comment-card { background: var(--blue-50); border-color: var(--blue-100); }
.comment.internal .comment-card { background: var(--amber-50); border-color: var(--amber-200); border-style: dashed; }
.comment-head { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-bottom: 6px; min-width: 0; }
.comment-head strong { font-weight: 600; color: var(--gray-900); }
.comment-head time { margin-left: auto; font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; }
.internal-label { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-12); font-weight: 600; color: var(--amber-800); }
.internal-label .icon { width: 13px; height: 13px; }
.comment .prose { color: var(--gray-800); }
.comment .files { margin-top: var(--sp-3); }
.timeline-empty { text-align: center; padding: var(--sp-6) 0 var(--sp-2); color: var(--text-muted); }

/* ---------- Misc shared ---------- */
.nav-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full);
  background: var(--badge-red); color: var(--white); font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.copyable { background: var(--surface); border: 1px dashed var(--green-200); border-radius: var(--r-sm); padding: 2px 8px; user-select: all; font-family: var(--mono); }
.error-code { font-size: 56px; font-weight: 750; letter-spacing: -.03em; color: var(--primary); margin: 0 0 var(--sp-2); line-height: 1; }
.inline-search { display: flex; gap: var(--sp-2); align-items: flex-end; }
.inline-search .field { flex: 1; margin-bottom: var(--sp-3); }
.inline-search .btn { margin-bottom: var(--sp-3); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: var(--sp-4); border-radius: var(--r-md); }
  .stats { gap: var(--sp-3); }
  .stat { padding: var(--sp-4); gap: var(--sp-3); }
  .stat-icon { width: 38px; height: 38px; border-radius: 10px; }
  .stat-n { font-size: var(--fs-24); }
  .stat-go { display: none; }
  .page-head { margin-bottom: var(--sp-5); }
  h1 { font-size: var(--fs-20); }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .toasts { right: 16px; left: 16px; width: auto; }
  dl.meta { grid-template-columns: minmax(90px, auto) 1fr; }
  input[type=text], input[type=email], input[type=password], input[type=search], select, textarea { min-height: 44px; font-size: 16px; }
}
.cat-chip { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-12); color: var(--text-subtle); font-weight: 500; white-space: nowrap; }
.cat-chip .icon { color: var(--gray-400); }
.badges .cat-chip { padding: 1px 9px; min-height: 22px; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); }
.empty-art .ea-back { fill: var(--blue-50); stroke: var(--blue-100); }
.empty-art .ea-card { fill: var(--surface); stroke: var(--gray-200); }
.empty-art .ea-line { fill: var(--gray-200); }
.empty-art .ea-dot { fill: var(--blue-300); }
.empty-art .ea-dot2 { fill: var(--gray-300); }
.empty-art .ea-badge { fill: var(--blue-600); }
.empty-art .ea-check { fill: none; stroke: var(--white); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.password-toggle .when-shown, .password-toggle[aria-pressed="true"] .when-hidden { display: none; }
.password-toggle[aria-pressed="true"] .when-shown { display: inline-block; }
.alert-body a, .toast a, .prose a { text-decoration: underline; text-underline-offset: 2px; font-weight: 560; }

/* ---------- Chips (reason, audit action, email result): icon + text, tone from the palette ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 9px; border-radius: var(--r-full); font-size: var(--fs-12); font-weight: 600; line-height: 1; white-space: nowrap; background: var(--chip-bg); color: var(--text-subtle); }
.chip .icon { flex: none; }
.chip-ok { background: var(--green-50); color: var(--green-700); }
.chip-info { background: var(--blue-100); color: var(--blue-700); }
.chip-warn { background: var(--amber-75); color: var(--amber-800); }
.chip-danger { background: var(--red-50); color: var(--red-800); }
.chip-muted { background: var(--slate-100); color: var(--slate-600); }
.src { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); font-weight: 560; }
.src-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.sk { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--gray-150) 25%, var(--gray-100) 50%, var(--gray-150) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
