:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1a2332;
    --muted: #5c6b7a;
    --primary: #0b5cab;
    --primary-dark: #084785;
    --border: #d8e0e8;
    --success: #1f7a4c;
    --warning: #9a6700;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    width: min(960px, 92vw);
    margin: 0 auto;
}

.container-wide {
    width: min(1400px, 96vw);
    margin: 0 auto;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    gap: 1rem;
}

.brand {
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

nav a.nav-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    padding-bottom: 0.15rem;
    border-bottom: 2px solid transparent;
}

nav a.nav-link:hover {
    color: var(--primary);
}

nav a.nav-link.is-active {
    color: var(--success);
    border-bottom-color: var(--success);
}

.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h1,
.card h2 {
    margin-top: 0;
}

.muted {
    color: var(--muted);
}

.status-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-published { background: #d9f2e5; color: var(--success); }
.status-partial { background: #fff4d6; color: var(--warning); }
.status-failed { background: #fde8e6; color: var(--danger); }
.status-pending { background: #e8eef5; color: var(--muted); }

.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 1.1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e8eef5;
    color: var(--text);
}

.btn-success {
    background: #1f8a4c;
    color: #fff;
}

.btn-success:hover {
    background: #176b3b;
}

.template-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.template-actions[hidden] {
    display: none !important;
}

.create-status {
    margin-top: 0.65rem;
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    background: #e8f5ee;
    color: #1f8a4c;
    font-weight: 600;
    font-size: 0.95rem;
}

.create-status.create-status-error {
    background: #fde8e6;
    color: var(--danger);
}

.submit-status {
    margin: 0;
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    background: #e8f5ee;
    color: #1f8a4c;
    font-weight: 600;
    font-size: 0.95rem;
}

.submit-status.submit-status-error {
    background: #fde8e6;
    color: var(--danger);
}

.image-url-header-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.image-url-header-row label {
    margin-bottom: 0;
}

.post-details-cell {
    max-width: 28rem;
}

.post-detail-line {
    margin-top: 0.35rem;
    font-size: 0.9rem;
}

.scheduler-error {
    margin-top: 0.65rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    background: #fde8e6;
    color: var(--danger);
    font-size: 0.92rem;
}

.scheduler-error strong {
    display: block;
    margin-bottom: 0.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

.alert {
    padding: 0.9rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success { background: #d9f2e5; color: var(--success); }
.alert-warning { background: #fff4d6; color: var(--warning); }
.alert-error { background: #fde8e6; color: var(--danger); }
.alert-info { background: #e8f2ff; color: var(--primary); }

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    font-size: 0.9rem;
    color: var(--muted);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.stat strong {
    display: block;
    font-size: 1.1rem;
}

.radio-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.radio-row label {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.schedule-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f8fafc;
}

.button-row,
.action-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.image-url-preview-wrap {
    margin-top: 0.65rem;
}

.image-url-preview-link {
    display: inline-block;
    text-decoration: none;
    color: inherit;
    cursor: default;
    pointer-events: none;
}

.image-url-preview-link.is-active {
    cursor: pointer;
    pointer-events: auto;
}

.image-url-preview-link.is-active .image-url-preview-box {
    border-color: var(--primary);
}

.image-url-preview-link.is-active:hover .image-url-preview-box {
    box-shadow: 0 0 0 2px rgba(11, 92, 171, 0.15);
}

.image-url-preview-box {
    position: relative;
    width: 96px;
    height: 96px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}

.image-url-preview-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.image-url-preview-label[hidden] {
    display: none;
}

.image-url-preview-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-url-preview-image[hidden] {
    display: none;
}

.posts-grid-toolbar {
    margin-bottom: 1rem;
}

.posts-grid-search-form {
    margin-bottom: 0.5rem;
}

.posts-grid-search-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.posts-grid-search-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.posts-grid-search-row input[type="search"] {
    flex: 1 1 280px;
    min-width: 220px;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.posts-grid-summary {
    margin: 0;
    font-size: 0.9rem;
}

.posts-grid-table-wrap {
    overflow-x: auto;
}

.posts-grid-table {
    width: 100%;
    min-width: 760px;
}

.scheduled-posts-table-wrap {
    overflow-x: auto;
}

.scheduled-posts-table {
    width: 100%;
    min-width: 1100px;
}

.scheduled-posts-table .run-count {
    font-weight: 700;
    font-size: 1.05rem;
}

.posts-grid-image-link {
    display: inline-block;
    text-decoration: none;
}

.posts-grid-image-box {
    width: 96px;
    height: 96px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}

.posts-grid-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.posts-grid-image-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.posts-grid-pagination {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1rem;
}

.posts-grid-page-label {
    font-weight: 600;
    color: var(--muted);
}

.template-type-select {
    width: 100%;
    max-width: 420px;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.template-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.template-master-file-label {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
}

.template-master-grid {
    display: grid;
    gap: 1.25rem;
}

.template-master-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    background: #fbfdff;
}

.template-master-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
}

.template-master-path {
    margin: 0;
    font-size: 0.85rem;
    word-break: break-all;
}

.template-master-preview-wrap {
    margin: 1rem 0;
    width: min(320px, 100%);
}

.template-master-preview {
    width: min(320px, 100%);
    aspect-ratio: 1;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    display: block;
}

.template-master-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
}

.login-body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top right, rgba(11, 92, 171, 0.12), transparent 42%),
        linear-gradient(180deg, #eef4fb 0%, var(--bg) 100%);
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(26, 35, 50, 0.08);
    padding: 2rem;
}

.login-card-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.login-card h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
}

.login-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.login-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.45rem;
    color: var(--text);
}

.login-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.85rem 0.95rem;
    border: 1px solid #c9d4df;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-input::placeholder {
    color: #8a98a8;
}

.login-input:hover {
    border-color: #aebccb;
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11, 92, 171, 0.15);
}

.login-password-wrap {
    position: relative;
}

.login-input-password {
    padding-right: 3rem;
}

.login-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.55rem;
    transform: translateY(-50%);
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.login-password-toggle:hover {
    background: #f1f5f9;
    color: var(--text);
}

.login-password-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(11, 92, 171, 0.15);
}

.login-eye-icon {
    width: 1.2rem;
    height: 1.2rem;
    fill: currentColor;
}

.login-submit {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    border-radius: 10px;
}

.logout-form {
    display: inline;
    margin: 0;
}

.logout-link {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}

.logout-link:hover {
    color: var(--primary);
}
