/* ==========================================================================
   AIpost Admin — Variant A4 · Contrast
   Global admin framework: layout, shell, and reusable components.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Brand */
    --teal: #2DB3A3;
    --teal-600: #279C8E;
    --teal-700: #217F74;
    --teal-800: #175C55;
    --teal-900: #0F3D38;
    --teal-200: #A7E3DB;
    --teal-100: #D4F0EC;
    --teal-50: #E8F7F5;
    --teal-25: #F4FBFA;

    /* Neutrals */
    --ink: #0A0C0F;
    --slate-900: #0F172A;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748B;
    --slate-400: #94A3B8;
    --slate-300: #CBD5E1;
    --slate-200: #E2E8F0;
    --slate-100: #F1F5F9;
    --slate-50: #F8FAFC;
    --white: #ffffff;

    /* Semantic */
    --success: #16A34A;
    --warn: #D97706;
    --danger: #DC2626;
    --info: #2563EB;

    /* Surfaces */
    --canvas: #F2F4F7;
    --sb-bg: #E6F4F1;
    --sb-bg-strong: #D4ECE7;

    /* Shadows */
    --shadow-card: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 2px 4px rgba(15, 23, 42, .05), 0 8px 20px rgba(15, 23, 42, .06);

    /* Typography */
    --font: 'Inter', system-ui, sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* Layout */
    --sb-w: 240px;
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; background: var(--canvas); }
html, body { max-width: 100vw; }

body {
    font-family: var(--font);
    color: var(--slate-700);
    background: var(--canvas);
    line-height: 1.5;
    font-size: 14px;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

h1, h2, h3 { font-family: var(--font); color: var(--slate-900); line-height: 1.2; letter-spacing: -.015em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
svg { display: block; }

/* ==========================================================================
   APP SHELL
   ========================================================================== */

.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sb {
    width: var(--sb-w);
    min-width: var(--sb-w);
    height: 100vh;
    position: sticky;
    top: 0;
    border-right: 1px solid var(--slate-200);
    background: var(--white);
    display: flex;
    flex-direction: column;
}

.sb-logo {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--slate-200);
}
.sb-logo svg { height: 26px; width: auto; }

.sb-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sb-sec {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--teal-700);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 14px 10px 6px;
    opacity: .75;
}
.sb-sec:first-child { padding-top: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--teal-800);
    position: relative;
    transition: background .12s ease, color .12s ease;
}
.nav-item svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75; fill: none; opacity: .85; }
.nav-item:hover { background: rgba(45, 179, 163, .10); color: var(--teal-900); }
.nav-item.active { color: var(--white); background: var(--teal); }
.nav-item.active svg { color: var(--white); opacity: 1; }

/* AI Generování — rainbow hue cycling applied to text + icon stroke.
   The SVG uses stroke: currentColor so the keyframe-driven color change
   propagates to both. When the item is active, .nav-item.active overrides
   back to solid white for readability against the teal background. */
