:root {
    --navy: #0b1f3a;
    --navy-2: #16345f;
    --background: #f5f7fa;
    --surface: #ffffff;
    --text: #172033;
    --muted: #667085;
    --border: #d9e0ea;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --success: #067647;
    --focus: #2e5fa5;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Tahoma, Arial, "Segoe UI", sans-serif;
    line-height: 1.7;
}
button, input { font: inherit; }
a { color: inherit; }

.app-page { min-height: 100vh; }
.site-header {
    background: var(--navy);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.header-inner {
    width: min(1120px, calc(100% - 32px));
    min-height: 84px;
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand-block,
.user-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}
.brand-block h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: 12px;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .04em;
}
.eyebrow {
    margin: 0 0 2px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}
.site-header .eyebrow { color: #cbd5e1; }
.username {
    color: #e7edf6;
    font-size: .92rem;
}
.dashboard-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 28px auto 48px;
    display: grid;
    gap: 20px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(11, 31, 58, .06);
    padding: 24px;
}
.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.section-heading h2 {
    margin: 0;
    font-size: 1.16rem;
    line-height: 1.5;
}
.url-form label,
.auth-form label {
    display: block;
    margin-bottom: 7px;
    color: var(--text);
    font-size: .9rem;
    font-weight: 700;
}
.url-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

input[type="text"],
input[type="password"],
input[type="url"] {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    padding: 10px 13px;
    outline: none;
}
input::placeholder { color: #98a2b3; }
input:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(46, 95, 165, .22);
    outline-offset: 2px;
    border-color: var(--focus);
}
.button,
.job-list button,
.job-list a {
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 9px 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.button-primary,
.job-list a {
    background: var(--navy-2);
    color: #fff;
}
.button-primary:hover,
.job-list a:hover { background: var(--navy); }
.button-secondary {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, .36);
}
.button-secondary:hover { background: rgba(255, 255, 255, .08); }
button:disabled {
    cursor: not-allowed;
    opacity: .55;
}
.download-button {
    display: block;
    margin-top: 18px;
}
.notice {
    min-height: 1.7em;
    margin: 12px 0 0;
    color: var(--muted);
}
.notice-error {
    padding: 10px 12px;
    border: 1px solid #fecdca;
    border-radius: 10px;
    background: var(--danger-bg);
    color: var(--danger);
}

.notice-success { color: var(--text); padding: 10px 12px; border-inline-start: 4px solid #15803d; }

.media-card:not(:empty) {
    margin-top: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 18px;
    align-items: start;
    border-top: 1px solid var(--border);
    padding-top: 18px;
}
.media-card h2,
.media-card p { margin: 0; }
.media-card h2 { font-size: 1.08rem; }
.media-card p { color: var(--muted); }
.media-card .media-caption {
    grid-column: 1 / -1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #f8fafc;
    color: var(--text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.8;
}
.media-card img,
.media-card:not(:empty):not(:has(img))::after {
    width: 220px;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #eef2f7;
}
.media-card img { object-fit: cover; }
.media-card:not(:empty):not(:has(img))::after {
    content: "تصویر موجود نیست";
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: .85rem;
}

.format-list {
    margin-top: 18px;
    display: grid;
    gap: 10px;
}
.format-list label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 50px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
}
.format-list label:has(input:checked) {
    border-color: var(--navy-2);
    background: #f3f6fb;
}
.format-list input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--navy-2);
}

