/* DroneShot Social Stats */
:root {
	--bg: #f6f7f9;
	--surface: #ffffff;
	--surface-2: #f1f3f6;
	--text: #111827;
	--muted: #6b7280;
	--border: #e3e6eb;
	--primary: #2563eb;
	--primary-text: #ffffff;
	--ok: #15803d;
	--ok-bg: #dcfce7;
	--warn: #a16207;
	--warn-bg: #fef3c7;
	--error: #b91c1c;
	--error-bg: #fee2e2;
	--info: #1d4ed8;
	--info-bg: #dbeafe;
	--mock: #7c2d12;
	--mock-bg: #ffedd5;
	--chart-grid: #e5e7eb;
	--fb: #1877f2;
	--ig: #d62976;
	--yt: #e00000;
	--radius: 10px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
	color-scheme: light;
}

:root[data-theme="dark"] {
	--bg: #0f1115;
	--surface: #171a21;
	--surface-2: #1f232c;
	--text: #e6e8ec;
	--muted: #9aa3b2;
	--border: #2a2f3a;
	--primary: #4f8cff;
	--ok: #4ade80;
	--ok-bg: #12321f;
	--warn: #facc15;
	--warn-bg: #3a300c;
	--error: #f87171;
	--error-bg: #3b1515;
	--info: #93c5fd;
	--info-bg: #172554;
	--mock: #fdba74;
	--mock-bg: #3b2111;
	--chart-grid: #2a2f3a;
	--fb: #5b9dff;
	--ig: #f06aa8;
	--yt: #ff5a5a;
	--shadow: none;
	color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
	:root[data-theme="auto"] {
		--bg: #0f1115;
		--surface: #171a21;
		--surface-2: #1f232c;
		--text: #e6e8ec;
		--muted: #9aa3b2;
		--border: #2a2f3a;
		--primary: #4f8cff;
		--ok: #4ade80;
		--ok-bg: #12321f;
		--warn: #facc15;
		--warn-bg: #3a300c;
		--error: #f87171;
		--error-bg: #3b1515;
		--info: #93c5fd;
		--info-bg: #172554;
		--mock: #fdba74;
		--mock-bg: #3b2111;
		--chart-grid: #2a2f3a;
		--fb: #5b9dff;
		--ig: #f06aa8;
		--yt: #ff5a5a;
		--shadow: none;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; line-height: 1.3; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85em; background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
code.break { word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.ok-text { color: var(--ok); }
.error-text { color: var(--error); }
.na { color: var(--muted); font-style: italic; font-size: .9em; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: .25rem 0; }

/* layout */
.container { max-width: 1480px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.container.narrow { max-width: 640px; padding-top: 4rem; }
.topbar {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; gap: 1.25rem;
	padding: .6rem 1.25rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand svg { color: var(--primary); }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a { padding: .4rem .7rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a.active { background: var(--surface-2); color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.footer { text-align: center; padding: 1rem; }
.page-head { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.breadcrumbs { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.flex-row { display: flex; align-items: center; gap: .75rem; }

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.1rem 1.25rem;
	box-shadow: var(--shadow);
	margin-bottom: 1.25rem;
}
.card.empty { text-align: center; padding: 2.5rem 1rem; }

/* banners & feedback */
.mock-banner { background: var(--mock-bg); color: var(--mock); padding: .5rem 1.25rem; text-align: center; font-size: .9rem; border-bottom: 1px solid var(--border); }
.loading-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--primary); z-index: 100; transition: width .2s, opacity .3s; opacity: 0; }
.loading-bar.active { width: 70%; opacity: 1; transition: width 3s ease-out; }
.is-loading .ajax { cursor: progress; }
.flashes { position: relative; }
.flash { position: relative; padding: .7rem 2.2rem .7rem 1rem; border-radius: 8px; margin-bottom: .75rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-info { background: var(--info-bg); color: var(--info); }
.flash-warning { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--error-bg); color: var(--error); }
.flash-close { position: absolute; right: .5rem; top: .45rem; background: none; border: 0; color: inherit; font-size: 1.2rem; cursor: pointer; }
.toast { position: fixed; right: 1rem; bottom: 1rem; max-width: 420px; padding: .8rem 1rem; border-radius: 8px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast-error { background: var(--error); color: #fff; }
.form-errors { list-style: none; padding: .6rem .9rem; margin: 0 0 .75rem; background: var(--error-bg); color: var(--error); border-radius: 8px; }

/* forms & buttons */
.input {
	width: 100%; padding: .5rem .65rem; font: inherit; color: var(--text);
	background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
.input-lg { padding: .7rem .8rem; font-size: 1rem; }
select.input { width: auto; max-width: 100%; }
textarea.input { resize: vertical; }
.form-stack { display: flex; flex-direction: column; gap: .5rem; }
.form-stack label { font-weight: 500; font-size: .9rem; }
.form-stack fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin: 0 0 .75rem; display: flex; flex-direction: column; gap: .45rem; }
.form-stack legend { font-weight: 600; padding: 0 .35rem; }
.form-stack .label { font-weight: 500; font-size: .9rem; }
label.check { font-weight: 400 !important; display: flex; gap: .5rem; align-items: center; }
.inline-form { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
	padding: .5rem .95rem; border-radius: 8px; border: 1px solid transparent;
	font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap;
	background: var(--surface-2); color: var(--text);
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; border-color: var(--border); color: var(--error); }
.btn-danger-ghost:hover { background: var(--error-bg); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn.disabled { opacity: .5; pointer-events: none; }
.btn-icon { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 2rem; height: 2rem; cursor: pointer; font-size: 1rem; }
.btn-row { display: flex; gap: .5rem; }
.link-btn { color: var(--muted); font-weight: 500; }
.link-btn:hover { color: var(--primary); }
.link-btn.danger:hover { color: var(--error); }
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-panel { position: absolute; right: 0; top: calc(100% + .4rem); width: 340px; z-index: 30; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-mock { background: var(--mock-bg); color: var(--mock); }
.pf-badge { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; font-size: .85rem; }
.pf-icon { vertical-align: -3px; flex: none; }
.pf-facebook { color: var(--fb); }
.pf-instagram { color: var(--ig); }
.pf-youtube { color: var(--yt); }
.pf-list { display: inline-flex; gap: .3rem; }
.pf-border-facebook { border-top: 3px solid var(--fb); }
.pf-border-instagram { border-top: 3px solid var(--ig); }
.pf-border-youtube { border-top: 3px solid var(--yt); }

/* comparison list */
.search-row { margin-bottom: 1rem; }
.comparison-list { display: flex; flex-direction: column; }
.comparison-item { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.comparison-item h2 { margin: 0; }
.comparison-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.meta-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: .35rem; }

/* dashboard */
.add-post-row { display: flex; gap: .5rem; }
.manual-id { margin-top: .5rem; }
.manual-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }
.manual-row label { display: flex; flex-direction: column; font-size: .85rem; gap: .2rem; }
.status-bar { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; padding: .55rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1rem; }
.post-card { margin: 0; display: flex; flex-direction: column; gap: .65rem; padding: .9rem 1rem; }
.post-card.dragging { opacity: .5; outline: 2px dashed var(--primary); }
.post-card-head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.drag-handle { cursor: grab; color: var(--muted); letter-spacing: -2px; user-select: none; }
.post-card-body { display: flex; gap: .75rem; }
.thumb { flex: none; width: 92px; height: 92px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-title h3 a { color: var(--text); }
.post-title p { margin: .2rem 0 0; }
.stale-note { background: var(--warn-bg); color: var(--warn); padding: .35rem .6rem; border-radius: 6px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: 0; }
.metric { background: var(--surface-2); border-radius: 8px; padding: .4rem .55rem; min-width: 0; }
.metric dt { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric dd { margin: 0; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-er { background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); }
.unsupported-list { margin: -.2rem 0 0; }
.increments { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.increments th, .increments td { padding: .2rem .35rem; text-align: right; border-bottom: 1px solid var(--border); }
.increments th:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.increments thead th { color: var(--muted); font-weight: 500; font-size: .75rem; }
.increments td.up { color: var(--ok); font-weight: 600; }
.post-card-foot { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: .55rem; margin-top: auto; }
.disclaimer { margin-top: .75rem; }

.charts-section { margin-top: 1.25rem; }
.chart-controls { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.chart-hint { margin: 0; flex-basis: 100%; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.segmented a { padding: .35rem .75rem; font-size: .85rem; color: var(--muted); border-right: 1px solid var(--border); font-weight: 500; }
.segmented a:last-child { border-right: 0; }
.segmented a:hover { background: var(--surface-2); text-decoration: none; }
.segmented a.active { background: var(--primary); color: var(--primary-text); }
.series-toggles { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .75rem; }
.series-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .8rem; cursor: pointer; }
.series-chip .dot { width: .7rem; height: .7rem; border-radius: 50%; }
.series-chip.off { opacity: .45; text-decoration: line-through; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chart-box { margin: 0; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; min-width: 0; }
.chart-box figcaption { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.chart-box-wide { grid-column: 1 / -1; }
.chart-wrap { position: relative; height: 280px; }

.history-panel { border-left: 4px solid var(--primary); }
.status-bar-info { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.add-post { margin-top: 1.25rem; }

/* comments side panel */
.drawer {
	position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
	width: min(480px, 100vw);
	display: flex; flex-direction: column;
	background: var(--surface); border-left: 1px solid var(--border);
	box-shadow: -8px 0 24px rgba(0, 0, 0, .18);
	transform: translateX(100%); transition: transform .2s ease-out;
	visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; }
.drawer .comment-filters { padding: .75rem 1rem 0; margin: 0; }
.drawer .comment-filters .input { flex: 1 1 140px; }
.drawer-body { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .25); }
@media (min-width: 1400px) {
	.drawer-backdrop { background: transparent; pointer-events: none; }
}
.comment-filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.comment-filters .input[type=search] { width: 220px; }
.comment-list { list-style: none; padding: 0; margin: 0; }
.comment { padding: .7rem 0; border-bottom: 1px solid var(--border); }
.comment-head { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.comment-text { margin: .3rem 0; white-space: normal; overflow-wrap: anywhere; }
.pager { display: flex; gap: .35rem; align-items: center; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a { padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 6px; }
.pager a.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .45rem .55rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-dense td, .table-dense th { padding: .3rem .45rem; font-size: .8rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.platform-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; min-width: 150px; margin-bottom: 1rem; }
.stat-label { color: var(--muted); font-size: .8rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.filters-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.checklist { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .9rem; display: flex; flex-direction: column; gap: .3rem; }
.checklist label { font-weight: 400; }
.auth-box { max-width: 380px; margin: 4rem auto; }

/* responsive */
@media (max-width: 1100px) {
	.platform-grid { grid-template-columns: 1fr; }
	.charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
	.grid-2, .grid-2-1 { grid-template-columns: 1fr; }
	.topbar { flex-wrap: wrap; gap: .5rem; }
	.topbar-right { margin-left: 0; }
	.mainnav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
	.comparison-item { flex-direction: column; align-items: stretch; }
	.add-post-row { flex-direction: column; }
	.cards-grid { grid-template-columns: 1fr; }
	.metrics { grid-template-columns: repeat(2, 1fr); }
	.chart-wrap { height: 230px; }
	.dropdown-panel { position: fixed; left: 1rem; right: 1rem; width: auto; }
}

.existing-posts { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.existing-posts h3 { margin-bottom: .5rem; }