.nav-item-ai:not(.active) {
    animation: nav-rainbow 4s linear infinite;
    font-weight: 600;
}
.nav-item-ai:not(.active) svg { opacity: 1; }
.nav-item-ai:not(.active):hover { background: rgba(45, 179, 163, .10); }
@keyframes nav-rainbow {
    0%   { color: #ec4899; }
    16%  { color: #f59e0b; }
    33%  { color: #22c55e; }
    50%  { color: #06b6d4; }
    66%  { color: #6366f1; }
    83%  { color: #8b5cf6; }
    100% { color: #ec4899; }
}
@media (prefers-reduced-motion: reduce) {
    .nav-item-ai:not(.active) { animation: none; color: #8b5cf6; }
}

.sb-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 0 0 6px;
    padding: 7px 12px;
    border-radius: 8px;
    background: var(--white);
    color: var(--teal-800);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--slate-200);
    box-shadow: var(--shadow-card);
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.sb-cta:hover {
    background: var(--teal-50);
    color: var(--teal-900);
    border-color: var(--teal-200);
}
.sb-cta svg {
    width: 14px; height: 14px;
    stroke: currentColor; stroke-width: 2; fill: none;
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: var(--teal-700);
    background: rgba(45, 179, 163, .12);
    padding: 1px 7px;
    border-radius: 4px;
}
.nav-item.active .nav-badge { background: var(--white); color: var(--teal-700); }

.sb-user {
    padding: 10px 12px;
    border-top: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    gap: 6px;
}
.sb-user-link {
    flex: 1; min-width: 0;
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background .12s ease;
}
.sb-user-link:hover { background: var(--teal-50); }
.sb-user-avatar {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 50%;
    background: var(--teal);
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name {
    font-size: 13px; font-weight: 600; color: var(--slate-900);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-role { font-size: 11px; color: var(--teal-700); font-weight: 500; }
.sb-user-btn {
    width: 36px; height: 44px; border-radius: 8px;
    color: var(--slate-500);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sb-user-btn:hover { background: var(--teal-50); color: var(--teal-700); }
.sb-user-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.75; fill: none; }

/* Impersonation banner — shown at the bottom of the sidebar (above the user
   box) when a superadmin is temporarily logged in as another user. */
.sb-impersonation {
    margin: 0 12px 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #FEF3C7;
    border: 1px solid #FDE68A;
    color: #92400E;
    display: flex; flex-direction: column; gap: 6px;
}
.sb-impersonation-label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    opacity: .85;
}
.sb-impersonation-name {
    font-size: 13px; font-weight: 600; color: #78350F;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-impersonation-btn {
    background: var(--white);
    color: #92400E;
    border: 1px solid #B45309;
    font-size: 12px; font-weight: 500;
    padding: 5px 8px;
    display: inline-flex; align-items: center; gap: 6px;
    width: 100%;
    justify-content: center;
}
.sb-impersonation-btn:hover { background: #B45309; color: var(--white); }

/* Trial badge — rendered at the bottom of the sidebar (above the user box,
   stacks with the impersonation banner when both apply) while the org is on
   an active trial subscription. Teal→indigo gradient panel drives the eye to
   the upgrade CTA without reading as an error state. */
.sb-trial {
    margin: 0 12px 10px;
    padding: 14px 14px 12px;
    border-radius: 10px;
    background: linear-gradient(160deg, var(--teal-600) 0%, var(--teal) 100%);
    color: #FFFFFF;
}
.sb-trial-head { margin-bottom: 10px; }
.sb-trial-tag {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    color: #FFFFFF;
    font-size: 10px; font-weight: 700;
    letter-spacing: .08em;
}
.sb-trial-date {
    display: flex; align-items: center; gap: 7px;
    margin-bottom: 12px;
    font-size: 12px; font-weight: 500;
    color: rgba(236, 254, 255, .85);
}
.sb-trial-date strong { color: #FFFFFF; font-weight: 700; }
.sb-trial-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--teal-800);
    font-size: 12.5px; font-weight: 600;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.sb-trial-btn:hover {
    background: var(--teal-50);
    color: var(--teal-900);
}
.sb-trial-btn svg { transition: transform .15s ease; }
.sb-trial-btn:hover svg { transform: translateX(2px); }

/* ==========================================================================
   TOPBAR
   ========================================================================== */

.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--white);
    border-bottom: 1px solid var(--slate-200);
    box-shadow: var(--shadow-card);
    position: sticky;
    top: 0;
    z-index: 10;
}

.crumbs {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--slate-500);
    list-style: none;
}
.crumbs a:hover { color: var(--slate-900); }
.crumbs .sep { color: var(--slate-300); }
.crumbs .cur { color: var(--slate-900); font-weight: 500; }

.top-actions { display: flex; align-items: center; gap: 8px; }

/* ==========================================================================
   CREDIT BADGE (topbar)
   ========================================================================== */
.credit-badge {
    display: inline-flex; align-items: center; gap: 7px;
    height: 32px; padding: 0 8px 0 12px;
    border-radius: 999px;
    background: linear-gradient(95deg, #FBBF24 0%, #F59E0B 100%);
    color: #451A03;
    font-size: 13px; font-weight: 700;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(120, 53, 15, .12);
    transition: filter .12s ease, box-shadow .12s ease;
    margin-right: 4px;
}
.credit-badge:hover {
    filter: brightness(1.04);
    box-shadow: 0 2px 4px rgba(120, 53, 15, .18);
}
.credit-badge:active { filter: brightness(.96); }
.credit-badge__icon {
    width: 15px; height: 15px; flex-shrink: 0;
    fill: none; stroke: #451A03; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    opacity: 1;
}
.credit-badge__value {
    font-variant-numeric: tabular-nums;
    letter-spacing: .005em;
    font-size: 14px;
    font-weight: 700;
    color: #1A1206;
}
.credit-badge__label {
    font-weight: 500;
    opacity: .78;
    font-size: 11.5px;
    letter-spacing: .015em;
    margin-left: -3px;
    color: #451A03;
}
.credit-badge__divider { display: none; }
.credit-badge__plus {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(120, 53, 15, .14);
    color: #451A03;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .12s ease;
}
.credit-badge:hover .credit-badge__plus { background: rgba(120, 53, 15, .22); }
.credit-badge__plus svg {
    width: 10px; height: 10px; display: block;
    fill: none; stroke: currentColor; stroke-width: 2.5;
    stroke-linecap: round;
}

.credit-badge.is-low {
    background: linear-gradient(95deg, #EF4444 0%, #DC2626 100%);
    color: #FFFFFF;
    border-color: rgba(127, 29, 29, .12);
    box-shadow: 0 1px 2px rgba(127, 29, 29, .2);
}
.credit-badge.is-low:hover { filter: brightness(1.04); }
.credit-badge.is-low .credit-badge__icon { stroke: #FFFFFF; opacity: 1; }
.credit-badge.is-low .credit-badge__value,
.credit-badge.is-low .credit-badge__label { color: #FFFFFF; }
.credit-badge.is-low .credit-badge__label { opacity: .85; }
.credit-badge.is-low .credit-badge__plus {
    color: #FFFFFF;
    background: rgba(255, 255, 255, .2);
}
.credit-badge.is-low:hover .credit-badge__plus { background: rgba(255, 255, 255, .3); }

@media (max-width: 720px) {
    .credit-badge__label { display: none; }
    .credit-badge { padding-left: 11px; gap: 6px; }
}

/* ==========================================================================
   CREDIT COST CHIP (inside AI buttons)
   ========================================================================== */
.credit-chip {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    margin-left: 8px; padding: 0 8px;
    height: 20px;
    border-radius: 999px;
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid rgba(146, 64, 14, .18);
    font-size: 11px; font-weight: 700;
    line-height: 1; letter-spacing: .01em;
    font-variant-numeric: tabular-nums;
    vertical-align: middle;
}
.credit-chip__icon {
    width: 11px; height: 11px;
    display: block;
    fill: none; stroke: currentColor; stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
    flex-shrink: 0;
}
.credit-chip [data-chip-value] {
    display: block; line-height: 1;
    /* Optical compensation — SVG diamond's geometric centre sits ~0.5px
       above the typographic baseline of the digits, so the digits look
       low without this nudge. */
    transform: translateY(.5px);
}
.btn:disabled .credit-chip { opacity: .6; }

.search {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px; border-radius: 8px;
    font-size: 12px; color: var(--slate-500);
    min-width: 260px;
    background: var(--canvas);
    transition: background .12s;
}
.search:hover { background: var(--teal-50); color: var(--teal-700); }
.search svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.75; fill: none; }
.search kbd {
    margin-left: auto;
    font-family: var(--mono); font-size: 10px;
    padding: 2px 6px; border-radius: 4px;
    color: var(--slate-500); background: var(--white);
    font-weight: 500;
}

.icon-btn {
    width: 32px; height: 32px; border-radius: 6px;
    color: var(--slate-500);
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.icon-btn:hover { background: var(--slate-200); color: var(--slate-900); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75; fill: none; }

.dot {
    position: absolute; top: 1px; right: 1px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px;
    background: #EF4444; color: var(--white);
    font-size: 9.5px; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--white);
}

.topbar-burger {
    display: none;
    width: 36px; height: 36px; border-radius: 6px;
    align-items: center; justify-content: center;
    color: var(--slate-700);
    background: none; border: none; cursor: pointer;
    margin-right: 8px;
}
.topbar-burger:hover { background: var(--slate-200); color: var(--slate-900); }
.topbar-burger svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; }

.sb-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(15, 23, 42, .4);
    z-index: 49;
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.sb-backdrop.open { opacity: 1; pointer-events: auto; }

/* ==========================================================================
   PAGE
   ========================================================================== */

.page { padding: 28px; max-width: 1400px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}
.page-title {
    font-size: 22px; font-weight: 600; color: var(--slate-900);
    display: flex; align-items: center; gap: 10px;
}
.page-title-tag {
    font-size: 11px; font-weight: 600;
    padding: 3px 10px; border-radius: 999px;
    background: var(--teal); color: var(--white);
}
.page-sub { font-size: 13px; color: var(--slate-500); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all .12s ease;
    border: 1px solid transparent;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }
.btn .ph-duotone { font-size: 15px; line-height: 1; }
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-700); }
.btn-outline { background: var(--white); color: var(--slate-700); box-shadow: var(--shadow-card); }
.btn-outline:hover { background: var(--slate-700); color: var(--white); box-shadow: var(--shadow-md); }
.btn-ghost { color: var(--slate-600); }
.btn-ghost:hover { background: var(--slate-200); color: var(--slate-900); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #B91C1C; }
.btn-warning { background: var(--white); color: #B45309; border-color: #B45309; }
.btn-warning:hover { background: #B45309; color: var(--white); }
.btn-trial {
    background: linear-gradient(95deg, var(--teal) 0%, var(--teal-600) 100%);
    color: var(--white);
    font-weight: 700;
    padding: 11px 16px;
    box-shadow: 0 1px 2px rgba(33, 127, 116, .2), 0 4px 12px -4px rgba(45, 179, 163, .5);
    border: 1px solid rgba(15, 61, 56, .2);
    transition: filter .12s ease, box-shadow .12s ease;
}
.btn-trial:hover {
    filter: brightness(1.05);
    box-shadow: 0 2px 4px rgba(33, 127, 116, .25), 0 6px 16px -4px rgba(45, 179, 163, .65);
}
.btn-trial:active { filter: brightness(.95); }
.btn-trial .ph-duotone { font-size: 16px; }

/* AI action button — uses the brand primary teal so AI triggers are
   consistent with every other primary CTA in the app. Kept as a separate
   class so the markup explicitly reads "this is an AI action" and so we can
   tweak the variant later (e.g. add a sparkle glow) in one place. */
.btn-ai {
    background: var(--teal);
    color: var(--white);
    font-weight: 600;
    border: 1px solid transparent;
    transition: background .12s ease;
}
.btn-ai:hover { background: var(--teal-700); color: var(--white); }
.btn-ai:active { background: var(--teal-800); }
.btn-ai[disabled] { background: var(--teal-200); cursor: not-allowed; opacity: .85; }
.btn-ai .ph-duotone { color: rgba(255, 255, 255, .95); }

/* ==========================================================================
   STATS
   ========================================================================== */

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.stat {
    padding: 18px;
    border-radius: 10px;
    background: var(--white);
    box-shadow: var(--shadow-card);
    transition: box-shadow .15s, transform .15s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label {
    font-size: 12px; color: var(--slate-500);
    font-weight: 500; margin-bottom: 8px;
    display: flex; align-items: center; justify-content: space-between;
}
.stat-label svg { width: 14px; height: 14px; stroke: var(--teal); stroke-width: 1.75; fill: none; }
.stat-label .ph-duotone { color: var(--teal); font-size: 16px; line-height: 1; }
.stat-val {
    font-size: 26px; font-weight: 600;
    color: var(--teal-800);
    letter-spacing: -.02em; line-height: 1;
}
.stat-delta {
    font-size: 12px; margin-top: 8px;
    display: flex; align-items: center; gap: 4px;
    font-weight: 500;
}
.stat-delta svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }
.up { color: var(--success); }
.down { color: var(--danger); }

/* ==========================================================================
   CARD
   ========================================================================== */

.card {
    border-radius: 10px;
    background: var(--white);
    box-shadow: var(--shadow-card);
}
.card-head, .ac-head {
    padding: 16px 20px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--slate-200);
}
.card-title {
    font-size: 15px; font-weight: 700; color: var(--slate-900);
    display: flex; align-items: center; gap: 8px;
}
.card-count {
    font-size: 11px; font-weight: 600;
    color: var(--white); background: var(--teal);
    padding: 2px 8px; border-radius: 999px;
}
.card-actions { display: flex; gap: 6px; }

.card-body { padding: 20px; }
.card-foot {
    padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--slate-50);
    border-radius: 0 0 10px 10px;
}
.foot-info { font-size: 12px; color: var(--slate-500); }

/* ==========================================================================
   TABLE
   ========================================================================== */

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap::-webkit-scrollbar { height: 8px; }
.tbl-wrap::-webkit-scrollbar-track { background: transparent; }
.tbl-wrap::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 4px; }
.tbl-wrap::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }

.tbl { width: 100%; border-collapse: collapse; min-width: 720px; }
.tbl th {
    text-align: left;
    font-size: 11px; font-weight: 700; color: var(--slate-700);
    text-transform: uppercase; letter-spacing: .06em;
    padding: 12px 20px;
    background: var(--slate-100);
    border-bottom: 1px solid var(--slate-200);
}
.tbl td { padding: 14px 20px; font-size: 13px; vertical-align: middle; }
.tbl tbody tr + tr td { box-shadow: inset 0 1px 0 var(--slate-100); }
.tbl tr:hover td { background: var(--teal-25); }

.td-id { font-family: var(--mono); font-size: 12px; color: var(--teal-700); font-weight: 500; }
.td-post { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; }
.td-post > :not(.td-thumb) { flex: 1; min-width: 0; }
.td-thumb {
    width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
    background: var(--teal-50);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: var(--teal-700);
    line-height: 1;
    overflow: hidden;
}
.td-thumb .ph-duotone { display: inline-block; line-height: 1; }
.td-thumb-img { background: var(--slate-100); }
.td-thumb-img img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.td-post-title {
    font-weight: 500; color: var(--slate-900); margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
}
.td-post-excerpt {
    font-size: 11px; color: var(--slate-500);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
}
.td-date { font-size: 12px; color: var(--slate-500); font-family: var(--mono); }
.td-act { text-align: right; }

.dots-btn {
    width: 26px; height: 26px; border-radius: 5px;
    color: var(--slate-400);
    display: inline-flex; align-items: center; justify-content: center;
}
.dots-btn:hover { background: var(--slate-200); color: var(--slate-900); }
.dots-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* ==========================================================================
   PLATFORM ICONS
   ========================================================================== */

.td-platforms { display: flex; gap: 4px; }
.platform {
    width: 22px; height: 22px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    color: var(--white);
}
.platform svg { width: 12px; height: 12px; fill: currentColor; }
.platform.fb { background: #1877F2; }
.platform.ig { background: linear-gradient(45deg, #F58529, #DD2A7B, #8134AF); }
.platform.li { background: #0A66C2; }
.platform.tt { background: #111111; }

/* ==========================================================================
   PILLS (status badges)
   ========================================================================== */

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600;
    padding: 4px 10px; border-radius: 999px;
}
.pill::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
}
.pill-draft { color: #475569; background: #E2E8F0; }
.pill-sched { color: #6D28D9; background: #EDE9FE; }
.pill-pub   { color: #047857; background: #D1FAE5; }
.pill-fail  { color: #BE123C; background: #FFE4E6; }
.pill-gen   { color: #0369A1; background: #E0F2FE; }
.pill-warn  { color: #B45309; background: #FEF3C7; }
.pill-muted { color: #64748B; background: #F1F5F9; }

/* ==========================================================================
   INFO LIST (dl/dt/dd definition rows used on detail pages)
   ========================================================================== */

.info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
}
.info-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 6px 0;
    border-bottom: 1px solid var(--slate-100);
}
.info-row:last-child { border-bottom: none; }
.info-row dt {
    flex: 0 0 140px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--slate-500);
}
.info-row dd {
    flex: 1 1 auto;
    margin: 0;
    font-size: 13px;
    color: var(--slate-800);
    word-break: break-word;
}
.info-strong { font-weight: 600; color: var(--slate-900); }
.info-muted  { color: var(--slate-400); }
.info-date   { color: var(--slate-600); font-variant-numeric: tabular-nums; }
.info-code {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--slate-700);
    background: var(--slate-100);
    padding: 1px 6px;
    border-radius: 4px;
}

/* Two-column detail layout used by organization / subscription detail pages */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
}

/* ==========================================================================
   PAGINATION
   ========================================================================== */

.pag { display: flex; gap: 4px; }
.pag-btn {
    min-width: 28px; height: 28px; padding: 0 10px;
    font-size: 12px; font-weight: 500;
    border-radius: 6px; background: transparent;
    color: var(--slate-600);
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .12s;
}
.pag-btn:hover { background: var(--slate-900); color: var(--white); }
.pag-btn.active { background: var(--teal); color: var(--white); }
.pag-btn svg { width: 12px; height: 12px; fill: currentColor; }

/* ==========================================================================
   GRID / ACTIVITY / SCHEDULE
   ========================================================================== */

.grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.ac-list { padding: 4px 0 10px; }
.ac-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 20px;
    font-size: 13px;
}
.ac-item:hover { background: var(--teal-25); }
.ac-bar {
    width: 3px; align-self: stretch;
    border-radius: 2px;
    background: var(--teal);
    flex-shrink: 0;
}
.ac-bar.teal  { background: var(--teal); }
.ac-bar.blue  { background: var(--info); }
.ac-bar.green { background: var(--success); }
.ac-bar.amber { background: var(--warn); }
.ac-bar.red   { background: var(--danger, #EF4444); }
.ac-bar.slate { background: var(--slate-300); }
.ac-text { flex: 1; color: var(--slate-700); min-width: 0; }
.ac-text b { color: var(--slate-900); font-weight: 600; }
.ac-meta {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.ac-actor {
    font-size: 12px; color: var(--slate-600);
    font-weight: 500; white-space: nowrap;
    max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.ac-org {
    font-size: 11px; color: var(--slate-400);
    white-space: nowrap;
    max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}
.ac-time {
    font-size: 11px; color: var(--slate-400);
    white-space: nowrap; font-family: var(--mono);
}
/* Clickable activity rows (anchor tag instead of div). */
a.ac-item {
    color: inherit; text-decoration: none;
    transition: background .12s ease;
}
a.ac-item:hover { background: var(--teal-25); }
a.ac-item:hover .ac-text { color: var(--slate-900); }

.sched-item {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 20px;
    transition: background .12s;
}
.sched-item:hover { background: var(--teal-25); }
.sched-date {
    width: 42px; flex-shrink: 0;
    text-align: center; padding: 6px 0;
    background: var(--teal-50);
    border: 1px solid var(--teal-100);
    border-radius: 6px;
}
.sched-day { font-size: 16px; font-weight: 700; color: var(--teal-800); line-height: 1; }
.sched-mon {
    font-size: 10px; color: var(--teal-700);
    text-transform: uppercase; letter-spacing: .04em;
    margin-top: 2px; font-weight: 600;
}
.sched-info { flex: 1; min-width: 0; }
.sched-title {
    font-size: 13px; font-weight: 500; color: var(--slate-900);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sched-meta {
    font-size: 11px; color: var(--slate-500); margin-top: 2px;
    display: flex; align-items: center; gap: 8px;
}
.sched-meta .platform { width: 16px; height: 16px; }
.sched-meta .platform svg { width: 9px; height: 9px; }

/* ==========================================================================
   DROPDOWNS
   ========================================================================== */

.dd-anchor { position: relative; display: inline-flex; }
.dropdown {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    width: 300px;
    max-width: calc(100vw - 24px);
    overflow: hidden;
}
.dropdown.dd-pop {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
    transform-origin: top right;
    animation: ddIn .14s ease-out;
}
.dd-anchor:not(.open) > .dd-pop { display: none; }
@keyframes ddIn {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.dd-head {
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--slate-200);
}
.dd-title {
    font-size: 14px; font-weight: 700; color: var(--slate-900);
    display: flex; align-items: center; gap: 8px;
}
.dd-title-count {
    font-size: 10.5px; font-weight: 700;
    padding: 2px 7px; border-radius: 999px;
    background: var(--teal); color: var(--white);
}
.dd-close {
    width: 26px; height: 26px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: var(--slate-500); cursor: pointer;
    border: none; background: none;
}
.dd-close:hover { background: var(--slate-200); color: var(--slate-900); }
.dd-close svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }
.dd-link {
    font-size: 12px; font-weight: 600; color: var(--teal-700);
    background: none; border: none; cursor: pointer;
    padding: 4px 8px; border-radius: 5px;
}
.dd-link:hover { background: var(--teal-50); }

.dd-body { max-height: 420px; overflow-y: auto; }
.dd-section { padding: 12px 16px; }
.dd-section + .dd-section { border-top: 1px solid var(--slate-100); }
.dd-section-label {
    font-size: 10px; font-weight: 700; color: var(--slate-500);
    text-transform: uppercase; letter-spacing: .08em;
    margin-bottom: 10px;
}

.dd-check {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 0; font-size: 13px; color: var(--slate-700);
    cursor: pointer; user-select: none;
}
.dd-check:hover { color: var(--slate-900); }
.dd-check input { position: absolute; opacity: 0; pointer-events: none; }
.dd-check .box {
    width: 16px; height: 16px; border-radius: 4px;
    border: 1.5px solid var(--slate-300);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all .12s;
    background: var(--white);
}
.dd-check input:checked ~ .box { background: var(--teal); border-color: var(--teal); }
.dd-check input:checked ~ .box::after {
    content: '';
    width: 4px; height: 8px;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(45deg) translate(-1px, -1px);
}
.dd-count { margin-left: auto; font-size: 11px; color: var(--slate-400); font-weight: 500; }

.dd-toggle {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 0; font-size: 13px; color: var(--slate-700);
    cursor: pointer; user-select: none;
}
.dd-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.dd-toggle .switch {
    position: relative;
    width: 30px; height: 18px;
    border-radius: 10px; background: var(--slate-300);
    flex-shrink: 0;
    transition: background .15s;
}
.dd-toggle .switch::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%;
    background: white;
    transition: transform .15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.dd-toggle input:checked ~ .switch { background: var(--teal); }
.dd-toggle input:checked ~ .switch::after { transform: translateX(12px); }
.dd-toggle-label { flex: 1; }
.dd-toggle-drag {
    color: var(--slate-300); cursor: grab;
    flex-shrink: 0;
    display: flex; padding: 4px; border-radius: 4px;
    transition: color .12s, background .12s;
}
.dd-toggle-drag:hover { color: var(--slate-600); background: var(--slate-100); }
.dd-toggle-drag:active { cursor: grabbing; }
.dd-toggle-drag svg { width: 14px; height: 14px; fill: currentColor; }
.dd-toggle.draggable {
    padding-left: 6px; padding-right: 6px;
    margin-left: -6px; margin-right: -6px;
    border-radius: 6px;
    transition: background .12s;
}
.dd-toggle.dragging { opacity: .45; background: var(--teal-25); }
.dd-placeholder {
    height: 2px; background: var(--teal); border-radius: 2px;
    margin: 4px 0; pointer-events: none;
    box-shadow: 0 0 0 3px rgba(45, 179, 163, .18);
}

.dd-foot {
    padding: 10px 14px;
    display: flex; justify-content: flex-end; gap: 8px;
    border-top: 1px solid var(--slate-200);
    background: var(--slate-50);
}
.dd-foot .btn { padding: 7px 14px; font-size: 12px; }

/* Notification list */
.notif-list { padding: 0; }
.notif-empty {
    padding: 22px 20px;
    text-align: center;
    font-size: 13px;
    color: var(--slate-500);
}
.notif-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px 14px 22px;
    cursor: pointer;
    transition: background .12s;
    position: relative;
}
.notif-item + .notif-item { border-top: 1px solid var(--slate-100); }
.notif-item:hover { background: var(--teal-25); }
.notif-item.unread { background: var(--teal-25); }
.notif-item.unread::before {
    content: ''; position: absolute;
    left: 8px; top: 20px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--teal);
}
.notif-icon {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.notif-icon.info { background: #E0F2FE; color: #0369A1; }
.notif-icon.ok   { background: #D1FAE5; color: #047857; }
.notif-icon.warn { background: #FEF3C7; color: #B45309; }
.notif-icon.err  { background: #FFE4E6; color: #BE123C; }
.notif-content { flex: 1; min-width: 0; }
.notif-text { font-size: 13px; color: var(--slate-700); line-height: 1.45; }
.notif-text b { font-weight: 600; color: var(--slate-900); }
.notif-time { font-size: 11px; color: var(--slate-400); margin-top: 3px; }

/* ==========================================================================
   ALERTS (flash messages)
   ========================================================================== */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px;
    border: 1px solid transparent;
}
.alert-success { background: #D1FAE5; color: #047857; border-color: #A7F3D0; }
.alert-error   { background: #FFE4E6; color: #BE123C; border-color: #FECDD3; }
.alert-warning { background: #FEF3C7; color: #B45309; border-color: #FDE68A; }
.alert-info    { background: #E0F2FE; color: #0369A1; border-color: #BAE6FD; }

.alert-close {
    margin-left: auto;
    width: 24px; height: 24px; border-radius: 5px;
    background: transparent; border: none; cursor: pointer;
    color: currentColor; opacity: .55;
    font-size: 18px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: opacity .12s, background .12s;
}
.alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }

/* ==========================================================================
   FORMS (baseline — refine later)
   ========================================================================== */

.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 12px; font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    font-family: inherit; font-size: 13px;
    color: var(--slate-900);
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    transition: border-color .12s, box-shadow .12s;
}
.form-control:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(45, 179, 163, .15);
}
.form-control::placeholder { color: var(--slate-400); }
textarea.form-control { min-height: 96px; resize: vertical; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    padding-right: 32px;
}

.form-text {
    display: block;
    font-size: 11.5px;
    color: var(--slate-500);
    margin-top: 6px;
    line-height: 1.45;
}
.form-required { color: var(--danger); margin-left: 2px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}
.form-grid .form-full { grid-column: 1 / -1; }
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 18px;
    margin-top: 6px;
    border-top: 1px solid var(--slate-100);
}
.form-actions .form-actions-spacer { flex: 1; }

/* Validation summary inside forms */
.form-errors {
    margin-bottom: 16px;
    padding: 12px 14px;
    background: #FFE4E6;
    color: #BE123C;
    border: 1px solid #FECDD3;
    border-radius: 8px;
    font-size: 13px;
}
.form-errors ul { margin: 4px 0 0 18px; }
.form-errors li + li { margin-top: 2px; }

.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1280px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1080px) {
    .grid { grid-template-columns: 1fr; }
    .page { padding: 20px; }
}
@media (max-width: 820px) {
    .sb {
        position: fixed; left: -260px;
        transition: left .25s ease;
        z-index: 50;
        box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
    }
    .sb.open { left: 0; }
    .sb-backdrop { display: block; }
    .main { min-width: 0; width: 100%; }
    .topbar-burger { display: flex; }
    .topbar { padding: 0 16px; height: 52px; }
    .page { padding: 16px; }
    .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-head > div:last-child { width: 100%; display: flex; }
    .page-head > div:last-child .btn { flex: 1; justify-content: center; }
    .stats { gap: 10px; }
    .stat { padding: 14px; }
    .stat-val { font-size: 22px; }
    .card-head { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
    .tbl th, .tbl td { padding: 10px 14px; }
    .crumbs li:not(:last-child):not(.cur) { display: none; }
    .crumbs .sep { display: none; }
    .card-foot { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
    .search { display: none; }
}
@media (max-width: 480px) {
    .stats { grid-template-columns: 1fr; }
    .page { padding: 12px; }
    .page-title { font-size: 20px; }
    .page-title-tag { font-size: 10px; padding: 2px 8px; }
    .stat-val { font-size: 20px; }
    .pag-btn:nth-of-type(4),
    .pag-btn:nth-of-type(5),
    .pag-btn:nth-of-type(6) { display: none; }
    .dropdown.dd-pop { left: 0; right: auto; max-width: calc(100vw - 24px); }
    .top-actions .dropdown.dd-pop { left: auto; right: 0; }
    .card-head { padding: 12px 14px; }
    .card-title { font-size: 14px; }
    .td-post-title, .td-post-excerpt { max-width: none; }
    .ac-item, .sched-item, .notif-item { padding-left: 14px; padding-right: 14px; }
    .dd-foot .btn { flex: 1; justify-content: center; }
}

