/* Subtrack V1.4 · adaptive library, personal identity and annual ledger */

:root {
  --v14-forest: #222820;
  --v14-forest-soft: #30382c;
  --v14-moss: #75856a;
  --v14-paper: #faf8f3;
  --v14-line: rgba(64, 55, 46, .12);
  --v14-muted: #81786c;
}

.brand-word b::after { content: "V1.4"; }

/* The library responds to its actual available width. This covers browser
   chrome, split view and zoom without identifying or fingerprinting devices. */
.status-group {
  container: subscription-cards / inline-size;
}
.status-items {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@container subscription-cards (max-width: 1120px) {
  .status-items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container subscription-cards (max-width: 780px) {
  .status-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container subscription-cards (max-width: 560px) {
  .status-items { gap: 10px; }
  .subscription-card {
    --card-padding: 12px;
    --badge-right: 12px;
    --badge-padding-x: 7px;
    --badge-font-size: 10px;
    --title-font-size: 15px;
    --price-font-size: 14px;
    --footer-font-size: 10px;
    --card-radius: 17px;
    min-width: 0;
    min-height: 164px;
  }
  .card-face-front .card-header .card-category {
    max-width: calc(100% - 70px);
    opacity: .72;
    transform: none;
  }
  .card-face-front .card-header .renewal-countdown { white-space: nowrap; }
  .card-face-front .card-amount { gap: 5px; }
  .card-face-front .card-amount small { opacity: .76; transform: none; }
  .card-face-front .card-open { display: none; }
  .card-face-back { padding: 12px; gap: 6px; }
  .flip-ledger-code { display: none; }
  .flip-ledger-category { max-width: 100%; }
  .flip-ledger-main { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .flip-project strong { margin-top: 3px; font-size: .96rem; -webkit-line-clamp: 1; }
  .flip-remaining {
    min-width: 0;
    padding: 0;
    border-left: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
  }
  .flip-remaining div { min-height: 30px; }
  .flip-remaining strong { font-size: 2rem; }
  .flip-ledger-foot { gap: 5px; }
  .flip-ledger-foot strong { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@container subscription-cards (max-width: 330px) {
  .status-items { grid-template-columns: minmax(0, 1fr); }
}

/* Identity button */
.account-orb {
  overflow: hidden;
  color: #fff;
  font: 600 .68rem/1 var(--font-display);
}
.account-orb img,
.account-orb > span {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.account-orb img { z-index: 2; object-fit: cover; }
.account-orb > span { display: grid; place-items: center; }

/* Personal homepage */
.account-dialog.profile-dialog {
  width: min(1120px, calc(100vw - 40px));
  height: min(820px, calc(100dvh - 32px));
  max-height: none;
  padding: 0;
  grid-template-columns: 310px minmax(0, 1fr);
  overflow: hidden;
  border-radius: 30px;
  background: var(--v14-paper);
}
.account-dialog.profile-dialog[open] {
  /* Keep dialog itself block-level: WebKit forces dialog:modal to block. */
  display: block;
  animation: v14-profile-in .42s cubic-bezier(.16, 1, .3, 1) both;
}
.profile-dialog > .profile-close {
  z-index: 12;
  top: 22px;
  right: 24px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--v14-line);
  color: #625b51;
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 10px 24px -18px rgba(34,31,26,.5);
}

.profile-identity {
  position: absolute;
  inset: 0 auto 0 0;
  width: 310px;
  min-width: 0;
  padding: 38px 34px 30px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: #f5f1e8;
  background:
    radial-gradient(15rem 18rem at 108% 42%, rgba(147, 162, 132, .16), transparent 68%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.013) 0 1px, transparent 1px 5px),
    linear-gradient(148deg, #30372d 0%, #1c211b 62%, #171b17 100%);
}
.profile-identity::before,
.profile-identity::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(207, 218, 195, .11);
  border-radius: 50%;
  pointer-events: none;
}
.profile-identity::before { width: 330px; height: 330px; right: -236px; top: 174px; }
.profile-identity::after { width: 250px; height: 250px; right: -177px; top: 214px; }
.profile-edition {
  position: relative;
  z-index: 1;
  margin: 0;
  color: rgba(238, 235, 224, .55);
  font: 600 .58rem/1 var(--font-body);
  letter-spacing: .18em;
}
.profile-avatar-stage {
  position: relative;
  z-index: 2;
  width: 134px;
  height: 134px;
  margin: 76px 0 28px;
}
.profile-avatar {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 42px;
  background:
    radial-gradient(circle at 34% 22%, rgba(255,255,255,.22), transparent 36%),
    linear-gradient(145deg, #819077, #52614b);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 26px 52px -28px rgba(0,0,0,.75);
  color: #fffaf0;
  font: 500 3.25rem/1 var(--font-display);
}
.profile-avatar::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 35px;
  pointer-events: none;
}
.profile-avatar img { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; object-fit: cover; }
.profile-avatar[data-processing="true"] { opacity: .55; }
.profile-avatar-edit {
  position: absolute;
  z-index: 4;
  right: -8px;
  bottom: -8px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 16px;
  color: #fff;
  background: rgba(86, 100, 78, .92);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 12px 26px -14px rgba(0,0,0,.8);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}
.profile-avatar-edit:hover { transform: translateY(-2px); background: #6e7e64; }
.profile-avatar-edit svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.profile-identity-copy { position: relative; z-index: 1; min-width: 0; }
.profile-identity-copy > p:first-child { margin: 0 0 9px; color: #9fa996; font-size: .56rem; letter-spacing: .17em; }
.profile-identity-copy h2 { margin: 0; color: #fffaf1; font-size: clamp(2rem, 3.3vw, 3rem); line-height: 1.05; letter-spacing: -.04em; overflow-wrap: anywhere; }
.profile-identity .account-email { margin: 12px 0 0; overflow: hidden; color: rgba(242,238,229,.58); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.profile-ledger-meta {
  position: relative;
  z-index: 1;
  margin: auto 0 0;
  padding-top: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid rgba(255,255,255,.11);
}
.profile-ledger-meta div { display: grid; gap: 6px; }
.profile-ledger-meta dt { color: rgba(242,238,229,.42); font-size: .57rem; letter-spacing: .06em; }
.profile-ledger-meta dd { margin: 0; color: rgba(255,250,241,.8); font-size: .7rem; font-variant-numeric: tabular-nums; }
.profile-ledger-meta dd i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #9bac8e; box-shadow: 0 0 0 3px rgba(155,172,142,.12); }

.profile-content {
  position: absolute;
  inset: 0 0 0 310px;
  min-width: 0;
  min-height: 0;
  padding: 32px 34px 40px;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 0 30px 30px 0;
  scrollbar-width: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,.34), transparent 28%),
    repeating-linear-gradient(0deg, rgba(62,49,37,.012) 0 1px, transparent 1px 5px),
    #faf8f3;
}
.profile-content::-webkit-scrollbar { width: 0; height: 0; }
.profile-scroll-cap {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  width: calc(100% - 310px);
  height: 34px;
  pointer-events: none;
  opacity: 0;
  background: #faf8f3;
  box-shadow: 0 9px 14px -16px rgba(48,42,34,.42);
  transition: opacity 120ms ease;
}
.profile-scroll-cap.is-scrolled { opacity: 1; }
.profile-scroll-progress {
  position: absolute;
  z-index: 11;
  right: 7px;
  width: 3px;
  overflow: hidden;
  border-radius: 99px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}
.profile-scroll-progress.is-active { opacity: .48; }
.profile-scroll-progress[hidden] { display: none; }
.profile-scroll-progress i {
  position: absolute;
  inset: 0 0 auto;
  display: block;
  width: 100%;
  min-height: 34px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(112,129,99,.88), rgba(71,83,65,.76));
  box-shadow: 0 0 0 1px rgba(255,255,255,.38);
  will-change: transform;
}
.profile-content-head {
  min-height: 82px;
  padding: 4px 58px 22px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--v14-line);
}
.profile-content-head h3 { margin: 6px 0 0; font-size: 1.7rem; font-weight: 600; letter-spacing: -.025em; }
.profile-cloud-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--v14-line); border-radius: 14px; color: #798371; background: rgba(255,255,255,.48); font: 600 .68rem/1 var(--font-display); }
.profile-section { padding: 26px 0; border-bottom: 1px solid var(--v14-line); }
.profile-section:last-child { border-bottom: 0; padding-bottom: 0; }
.profile-section-title { margin-bottom: 18px; display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.profile-section-title > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.profile-section-title > div > span { color: #9b958b; font: italic .61rem/1 var(--font-display); }
.profile-section-title h4 { margin: 0; color: #2b2924; font-size: 1.05rem; font-weight: 600; }
.profile-section-title > small { color: #948c81; font-size: .65rem; font-style: italic; }

.profile-editor form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.profile-name-field { min-width: 0; display: grid; gap: 7px; color: #776f64; font-size: .68rem; }
.profile-name-field input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1px solid rgba(65,56,47,.12);
  border-radius: 15px;
  outline: 0;
  color: #26241f;
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.94), 0 10px 24px -22px rgba(45,38,31,.55);
  font: 500 .92rem/1 var(--font-body);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.profile-name-field input:focus { border-color: rgba(112,129,99,.58); box-shadow: 0 0 0 4px rgba(112,129,99,.09); }
.profile-form-actions { display: flex; align-items: center; gap: 8px; }
.profile-remove-avatar,
.profile-save { min-height: 50px; border-radius: 15px; }
.profile-remove-avatar { padding: 0 13px; color: #81786c; font-size: .69rem; }
.profile-remove-avatar:hover:not(:disabled) { color: #a55d52; background: rgba(176,95,85,.06); }
.profile-remove-avatar:disabled { opacity: .36; cursor: default; }
.profile-save { min-width: 126px; justify-content: center; }
.profile-feedback { grid-column: 1 / -1; min-height: 17px; margin: -2px 0 0; color: #847b70; font-size: .67rem; }
.profile-feedback[data-state="success"] { color: #63745a; }
.profile-feedback[data-state="error"] { color: #ad5f55; }

.annual-title-row { align-items: center; }
.report-year-control select {
  min-width: 100px;
  min-height: 42px;
  padding: 0 34px 0 13px;
  border: 1px solid var(--v14-line);
  border-radius: 13px;
  appearance: none;
  color: #504b43;
  background: rgba(255,255,255,.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23766f64' stroke-width='1.25' stroke-linecap='round'/%3E%3C/svg%3E") right 13px center / 9px 6px no-repeat;
  font: 500 .72rem/1 var(--font-body);
}
.annual-hero {
  position: relative;
  min-height: 176px;
  padding: 25px 28px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(210px, 1.2fr);
  align-items: end;
  gap: 28px;
  border: 1px solid rgba(68,78,61,.17);
  border-radius: 21px;
  color: #f8f5ed;
  background:
    radial-gradient(18rem 10rem at 92% -12%, rgba(196,208,183,.14), transparent 70%),
    linear-gradient(145deg, #34402f, #232a21 65%, #1d231c);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 22px 44px -34px rgba(35,44,31,.75);
}
.annual-hero::after { content: attr(data-year); position: absolute; right: 20px; top: -28px; color: rgba(255,255,255,.035); font: 600 8rem/1 var(--font-display); }
.annual-hero > div { position: relative; z-index: 1; display: grid; }
.annual-hero > div p { margin: 0 0 17px; color: #aebba4; font-size: .53rem; font-weight: 600; letter-spacing: .14em; }
.annual-hero > div strong { overflow: hidden; color: #fffaf1; font: 500 clamp(1.75rem, 3.4vw, 2.65rem)/1 var(--font-display); letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.annual-hero > div span { margin-top: 8px; color: rgba(247,243,233,.52); font-size: .64rem; }
.annual-hero > p { position: relative; z-index: 1; max-width: 34ch; margin: 0; justify-self: end; color: rgba(247,243,233,.7); font-size: .72rem; line-height: 1.75; }
.report-metrics { margin-top: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.report-metrics > div { min-width: 0; min-height: 96px; padding: 16px; display: grid; align-content: space-between; grid-template-columns: 1fr auto; border: 1px solid var(--v14-line); border-radius: 17px; background: rgba(255,255,255,.48); }
.report-metrics span { grid-column: 1 / -1; color: #8c8377; font-size: .63rem; }
.report-metrics strong { min-width: 0; overflow: hidden; color: #2e2b26; font: 600 1.3rem/1.1 var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.report-metrics small { align-self: end; color: #989084; font-size: .59rem; }
.report-breakdown { margin-top: 22px; }
.report-breakdown > header { margin-bottom: 13px; display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.report-breakdown > header span { color: #4d4841; font-size: .74rem; font-weight: 600; }
.report-breakdown > header small { color: #9a9186; font-size: .61rem; font-style: italic; }
.report-bars { display: grid; gap: 11px; }
.report-bar-row { display: grid; gap: 6px; }
.report-bar-row > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; color: #756d62; font-size: .65rem; }
.report-bar-row strong { color: #71695f; font-size: .62rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.report-bar-row > i { position: relative; height: 4px; overflow: hidden; border-radius: 99px; background: rgba(56,48,40,.075); }
.report-bar-row > i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--report-share); border-radius: inherit; background: linear-gradient(90deg, #607257, #91a086); transform-origin: left; animation: v14-bar-in .62s cubic-bezier(.16,1,.3,1) both; }
.report-empty { margin: 0; padding: 18px; border: 1px dashed var(--v14-line); border-radius: 14px; color: #91887c; text-align: center; font-size: .7rem; }
.report-note { margin: 17px 0 0; color: #9a9185; font-size: .59rem; font-style: italic; }

.security-command { padding: 15px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 13px; border: 1px solid var(--v14-line); border-radius: 17px; background: rgba(255,255,255,.46); }
.security-command-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(105,122,95,.22);
  border-radius: 13px;
  color: #66775d;
  background: linear-gradient(145deg, rgba(255,255,255,.76), rgba(112,129,99,.1));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 8px 18px -16px rgba(57,69,51,.7);
}
.security-command-icon svg { width: 21px; height: 21px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.security-command > div { min-width: 0; display: grid; gap: 4px; }
.security-command strong { color: #34312b; font-size: .76rem; }
.security-command small { color: #8a8175; font-size: .64rem; line-height: 1.45; }
.security-command .passkey-button { min-width: 132px; min-height: 46px; }
.profile-security .account-actions { margin-top: 13px; align-items: center; justify-content: space-between; }
.profile-security .account-actions > span { max-width: 42ch; color: #999084; font-size: .6rem; font-style: italic; }
.profile-security .account-actions .text-button { min-width: 96px; }

@keyframes v14-profile-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 20px)) scale(.985); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes v14-bar-in { from { transform: scaleX(0); } }

@media (max-width: 900px) {
  .account-dialog.profile-dialog { grid-template-columns: 250px minmax(0, 1fr); }
  .profile-identity { width: 250px; }
  .profile-content { left: 250px; }
  .profile-scroll-cap { width: calc(100% - 250px); }
  .profile-identity { padding-inline: 26px; }
  .profile-avatar-stage { width: 112px; height: 112px; margin-top: 74px; }
  .profile-avatar { border-radius: 35px; font-size: 2.8rem; }
  .profile-avatar::after { border-radius: 29px; }
  .profile-content { padding-inline: 26px; }
  .profile-editor form { grid-template-columns: minmax(0,1fr); }
  .profile-form-actions { justify-content: flex-end; }
}

@media (max-width: 720px) {
  .account-dialog.profile-dialog {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 218px minmax(0, 1fr);
    border-radius: 24px;
  }
  .profile-dialog > .profile-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    color: rgba(255,250,242,.84);
    border-color: rgba(255,255,255,.14);
    background: rgba(255,255,255,.08);
  }
  .profile-identity {
    inset: 0 0 auto;
    width: 100%;
    height: 218px;
    padding: 20px 22px;
    display: grid;
    grid-template-columns: 104px minmax(0,1fr);
    grid-template-rows: auto 1fr auto;
    column-gap: 18px;
    align-items: center;
  }
  .profile-edition { grid-column: 1 / -1; }
  .profile-avatar-stage { width: 96px; height: 96px; margin: 12px 0 0; grid-row: 2 / 4; }
  .profile-avatar { border-radius: 30px; font-size: 2.35rem; }
  .profile-avatar::after { inset: 6px; border-radius: 24px; }
  .profile-avatar-edit { width: 44px; height: 44px; right: -4px; bottom: -6px; }
  .profile-identity-copy { align-self: end; }
  .profile-identity-copy h2 { font-size: 1.85rem; }
  .profile-ledger-meta { margin: 12px 0 0; padding-top: 11px; align-self: start; }
  .profile-content { inset: 218px 0 0; padding: 24px 18px 34px; }
  .profile-content {
    border-radius: 0 0 24px 24px;
  }
  .profile-scroll-cap { top: 218px; width: 100%; height: 28px; }
  .profile-scroll-progress { right: 5px; }
  .profile-content-head { min-height: 70px; padding-right: 0; }
  .profile-content-head h3 { font-size: 1.4rem; }
  .profile-cloud-mark { display: none; }
  .profile-section { padding: 23px 0; }
  .profile-section-title { align-items: flex-start; }
  .profile-section-title > small { max-width: 44%; text-align: right; }
  .annual-hero { min-height: 210px; grid-template-columns: minmax(0,1fr); align-items: end; gap: 18px; }
  .annual-hero > p { justify-self: start; }
  .report-metrics { grid-template-columns: 1fr 1fr; }
  .report-metrics > div:last-child { grid-column: 1 / -1; }
  .security-command { grid-template-columns: auto minmax(0,1fr); }
  .security-command .passkey-button { grid-column: 1 / -1; width: 100%; }
  .profile-security .account-actions { align-items: stretch; flex-direction: column; }
  .profile-security .account-actions .text-button { width: 100%; }
}

@media (max-width: 600px) {
  /* Fallback for engines without container queries. */
  .status-items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .status-group-head { margin-bottom: 14px; }
  .status-group + .status-group { margin-top: 38px; }
}

@media (max-width: 380px) {
  .profile-identity { grid-template-columns: 88px minmax(0,1fr); column-gap: 14px; }
  .profile-avatar-stage { width: 82px; height: 82px; }
  .profile-avatar-edit { right: -8px; }
  .profile-identity-copy h2 { font-size: 1.58rem; }
  .profile-ledger-meta dt { display: none; }
  .profile-form-actions { display: grid; grid-template-columns: 1fr 1.25fr; }
  .profile-remove-avatar, .profile-save { width: 100%; min-width: 0; padding-inline: 8px; }
  .annual-title-row { align-items: center; }
  .report-year-control select { min-width: 92px; }
}

@media (max-width: 340px) {
  .status-items { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .account-dialog.profile-dialog[open],
  .report-bar-row > i::after { animation: none; }
}
