/* FamiTools design tokens – from the design canvas (Figtree body, Bricolage Grotesque display). */
:root {
  --ft-bg: #F3F5F2;
  --ft-surface: #FFFFFF;
  --ft-surface-2: #F4F8F6;
  --ft-border: #DDE2DC;
  --ft-border-strong: #C9D0C8;
  --ft-text: #1A211D;
  --ft-text-2: #3F4943;
  --ft-muted: #5A645E;
  --ft-primary: #1F5E4B;
  --ft-primary-hover: #163F33;
  --ft-primary-soft: #E3EEE8;
  --ft-accent-soft: #F4E3C8;
  --ft-accent-text: #7A3E06;
  --ft-danger: #B42318;
  --ft-danger-soft: #FEE4E2;
  --ft-warn-soft: #FEF0C7;
  --ft-warn-text: #93370D;
  --ft-radius: 10px;
  --ft-radius-lg: 18px;
  --ft-font: 'Figtree', 'Segoe UI', system-ui, sans-serif;
  --ft-font-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --ft-sidebar: 264px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ft-bg); color: var(--ft-text); font-family: var(--ft-font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--ft-primary); }
a:hover { color: var(--ft-primary-hover); }
h1, h2, h3 { font-family: var(--ft-font-display); font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; margin: 0; }
h1 { font-size: 32px; } h2 { font-size: 24px; } h3 { font-size: 18px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid rgba(31, 94, 75, 0.35); outline-offset: 2px; }
.ft-skip { position: absolute; left: 16px; top: -48px; z-index: 100; padding: 10px 14px; background: var(--ft-primary); color: #fff; border-radius: var(--ft-radius); font-weight: 700; text-decoration: none; }
.ft-skip:focus { top: 12px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; }
}

.ft-splash { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 10px; font-family: var(--ft-font-display); font-weight: 700; font-size: 24px; }
.ft-logo-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--ft-primary); display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.ft-logo-mark svg { width: 22px; height: 22px; }
.ft-logo { display: flex; align-items: center; gap: 10px; font-family: var(--ft-font-display); font-weight: 700; font-size: 22px; color: var(--ft-text); text-decoration: none; }