.gallery-picker {
    display: grid;
    gap: 14px;
}
.gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
}
.gallery-summary {
    color: var(--navy);
    font-size: .9rem;
}
.gallery-toolbar-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.gallery-text-button {
    border: 0;
    padding: 2px 0;
    background: transparent;
    color: var(--navy-2);
    font: inherit;
    font-size: .84rem;
    font-weight: 800;
    cursor: pointer;
}
.gallery-text-button:hover { text-decoration: underline; }
.gallery-hint {
    margin: 0;
    color: var(--muted);
    font-size: .84rem;
}
.gallery-slide-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.format-list .gallery-slide-card {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    align-items: stretch;
    min-height: 0;
    padding: 10px;
    overflow: hidden;
    background: #fff;
}
.format-list .gallery-slide-card:has(input:checked) {
    border-color: var(--navy-2);
    background: #f3f6fb;
    box-shadow: 0 0 0 2px rgba(22, 52, 95, .07);
}
.gallery-slide-card > input[type="checkbox"] {
    position: absolute;
    z-index: 3;
    top: 17px;
    right: 17px;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--navy-2);
}
.gallery-slide-preview {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 10px;
    background: #eef2f7;
}
.gallery-slide-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-slide-placeholder {
    padding: 12px;
    color: var(--muted);
    font-size: .76rem;
    text-align: center;
}
.gallery-kind-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    min-height: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(11, 31, 58, .88);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
}
.gallery-kind-video::before {
    content: "▶";
    margin-left: 5px;
    font-size: .64rem;
}
.gallery-slide-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.gallery-slide-copy strong {
    color: var(--navy);
    font-size: .9rem;
}
.gallery-slide-copy small {
    color: var(--muted);
    font-size: .74rem;
    line-height: 1.5;
}
@media (max-width: 900px) {
    .gallery-slide-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .gallery-toolbar { align-items: flex-start; flex-direction: column; }
    .gallery-slide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 390px) {
    .gallery-slide-grid { grid-template-columns: 1fr; }
}
.job-list {
    display: grid;
    gap: 12px;
}
.job-list:empty::before {
    content: "موردی برای نمایش وجود ندارد.";
    color: var(--muted);
    font-size: .9rem;
}

