/* letty — lty v2 stylesheet.
   Implements the 2026 redesign: Geist type, quiet chrome, dot-based status.
   White-label: only --lty-brand / --lty-brand-ink change per tenant.
   Supersedes the compiled design-system sheet (design/letty-design-system/). */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500&display=swap');

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --lty-brand: #15803D;            /* per-tenant accent (links, marks, active) */
  --lty-brand-ink: #166534;

  --lty-bg: #FAFAFA;
  --lty-surface: #FFFFFF;
  --lty-ink: #18181B;
  --lty-ink-2: #52525B;
  --lty-ink-3: #A1A1AA;
  --lty-line: #E9E9EB;
  --lty-line-2: #DEDEE1;

  --lty-ok: #16A34A;
  --lty-warn: #D97706;
  --lty-danger: #DC2626;
  --lty-ai: #7C3AED;

  --lty-font: 'Geist', -apple-system, "Segoe UI", sans-serif;
  --lty-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --lty-r: 8px;
  --lty-r-sm: 6px;
  --lty-shadow: 0 1px 2px rgba(24, 24, 27, .04);
  --lty-shadow-lg: 0 12px 48px rgba(24, 24, 27, .16);
}

/* ============================================================
   BASE
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: var(--lty-font);
  color: var(--lty-ink);
  background: var(--lty-bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.006em;
}
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; letter-spacing: inherit; }
a { color: inherit; text-decoration: none; }
svg { flex: none; }

/* status dot — the only status device in the system */
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 99px; background: var(--lty-ink-3); flex: none; }
.dot.ok { background: var(--lty-ok); }
.dot.warn { background: var(--lty-warn); }
.dot.danger { background: var(--lty-danger); }
.dot.ai { background: var(--lty-ai); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: .79rem; color: var(--lty-ink-2); white-space: nowrap; }
.status.strong { color: var(--lty-ink); }

.mono { font-family: var(--lty-mono); font-variant-numeric: tabular-nums; font-size: .79rem; }
.ref { font-family: var(--lty-mono); font-size: .72rem; color: var(--lty-ink-3); }
.muted { color: var(--lty-ink-2); }
.dim { color: var(--lty-ink-3); }

/* ============================================================
   SHELL
   ============================================================ */
.lty-app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.lty-sidebar {
  background: var(--lty-surface); border-right: 1px solid var(--lty-line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.lty-brandrow { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; }
.lty-mark, .lty-brandmark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--lty-brand); color: #fff;
  display: grid; place-items: center; font-size: .68rem; font-weight: 600; letter-spacing: .01em; flex: none;
}
.lty-brandmark--lg { width: 38px; height: 38px; font-size: .9rem; border-radius: 9px; }
.lty-brand-name { font-size: .86rem; font-weight: 600; line-height: 1.15; display: block; }
.lty-brand-sub { font-size: .68rem; color: var(--lty-ink-3); display: block; }

