* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Montserrat', system-ui, sans-serif;
    background: #f4f5f9;
    color: #1e2233;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 40px;
    background: linear-gradient(135deg, #14142a 0%, #2b1a4a 60%, #481f6b 100%);
    box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.brand {
    font-family: 'Cinzel', serif;
    font-weight: 800;
    font-size: 30px;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #ffd36b, #ff7a59, #b478ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
    text-shadow: 0 0 1px rgba(255,255,255,0.2);
}

.tg-link {
    color: #ffd36b;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(255,211,107,0.5);
    padding: 6px 14px;
    border-radius: 20px;
    transition: 0.2s;
}
.tg-link:hover { background: rgba(255,211,107,0.15); }

.container {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.site-footer {
    text-align: center;
    padding: 18px;
    color: #7a7f95;
    font-size: 13px;
}

.card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(20,20,50,0.08);
    padding: 28px 32px;
}
.card.narrow { max-width: 520px; margin: 40px auto; }
.card h2 { margin-top: 0; font-family: 'Cinzel', serif; letter-spacing: 1px; }

.form label {
    display: block;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 14px;
}
.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form input[type="file"],
.form textarea {
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid #d3d7e6;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: #fafbff;
}
.form input:focus, .form textarea:focus {
    outline: none;
    border-color: #7c5cff;
    box-shadow: 0 0 0 3px rgba(124,92,255,0.15);
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: #e8eaf2;
    color: #23263a;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-family: inherit;
    transition: 0.15s;
}
.btn:hover { background: #d9dce8; }
.btn-primary { background: #5b39d1; color: #fff; }
.btn-primary:hover { background: #4a2cb8; }
.btn-danger { background: #e74c5c; color: #fff; }
.btn-danger:hover { background: #cf3d4c; }

.actions { display: flex; gap: 10px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.toolbar h2 { margin: 0; font-family: 'Cinzel', serif; }
.toolbar .btn { margin-left: 8px; }

h3 {
    margin-top: 36px;
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
    color: #2b1a4a;
}

/* Обертка для таблицы, чтобы она не вылезала за пределы экрана */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(20,20,50,0.06);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #eef0f6;
    font-size: 14px;
    vertical-align: middle;
}
.table th { background: #f7f8fc; font-weight: 700; color: #3a3f55; }
.table tr:last-child td { border-bottom: none; }

.cell-filename {
    word-break: break-word;
    max-width: 200px;
}

.names-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    font-size: 13px;
    line-height: 1.5;
}
.names-list li {
    margin-bottom: 2px;
}
.time-list {
    color: #7a7f95;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.badge-wait { background: #e8f7ee; color: #21823f; }
.badge-dl { background: #fdecef; color: #b62e3e; }
.badge-part { background: #fff4e0; color: #b06a00; }

.link-group {
    display: flex;
    gap: 6px;
    align-items: center;
}
.link-group .link-input {
    flex: 1;
    width: 100%;
    min-width: 100px;
    padding: 6px 8px;
    border: 1px solid #d3d7e6;
    border-radius: 6px;
    font-size: 12px;
    background: #fafbff;
}

.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}
.btn-copy {
    background: #e8eaf2;
    color: #23263a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.15s;
}
.btn-copy:hover { background: #d9dce8; }
.btn-success { 
    background: #21823f !important; 
    color: #fff !important; 
}

.muted { color: #7a7f95; }
.small { font-size: 13px; }

.progress {
    background: #eef1fb;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin: 12px 0;
}

.flash {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-weight: 600;
    font-size: 14px;
}
.flash-success { background: #e8f7ee; color: #21823f; }
.flash-error   { background: #fdecef; color: #b62e3e; }

/* Мобильная адаптация (Карточный вид) */
@media (max-width: 768px) {
    .table thead {
        display: none;
    }
    .table, .table tbody, .table tr, .table td {
        display: block;
        width: 100%;
    }
    .table tr {
        margin-bottom: 15px;
        border: 1px solid #eef0f6;
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 10px 15px;
        border-bottom: 1px solid #f4f5f9;
        text-align: right;
        gap: 15px;
    }
    .table td:last-child {
        border-bottom: none;
    }
    .table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #7a7f95;
        font-size: 13px;
        text-align: left;
        flex-shrink: 0;
        padding-top: 2px;
    }
    .cell-filename {
        max-width: 100%;
        word-break: break-all;
    }
    .names-list {
        text-align: right;
    }
    .link-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .link-group .link-input {
        margin-bottom: 5px;
    }
    .action-buttons {
        justify-content: flex-end;
        width: 100%;
    }
    .table-wrapper {
        overflow-x: visible;
        background: transparent;
        box-shadow: none;
    }
    
    /* Адаптив для шапки и карточек */
    .site-header { 
        padding: 16px 20px; 
        flex-direction: column; 
        gap: 10px; 
    }
    .brand { font-size: 22px; }
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}