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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242736;
    --border: #2e3142;
    --text: #e4e4e7;
    --text2: #9ca3af;
    --accent: #6366f1;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-tov { color: var(--accent); }

/* T-OV overlay badge */
.overlay-text { position: fixed; bottom: 18px; right: 24px; z-index: 200; }
.overlay-text a {
    display: inline-flex;
    align-items: center;
    padding: 1px 4px;
    border-radius: 3px;
    background: #e05c00;
    text-decoration: none;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(224,92,0,0.25);
    transition: all 0.3s ease;
    animation: tov-glow 2s ease-in-out infinite;
}
@keyframes tov-glow {
    0%, 100% { box-shadow: 0 2px 8px rgba(224,92,0,0.25); filter: brightness(1); }
    50% { box-shadow: 0 2px 20px rgba(224,92,0,0.6), 0 0 40px rgba(255,122,46,0.2); filter: brightness(1.15); }
}
.overlay-text a:hover {
    background: #ff7a2e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(224,92,0,0.35);
    animation: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.remaining {
    font-size: 13px;
    color: var(--text2);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: #4f46e5; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover { background: #dc2020; }

.btn-ghost {
    background: transparent;
    color: var(--text2);
    padding: 8px;
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-subscribe {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    text-decoration: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.btn-subscribe:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); }

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 18px;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* Submit area */
.submit-area {
    padding: 20px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: none;
}

.submit-area.open { display: block; }

.submit-area textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.submit-area textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.submit-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.char-count { font-size: 12px; color: var(--text2); }

/* Kanban */
.kanban {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    padding: 20px 24px;
    min-height: calc(100vh - 130px);
}

.column {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.column-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.column-header .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.col-valuable .dot { background: var(--green); }
.col-neutral .dot { background: var(--yellow); }
.col-trash .dot { background: var(--red); }

.column-header .count {
    margin-left: auto;
    background: var(--surface2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--text2);
}

.column-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Cards */
.card {
    background: var(--surface2);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.card:hover {
    border-color: var(--border);
    transform: translateY(-1px);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
}

.card-preview {
    font-size: 13px;
    color: var(--text2);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--text2);
}

.card-source {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface);
    font-size: 10px;
    text-transform: uppercase;
}

.card-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
    aspect-ratio: 16/9;
    object-fit: cover;
}

/* Processing card */
.card.processing {
    border: 1px solid var(--accent);
    border-style: dashed;
}

.card.processing .card-title {
    color: var(--accent);
}

.processing-stages {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.processing-stage {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.processing-stage.active {
    color: var(--accent);
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Detail Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-close {
    float: right;
    font-size: 20px;
    cursor: pointer;
    color: var(--text2);
    background: none;
    border: none;
}
.modal-close:hover { color: var(--text); }

.modal h2 {
    font-size: 18px;
    margin-bottom: 16px;
    padding-right: 30px;
}

.modal-section {
    margin-bottom: 16px;
}

.modal-section h3 {
    font-size: 13px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.modal-section .content {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-section .content a {
    color: var(--accent);
    text-decoration: none;
}
.modal-section .content a:hover {
    text-decoration: underline;
}

.collapsible summary {
    font-size: 13px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}
.collapsible summary:hover {
    color: var(--text);
}
.collapsible .content {
    margin-top: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.badge-valuable { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-neutral { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-trash { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-processing { background: rgba(99,102,241,0.15); color: var(--accent); }

.modal-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* Admin Modal */
.admin-modal {
    max-width: 800px;
}

.admin-modal h2 { margin-bottom: 20px; }

.setting-group {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
}

.setting-group h3 {
    font-size: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    display: block;
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 4px;
    margin-top: 10px;
}

.setting-group label:first-of-type { margin-top: 0; }

.setting-group input,
.setting-group textarea,
.setting-group select {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}

.setting-group textarea {
    min-height: 100px;
    resize: vertical;
}

.retention-row {
    display: flex;
    gap: 16px;
}
.retention-row div {
    flex: 1;
}
.retention-row input {
    width: 100% !important;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.admin-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Auth modal */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.auth-error {
    color: var(--red);
    font-size: 13px;
    display: none;
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text2);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content { min-height: 200px; }

/* Subscribers */
.subscribers-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}
.subscribers-stats .stat-card {
    flex: 1;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}
.stat-card .stat-label {
    font-size: 12px;
    color: var(--text2);
    margin-top: 4px;
}

.subscribers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sub-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 8px;
}
.sub-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sub-name {
    font-size: 14px;
    font-weight: 500;
}
.sub-meta {
    font-size: 11px;
    color: var(--text2);
}
.sub-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.sub-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(99,102,241,0.15);
    color: var(--accent);
}
.sub-badge.premium {
    background: rgba(234,179,8,0.15);
    color: var(--yellow);
}
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
}
.sub-detail {
    margin: -4px 0 8px;
    padding: 12px 16px;
    background: var(--surface2);
    border-radius: 0 0 8px 8px;
    font-size: 11px;
    color: var(--text2);
    line-height: 1.6;
}
.detail-section {
    margin-bottom: 8px;
}
.detail-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.detail-item:last-child { border-bottom: none; }

/* Finances */
.finance-period {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.finance-period label {
    font-size: 13px;
    color: var(--text2);
}
.finance-period select {
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
}
.finance-totals {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}
.finance-totals .stat-card {
    flex: 1;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.finance-breakdown {
    margin-bottom: 20px;
}
.finance-breakdown h3 {
    font-size: 13px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.breakdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 6px;
}
.breakdown-row .stage-name {
    font-size: 14px;
    font-weight: 500;
}
.breakdown-row .stage-stats {
    font-size: 12px;
    color: var(--text2);
    text-align: right;
}
.finance-daily h3 {
    font-size: 13px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.daily-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.daily-row:last-child { border-bottom: none; }
.daily-date { color: var(--text2); }
.daily-cost { font-weight: 500; }

/* Help Modal */
.help-content {
    font-size: 14px;
    line-height: 1.7;
}
.help-content p {
    margin-bottom: 12px;
}
.help-content ol, .help-content ul {
    margin: 8px 0 12px 20px;
}
.help-content li {
    margin-bottom: 6px;
}
.help-content a {
    color: var(--accent);
    text-decoration: none;
}
.help-content a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 900px) {
    .kanban {
        grid-template-columns: 1fr;
    }
    .column {
        max-height: 400px;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 12px 16px;
    }
    .kanban {
        padding: 12px;
        gap: 12px;
    }
    .submit-area {
        padding: 12px 16px;
    }
}
