:root {
    --bg: #f6f6f8;
    --surface: #fff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #1e8ec9;
    --primary-dark: #1772a2;
    --secondary: #6b7280;
    --secondary-dark: #4b5563;
    --radius: .5rem;
    --border-color: #e0e0e2;
    --table-background-color: #f6f6f8;
    --table-border-color: #e5e7eb;
    --table-font-color: #374151;
    --shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

h1,h2,h3 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 0 }
small { font-size: .75rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

hr { height: 0; border: 0; border-top: 1px solid var(--secondary); margin: 1rem 0; }

.site { min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; }
.container { width: min(1120px, 100% - 2rem); margin-inline: auto; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    color: #fff;
    background: rgba(17, 68, 93, .9);
    backdrop-filter: blur(3px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 3rem;
}

.logo { margin: 0; font-size: 1.3rem; }
.logo a { color: #fff; }
.logo a:hover { text-decoration: none; }
.logo svg { display: none }

.topbar .user-info { display: none; }

.main-nav { display: flex; flex-wrap: wrap; gap: .3rem; }
.main-nav a {
    color: #fff;
    font-size: .9rem;
    padding: .35rem .65rem;
    border-radius: var(--radius);
}
.main-nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }

.main-content { padding: 1.25rem 0 2rem; }
.content { display: grid; gap: 1rem; }

.grid { display: grid; }
.text-muted { color: var(--muted); }

.page-header {
    display: flex;
    align-content: center;
    align-items: flex-start;
    justify-content: space-between;
    gap: .8rem;
    flex-wrap: wrap;
}
.page-header h2 { align-self: center }
.page-header-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-self: center }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    padding: .35rem .6rem;
    border: 0;
    border-radius: calc(var(--radius) / 2);
    background: var(--primary);
    color: #fff;
    font-size: .85rem;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-link { color: var(--text); background: none; }
.btn-link:hover { background: none; }
.btn-small { padding: .25rem .5rem; font-size: .8rem; }

.table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}
.table th,
.table td {
    padding: .5rem .8rem;
    border-bottom: 1px solid var(--table-border-color);
    vertical-align: top;
    font-size: .9rem;
}
.table th {
    background: var(--table-background-color);
    text-align: left;
    font-weight: 600;
    color: var(--table-font-color);
}
.table tr:last-child td {
    border-bottom: none;
}
.table tr.valign-middle td { vertical-align: middle; }

.thumb-cell { width: 90px; }
.thumb { width: 80px; height: 80px; object-fit: contain; border-radius: var(--radius); vertical-align: middle; }
.thumb-xs { width: 30px; height: 30px; }
.thumb.placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #6b7280;
    background: #e5e7eb;
    font-size: 1.3rem;
}
.current-image { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }

.actions { white-space: nowrap; text-align: right !important; }
.actions .btn { margin: 0 .2rem .25rem 0; }

.form,
.card,
.channel-info,
.platform-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.platform-section { padding: 1rem; margin-bottom: 1.5rem; }
.platform-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem;
}

.form {
    background: #fff;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}
.form-group { margin-bottom: .9rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .9rem; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea,
.inline-input {
    width: 100%;
    padding: .4rem .5rem;
    border-radius: calc(var(--radius) / 2);
    border: 1px solid #d1d5db;
    font-size: .9rem;
    font-family: inherit;
}
.form-group textarea { min-height: 120px; resize: vertical; }
.form-actions { margin-top: .9rem; }
.inline-form { display: inline; }

.help-text { display: block; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.help-text button {
    margin: .1rem .15rem .1rem 0;
    border: 1px solid var(--line);
    border-radius: .4rem;
    padding: .12rem .35rem;
    background: #f8fafc;
    cursor: pointer;
}
.help-text button:hover { background: #eef2ff; }

.dropzone{
    padding: 12px; border: 2px dashed #d1d5db; border-radius: 6px;
    background:#fff; cursor:pointer; font-size: 13px; color:#6b7280;
}
.dropzone.is-over{ border-color:#2563eb; background:#f0f7ff; }

.flash-wrapper {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 50rem;
    text-align: center;
    z-index: 9999;
}
.flash {
    border-radius: .6rem;
    border: 1px solid transparent;
    padding: .58rem .75rem;
    margin-bottom: .5rem;
    font-size: .9rem;
    opacity: 1;
    transition: opacity 0.4s ease;
}
.flash.is-hiding {
    opacity: 0;
}
.flash-success { background: #ecfdf3; color: #166534; border-color: #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.badge { display: inline-block; padding: .14rem .45rem; border-radius: 1rem; font-size: .75rem; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: #e5e7eb; color: #374151; }

.log-info {
    gap: 0 .5rem;
	grid-template-columns: auto auto 1fr;
}

.channel-info {
    background: #fff;
    padding: .75rem 1rem;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
    margin-bottom: 1.5rem;
    font-size: .9rem;
}

.card {
    padding: .75rem 1rem;
}
.card-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: .5rem;
}
.card h3 {
	font-size: 1.05rem;
    margin: 0 0 .25rem;
}
.card-excerpt {
    margin: 0 0 .5rem;
    font-size: .9rem;
    color: #4b5563;
}
.card-thumb img.thumb {
    max-width: 80px;
    max-height: 80px;
}

.post-platforms {
    margin-top: .5rem;
    border-top: 1px solid #e5e7eb;
    padding-top: .5rem;
}
.post-platform-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .35rem 0;
    border-bottom: 1px dashed #e5e7eb;
}
.post-platform-row:last-child {
    border-bottom: none;
}
.post-platform-meta {
    font-size: .85rem;
	display: grid;
	gap: .5rem;
	grid-template-columns: 8rem 10rem auto auto 1fr;
	align-items: center;
}
.post-platform-actions {
    text-align: right;
}

.pagination {
    margin-top: 1rem;
    text-align: center;
}
.pagination .page {
    display: inline-block;
    padding: .3rem .6rem;
    margin: 0 .1rem;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    font-size: .85rem;
    background: #fff;
    color: #111827;
    text-decoration: none;
}
.pagination .page.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    pointer-events: none;
}

.footer {
    border-top: 1px solid #e5e7eb;
    padding: .9rem 0 1.2rem;
    margin-top: 2rem;
    font-size: .8rem;
    color: var(--muted);
    text-align: center;
}

.login-body { padding: 6rem 0; }
.login-body h1 { margin-bottom: 2rem !important; }
.login-container { width: min(340px, 100%); text-align: center; }
.login-container input { text-align: center; }

@media (min-width: 576px) {
    .logo svg { display: inline; vertical-align: middle; width: 3rem; }
    .topbar .user-info { display: block; }
}
@media (max-width: 760px) {
    .container { width: min(1120px, 100% - 1rem); }
    .table { display: block; overflow-x: auto; }
    .post-platform-row,
    .post-platform-actions { flex-direction: column; align-items: flex-start; }
    .actions { white-space: normal; }
}