/* Layout */
.ft-shell { display: grid; grid-template-columns: var(--ft-sidebar) minmax(0, 1fr); min-height: 100vh; }
.ft-sidebar { background: var(--ft-surface); border-right: 1px solid var(--ft-border); display: flex; flex-direction: column; gap: 20px; padding: 20px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.ft-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ft-sidebar .ft-sidebar-close { display: none; }
.ft-main { padding: 32px 40px 48px; max-width: 1280px; width: 100%; }
.ft-family-switch { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--ft-border); border-radius: 14px; background: var(--ft-surface); cursor: pointer; text-align: left; }
.ft-family-switch:hover { background: var(--ft-surface-2); }
.ft-family-switch .name { font-weight: 700; }
.ft-family-switch .meta { font-size: 13px; color: var(--ft-muted); }
.ft-nav-section { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ft-muted); margin: 0 0 6px 12px; }
.ft-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ft-nav a, .ft-nav .ft-nav-disabled { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--ft-radius); color: var(--ft-text-2); text-decoration: none; font-weight: 500; min-height: 44px; }
.ft-nav a:hover { background: var(--ft-surface-2); color: var(--ft-text); }
.ft-nav a.active { background: var(--ft-primary-soft); color: var(--ft-primary); font-weight: 700; }
.ft-nav .ft-nav-disabled { color: var(--ft-muted); opacity: 0.85; }
.ft-nav svg { width: 20px; height: 20px; flex: none; }
.ft-nav .count { margin-left: auto; font-size: 12px; font-weight: 700; background: var(--ft-accent-soft); color: var(--ft-accent-text); border-radius: 999px; padding: 2px 8px; }
.ft-sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--ft-border); }
.ft-sidebar-footer .who { display: flex; flex-direction: column; min-width: 0; }
.ft-sidebar-footer .who .n { font-weight: 700; }
.ft-sidebar-footer .who .e { font-size: 12px; color: var(--ft-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-topbar { display: none; }
.ft-family-menu { position: absolute; z-index: 20; margin-top: 6px; width: calc(var(--ft-sidebar) - 32px); background: var(--ft-surface); border: 1px solid var(--ft-border); border-radius: 14px; box-shadow: 0 12px 32px rgba(26, 33, 29, 0.12); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.ft-family-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: left; min-height: 44px; }
.ft-family-menu button:hover { background: var(--ft-surface-2); }

/* Auth layout */
.ft-auth { min-height: 100vh; display: flex; flex-direction: column; padding: 32px 24px; gap: 32px; }
.ft-auth-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; max-width: 1100px; width: 100%; margin: 0 auto; }
.ft-auth-body { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
.ft-auth-card { max-width: 480px; width: 100%; margin: 0 auto; }
.ft-steps { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; flex-wrap: wrap; }
.ft-steps li { display: flex; align-items: center; gap: 8px; color: var(--ft-muted); }
.ft-steps li.done, .ft-steps li.current { color: var(--ft-text); }
.ft-steps .dot { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--ft-border); color: var(--ft-text-2); font-size: 13px; }
.ft-steps li.done .dot, .ft-steps li.current .dot { background: var(--ft-primary); color: #fff; }
.ft-steps .line { width: 40px; height: 2px; background: #A9B3AC; }
.ft-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ft-muted); }

/* Cards & blocks */
.ft-card { background: var(--ft-surface); border: 1px solid var(--ft-border); border-radius: var(--ft-radius-lg); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.ft-card.compact { padding: 20px; gap: 12px; }
.ft-card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ft-stack { display: flex; flex-direction: column; gap: 16px; }
.ft-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ft-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.ft-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; align-items: start; }
.ft-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; }
.ft-muted { color: var(--ft-muted); }
.ft-small { font-size: 13px; }
.ft-title { margin-bottom: 4px; }
.ft-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.ft-page-head .sub { color: var(--ft-muted); margin-top: 6px; }
.ft-divider { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ft-muted); }
.ft-divider::before, .ft-divider::after { content: ""; flex: 1; height: 1px; background: var(--ft-border); }
.ft-highlight { border: 2px solid var(--ft-primary); border-radius: 14px; padding: 18px; background: var(--ft-surface-2); display: flex; flex-direction: column; gap: 12px; }
.ft-stat { display: flex; flex-direction: column; gap: 6px; }
.ft-stat .label { font-size: 13px; font-weight: 600; color: var(--ft-muted); }
.ft-stat .value { font-family: var(--ft-font-display); font-size: 26px; font-weight: 700; white-space: nowrap; }
.ft-stat-button { align-items: flex-start; text-align: left; font: inherit; color: inherit; background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; margin: -6px -8px; cursor: pointer; }
.ft-stat-button:hover { background: var(--ft-surface-2); }
.ft-stat-button:focus-visible { outline: 2px solid var(--ft-primary); outline-offset: 2px; }
.ft-stat .delta { font-size: 13px; color: var(--ft-muted); }

/* Buttons */
.ft-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--ft-radius); border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s; }
.ft-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ft-btn-primary { background: var(--ft-primary); border-color: var(--ft-primary); color: #fff; }
.ft-btn-primary:hover:not(:disabled) { background: var(--ft-primary-hover); }
.ft-btn-secondary { background: var(--ft-surface); border-color: var(--ft-border-strong); color: var(--ft-text); }
.ft-btn-secondary:hover:not(:disabled) { background: var(--ft-surface-2); }
.ft-btn-outline { background: transparent; border-color: var(--ft-text); color: var(--ft-text); }
.ft-btn-ghost { background: transparent; color: var(--ft-primary); padding: 0 10px; min-height: 36px; }
.ft-btn-ghost:hover:not(:disabled) { background: var(--ft-primary-soft); }
.ft-btn-danger { background: var(--ft-surface); border-color: var(--ft-danger); color: var(--ft-danger); }
.ft-btn-danger:hover:not(:disabled) { background: var(--ft-danger-soft); }
.ft-btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.ft-btn-full { width: 100%; }
.ft-spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ft-spin .7s linear infinite; }
@keyframes ft-spin { to { transform: rotate(360deg); } }

