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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sidebar-width: 260px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 14px;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* サイドバー */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
}

.sidebar-nav {
    padding: 16px 0;
    flex: 1;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: var(--text-secondary);
    font-size: 14px;
}

.nav-item:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.nav-item.active {
    background: #eff6ff;
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
    font-weight: 600;
}

.nav-icon {
    margin-right: 12px;
    font-size: 18px;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
}

/* カード */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 20px;
}

/* グリッドレイアウト */
.content-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
}

@media (max-width: 1400px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* フォーム */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: var(--card-bg);
    color: var(--text-color);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 12px;
}

.file-name {
    display: block;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.add-article-form {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

/* ボタン */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-color);
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-success:hover {
    background: var(--secondary-hover);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* テーブル */
.table-container {
    overflow-x: auto;
    margin-top: 16px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.table-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.article-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    font-size: 13px;
}

.article-table thead {
    background: var(--bg-color);
}

.article-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.article-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.article-table tbody tr:hover {
    background: var(--bg-color);
}

.article-table tbody tr.empty-row td {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.article-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.article-checkbox:checked {
    background-color: var(--primary-color);
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.generating {
    background: #dbeafe;
    color: #1e40af;
}

.status-badge.completed {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.error {
    background: #fee2e2;
    color: #991b1b;
}

.table-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.article-title-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.article-title-cell strong {
    font-size: 14px;
    color: var(--text-color);
}

.article-settings {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.word-count-input {
    width: 100px;
    padding: 4px 8px;
    font-size: 12px;
}

.article-completed {
    background: #f0fdf4;
}

.article-completed:hover {
    background: #dcfce7;
}

/* プロンプトプレビュー */
.prompt-preview {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.prompt-preview h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-color);
}

.preview-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--card-bg);
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* 記事詳細 */
.article-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-field label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-field > div {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.6;
}

.content-preview {
    padding: 20px;
    background: var(--bg-color);
    border-radius: 6px;
    max-height: 500px;
    overflow-y: auto;
}

.content-preview h2.heading-primary {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.content-preview h3.heading-secondary {
    font-size: 20px;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-color);
}

.content-preview p.paragraph {
    margin-bottom: 16px;
    line-height: 1.8;
    color: var(--text-color);
}

.content-preview ul.list,
.content-preview ol.list-ordered {
    margin-bottom: 16px;
    padding-left: 24px;
}

.content-preview li.list-item {
    margin-bottom: 8px;
    line-height: 1.6;
}

.content-preview strong.text-bold {
    font-weight: 600;
}

.content-preview em.text-italic {
    font-style: italic;
}

/* 進行度ポップアップ */
.progress-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 8px 8px 0 0;
}

.progress-header span {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

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

.progress-actions .btn-sm {
    padding: 4px 12px;
    font-size: 12px;
    min-width: 60px;
}

.progress-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    line-height: 1;
}

.progress-close:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-color);
    margin: 12px 16px;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.progress-text span:first-child {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 14px;
}

.progress-info {
    padding: 0 16px 12px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* メッセージ */
.message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .article-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .preview-meta {
        flex-direction: column;
        gap: 10px;
    }
}

/* プロンプト設定 */
.prompt-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    min-height: 200px;
}

.prompt-name-input-group {
    display: flex;
    gap: 8px;
}

.prompt-name-input {
    flex: 1;
}

.saved-prompts-list {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    background: var(--bg-color);
    width: 100%;
    box-sizing: border-box;
}

.saved-prompt-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    gap: 6px;
    min-height: 32px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    transition: all 0.2s;
}

.saved-prompt-item.selected {
    background: #eff6ff;
    border-color: var(--primary-color);
}

.saved-prompt-item:last-child {
    margin-bottom: 0;
}

.prompt-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    min-width: 16px;
    max-width: 16px;
}

.prompt-name {
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
    max-width: 120px;
    min-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    flex-shrink: 1;
}

.prompt-name:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.selected-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--primary-color);
    color: white;
    font-size: 10px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 2px;
}

.prompt-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.prompt-actions .btn {
    padding: 3px 6px;
    font-size: 11px;
    min-width: 38px;
    line-height: 1.2;
    white-space: nowrap;
}

.saved-prompts-list .empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
}

/* 使用量統計 */
.usage-stats {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.usage-provider {
    padding: 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.usage-provider h4 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: var(--text-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
}

.model-name {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 8px;
}

.usage-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.usage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.usage-item:last-child {
    border-bottom: none;
}

.usage-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
}

.usage-value {
    font-weight: 600;
    color: var(--text-color);
    font-size: 16px;
}

.usage-cost {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 6px;
    margin-top: 8px;
}

.usage-cost .usage-value {
    color: var(--primary-color);
    font-size: 18px;
}

.usage-cost small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.usage-total {
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 8px;
    color: white;
}

.usage-total h4 {
    margin: 0 0 16px 0;
    font-size: 20px;
    color: white;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 8px;
}

.usage-total .usage-label {
    color: rgba(255, 255, 255, 0.9);
}

.usage-total .usage-value {
    color: white;
}

/* 月別フィルター */
.usage-provider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.usage-provider-header h3 {
    margin: 0;
    font-size: 20px;
    color: var(--text-color);
}

.month-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.month-filter label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
    font-size: 20px;
}

.usage-total .usage-cost {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.usage-total .usage-cost .usage-label {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

.usage-total .usage-cost .usage-value {
    color: white;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 月別グラフ */
.chart-container {
    margin-top: 24px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 16px;
    min-height: 300px;
    padding: 20px;
    background: var(--bg-color);
    border-radius: 8px;
}

.chart-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 120px;
}

.chart-bar-wrapper {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}

.chart-bar {
    width: 100%;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 4px;
    transition: height 0.3s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
}

.chart-bar-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
}

.chart-bar-label {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.chart-container .empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