.lty-nav { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.lty-nav-label, .lty-nav-group-label { padding: 14px 10px 5px; font-size: .7rem; font-weight: 500; color: var(--lty-ink-3); }
.lty-nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 6px 10px; border-radius: var(--lty-r-sm);
  font-size: .83rem; color: var(--lty-ink-2);
}
.lty-nav-item:hover { background: var(--lty-bg); color: var(--lty-ink); }
.lty-nav-item.is-active { background: #F1F1F3; color: var(--lty-ink); font-weight: 500; }
.lty-nav-item__icon { display: grid; place-items: center; width: 16px; height: 16px; color: inherit; }
.lty-nav-item__count, .lty-nav-item .n {
  margin-left: auto; font-family: var(--lty-mono); font-size: .68rem; color: var(--lty-ink-3);
}
.lty-nav-item__count.alert, .lty-nav-item .n.alert { color: var(--lty-danger); }

.lty-userfoot { border-top: 1px solid var(--lty-line); display: flex; align-items: center; gap: 9px; padding: 12px 16px; }
.lty-avatar {
  width: 26px; height: 26px; border-radius: 99px; flex: none; background: #F1F1F3; color: var(--lty-ink-2);
  display: grid; place-items: center; font-size: .62rem; font-weight: 600;
}
.lty-userfoot-copy { min-width: 0; }
.lty-userfoot-name { font-size: .78rem; font-weight: 500; line-height: 1.2; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lty-userfoot-role { font-size: .66rem; color: var(--lty-ink-3); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lty-userfoot .lty-icon-btn { margin-left: auto; }

.lty-main { display: flex; flex-direction: column; min-width: 0; }
.lty-topbar {
  display: flex; align-items: center; gap: 14px; background: var(--lty-surface);
  border-bottom: 1px solid var(--lty-line); padding: 0 24px; height: 50px; position: sticky; top: 0; z-index: 20;
}
.lty-search {
  display: flex; align-items: center; gap: 8px; flex: 1; max-width: 400px;
  border: 1px solid var(--lty-line); border-radius: var(--lty-r);
  background: var(--lty-bg); padding: 6px 11px; color: var(--lty-ink-3);
}
.lty-search:focus-within { border-color: var(--lty-line-2); background: var(--lty-surface); }
.lty-search input { border: none; background: none; outline: none; flex: 1; font: inherit; font-size: .8rem; color: var(--lty-ink); min-width: 0; }
.lty-search input::placeholder { color: var(--lty-ink-3); }
.lty-search kbd { font-family: var(--lty-mono); font-size: .62rem; color: var(--lty-ink-3); border: 1px solid var(--lty-line); border-radius: 4px; padding: 1px 5px; background: var(--lty-surface); }
.lty-topbar-spacer { flex: 1; }
.lty-host { font-family: var(--lty-mono); font-size: .7rem; color: var(--lty-ink-3); }
.lty-icon-btn { position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--lty-r-sm); color: var(--lty-ink-2); }
.lty-icon-btn:hover { background: var(--lty-bg); color: var(--lty-ink); }
.lty-icon-btn--sm { width: 26px; height: 26px; }

.lty-content { padding: 28px 32px 64px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ============================================================
   PAGE HEADER  (legacy .page-header maps to the lty head)
   ============================================================ */
.lty-head, .page-header { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; }
.lty-crumb, .page-kicker { display: flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--lty-ink-3); margin-bottom: 7px; }
.lty-crumb a:hover { color: var(--lty-ink); }
.lty-head h1, .page-header-copy h2 { font-size: 1.3rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.page-header-copy p, .page-subheading, .form-intro { font-size: .8rem; color: var(--lty-ink-2); margin-top: 6px; max-width: 64ch; line-height: 1.55; }
.lty-head-meta { margin-left: auto; text-align: right; font-size: .76rem; color: var(--lty-ink-2); line-height: 1.7; }
.lty-head-meta b { font-weight: 600; color: var(--lty-ink); }
.lty-head-actions, .page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   BUTTONS
   ============================================================ */
.lty-btn, .button-link,
.form-card button[type="submit"], .stack button[type="submit"] {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 500;
  border-radius: var(--lty-r-sm); padding: 6px 13px; border: 1px solid transparent; white-space: nowrap;
  transition: background .12s, border-color .12s;
  cursor: pointer;
}
.lty-btn--primary,
.form-card button[type="submit"], .stack button[type="submit"] { background: var(--lty-ink); color: #fff; }
.lty-btn--primary:hover,
.form-card button[type="submit"]:hover, .stack button[type="submit"]:hover { background: #000; }
.lty-btn--ghost, .button-link { border-color: var(--lty-line-2); background: var(--lty-surface); color: var(--lty-ink); }
.lty-btn--ghost:hover, .button-link:hover { border-color: var(--lty-ink-3); }
.lty-btn--sm { padding: 4px 10px; font-size: .76rem; }
.lty-btn--lg { padding: 8px 16px; font-size: .84rem; justify-content: center; }
.button-link-danger { color: var(--lty-danger); }
.button-link-danger:hover { border-color: var(--lty-danger); }
.button-link-quiet { border-color: transparent; background: none; color: var(--lty-ink-2); }
.button-link-quiet:hover { color: var(--lty-ink); border-color: transparent; }
.inline-form { display: inline-flex; }
.lty-link { font-size: .78rem; font-weight: 500; color: var(--lty-brand-ink); }
.lty-link:hover { text-decoration: underline; }

/* ============================================================
   CARDS
   ============================================================ */
.lty-card, .card {
  background: var(--lty-surface); border: 1px solid var(--lty-line);
  border-radius: var(--lty-r); box-shadow: var(--lty-shadow);
}
.lty-card__header, .lty-card-head { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--lty-line); }
.lty-card__title, .lty-card-title { font-size: .83rem; font-weight: 600; }
.lty-card__header .lty-btn, .lty-card-head .lty-link { margin-left: auto; }
.lty-card__body, .lty-card-body { padding: 18px; }

.section-card { padding: 18px; }
.section-card > h3, .form-card > h3, .section-head h3, .section-card > div > h3 { font-size: .83rem; font-weight: 600; margin-bottom: 12px; }
.section-divider { border-top: 1px solid var(--lty-line); margin: 16px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head h3 { margin-bottom: 0; }
.card-kicker { font-size: .7rem; font-weight: 500; color: var(--lty-ink-3); margin-bottom: 2px; }
.table-card { padding: 0; overflow-x: auto; }
.table-card > h3 { padding: 13px 18px 0; margin-bottom: 4px; }
.wide-card { grid-column: 1 / -1; }
.table-meta { font-size: .75rem; color: var(--lty-ink-2); line-height: 1.55; }

/* ============================================================
   STATS
   ============================================================ */
.lty-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.lty-stat-grid .lty-card__body { padding: 16px 18px 14px; }
.lty-stat__label { font-size: .74rem; color: var(--lty-ink-2); display: flex; align-items: center; gap: 7px; }
.lty-stat__value { font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 8px; line-height: 1; }
.lty-stat__meta { font-size: .73rem; color: var(--lty-ink-3); margin-top: 7px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.summary-metric { background: var(--lty-surface); border: 1px solid var(--lty-line); border-radius: var(--lty-r); box-shadow: var(--lty-shadow); padding: 16px 18px 14px; }
.summary-metric span, .summary-metric p { font-size: .74rem; color: var(--lty-ink-2); }
.summary-metric .metric { display: block; font-size: 1.3rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 8px; line-height: 1.1; font-family: var(--lty-mono); }

/* ============================================================
   TABLES
   ============================================================ */
.lty-table, .data-table, .lty-content table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.lty-table thead th, .data-table thead th, .lty-content table thead th {
  text-align: left; font-size: .72rem; font-weight: 500; color: var(--lty-ink-3);
  padding: 9px 18px; border-bottom: 1px solid var(--lty-line);
}
.lty-table td, .data-table td, .lty-content table td { padding: 11px 18px; border-bottom: 1px solid var(--lty-line); vertical-align: middle; }
.lty-table tbody tr:last-child td, .data-table tbody tr:last-child td, .lty-content table tbody tr:last-child td { border-bottom: none; }
.lty-table tbody tr:hover, .data-table tbody tr:hover { background: var(--lty-bg); }
.lty-table .r, .data-table .r { text-align: right; }
.data-table a { font-weight: 500; }
.data-table a:hover { text-decoration: underline; }
.row-title { font-weight: 500; line-height: 1.3; }
.empty-row td { color: var(--lty-ink-3); font-size: .78rem; }
.lty-table tfoot td, .data-table tfoot td {
  padding: 10px 18px; font-size: .74rem; color: var(--lty-ink-2);
  border-top: 1px solid var(--lty-line); background: var(--lty-bg);
}

/* ============================================================
   LAYOUT HELPERS
   ============================================================ */
.lty-stack, .stack { display: grid; gap: 16px; }
.stack { gap: 12px; }
.lty-grid-main, .dashboard-lower { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.lty-col { display: grid; gap: 16px; align-content: start; }
.lty-cols, .detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.detail-main, .detail-rail { display: grid; gap: 16px; align-content: start; min-width: 0; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid .full, .full { grid-column: 1 / -1; }

/* ============================================================
   META LISTS
   ============================================================ */
.lty-meta { list-style: none; display: grid; gap: 0 18px; }
.lty-meta__item { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--lty-line); font-size: .8rem; }
.lty-meta__item:last-child { border-bottom: none; }
.lty-meta__key { color: var(--lty-ink-2); }
.lty-meta__value { font-weight: 500; text-align: right; }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 18px; }
.meta-item > span { display: block; font-size: .72rem; color: var(--lty-ink-3); margin-bottom: 3px; }
.meta-item > p { font-size: .82rem; font-weight: 500; }

.detail-list { list-style: none; }
.detail-list li { padding: 8px 0; border-bottom: 1px solid var(--lty-line); font-size: .8rem; }
.detail-list li:first-child { padding-top: 0; }
.detail-list li:last-child { border-bottom: none; padding-bottom: 0; }
.detail-list li strong { display: block; font-weight: 500; font-size: .8rem; }
.detail-list li span { display: block; font-size: .73rem; color: var(--lty-ink-2); margin-top: 2px; }
.detail-list li a { font-weight: 500; }
.detail-list li a:hover { text-decoration: underline; }
.detail-list li p { color: var(--lty-ink-3); font-size: .78rem; }

/* ============================================================
   FEED ROWS (dashboard lists)
   ============================================================ */
.lty-row { display: flex; gap: 12px; align-items: flex-start; padding: 13px 18px; border-bottom: 1px solid var(--lty-line); }
.lty-row:last-child { border-bottom: none; }
.lty-row:hover { background: var(--lty-bg); }
.lty-row > .dot { margin-top: 7px; }
.lty-row__body { flex: 1; min-width: 0; display: block; }
.lty-row__title { font-size: .83rem; font-weight: 500; display: block; }
a.lty-row__title:hover { text-decoration: underline; }
.lty-row__meta { font-size: .75rem; color: var(--lty-ink-2); margin-top: 2px; display: block; }
.lty-row__aside { font-family: var(--lty-mono); font-size: .68rem; color: var(--lty-ink-3); white-space: nowrap; margin-top: 4px; }

.lty-empty { display: grid; place-items: center; gap: 8px; text-align: center; color: var(--lty-ink-3); }
.lty-empty__icon { color: var(--lty-ink-3); }
.lty-empty__desc { font-size: .76rem; color: var(--lty-ink-3); }

/* ============================================================
   NOTICES / FLASHES
   ============================================================ */
.lty-notice, .flash {
  display: flex; gap: 11px; align-items: center; background: var(--lty-surface);
  border: 1px solid var(--lty-line); border-radius: var(--lty-r); padding: 12px 16px;
  font-size: .8rem; color: var(--lty-ink-2);
}
.lty-notice b, .flash b { color: var(--lty-ink); font-weight: 500; }
.flashes { display: grid; gap: 8px; margin-bottom: 20px; }
.flash svg { width: 15px; height: 15px; flex: none; }
.flash-success { color: var(--lty-ink); }
.flash-success svg { color: var(--lty-ok); }
.flash-error { color: var(--lty-ink); }
.flash-error svg { color: var(--lty-danger); }

/* ============================================================
   TABS / FILTERS
   ============================================================ */
.lty-tabs, .lty-filters { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--lty-line); }
.lty-tab, .lty-filter {
  padding: 7px 0 9px; font-size: .8rem; color: var(--lty-ink-2);
  border-bottom: 1.5px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: baseline;
}
.lty-tab:hover, .lty-filter:hover { color: var(--lty-ink); }
.lty-tab.is-active, .lty-filter.is-on { color: var(--lty-ink); font-weight: 500; border-bottom-color: var(--lty-ink); }
.lty-tab .n, .lty-filter .n { font-family: var(--lty-mono); font-size: .68rem; color: var(--lty-ink-3); }

/* ============================================================
   FORMS
   ============================================================ */
.form-shell { max-width: 820px; display: grid; gap: 14px; }
.form-card { padding: 20px; }
.form-card label, .stack label {
  display: block; font-size: .75rem; font-weight: 500; color: var(--lty-ink-2);
}
.form-card label input, .form-card label select, .form-card label textarea,
.stack label input, .stack label select, .stack label textarea {
  display: block; width: 100%; margin-top: 6px;
}
.form-card input, .form-card select, .form-card textarea,
.stack input, .stack select, .stack textarea {
  border: 1px solid var(--lty-line-2); border-radius: var(--lty-r-sm);
  padding: 8px 12px; font: inherit; font-size: .84rem; background: var(--lty-surface); color: var(--lty-ink);
}
.form-card input:focus, .form-card select:focus, .form-card textarea:focus,
.stack input:focus, .stack select:focus, .stack textarea:focus {
  outline: none; border-color: var(--lty-ink); box-shadow: 0 0 0 3px rgba(24, 24, 27, .06);
}
.form-card input[type="checkbox"], .stack input[type="checkbox"] { width: auto; display: inline-block; margin: 0; }
.checkbox-field { display: flex !important; align-items: center; gap: 8px; }
.checkbox-field input { margin-top: 0 !important; }
.form-card input[type="file"], .stack input[type="file"] { border: 1px dashed var(--lty-line-2); background: var(--lty-bg); font-size: .76rem; }

.lty-field { display: block; margin-bottom: 14px; }
.lty-field__label { display: block; font-size: .75rem; font-weight: 500; color: var(--lty-ink-2); margin-bottom: 6px; }
.lty-input {
  display: flex; align-items: center; gap: 8px; padding: 0 0 0 12px;
  border: 1px solid var(--lty-line-2); border-radius: var(--lty-r-sm); background: var(--lty-surface);
}
.lty-input input { border: none; flex: 1; padding: 8px 12px 8px 0; background: none; font: inherit; font-size: .84rem; color: var(--lty-ink); min-width: 0; }
.lty-input input:focus { outline: none; }
.lty-input:focus-within { border-color: var(--lty-ink); box-shadow: 0 0 0 3px rgba(24, 24, 27, .06); }
.lty-input__icon { color: var(--lty-ink-3); display: grid; place-items: center; }

/* ============================================================
   LOGIN
   ============================================================ */
.lty-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--lty-bg); }
.lty-login__inner { width: 100%; max-width: 360px; }
.lty-login__brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.lty-login__brand-copy { display: grid; gap: 3px; }
.lty-login__brand-name { font-size: 1.15rem; font-weight: 600; letter-spacing: -.015em; }
.lty-login__brand-sub { font-size: .78rem; color: var(--lty-ink-2); }
.lty-login .lty-card__body { padding: 22px; }
.lty-login__head { margin-bottom: 16px; }
.lty-login__title { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.lty-login__lead { font-size: .78rem; color: var(--lty-ink-2); margin-top: 5px; line-height: 1.5; }
.lty-login__foot { margin-top: 20px; text-align: center; font-family: var(--lty-mono); font-size: .64rem; color: var(--lty-ink-3); }
.lty-login .flashes { margin: 0 0 14px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1000px) {
  .lty-app { grid-template-columns: 60px 1fr; }
  .lty-brand-copy, .lty-brand-name, .lty-brand-sub, .lty-nav-item .t, .lty-nav-label, .lty-nav-group-label,
  .lty-userfoot-copy, .lty-nav-item__count, .lty-nav-item .n, .lty-host { display: none; }
  .lty-nav-item { justify-content: center; }
  .lty-cols, .detail-grid, .lty-grid-main, .dashboard-lower { grid-template-columns: 1fr; }
  .lty-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid, .grid.three, .grid.two { grid-template-columns: 1fr; }
  .lty-content { padding: 20px 16px 48px; }
}
