/* ============================================================
   ASSH Management Agent — App chrome
   Restrained ASSH styling: neutral gray chrome + navy/teal accents.
   Linear-density internal tool look.
   ============================================================ */

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  color: #1a1d21;
  background: #fafbfc;
  -webkit-font-smoothing: antialiased;
}

/* App shell ---------------------------------------------------- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}
.app__scroll {
  flex: 1;
  overflow: auto;
}
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 40px 80px;
}
.page--wide { max-width: 1280px; }

/* Page header ------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid #eceef1;
}
.page-header__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  line-height: 28px;
  color: #0c1116;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-header__sub {
  font-size: 13px;
  color: #6b7480;
  margin: 0;
}
.page-header__actions { display: flex; gap: 8px; align-items: center; }

/* Breadcrumb / tab nav under header */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #eceef1;
  margin: -24px 0 24px;
  padding-bottom: 0;
}
.tabs__tab {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  color: #6b7480;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur-fast) var(--ease-std);
}
.tabs__tab:hover { color: #1a1d21; }
.tabs__tab--active { color: var(--accent-color, var(--assh-teal)); border-bottom-color: var(--accent-color, var(--assh-teal)); }

/* Buttons ----------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  line-height: 16px;
  color: #1a1d21;
  background: #fff;
  border: 1px solid #d9dde2;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  height: 32px;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-std), border-color var(--dur-fast) var(--ease-std), color var(--dur-fast) var(--ease-std);
}
.btn:hover { background: #f5f7f9; border-color: #c5cbd2; }
.btn:focus-visible { outline: 2px solid var(--accent-color, var(--assh-teal)); outline-offset: 1px; }

.btn--primary {
  background: var(--accent-color, var(--assh-teal));
  color: #fff;
  border-color: transparent;
}
.btn--primary:hover {
  background: var(--accent-color-dark, var(--assh-teal-dark));
  border-color: transparent;
}

.btn--ghost { background: transparent; border-color: transparent; color: #475260; }
.btn--ghost:hover { background: #f0f2f5; }

.btn--danger {
  color: var(--assh-ui-red-dark);
  border-color: #f1c8cb;
  background: #fff;
}
.btn--danger:hover { background: var(--assh-ui-red-light); border-color: var(--assh-ui-red); }

.btn--danger-solid {
  background: var(--assh-ui-red);
  color: #fff;
  border-color: transparent;
}
.btn--danger-solid:hover { background: var(--assh-ui-red-dark); }

.btn--warning {
  color: #7a5d10;
  border-color: #f3d77a;
  background: #fffbeb;
}
.btn--warning:hover { background: #fef3c7; border-color: #eab308; }
[data-theme="dark"] .btn--warning {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}
[data-theme="dark"] .btn--warning:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.55);
}

.btn--sm { height: 26px; padding: 4px 9px; font-size: 12px; }
.btn--lg { height: 38px; padding: 10px 16px; font-size: 14px; }
.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 26px; }

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Form controls ---------------------------------------------- */
.input, .textarea, .select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  color: #1a1d21;
  background: #fff;
  border: 1px solid #d9dde2;
  border-radius: 6px;
  padding: 7px 11px;
  transition: border-color var(--dur-fast) var(--ease-std), box-shadow var(--dur-fast) var(--ease-std);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent-color, var(--assh-teal));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent-color, var(--assh-teal)) 18%, transparent);
}
.textarea { padding: 10px 12px; line-height: 22px; resize: vertical; min-height: 110px; }
.input--lg { padding: 10px 12px; font-size: 15px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field__label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  color: #1a1d21;
}
.field__hint { font-size: 12px; color: #6b7480; margin-top: 2px; }
.field__row { display: flex; gap: 10px; align-items: center; }

/* Toggle ----------------------------------------------------- */
.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle__track {
  position: absolute; inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease-std);
  cursor: pointer;
}
.toggle__track::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform var(--dur-fast) var(--ease-std);
}
.toggle input:checked + .toggle__track { background: var(--accent-color, var(--assh-teal)); }
.toggle input:checked + .toggle__track::before { transform: translateX(14px); }
.toggle--lg { width: 42px; height: 24px; }
.toggle--lg .toggle__track::before { width: 20px; height: 20px; }
.toggle--lg input:checked + .toggle__track::before { transform: translateX(18px); }