/* Forms */
.ft-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ft-text-2); }
.ft-field input, .ft-field select, .ft-field textarea { min-height: 46px; padding: 0 12px; border: 1px solid var(--ft-border-strong); border-radius: var(--ft-radius); background: var(--ft-surface); font-weight: 400; color: var(--ft-text); width: 100%; }
.ft-field textarea { padding: 10px 12px; min-height: 90px; }
.ft-field input:focus, .ft-field select:focus { border-color: var(--ft-primary); outline: none; box-shadow: 0 0 0 3px rgba(31, 94, 75, 0.18); }
.ft-field.invalid input, .ft-field.invalid select { border-color: var(--ft-danger); }
.ft-field .hint { font-weight: 400; color: var(--ft-muted); }
.ft-field .error { font-weight: 500; color: var(--ft-danger); }
.ft-check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ft-text-2); cursor: pointer; }
.ft-check input { width: 20px; height: 20px; accent-color: var(--ft-primary); margin: 0; }
.ft-code { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.ft-code input { height: 56px; min-width: 0; text-align: center; border: 1px solid var(--ft-border-strong); border-radius: var(--ft-radius); font-size: 22px; font-weight: 700; background: var(--ft-surface); }
.ft-code input:focus { border: 2px solid var(--ft-primary); outline: none; }
.ft-toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.ft-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ft-toggle .track { width: 44px; height: 26px; border-radius: 999px; background: var(--ft-border-strong); position: relative; transition: background .15s; flex: none; }
.ft-toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.ft-toggle input:checked + .track { background: var(--ft-primary); }
.ft-toggle input:checked + .track::after { transform: translateX(18px); }
.ft-toggle input:disabled + .track { opacity: .5; }
.ft-toggle input:focus-visible + .track { outline: 3px solid rgba(31, 94, 75, 0.35); outline-offset: 2px; }

/* Badges, avatars, alerts */
.ft-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--ft-surface-2); color: var(--ft-text-2); border: 1px solid var(--ft-border); }
.ft-badge.green { background: var(--ft-primary-soft); color: var(--ft-primary); border-color: transparent; }
.ft-badge.amber { background: var(--ft-warn-soft); color: var(--ft-warn-text); border-color: transparent; }
.ft-badge.red { background: var(--ft-danger-soft); color: var(--ft-danger); border-color: transparent; }
.ft-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--ft-accent-soft); color: var(--ft-accent-text); font-weight: 700; flex: none; }
.ft-avatar.green { background: var(--ft-primary-soft); color: var(--ft-primary); }
.ft-avatar.sm { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }
.ft-avatar.md { width: 40px; height: 40px; font-size: 15px; }
.ft-avatar.lg { width: 56px; height: 56px; font-size: 20px; border-radius: 16px; }
.ft-alert { padding: 12px 14px; border-radius: var(--ft-radius); font-size: 14px; border: 1px solid transparent; }
.ft-alert.info { background: var(--ft-primary-soft); color: var(--ft-primary); }
.ft-alert.error { background: var(--ft-danger-soft); color: var(--ft-danger); }
.ft-alert.warn { background: var(--ft-warn-soft); color: var(--ft-warn-text); }

/* Tables & lists */
.ft-table-wrap { overflow-x: auto; }
.ft-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ft-table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ft-muted); padding: 8px 10px; border-bottom: 1px solid var(--ft-border); }
.ft-table td { padding: 12px 10px; border-bottom: 1px solid var(--ft-border); vertical-align: middle; }
.ft-table tr:last-child td { border-bottom: 0; }
.ft-sort { all: unset; cursor: pointer; white-space: nowrap; border-radius: 4px; }
.ft-sort:hover { color: var(--ft-text); }
.ft-sort:focus-visible { outline: 2px solid var(--ft-primary); outline-offset: 2px; }
th[aria-sort="ascending"] .ft-sort, th[aria-sort="descending"] .ft-sort { color: var(--ft-text); }
.ft-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ft-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--ft-border); flex-wrap: wrap; }
.ft-activity .ft-avatar { background: var(--ft-surface-2); color: var(--ft-text-2); }
.ft-list li:last-child { border-bottom: 0; }
.ft-list .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ft-list .grow .t { font-weight: 700; }
.ft-list .grow .m { font-size: 13px; color: var(--ft-muted); }
.ft-dot-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-size: 14px; }
.ft-yes { color: var(--ft-primary); font-weight: 700; } .ft-no { color: var(--ft-muted); }

