.cw-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 12px 48px;
}

.cw-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 28px;
    padding: 22px 24px;
    border-radius: 12px;
    background: linear-gradient(145deg, #ffffff 0%, #f4f7fb 100%);
    border: 1px solid #e4e9ef;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.cw-header h1 {
    margin: 0 0 8px 0;
    font-size: 1.65rem;
    color: #2c3e50;
    text-align: left;
}

.cw-header h1 .fa-shield-halved {
    margin-right: 10px;
    color: #5d6d7e;
}

.cw-header p {
    margin: 0;
    color: #7f8c8d;
    font-size: 0.95rem;
    max-width: 36rem;
    line-height: 1.45;
    text-align: left;
}

.cw-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #dce4ec;
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.cw-back:hover {
    background: #ebf5fb;
}

.cw-root {
    min-height: 120px;
}

.cw-loading {
    text-align: center;
    color: #95a5a6;
    font-style: italic;
    padding: 32px;
}

.cw-banner {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.cw-banner.error {
    background: #fadbd8;
    color: #922b21;
    border: 1px solid #f5b7b1;
}

.cw-banner.success {
    background: #d5f5e3;
    color: #1e8449;
    border: 1px solid #a9dfbf;
}

.cw-add-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 22px;
    border: 1px solid #e8ecf1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cw-add-card h2 {
    margin: 0 0 14px 0;
    font-size: 1.05rem;
    color: #2c3e50;
}

.cw-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.cw-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 160px;
}

.cw-field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #5d6d7e;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cw-field input {
    padding: 10px 12px;
    border: 1px solid #dce4ec;
    border-radius: 8px;
    font-size: 0.95rem;
}

.cw-field input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

.cw-btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

.cw-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cw-btn-primary {
    background: #3498db;
    color: #fff;
}

.cw-btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.cw-btn-ghost {
    background: #ecf0f1;
    color: #2c3e50;
}

.cw-btn-ghost:hover:not(:disabled) {
    background: #d5dbdb;
}

.cw-btn-danger {
    background: #fdf2f2;
    color: #c0392b;
    border: 1px solid #f5b7b1;
}

.cw-btn-danger:hover:not(:disabled) {
    background: #fadbd8;
}

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

.cw-list-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8ecf1;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cw-list-card h2 {
    margin: 0;
    padding: 16px 20px;
    font-size: 1.05rem;
    color: #2c3e50;
    border-bottom: 1px solid #eef2f6;
}

.cw-empty {
    padding: 36px 20px;
    text-align: center;
    color: #95a5a6;
    font-size: 0.95rem;
}

.cw-table-wrap {
    overflow-x: auto;
}

.cw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.cw-table th,
.cw-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f3f6;
}

.cw-table th {
    background: #f8fafc;
    color: #5d6d7e;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cw-table tr:last-child td {
    border-bottom: none;
}

.cw-table input {
    width: 100%;
    max-width: 280px;
    padding: 8px 10px;
    border: 1px solid #dce4ec;
    border-radius: 6px;
    font-size: 0.9rem;
}

.cw-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.cw-types-card {
    background: #fff;
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 22px;
    border: 1px solid #e8ecf1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cw-types-card h2 {
    margin: 0 0 12px 0;
    font-size: 1.05rem;
    color: #2c3e50;
}

.cw-types-card ul {
    margin: 0;
    padding-left: 1.2rem;
    color: #5d6d7e;
    font-size: 0.9rem;
    line-height: 1.55;
}

.cw-types-card li {
    margin-bottom: 8px;
}

.cw-types-note {
    margin: 14px 0 0 0;
    font-size: 0.85rem;
    color: #7f8c8d;
    line-height: 1.45;
}

.cw-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    align-items: end;
}

.cw-field-submit .cw-btn {
    width: auto;
    min-width: 120px;
}

.cw-label-spacer {
    visibility: hidden;
}

.cw-col-links .cw-id-input {
    max-width: 120px;
    display: block;
    margin-bottom: 6px;
}

.cw-col-links .cw-id-input:last-child {
    margin-bottom: 0;
}

