:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #1a1a1a);
    --hint: var(--tg-theme-hint-color, #999999);
    --link: var(--tg-theme-link-color, #2678b6);
    --btn: var(--tg-theme-button-color, #2678b6);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 0;
    line-height: 1.5;
}

.nav {
    display: flex;
    gap: 0;
    background: var(--secondary-bg);
    overflow-x: auto;
    white-space: nowrap;
    padding: 0 8px;
}

.nav-link {
    padding: 12px 16px;
    text-decoration: none;
    color: var(--hint);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link.active {
    color: var(--link);
    border-bottom-color: var(--link);
}

.container {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    font-size: 22px;
    margin-bottom: 16px;
}

h2 {
    font-size: 18px;
    margin: 20px 0 12px;
}

h3 {
    font-size: 15px;
    margin-bottom: 8px;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.card {
    background: var(--secondary-bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.card h3 {
    font-size: 12px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    margin: 4px 0;
}

.card p {
    font-size: 12px;
    color: var(--hint);
}

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

.btn:hover { opacity: 0.85; }

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

.btn-success {
    background: #34c759;
    color: white;
}

.btn-warning {
    background: #ff9500;
    color: white;
}

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

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
    width: 100%;
    margin-top: 16px;
}

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

/* Review Cards */
.reviews-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.review-card {
    background: var(--secondary-bg);
    border-radius: var(--radius);
    padding: 16px;
}

.review-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.badge {
    background: var(--btn);
    color: var(--btn-text);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.date {
    font-size: 12px;
    color: var(--hint);
    margin-left: auto;
}

.feedback-scores {
    display: flex;
    gap: 16px;
    margin: 8px 0;
    font-size: 13px;
}

.score {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 11px;
    color: var(--hint);
}

.score-value {
    font-weight: 600;
}

.comment {
    font-style: italic;
    color: var(--hint);
    font-size: 13px;
    margin: 4px 0;
}

.review-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Table */
.data-table, table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--secondary-bg);
}

th {
    font-size: 12px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Progress Bar */
.progress-bar {
    position: relative;
    background: var(--secondary-bg);
    border-radius: 8px;
    height: 24px;
    overflow: hidden;
    min-width: 80px;
}

.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--btn);
    opacity: 0.3;
    border-radius: 8px;
}

.progress-bar span {
    position: relative;
    z-index: 1;
    padding: 0 8px;
    font-size: 13px;
    line-height: 24px;
}

/* Status Badge */
.status {
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

.status-active { background: #e8f5e9; color: #2e7d32; }
.status-submitted { background: #fff3e0; color: #e65100; }
.status-done { background: #e3f2fd; color: #1565c0; }
.status-locked { background: #f5f5f5; color: #9e9e9e; }

/* Builder Layout */
.builder-layout {
    display: flex;
    gap: 16px;
}

.builder-sidebar {
    width: 240px;
    flex-shrink: 0;
}

.builder-main {
    flex: 1;
}

.plan-form {
    margin-bottom: 16px;
}

.plan-form label {
    display: block;
    font-size: 13px;
    color: var(--hint);
    margin: 8px 0 4px;
}

.plan-form input, .payment-add input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--secondary-bg);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
}

/* Block List */
.block-list .block-item {
    padding: 10px 12px;
    background: var(--secondary-bg);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.block-item:hover {
    opacity: 0.8;
}

.block-item .block-days {
    font-size: 12px;
    color: var(--hint);
}

/* Plan Tasks */
.plan-tasks-list {
    min-height: 100px;
    border: 2px dashed var(--secondary-bg);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 16px;
}

.plan-task-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--secondary-bg);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: grab;
}

.plan-task-item .task-num {
    font-weight: 700;
    color: var(--hint);
    width: 24px;
}

.plan-task-item .task-remove {
    margin-left: auto;
    cursor: pointer;
    color: var(--hint);
}

/* Payments */
.payment-add {
    display: flex;
    gap: 8px;
    align-items: end;
    margin-bottom: 12px;
}

.payment-add input {
    width: auto;
    flex: 1;
}

/* Block Scores */
.block-score {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--secondary-bg);
}

.block-title {
    flex: 1;
}

.block-rating {
    font-weight: 600;
}

.block-rating.low {
    color: #e53935;
}

.block-count {
    font-size: 12px;
    color: var(--hint);
}

.section {
    margin-bottom: 24px;
}

.empty {
    color: var(--hint);
    text-align: center;
    padding: 20px;
}

@media (max-width: 600px) {
    .builder-layout {
        flex-direction: column;
    }
    .builder-sidebar {
        width: 100%;
    }
    .cards-grid {
        grid-template-columns: 1fr 1fr;
    }
}
