/**
 * The script dashboard.
 *
 * Depends on sg.css, which carries the tokens, the buttons and the script
 * layout itself — a saved script is rendered by the same code as a fresh one,
 * so it has to inherit the same rules rather than a second copy of them.
 *
 * Same specificity discipline as sg.css: the theme styles bare element
 * selectors in main.css at 0-1-1, so anything that could collide is written
 * with two classes.
 */

.sga {
	--sga-radius: var(--r, 16px);
	--sga-line: var(--hairline, #E7D8F2);
	margin-block: 1.5rem;
}

.sga [hidden] {
	display: none;
}

/*
 * Anchors styled as buttons.
 *
 * service.css sets `.svc-page a:not(.btn)` at 0-2-1, which outranks
 * `.sg .sg-btn-primary` at 0-2-0 and paints the brand magenta onto the magenta
 * gradient — the same magenta-on-magenta collision that once hit the service
 * pages. The generator itself never saw it because its buttons are <button>
 * elements; here half of them are links, so they have to out-specify the theme
 * outright rather than hope to be later in the cascade.
 */
.sga a.sg-btn.sg-btn-primary,
.sga a.sg-btn.sg-btn-primary:hover,
.sga a.sg-btn.sg-btn-primary:focus {
	color: #fff;
}

.sga a.sg-btn.sg-btn-ghost {
	color: var(--ink, #1E1233);
}

.sga a.sg-btn.sg-btn-ghost:hover,
.sga a.sg-btn.sg-btn-ghost:focus {
	color: var(--violet, #9B23D4);
}

.sga-boot {
	margin: 0;
	padding: 2rem 0;
	text-align: center;
	color: var(--muted, #7C6B94);
}

.sga-card {
	padding: clamp(1.15rem, 3vw, 1.75rem);
	background: var(--surface, #fff);
	border: 1px solid var(--sga-line);
	border-radius: var(--sga-radius);
	box-shadow: var(--sh-sm, 0 1px 2px #1E123310, 0 2px 6px #1E12330A);
}

/* ---------------- signed out ---------------- */

.sga-out {
	max-width: 34rem;
	margin-inline: auto;
	text-align: center;
}

.sga .sga-out-title {
	margin: 0 0 .5rem;
	font-size: 1.3rem;
	font-weight: 800;
	color: var(--ink, #1E1233);
}

.sga-out-text {
	margin: 0 0 1.25rem;
	font-size: .95rem;
	line-height: 1.6;
	color: var(--ink-2, #4C3D66);
}

/* ---------------- who ---------------- */

.sga-who {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: .5rem;
	margin: 0 0 1rem;
	font-size: .88rem;
	color: var(--muted, #7C6B94);
}

/* ---------------- plan ---------------- */

.sga-plan-top {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: .75rem;
	margin-bottom: 1.15rem;
}

.sga-eyebrow {
	margin: 0 0 .15rem;
	font-size: .74rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--violet, #9B23D4);
}

.sga .sga-plan-name {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 800;
	line-height: 1.15;
	color: var(--ink, #1E1233);
}

.sga-meter-track {
	height: .5rem;
	margin-bottom: .6rem;
	border-radius: 999px;
	background: var(--paper, #F5ECFA);
	overflow: hidden;
}

.sga-meter-fill {
	display: block;
	height: 100%;
	width: 0;
	border-radius: 999px;
	background: var(--violet, #9B23D4);
	transition: width .35s ease;
}

.sga-meter-text {
	margin: 0;
	font-size: .95rem;
	font-weight: 650;
	color: var(--ink, #1E1233);
}

.sga-meter-reset {
	margin: .15rem 0 0;
	font-size: .85rem;
	color: var(--muted, #7C6B94);
}

.sga-notice {
	margin: 1.1rem 0 0;
	padding: .8rem .95rem;
	border: 1px solid var(--sga-line);
	border-radius: var(--r-sm, 10px);
	background: var(--violet-soft, #9B23D414);
	font-size: .88rem;
	line-height: 1.55;
	color: var(--ink-2, #4C3D66);
}

.sga-billing {
	margin: 1rem 0 0;
	font-size: .86rem;
}

/* ---------------- sections ---------------- */

.sga-section {
	margin-top: 2rem;
}

.sga .sga-h2 {
	margin: 0 0 .9rem;
	font-size: 1.2rem;
	font-weight: 800;
	color: var(--ink, #1E1233);
}

/* ---------------- plans ---------------- */

.sga-plans {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
	gap: .8rem;
}

.sga-tier {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: .3rem;
	padding: 1.1rem;
	border: 1px solid var(--sga-line);
	border-radius: var(--sga-radius);
	background: var(--surface, #fff);
}

.sga-tier.is-current {
	border-color: var(--violet, #9B23D4);
	background: var(--violet-soft, #9B23D414);
}

.sga .sga-tier-name {
	margin: 0;
	font-size: 1.02rem;
	font-weight: 750;
	color: var(--ink, #1E1233);
}

.sga-tier-price {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 800;
	color: var(--ink, #1E1233);
}

.sga-tier-period,
.sga-tier-allowance {
	font-size: .84rem;
	font-weight: 500;
	color: var(--muted, #7C6B94);
}

.sga-tier-allowance {
	margin: 0 0 .5rem;
}

.sga-tier-current {
	margin: 0;
	font-size: .8rem;
	font-weight: 700;
	color: var(--violet, #9B23D4);
}

.sga-tier-soon {
	font-size: .82rem;
	color: var(--muted, #7C6B94);
}

/* Pushes the button to the bottom so cards of different heights line up. */
.sga-tier-cta {
	margin-top: auto;
}

/* ---------------- scripts ---------------- */

.sga-scripts-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: .6rem;
	margin-bottom: .5rem;
}

.sga-scripts-head .sga-h2 {
	margin: 0;
}

.sga-retention {
	margin: 0 0 .9rem;
	font-size: .85rem;
	color: var(--muted, #7C6B94);
}

.sga-list {
	display: grid;
	gap: .6rem;
}

.sga-item {
	padding: .95rem 1.1rem;
	border: 1px solid var(--sga-line);
	border-radius: var(--r-sm, 10px);
	background: var(--surface, #fff);
}

.sga-item-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: .6rem;
}

.sga-item-meta {
	min-width: 0;
	flex: 1 1 14rem;
}

.sga .sga-item-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.35;
	color: var(--ink, #1E1233);
}

.sga-item-sub {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5rem;
	margin: .2rem 0 0;
	font-size: .82rem;
	color: var(--muted, #7C6B94);
}

.sga-item-goal {
	padding: .1rem .45rem;
	border-radius: 999px;
	background: var(--paper, #F5ECFA);
	font-weight: 650;
}

.sga-item-tools {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem;
}

/* Red only once armed, so the destructive state is the one that looks it. */
.sga .sg-btn.is-confirming {
	border-color: #B02121;
	color: #B02121;
}

.sga-item-body {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--sga-line);
}

.sga-empty {
	margin: 0;
	padding: 1.5rem;
	border: 1px dashed var(--sga-line);
	border-radius: var(--sga-radius);
	text-align: center;
	font-size: .92rem;
	color: var(--muted, #7C6B94);
}

@media (max-width: 560px) {
	.sga-item-tools {
		width: 100%;
	}

	.sga-item-tools .sg-btn {
		flex: 1 1 auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sga-meter-fill {
		transition: none;
	}
}