.cw-th-actions {
    width: 200px;
    text-align: right;
}

@media (max-width: 640px) {
    .cw-form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .cw-form-grid {
        grid-template-columns: 1fr;
    }

    .cw-btn {
        width: 100%;
    }
}

/* --- Analytical view (/cw) --- */
.cw-analytics-page {
    max-width: 1200px;
}

.cw-analytics-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 20px;
    align-items: start;
}

.cw-picker {
    position: sticky;
    top: 12px;
    background: #fff;
    border: 1px solid #e4e9ef;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.cw-picker-title {
    margin: 0 0 12px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #7f8c8d;
}

.cw-picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 70vh;
    overflow-y: auto;
}

.cw-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    text-align: left;
}

.cw-picker-item:hover {
    border-color: #dce4ec;
    background: #fff;
}

.cw-picker-item.is-active {
    border-color: #3498db;
    background: #ebf5fb;
}

.cw-picker-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cw-picker-meta strong {
    font-size: 0.92rem;
    color: #2c3e50;
}

.cw-picker-aff {
    font-size: 0.78rem;
    color: #7f8c8d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-picker-badge {
    display: inline-block;
    margin-top: 2px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #1a5276;
    background: #d6eaf8;
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
}

.cw-picker-badge--muted {
    color: #7f8c8d;
    background: #ecf0f1;
}

.cw-avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #ecf0f1;
}

.cw-analysis-main {
    min-height: 320px;
}

.cw-analysis-placeholder {
    padding: 48px 24px;
    text-align: center;
}

.cw-profile-header {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 20px;
    padding: 18px 20px;
    background: linear-gradient(145deg, #fff 0%, #f4f7fb 100%);
    border: 1px solid #e4e9ef;
    border-radius: 12px;
}

.cw-profile-header h2 {
    margin: 0 0 6px;
    font-size: 1.45rem;
    color: #2c3e50;
}

.cw-profile-aff {
    margin: 0 0 4px;
    color: #5d6d7e;
}

.cw-profile-social {
    margin: 0;
    font-size: 0.9rem;
}

.cw-link-note {
    margin: 10px 0 0;
    font-size: 0.85rem;
    color: #5d6d7e;
}

.cw-link-note--warn {
    color: #9a6700;
}

.cw-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.cw-stat-card {
    background: #fff;
    border: 1px solid #e4e9ef;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.cw-stat-val {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c3e50;
}

.cw-stat-lbl {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cw-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

.cw-chart-card {
    background: #fff;
    border: 1px solid #e4e9ef;
    border-radius: 10px;
    padding: 14px;
}

.cw-chart-card--wide {
    grid-column: 1 / -1;
}

.cw-chart-card h3 {
    margin: 0 0 10px;
    font-size: 0.92rem;
    color: #2c3e50;
}

.cw-chart-wrap {
    position: relative;
    height: 220px;
}

.cw-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.cw-breakdown-card {
    background: #fff;
    border: 1px solid #e4e9ef;
    border-radius: 10px;
    padding: 12px 14px;
}

.cw-breakdown-card h3 {
    margin: 0 0 10px;
    font-size: 0.88rem;
    color: #2c3e50;
}

.cw-bar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cw-bar-list li {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.82rem;
}

.cw-bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cw-bar-track {
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
}

.cw-bar-fill {
    display: block;
    height: 100%;
    background: #3498db;
    border-radius: 4px;
}

.cw-bar-count {
    color: #7f8c8d;
    font-variant-numeric: tabular-nums;
}

.cw-muted {
    color: #95a5a6;
    font-size: 0.85rem;
}

.cw-stance-table-section h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.cw-stance-table td,
.cw-stance-table th {
    font-size: 0.82rem;
}

@media (max-width: 860px) {
    .cw-analytics-layout {
        grid-template-columns: 1fr;
    }

    .cw-picker {
        position: static;
        max-height: none;
    }

    .cw-picker-list {
        max-height: 240px;
    }

    .cw-charts-grid {
        grid-template-columns: 1fr;
    }
}