/* Checkbox & radio --- minimal ----- */
.checkbox, .radio {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid #c5cbd2;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--dur-fast) var(--ease-std), background var(--dur-fast) var(--ease-std);
}
.radio { border-radius: 50%; }
.checkbox:checked, .radio:checked {
  background: var(--accent-color, var(--assh-teal));
  border-color: var(--accent-color, var(--assh-teal));
}
.checkbox:checked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'><path d='M3.5 8.5l3 3 6-7' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/12px no-repeat;
}
.radio:checked::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Card ------------------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid #eceef1;
  border-radius: 8px;
  overflow: hidden;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #eceef1;
}
.card__header h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  color: #1a1d21;
  margin: 0;
}
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__footer {
  padding: 12px 18px;
  border-top: 1px solid #eceef1;
  background: #fafbfc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Chip / tag ------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 11.5px;
  line-height: 14px;
  padding: 3px 8px;
  background: #f0f2f5;
  color: #475260;
  border-radius: 4px;
}
.chip--teal { background: var(--assh-teal-c); color: var(--assh-teal-dark); }
.chip--blue { background: var(--assh-blue-c); color: var(--assh-blue-dark); }
.chip--green { background: var(--assh-green-c); color: #5b6b30; }
.chip--purple { background: var(--assh-ui-purple-light); color: var(--assh-ui-purple-dark); }
.chip--pink { background: var(--assh-ui-pink-light); color: var(--assh-ui-pink-dark); }
.chip--yellow { background: var(--assh-ui-yellow-light); color: var(--assh-ui-yellow-dark); }
.chip--red { background: var(--assh-ui-red-light); color: var(--assh-ui-red-dark); }
.chip--dot::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* Status dot ------------------------------------------------- */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #9FA8AF;
  flex-shrink: 0;
}
.dot--pulse {
  position: relative;
  background: var(--assh-ui-green);
}
.dot--pulse::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--assh-ui-green);
  opacity: 0.35;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.4; }
  100% { transform: scale(2.2); opacity: 0; }
}
.dot--yellow { background: var(--assh-ui-yellow); }
.dot--red { background: var(--assh-ui-red); }
.dot--gray { background: #9FA8AF; }
.dot--teal { background: var(--assh-teal); }

/* Modal ------------------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 33, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: backdrop-in 140ms var(--ease-std);
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff;
  border-radius: 10px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 48px rgba(15, 23, 33, 0.20);
  animation: modal-in 180ms var(--ease-std);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal__header { padding: 20px 22px 0; }
.modal__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  margin: 0 0 6px;
  color: #0c1116;
}
.modal__body { padding: 8px 22px 20px; color: #475260; font-size: 13.5px; line-height: 20px; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid #eceef1;
  background: #fafbfc;
  border-radius: 0 0 10px 10px;
}

/* Status banner --------------------------------------------- */
.banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid #eceef1;
  background: #fff;
  margin-bottom: 24px;
}
.banner__icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.banner__title { font-family: var(--font-heading); font-weight: 700; font-size: 14px; color: #0c1116; margin: 0 0 2px; }
.banner__sub { font-size: 12.5px; color: #6b7480; margin: 0; }
.banner__cta { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.banner--active { border-color: #c8e6cd; background: linear-gradient(to right, #f1faf3, #fff 70%); }
.banner--active .banner__icon { background: #dcf2e1; color: var(--assh-ui-green-dark); }

.banner--paused { border-color: #fde2a8; background: linear-gradient(to right, #fff8e1, #fff 70%); }
.banner--paused .banner__icon { background: #fdecbf; color: var(--assh-ui-yellow-dark); }

.banner--dry { border-color: #c8dff1; background: linear-gradient(to right, #eef4fb, #fff 70%); }
.banner--dry .banner__icon { background: var(--assh-blue-c); color: var(--assh-blue-dark); }

/* Stat tile ------------------------------------------------- */
.stat {
  padding: 16px 18px;
  border: 1px solid #eceef1;
  border-radius: 8px;
  background: #fff;
}
.stat__label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7480;
  margin: 0 0 8px;
  font-family: var(--font-heading);
}
.stat__value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 26px;
  line-height: 30px;
  color: #0c1116;
  margin: 0;
  letter-spacing: -0.01em;
}
.stat__sub {
  font-size: 12px;
  color: #6b7480;
  margin: 6px 0 0;
}

/* Empty state ----------------------------------------------- */
.empty {
  text-align: center;
  padding: 56px 24px;
  border: 1px dashed #d9dde2;
  border-radius: 10px;
  background: #fafbfc;
}
.empty__icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--assh-teal-c);
  color: var(--assh-teal-dark);
  display: inline-flex;
  align-items: center; justify-content: center;
  margin-bottom: 16px;
}

/* Utility ---------------------------------------------------- */
.row { display: flex; gap: 8px; align-items: center; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: #6b7480; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 4px;
  background: #f0f2f5;
  border: 1px solid #e0e3e7;
  color: #475260;
}
.divider { height: 1px; background: #eceef1; margin: 16px 0; border: 0; }
.section-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7480;
  margin: 0 0 12px;
}

/* Scrollbar ------------------------------------------------- */
.app__scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.app__scroll::-webkit-scrollbar-thumb { background: #d9dde2; border-radius: 999px; border: 2px solid #fff; }
.app__scroll::-webkit-scrollbar-thumb:hover { background: #c5cbd2; }

/* Tooltip --------------------------------------------------- */
.tooltip {
  position: relative;
}
.tooltip__bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1d21;
  color: #fff;
  font-size: 11.5px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-std);
  z-index: 50;
}
.tooltip:hover .tooltip__bubble { opacity: 1; }

/* Loading state for submit buttons — hides label, centers spinner. */
.btn--loading { position: relative; pointer-events: none; opacity: 0.9; }
.btn--loading > * { visibility: hidden; }
.btn--loading::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Tooltip icon — info bubble that appears on hover/focus.
   Used by the Manual Triage button (and any future header icons
   that need an explanatory popover). Theme-aware via --bg-elevated.
   ============================================================ */
.tooltip-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--fg-muted-app, #6b7480);
  cursor: help;
  outline: none;
  transition: color var(--dur-fast, 120ms) var(--ease-std, ease);
}
.tooltip-icon:hover,
.tooltip-icon:focus { color: var(--fg-app, #1a1d21); }

.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  min-width: 220px;
  max-width: 320px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elevated, #1a1d21);
  color: var(--fg-app, #ffffff);
  border: 1px solid var(--bg-border-strong, #2f3741);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast, 120ms) var(--ease-std, ease),
              transform var(--dur-fast, 120ms) var(--ease-std, ease);
  z-index: 100;
}
.tooltip-icon:hover::after,
.tooltip-icon:focus::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Light theme — make the tooltip read clearly against a light page. */
:root .tooltip-icon::after {
  background: #1a1d21;
  color: #ffffff;
  border-color: #1a1d21;
}
[data-theme="dark"] .tooltip-icon::after {
  background: var(--bg-elevated, #161a1f);
  color: var(--fg-app, #e6e9ed);
  border-color: var(--bg-border-strong, #2f3741);
}
