/* NiceUI Theme Generator — scoped to .tg */
.tg { display: grid; grid-template-columns: minmax(0, 1fr) 360px; height: calc(100vh - var(--ap-bar, 52px)); height: calc(100dvh - var(--ap-bar, 52px)); }
.tg [hidden] { display: none !important; }

/* left: toolbar + preview */
.tg-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.tg-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tg-seg { display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--s1); }
.tg-seg button { height: 30px; padding: 0 14px; border-radius: 7px; font-size: 12.5px; color: var(--mute); }
.tg-seg button[aria-pressed="true"] { background: var(--sky); color: var(--sky-ink); }
.tg-scale { display: flex; flex: 1; min-width: 0; height: 36px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.tg-sw { position: relative; flex: 1; min-width: 0; transition: flex .2s; }
.tg-sw span { position: absolute; inset: auto 0 3px; font: 9.5px var(--mono); text-align: center; color: rgba(0,0,0,.55); opacity: 0; transition: opacity .2s; }
.tg-sw:nth-child(n+6) span { color: rgba(255,255,255,.7); }
.tg-sw:hover { flex: 1.8; }
.tg-sw:hover span { opacity: 1; }
.tg-pv-wrap { flex: 1; min-height: 0; border-radius: 18px; border: 1px solid var(--line-2); overflow: hidden; }

/* the preview app, styled only by the generated variables */
.tg-pv { height: 100%; overflow: auto; background: var(--background); color: var(--foreground); font-family: var(--font-sans); font-size: 13px; color-scheme: light; }
.tg-pv[data-mode="dark"] { color-scheme: dark; }
.tg-app { position: relative; display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 100%; }
.tg-nav { display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--card); }
.tg-logo { display: flex; align-items: center; gap: 8px; padding: 4px 8px 14px; font-size: 14px; }
.tg-logo-mark { width: 20px; height: 20px; border-radius: calc(var(--radius) - 4px); background: var(--primary); }
.tg-nav a { padding: 7px 10px; border-radius: calc(var(--radius) - 2px); color: var(--muted-foreground); cursor: default; }
.tg-nav a.on { background: var(--accent); color: var(--accent-foreground); font-weight: 500; }
.tg-nav-card { margin-top: auto; display: grid; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); }
.tg-nav-card span { color: var(--muted-foreground); font-size: 12px; line-height: 1.45; }
.tg-content { min-width: 0; display: grid; gap: 14px; align-content: start; padding: 20px 22px 24px; }
.tg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tg-head h3 { font-family: var(--font-heading); font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.tg-head p, .tg-mute { color: var(--muted-foreground); }
.tg-head-r, .tg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tg-btn { display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px; border-radius: calc(var(--radius) - 2px); font-size: 13px; font-weight: 500; cursor: default; transition: opacity .2s; }
.tg-btn:hover { opacity: .9; }
.tg-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.tg-btn-p { background: var(--primary); color: var(--primary-foreground); }
.tg-btn-s { background: var(--secondary); color: var(--secondary-foreground); }
.tg-btn-o { border: 1px solid var(--input); background: var(--background); color: var(--foreground); }
.tg-btn-d { background: var(--destructive); color: var(--destructive-foreground); }
.tg-tabs { display: inline-flex; gap: 2px; justify-self: start; padding: 3px; border-radius: var(--radius); background: var(--muted); color: var(--muted-foreground); }
.tg-tabs span { padding: 5px 12px; border-radius: calc(var(--radius) - 2px); }
.tg-tabs span.on { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tg-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tg-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--card-foreground); }
.tg-kpis .tg-card { display: grid; gap: 4px; }
.tg-k { color: var(--muted-foreground); font-size: 12px; }
.tg-kpis b { font-family: var(--font-heading); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.tg-up { font-size: 11.5px; color: var(--primary); font-weight: 500; }
.tg-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; align-items: start; }
.tg-card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.tg-badge { padding: 2px 9px; border-radius: 999px; background: var(--secondary); color: var(--secondary-foreground); font-size: 11px; font-weight: 500; }
.tg-bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.tg-bars i { flex: 1; border-radius: calc(var(--radius) * .5) calc(var(--radius) * .5) 2px 2px; background: var(--c); opacity: .9; }
.tg-form { display: grid; gap: 10px; align-content: start; }
.tg-form .tg-card-h { margin-bottom: 2px; }
.tg-lbl { display: grid; gap: 5px; font-size: 12px; font-weight: 500; }
.tg-input { display: flex; align-items: center; height: 34px; padding: 0 10px; border: 1px solid var(--input); border-radius: calc(var(--radius) - 2px); background: var(--background); color: var(--foreground); font: inherit; font-weight: 400; outline: none; }
.tg-input:focus { box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.tg-select::after { content: "▾"; margin-left: auto; color: var(--muted-foreground); }
.tg-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.tg-box { width: 16px; height: 16px; border-radius: 4px; background: var(--primary); box-shadow: inset 0 0 0 4px var(--primary), inset 0 0 0 6px var(--primary-foreground); }
.tg-alert { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 12px; padding: 12px 14px; border: 1px solid var(--border); border-left: 3px solid var(--destructive); border-radius: var(--radius); background: var(--card); }
.tg-alert span { color: var(--muted-foreground); }
.tg-table { display: grid; gap: 2px; }
.tg-tr { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.tg-tr:first-of-type { border-top: 0; }
.tg-av { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--muted); color: var(--muted-foreground); font-size: 11px; font-weight: 600; }
.tg-who { display: grid; min-width: 0; }
.tg-who b { font-weight: 500; }
.tg-who i { font-style: normal; color: var(--muted-foreground); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-pill { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; border: 1px solid var(--border); color: var(--muted-foreground); }
.tg-pill-paid { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.tg-pill-refunded { color: var(--destructive); }
.tg-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.tg-dialog { display: grid; align-content: start; gap: 8px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--popover); color: var(--popover-foreground); box-shadow: 0 16px 40px -12px rgba(0,0,0,.35); }
.tg-dialog b { font-family: var(--font-heading); font-size: 15px; }
.tg-dialog p { color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }
.tg-dialog .tg-row { justify-content: flex-end; }

/* right: control panel */
.tg-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--s1); }
.tg-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: grid; gap: 10px; align-content: start; }
.tg-sec { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--s2); }
.tg-sec h2 { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 500; color: var(--mute); }
.tg-sub { font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--dim); }
.tg-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tg-presets button { display: grid; justify-items: center; gap: 5px; padding: 8px 4px 6px; border: 1px solid var(--line); border-radius: 10px; font-size: 11.5px; color: var(--mute); transition: border-color .2s, color .2s; }
.tg-presets button:hover, .tg-presets button[aria-pressed="true"] { border-color: var(--sky-line); color: var(--text); }
.tg-presets i { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.tg-ghost { justify-self: start; height: 30px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 9px; font-size: 12.5px; color: var(--mute); }
.tg-ghost:hover { color: var(--text); border-color: var(--sky-line); }
.tg-brand { display: flex; gap: 8px; }
.tg-brand input[type="color"] { width: 44px; height: 40px; padding: 0; border: 1px solid var(--line-2); border-radius: 10px; background: none; cursor: pointer; }
.tg-brand input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.tg-brand input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }
.tg-hex { flex: 1; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--text); font: 14px var(--mono); outline: none; }
.tg-hex:focus { border-color: var(--sky-line); }
.tg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tg-chips button { height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--mute); transition: color .2s, border-color .2s, background .2s; }
.tg-chips button:hover { color: var(--text); }
.tg-chips button[aria-pressed="true"] { background: var(--sky); border-color: var(--sky); color: var(--sky-ink); }
.tg-rng { display: grid; gap: 6px; font-size: 13px; color: var(--mute); }
.tg-rng > span { display: flex; justify-content: space-between; }
.tg-rng output { font: 12px var(--mono); color: var(--text); }
.tg-rng input { width: 100%; accent-color: var(--sky); }
.tg-contrast { display: grid; gap: 6px; }
.tg-cr { display: grid; grid-template-columns: 34px 1fr auto auto; align-items: center; gap: 10px; font-size: 12.5px; color: var(--mute); }
.tg-cr-s { display: grid; place-items: center; height: 26px; border-radius: 7px; font-weight: 600; font-size: 12px; box-shadow: inset 0 0 0 1px var(--line); }
.tg-cr b { font: 12px var(--mono); color: var(--text); }
.tg-g { font-style: normal; font: 10px var(--mono); padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em; }
.tg-g-aaa, .tg-g-aa { background: rgba(52,211,153,.15); color: #34d399; }
.tg-g-aalarge { background: rgba(251,191,36,.15); color: #fbbf24; }
.tg-g-fail { background: rgba(248,113,113,.15); color: #f87171; }
html[data-theme="light"] .tg-g-aaa, html[data-theme="light"] .tg-g-aa { color: #047857; }
html[data-theme="light"] .tg-g-aalarge { color: #b45309; }
html[data-theme="light"] .tg-g-fail { color: #b91c1c; }
.tg-tokens { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tg-tok { display: grid; grid-template-columns: 16px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 6px; border-radius: 8px; text-align: left; transition: background .2s; }
.tg-tok:hover { background: rgba(255,255,255,.04); }
.tg-tok i { grid-row: span 2; width: 16px; height: 16px; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(127,127,127,.35); }
.tg-tok span { font-size: 11.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-tok code { font-size: 10.5px; color: var(--dim); }

/* export, pinned at the bottom of the panel */
.tg-export { display: grid; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: var(--s1); }
.tg-tabs-x { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; }
.tg-tabs-x button { height: 28px; border-radius: 7px; font-size: 11px; color: var(--mute); white-space: nowrap; }
.tg-tabs-x button[aria-selected="true"] { background: var(--sky); color: var(--sky-ink); }
.tg-code { max-height: 150px; overflow: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: 11px/1.55 var(--mono); color: #c9ccd2; white-space: pre; }
html[data-theme="light"] .tg-code { color: #2b2f36; }
.tg-actions { display: flex; gap: 6px; }
.tg-actions .btn-sky { flex: 1; justify-content: center; }

@media (max-width: 1100px) {
  .tg-app { grid-template-columns: minmax(0, 1fr); }
  .tg-nav { display: none; }
}
@media (max-width: 1000px) {
  .tg { height: auto; grid-template-columns: 1fr; }
  .tg-pv-wrap { height: 70vh; flex: none; }
  .tg-side { border-left: 0; border-top: 1px solid var(--line); }
  .tg-scroll { overflow: visible; }
  .tg-export { position: sticky; bottom: 0; z-index: 5; }
}
@media (max-width: 640px) {
  .tg-kpis, .tg-grid { grid-template-columns: 1fr; }
  .tg-alert { grid-template-columns: 1fr; }
  .tg-content { padding: 16px 14px 20px; }
  .tg-tabs { flex-wrap: wrap; }
  .tg-presets { grid-template-columns: repeat(4, 1fr); }
  .tg-tabs-x button { font-size: 10.5px; }
}