.job-list article {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 16px;
}
.job-list h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}
.job-list p {
    margin: 6px 0;
    color: var(--muted);
}
.job-list progress {
    width: 100%;
    height: 10px;
    margin: 8px 0 12px;
    accent-color: var(--navy-2);
}
.job-list button,
.job-list a { margin-top: 8px; }
.job-list button {
    background: #fff;
    color: var(--navy-2);
    border-color: var(--border);
}
.job-list button:hover { background: #f8fafc; }
.active-panel { border-inline-start: 4px solid var(--navy-2); }
.history-panel { margin-bottom: 8px; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-shell { width: min(100%, 420px); }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(11, 31, 58, .08);
    padding: 28px;
}
.auth-card .brand-mark {
    margin-bottom: 18px;
    border-color: var(--navy-2);
    color: var(--navy-2);
}
.auth-card h1 {
    margin: 0;
    font-size: 1.35rem;
}
.muted {
    margin: 6px 0 20px;
    color: var(--muted);
    font-size: .92rem;
}
.auth-form { display: grid; gap: 10px; }
.auth-form .button { margin-top: 8px; width: 100%; }

@media (max-width: 720px) {
    .header-inner {
        min-height: auto;
        padding-block: 16px;
        align-items: flex-start;
        flex-direction: column;
    }
    .user-actions {
        width: 100%;
        justify-content: space-between;
    }
    .dashboard-shell {
        width: min(100% - 20px, 1120px);
        margin-top: 14px;
        gap: 12px;
    }
    .panel { padding: 18px; border-radius: 14px; }
    .url-row { grid-template-columns: 1fr; }
    .url-row .button { width: 100%; }
    .media-card:not(:empty) { grid-template-columns: 1fr; }
    .media-card img,
    .media-card:not(:empty):not(:has(img))::after { width: 100%; }
    .brand-block { align-items: flex-start; }
    .brand-block h1 { font-size: .98rem; }
}

/* Integrated app navigation */
.brand-link { color: inherit; text-decoration: none; }
.app-nav { border-top: 1px solid rgba(255,255,255,.1); }
.app-nav-inner {
    width: min(1120px, calc(100% - 32px));
    margin-inline: auto;
    display: flex;
    gap: 6px;
}
.app-nav-link {
    position: relative;
    padding: 12px 18px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 700;
    font-size: .92rem;
}
.app-nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.app-nav-link.is-active { color: #fff; }
.app-nav-link.is-active::after {
    content: "";
    position: absolute;
    inset-inline: 16px;
    bottom: 0;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: #fff;
}

.page-intro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}
.page-intro h2 { margin: 0; font-size: 1.35rem; }
.compact { margin: 5px 0 0; }
.status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 800;
    white-space: nowrap;
}
.status-success { color: #067647; background: #ecfdf3; border: 1px solid #abefc6; }
.status-danger, .status-failed { color: #b42318; background: #fef3f2; border: 1px solid #fecdca; }
.status-neutral, .status-draft { color: #475467; background: #f2f4f7; border: 1px solid #e4e7ec; }
.status-publishing, .status-partial { color: #175cd3; background: #eff8ff; border: 1px solid #b2ddff; }

/* Publisher */
.publisher-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr);
    gap: 20px;
    align-items: start;
}
.publisher-main, .publisher-side { display: grid; gap: 20px; }
.publisher-side { position: sticky; top: 18px; }
.publisher-form { display: grid; gap: 22px; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.field-block { display: grid; gap: 7px; font-size: .9rem; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    padding: 10px 13px;
    outline: none;
    font: inherit;
}
textarea { resize: vertical; min-height: 140px; }
select { min-height: 46px; }
textarea:focus-visible, select:focus-visible {
    outline: 3px solid rgba(46,95,165,.22);
    outline-offset: 2px;
    border-color: var(--focus);
}
.composer-section { border-top: 1px solid var(--border); padding-top: 20px; }
.composer-section-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 12px;
}
.composer-section-head h3 { margin: 0; font-size: 1rem; }
.composer-section-head p { margin: 3px 0 0; color: var(--muted); font-size: .85rem; }
.inline-actions { display: flex; gap: 10px; }
.text-button {
    border: 0;
    padding: 4px 6px;
    background: transparent;
    color: var(--navy-2);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
.muted-button { color: var(--muted); }
.selection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.selection-grid-media { max-height: 330px; overflow: auto; padding-inline-end: 2px; }

.selection-card {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 68px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #fff;
    cursor: pointer;
}
.selection-card:has(input:checked) { border-color: var(--navy-2); background: #f3f6fb; box-shadow: 0 0 0 2px rgba(22,52,95,.06); }
.selection-card.is-warning { opacity: .62; cursor: not-allowed; }
.selection-card input { width: 18px; height: 18px; accent-color: var(--navy-2); }
.selection-copy { min-width: 0; display: grid; }
.selection-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-copy small, .connection-inline { color: var(--muted); font-size: .78rem; }
.platform-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: #eaf0f8;
    color: var(--navy-2);
    font-weight: 900;
}
.platform-telegram { background: #e8f5ff; color: #1479b8; }
.platform-bale { background: #eaf7f5; color: #057a6b; }
.platform-rubika { background: #f4efff; color: #6941c6; }
.platform-eitaa { background: #fff4e8; color: #b54708; }
.media-type-pill { padding: 4px 8px; border-radius: 9px; background: #f2f4f7; color: #475467; font-size: .72rem; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.social-preview { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #fff; }
.preview-header { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border); }
.preview-header div { display: grid; }
.preview-header small { color: var(--muted); }
.preview-media { min-height: 150px; display: grid; place-items: center; background: #eef2f7; color: var(--muted); }
.social-preview p { margin: 0; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.target-status-list, .publish-history { display: grid; gap: 10px; }
.target-status-row, .publish-history-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.target-status-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.target-status-row div { display: grid; }
.target-status-row small, .target-error, .publish-history-card small { color: var(--muted); font-size: .8rem; }
.target-error { color: var(--danger); max-width: 100%; }
.publish-history-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.publish-history-card p { margin: 7px 0; color: var(--muted); }
.empty-state { margin: 0; color: var(--muted); font-size: .9rem; }

/* Channels */
.channel-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat-card { display: grid; gap: 4px; padding-block: 18px; }
.stat-card span { color: var(--muted); font-size: .82rem; }
.stat-card strong { font-size: 1.45rem; color: var(--navy); }
.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.integration-card { display: grid; gap: 16px; }
.integration-card.is-disabled { opacity: .68; }
.integration-card-head, .integration-identity, .integration-actions { display: flex; align-items: center; gap: 12px; }
.integration-card-head { justify-content: space-between; }
.integration-identity h3 { margin: 1px 0 0; font-size: 1rem; }
.integration-identity small { color: var(--muted); }
.integration-details { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: #f8fafc; }
.integration-details div { display: flex; justify-content: space-between; gap: 12px; }
.integration-details span { color: var(--muted); font-size: .8rem; }
.integration-details strong { font-size: .85rem; direction: ltr; text-align: left; overflow-wrap: anywhere; }
.integration-actions { flex-wrap: wrap; }
.button-small { min-height: 36px; padding: 6px 10px; font-size: .8rem; }
.button-ghost, .button-secondary-dark {
    background: #fff;
    color: var(--navy-2);
    border-color: var(--border);
}
.button-ghost:hover, .button-secondary-dark:hover { background: #f8fafc; }

.dialog-layer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; }
.dialog-layer[hidden] { display: none; }
.dialog-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(11,31,58,.52); cursor: default; }
.channel-dialog { position: relative; z-index: 1; width: min(100%, 620px); max-height: calc(100vh - 36px); overflow: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-size: 1.25rem; }
.toggle-row { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--navy-2); }
.field-block small { color: var(--muted); font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

@media (max-width: 900px) {
    .publisher-grid { grid-template-columns: 1fr; }
    .publisher-side { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .channel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .app-nav-inner { width: min(100% - 20px, 1120px); }
    .app-nav-link { flex: 1; text-align: center; padding-inline: 8px; }
    .page-intro { align-items: stretch; flex-direction: column; }
    .page-intro .button { width: 100%; }
    .publisher-side { grid-template-columns: 1fr; }
    .selection-grid, .form-grid, .channel-stats { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .composer-section-head, .composer-actions { align-items: stretch; flex-direction: column; }
    .composer-actions .button { width: 100%; }
    .selection-card { grid-template-columns: auto auto minmax(0, 1fr); }
    .selection-card .connection-inline { grid-column: 2 / -1; }
    .integration-card-head { align-items: flex-start; }
    .integration-details div { flex-direction: column; gap: 2px; }
    .integration-details strong { text-align: right; }
    .integration-actions .button { flex: 1; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions .button { width: 100%; }
}


/* Workspace / team */
.workspace-switcher-wrap{display:grid;gap:2px;color:#cbd5e1;font-size:.7rem}.workspace-switcher-wrap select{min-width:150px;max-width:230px;height:36px;padding:4px 10px;border:1px solid rgba(255,255,255,.28);border-radius:9px;background:#fff;color:var(--text)}
.workspace-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.workspace-panel{display:grid;align-content:start;gap:14px}.inline-form{display:flex;gap:10px}.inline-form input{min-width:0;flex:1}.stack-form{display:grid;gap:12px}
.invite-result{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:12px;border:1px dashed var(--border);border-radius:10px;background:var(--background)}.invite-result strong{font-size:1.05rem;letter-spacing:.04em}
.workspace-members-panel{margin-top:16px}.workspace-members{display:grid;gap:10px}.workspace-member{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:12px 14px;border:1px solid var(--border);border-radius:12px;background:var(--surface)}.workspace-member-copy{display:grid}.workspace-member-copy small{color:var(--muted)}.workspace-member-actions{display:flex;align-items:center;gap:8px}.workspace-member-actions select{height:38px;border:1px solid var(--border);border-radius:9px;background:#fff;padding-inline:10px}
@media(max-width:760px){.workspace-grid{grid-template-columns:1fr}.workspace-member{align-items:flex-start;flex-direction:column}.workspace-member-actions{width:100%;flex-wrap:wrap}.workspace-switcher-wrap{width:100%}.workspace-switcher-wrap select{width:100%;max-width:none}.user-actions{flex-wrap:wrap}}