.ft-error-ui { background: var(--ft-danger-soft); color: var(--ft-danger); bottom: 0; display: none; left: 0; padding: 0.8rem 1.2rem; position: fixed; width: 100%; z-index: 1000; }
.ft-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

@media (max-width: 900px) {
  .ft-shell { grid-template-columns: minmax(0, 1fr); }
  .ft-sidebar { display: none; }
  .ft-sidebar.open { display: flex; position: fixed; inset: 0; z-index: 30; height: auto; border-right: 0; }
  .ft-sidebar .ft-sidebar-close { display: inline-flex; }
  h1 { font-size: 26px; } h2 { font-size: 21px; }
  .ft-card { padding: 20px; }
  .ft-main { padding: 20px 16px 40px; }
  /* Forms use grid-column: span N inline for wide fields; in a single column that would create phantom columns. */
  .ft-grid-2 > *, .ft-grid-3 > *, .ft-grid-4 > * { grid-column: auto !important; }
  .ft-page-head { flex-direction: column; align-items: stretch; }
  .ft-page-head > .ft-row { justify-content: flex-start; }
  .ft-family-menu { width: calc(100vw - 32px); }
  .ft-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--ft-surface); border-bottom: 1px solid var(--ft-border); position: sticky; top: 0; z-index: 10; }
  .ft-grid-2, .ft-grid-3, .ft-grid-4 { grid-template-columns: minmax(0, 1fr); }
  .ft-auth { padding: 20px 16px; }
  .ft-page-head { margin-bottom: 20px; }
  .ft-dot-list { grid-template-columns: minmax(0, 1fr); }
}

/* Inventory */
.ft-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ft-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--ft-border); border-radius: 14px; background: var(--ft-surface); text-align: left; cursor: pointer; font: inherit; color: inherit; transition: border-color .12s, background .12s; }
.ft-item:hover { border-color: var(--ft-border-strong); background: var(--ft-surface-2); }
.ft-item.active { border-color: var(--ft-primary); box-shadow: 0 0 0 1px var(--ft-primary); }
.ft-item.disposed { opacity: .6; }
.ft-item .thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--ft-surface-2); color: var(--ft-muted); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.ft-item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ft-item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ft-item .body .t { font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ft-item .body .m { font-size: 13px; color: var(--ft-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-item .tags { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: none; }
.ft-photo-main { display: block; border-radius: 14px; overflow: hidden; background: var(--ft-surface-2); aspect-ratio: 4 / 3; }
.ft-photo-main img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ft-photo-empty { aspect-ratio: 4 / 3; border-radius: 14px; background: var(--ft-surface-2); color: var(--ft-muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.ft-photo-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.ft-photo-strip button { width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--ft-surface-2); cursor: pointer; }
.ft-photo-strip button.active { border-color: var(--ft-primary); }
.ft-photo-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ft-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.ft-dl dt { color: var(--ft-muted); font-weight: 600; }
.ft-dl dd { margin: 0; }

/* Confirm dialog */
.ft-dialog-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(26, 33, 29, 0.45); }
.ft-dialog { width: 100%; max-width: 420px; background: var(--ft-surface); border: 1px solid var(--ft-border); border-radius: var(--ft-radius-lg); box-shadow: 0 24px 48px rgba(26, 33, 29, 0.2); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.ft-dialog-wide { max-width: 760px; max-height: calc(100vh - 32px); overflow-y: auto; }
.ft-dialog-title { margin: 0; font-family: var(--ft-font-display); font-size: 1.25rem; }
.ft-dialog-message { margin: 0; color: var(--ft-text-2); }
.ft-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
